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))))
884 (article 1.0 point)))
895 (edit-group 1.0 point)))
899 (edit-server 1.0 point)))
903 (edit-score 1.0 point)))
930 (if gnus-carpal '(summary-carpal 4))
931 ("*Shell Command Output*" 1.0)))
939 "Window configuration for all possible Gnus buffers.
940 This variable is a list of lists. Each of these lists has a NAME and
941 a RULE. The NAMEs are commonsense names like `group', which names a
942 rule used when displaying the group buffer; `summary', which names a
943 rule for what happens when you enter a group and do not display an
944 article buffer; and so on. See the value of this variable for a
945 complete list of NAMEs.
947 Each RULE is a list of vectors. The first element in this vector is
948 the name of the buffer to be displayed; the second element is the
949 percentage of the screen this buffer is to occupy (a number in the
950 0.0-0.99 range); the optional third element is `point', which should
951 be present to denote which buffer point is to go to after making this
952 buffer configuration.")
954 (defvar gnus-window-to-buffer
955 '((group . gnus-group-buffer)
956 (summary . gnus-summary-buffer)
957 (article . gnus-article-buffer)
958 (server . gnus-server-buffer)
959 (browse . "*Gnus Browse Server*")
960 (edit-group . gnus-group-edit-buffer)
961 (edit-server . gnus-server-edit-buffer)
962 (group-carpal . gnus-carpal-group-buffer)
963 (summary-carpal . gnus-carpal-summary-buffer)
964 (server-carpal . gnus-carpal-server-buffer)
965 (browse-carpal . gnus-carpal-browse-buffer)
966 (edit-score . gnus-score-edit-buffer)
967 (mail . gnus-mail-buffer)
968 (post . gnus-post-news-buffer)
969 (faq . gnus-faq-buffer)
970 (picons . "*Picons*")
971 (tree . gnus-tree-buffer)
972 (info . gnus-info-buffer)
973 (article-copy . gnus-article-copy)
974 (draft . gnus-draft-buffer))
975 "Mapping from short symbols to buffer names or buffer variables.")
977 (defvar gnus-carpal nil
978 "*If non-nil, display clickable icons.")
980 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
981 "*Function called with a group name when new group is detected.
982 A few pre-made functions are supplied: `gnus-subscribe-randomly'
983 inserts new groups at the beginning of the list of groups;
984 `gnus-subscribe-alphabetically' inserts new groups in strict
985 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
986 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
987 for your decision; `gnus-subscribe-killed' kills all new groups.")
989 ;; Suggested by a bug report by Hallvard B Furuseth.
990 ;; <h.b.furuseth@usit.uio.no>.
991 (defvar gnus-subscribe-options-newsgroup-method
992 (function gnus-subscribe-alphabetically)
993 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
994 If, for instance, you want to subscribe to all newsgroups in the
995 \"no\" and \"alt\" hierarchies, you'd put the following in your
998 options -n no.all alt.all
1000 Gnus will the subscribe all new newsgroups in these hierarchies with
1001 the subscription method in this variable.")
1003 (defvar gnus-subscribe-hierarchical-interactive nil
1004 "*If non-nil, Gnus will offer to subscribe hierarchically.
1005 When a new hierarchy appears, Gnus will ask the user:
1007 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1009 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1010 subscribe to all newsgroups in the hierarchy and `s' will skip this
1011 hierarchy in its entirety.")
1013 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1014 "*Function used for sorting the group buffer.
1015 This function will be called with group info entries as the arguments
1016 for the groups to be sorted. Pre-made functions include
1017 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1018 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1019 `gnus-group-sort-by-rank'.
1021 This variable can also be a list of sorting functions. In that case,
1022 the most significant sort function should be the last function in the
1025 ;; Mark variables suggested by Thomas Michanek
1026 ;; <Thomas.Michanek@telelogic.se>.
1027 (defvar gnus-unread-mark ?
1028 "*Mark used for unread articles.")
1029 (defvar gnus-ticked-mark ?!
1030 "*Mark used for ticked articles.")
1031 (defvar gnus-dormant-mark ??
1032 "*Mark used for dormant articles.")
1033 (defvar gnus-del-mark ?r
1034 "*Mark used for del'd articles.")
1035 (defvar gnus-read-mark ?R
1036 "*Mark used for read articles.")
1037 (defvar gnus-expirable-mark ?E
1038 "*Mark used for expirable articles.")
1039 (defvar gnus-killed-mark ?K
1040 "*Mark used for killed articles.")
1041 (defvar gnus-souped-mark ?F
1042 "*Mark used for killed articles.")
1043 (defvar gnus-kill-file-mark ?X
1044 "*Mark used for articles killed by kill files.")
1045 (defvar gnus-low-score-mark ?Y
1046 "*Mark used for articles with a low score.")
1047 (defvar gnus-catchup-mark ?C
1048 "*Mark used for articles that are caught up.")
1049 (defvar gnus-replied-mark ?A
1050 "*Mark used for articles that have been replied to.")
1051 (defvar gnus-cached-mark ?*
1052 "*Mark used for articles that are in the cache.")
1053 (defvar gnus-saved-mark ?S
1054 "*Mark used for articles that have been saved to.")
1055 (defvar gnus-process-mark ?#
1057 (defvar gnus-ancient-mark ?O
1058 "*Mark used for ancient articles.")
1059 (defvar gnus-sparse-mark ?Q
1060 "*Mark used for sparsely reffed articles.")
1061 (defvar gnus-canceled-mark ?G
1062 "*Mark used for canceled articles.")
1063 (defvar gnus-score-over-mark ?+
1064 "*Score mark used for articles with high scores.")
1065 (defvar gnus-score-below-mark ?-
1066 "*Score mark used for articles with low scores.")
1067 (defvar gnus-empty-thread-mark ?
1068 "*There is no thread under the article.")
1069 (defvar gnus-not-empty-thread-mark ?=
1070 "*There is a thread under the article.")
1072 (defvar gnus-view-pseudo-asynchronously nil
1073 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1075 (defvar gnus-view-pseudos nil
1076 "*If `automatic', pseudo-articles will be viewed automatically.
1077 If `not-confirm', pseudos will be viewed automatically, and the user
1078 will not be asked to confirm the command.")
1080 (defvar gnus-view-pseudos-separately t
1081 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1082 If nil, all files that use the same viewing command will be given as a
1083 list of parameters to that command.")
1085 (defvar gnus-insert-pseudo-articles t
1086 "*If non-nil, insert pseudo-articles when decoding articles.")
1088 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1089 "*Format of group lines.
1090 It works along the same lines as a normal formatting string,
1091 with some simple extensions.
1093 %M Only marked articles (character, \"*\" or \" \")
1094 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1095 %L Level of subscribedness (integer)
1096 %N Number of unread articles (integer)
1097 %I Number of dormant articles (integer)
1098 %i Number of ticked and dormant (integer)
1099 %T Number of ticked articles (integer)
1100 %R Number of read articles (integer)
1101 %t Total number of articles (integer)
1102 %y Number of unread, unticked articles (integer)
1103 %G Group name (string)
1104 %g Qualified group name (string)
1105 %D Group description (string)
1106 %s Select method (string)
1107 %o Moderated group (char, \"m\")
1108 %p Process mark (char)
1109 %O Moderated group (string, \"(m)\" or \"\")
1110 %P Topic indentation (string)
1111 %l Whether there are GroupLens predictions for this group (string)
1112 %n Select from where (string)
1113 %z A string that look like `<%s:%n>' if a foreign select method is used
1114 %u User defined specifier. The next character in the format string should
1115 be a letter. Gnus will call the function gnus-user-format-function-X,
1116 where X is the letter following %u. The function will be passed the
1117 current header as argument. The function should return a string, which
1118 will be inserted into the buffer just like information from any other
1121 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1122 the mouse point move inside the area. There can only be one such area.
1124 Note that this format specification is not always respected. For
1125 reasons of efficiency, when listing killed groups, this specification
1126 is ignored altogether. If the spec is changed considerably, your
1127 output may end up looking strange when listing both alive and killed
1130 If you use %o or %O, reading the active file will be slower and quite
1131 a bit of extra memory will be used. %D will also worsen performance.
1132 Also note that if you change the format specification to include any
1133 of these specs, you must probably re-start Gnus to see them go into
1136 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1137 "*The format specification of the lines in the summary buffer.
1139 It works along the same lines as a normal formatting string,
1140 with some simple extensions.
1142 %N Article number, left padded with spaces (string)
1144 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1145 %n Name of the poster (string)
1146 %a Extracted name of the poster (string)
1147 %A Extracted address of the poster (string)
1148 %F Contents of the From: header (string)
1149 %x Contents of the Xref: header (string)
1150 %D Date of the article (string)
1151 %d Date of the article (string) in DD-MMM format
1152 %M Message-id of the article (string)
1153 %r References of the article (string)
1154 %c Number of characters in the article (integer)
1155 %L Number of lines in the article (integer)
1156 %I Indentation based on thread level (a string of spaces)
1157 %T A string with two possible values: 80 spaces if the article
1158 is on thread level two or larger and 0 spaces on level one
1159 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1160 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1161 %[ Opening bracket (character, \"[\" or \"<\")
1162 %] Closing bracket (character, \"]\" or \">\")
1163 %> Spaces of length thread-level (string)
1164 %< Spaces of length (- 20 thread-level) (string)
1165 %i Article score (number)
1166 %z Article zcore (character)
1167 %t Number of articles under the current thread (number).
1168 %e Whether the thread is empty or not (character).
1169 %l GroupLens score (number)
1170 %u User defined specifier. The next character in the format string should
1171 be a letter. Gnus will call the function gnus-user-format-function-X,
1172 where X is the letter following %u. The function will be passed the
1173 current header as argument. The function should return a string, which
1174 will be inserted into the summary just like information from any other
1177 Text between %( and %) will be highlighted with `gnus-mouse-face'
1178 when the mouse point is placed inside the area. There can only be one
1181 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1182 with care. For reasons of efficiency, Gnus will compute what column
1183 these characters will end up in, and \"hard-code\" that. This means that
1184 it is illegal to have these specs after a variable-length spec. Well,
1185 you might not be arrested, but your summary buffer will look strange,
1186 which is bad enough.
1188 The smart choice is to have these specs as for to the left as
1191 This restriction may disappear in later versions of Gnus.")
1193 (defvar gnus-summary-dummy-line-format
1195 "*The format specification for the dummy roots in the summary buffer.
1196 It works along the same lines as a normal formatting string,
1197 with some simple extensions.
1201 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1202 "*The format specification for the summary mode line.
1203 It works along the same lines as a normal formatting string,
1204 with some simple extensions:
1207 %p Unprefixed group name
1208 %A Current article number
1210 %U Number of unread articles in the group
1211 %e Number of unselected articles in the group
1212 %Z A string with unread/unselected article counts
1213 %g Shortish group name
1214 %S Subject of the current article
1215 %u User-defined spec
1216 %s Current score file name
1217 %d Number of dormant articles
1218 %r Number of articles that have been marked as read in this session
1219 %E Number of articles expunged by the score files")
1221 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1222 "*The format specification for the article mode line.
1223 See `gnus-summary-mode-line-format' for a closer description.")
1225 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1226 "*The format specification for the group mode line.
1227 It works along the same lines as a normal formatting string,
1228 with some simple extensions:
1230 %S The native news server.
1231 %M The native select method.")
1233 (defvar gnus-valid-select-methods
1234 '(("nntp" post address prompt-address)
1235 ("nnspool" post address)
1236 ("nnvirtual" post-mail virtual prompt-address)
1237 ("nnmbox" mail respool address)
1238 ("nnml" mail respool address)
1239 ("nnmh" mail respool address)
1240 ("nndir" post-mail prompt-address address)
1241 ("nneething" none address prompt-address)
1242 ("nndoc" none address prompt-address)
1243 ("nnbabyl" mail address respool)
1244 ("nnkiboze" post address virtual)
1245 ("nnsoup" post-mail address)
1246 ("nndraft" post-mail)
1247 ("nnfolder" mail respool address))
1248 "An alist of valid select methods.
1249 The first element of each list lists should be a string with the name
1250 of the select method. The other elements may be be the category of
1251 this method (ie. `post', `mail', `none' or whatever) or other
1252 properties that this method has (like being respoolable).
1253 If you implement a new select method, all you should have to change is
1254 this variable. I think.")
1256 (defvar gnus-updated-mode-lines '(group article summary tree)
1257 "*List of buffers that should update their mode lines.
1258 The list may contain the symbols `group', `article' and `summary'. If
1259 the corresponding symbol is present, Gnus will keep that mode line
1260 updated with information that may be pertinent.
1261 If this variable is nil, screen refresh may be quicker.")
1263 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1264 (defvar gnus-mode-non-string-length nil
1265 "*Max length of mode-line non-string contents.
1266 If this is nil, Gnus will take space as is needed, leaving the rest
1267 of the modeline intact.")
1270 ;(defvar gnus-mouse-face 'highlight
1271 ; "*Face used for mouse highlighting in Gnus.
1272 ;No mouse highlights will be done if `gnus-visual' is nil.")
1274 (defvar gnus-summary-mark-below nil
1275 "*Mark all articles with a score below this variable as read.
1276 This variable is local to each summary buffer and usually set by the
1279 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1280 "*List of functions used for sorting articles in the summary buffer.
1281 This variable is only used when not using a threaded display.")
1283 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1284 "*List of functions used for sorting threads in the summary buffer.
1285 By default, threads are sorted by article number.
1287 Each function takes two threads and return non-nil if the first thread
1288 should be sorted before the other. If you use more than one function,
1289 the primary sort function should be the last. You should probably
1290 always include `gnus-thread-sort-by-number' in the list of sorting
1291 functions -- preferably first.
1293 Ready-mady functions include `gnus-thread-sort-by-number',
1294 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1295 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1296 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1298 (defvar gnus-thread-score-function '+
1299 "*Function used for calculating the total score of a thread.
1301 The function is called with the scores of the article and each
1302 subthread and should then return the score of the thread.
1304 Some functions you can use are `+', `max', or `min'.")
1306 (defvar gnus-summary-expunge-below nil
1307 "All articles that have a score less than this variable will be expunged.")
1309 (defvar gnus-thread-expunge-below nil
1310 "All threads that have a total score less than this variable will be expunged.
1311 See `gnus-thread-score-function' for en explanation of what a
1312 \"thread score\" is.")
1314 (defvar gnus-auto-subscribed-groups
1315 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1316 "*All new groups that match this regexp will be subscribed automatically.
1317 Note that this variable only deals with new groups. It has no effect
1318 whatsoever on old groups.")
1320 (defvar gnus-options-subscribe nil
1321 "*All new groups matching this regexp will be subscribed unconditionally.
1322 Note that this variable deals only with new newsgroups. This variable
1323 does not affect old newsgroups.")
1325 (defvar gnus-options-not-subscribe nil
1326 "*All new groups matching this regexp will be ignored.
1327 Note that this variable deals only with new newsgroups. This variable
1328 does not affect old (already subscribed) newsgroups.")
1330 (defvar gnus-auto-expirable-newsgroups nil
1331 "*Groups in which to automatically mark read articles as expirable.
1332 If non-nil, this should be a regexp that should match all groups in
1333 which to perform auto-expiry. This only makes sense for mail groups.")
1335 (defvar gnus-total-expirable-newsgroups nil
1336 "*Groups in which to perform expiry of all read articles.
1337 Use with extreme caution. All groups that match this regexp will be
1338 expiring - which means that all read articles will be deleted after
1339 (say) one week. (This only goes for mail groups and the like, of
1342 (defvar gnus-group-uncollapsed-levels 1
1343 "Number of group name elements to leave alone when making a short group name.")
1345 (defvar gnus-hidden-properties '(invisible t intangible t)
1346 "Property list to use for hiding text.")
1348 (defvar gnus-modtime-botch nil
1349 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1350 due to the bogus appearance that .newsrc was modified on disc.")
1354 (defvar gnus-group-mode-hook nil
1355 "*A hook for Gnus group mode.")
1357 (defvar gnus-summary-mode-hook nil
1358 "*A hook for Gnus summary mode.
1359 This hook is run before any variables are set in the summary buffer.")
1361 (defvar gnus-article-mode-hook nil
1362 "*A hook for Gnus article mode.")
1364 (defvar gnus-summary-prepare-exit-hook nil
1365 "*A hook called when preparing to exit from the summary buffer.
1366 It calls `gnus-summary-expire-articles' by default.")
1367 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1369 (defvar gnus-summary-exit-hook nil
1370 "*A hook called on exit from the summary buffer.")
1372 (defvar gnus-group-catchup-group-hook nil
1373 "*A hook run when catching up a group from the group buffer.")
1375 (defvar gnus-open-server-hook nil
1376 "*A hook called just before opening connection to the news server.")
1378 (defvar gnus-load-hook nil
1379 "*A hook run while Gnus is loaded.")
1381 (defvar gnus-startup-hook nil
1382 "*A hook called at startup.
1383 This hook is called after Gnus is connected to the NNTP server.")
1385 (defvar gnus-get-new-news-hook nil
1386 "*A hook run just before Gnus checks for new news.")
1388 (defvar gnus-after-getting-new-news-hook nil
1389 "*A hook run after Gnus checks for new news.")
1391 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1392 "*A function that is called to generate the group buffer.
1393 The function is called with three arguments: The first is a number;
1394 all group with a level less or equal to that number should be listed,
1395 if the second is non-nil, empty groups should also be displayed. If
1396 the third is non-nil, it is a number. No groups with a level lower
1397 than this number should be displayed.
1399 The only current function implemented is `gnus-group-prepare-flat'.")
1401 (defvar gnus-group-prepare-hook nil
1402 "*A hook called after the group buffer has been generated.
1403 If you want to modify the group buffer, you can use this hook.")
1405 (defvar gnus-summary-prepare-hook nil
1406 "*A hook called after the summary buffer has been generated.
1407 If you want to modify the summary buffer, you can use this hook.")
1409 (defvar gnus-summary-generate-hook nil
1410 "*A hook run just before generating the summary buffer.
1411 This hook is commonly used to customize threading variables and the
1414 (defvar gnus-article-prepare-hook nil
1415 "*A hook called after an article has been prepared in the article buffer.
1416 If you want to run a special decoding program like nkf, use this hook.")
1418 ;(defvar gnus-article-display-hook nil
1419 ; "*A hook called after the article is displayed in the article buffer.
1420 ;The hook is designed to change the contents of the article
1421 ;buffer. Typical functions that this hook may contain are
1422 ;`gnus-article-hide-headers' (hide selected headers),
1423 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1424 ;`gnus-article-hide-signature' (hide signature) and
1425 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1426 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1427 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1428 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1430 (defvar gnus-article-x-face-command
1431 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1432 "String or function to be executed to display an X-Face header.
1433 If it is a string, the command will be executed in a sub-shell
1434 asynchronously. The compressed face will be piped to this command.")
1436 (defvar gnus-article-x-face-too-ugly nil
1437 "Regexp matching posters whose face shouldn't be shown automatically.")
1439 (defvar gnus-select-group-hook nil
1440 "*A hook called when a newsgroup is selected.
1442 If you'd like to simplify subjects like the
1443 `gnus-summary-next-same-subject' command does, you can use the
1446 (setq gnus-select-group-hook
1449 (mapcar (lambda (header)
1450 (mail-header-set-subject
1452 (gnus-simplify-subject
1453 (mail-header-subject header) 're-only)))
1454 gnus-newsgroup-headers))))")
1456 (defvar gnus-select-article-hook nil
1457 "*A hook called when an article is selected.")
1459 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1460 "*A hook called to apply kill files to a group.
1461 This hook is intended to apply a kill file to the selected newsgroup.
1462 The function `gnus-apply-kill-file' is called by default.
1464 Since a general kill file is too heavy to use only for a few
1465 newsgroups, I recommend you to use a lighter hook function. For
1466 example, if you'd like to apply a kill file to articles which contains
1467 a string `rmgroup' in subject in newsgroup `control', you can use the
1470 (setq gnus-apply-kill-hook
1473 (cond ((string-match \"control\" gnus-newsgroup-name)
1474 (gnus-kill \"Subject\" \"rmgroup\")
1475 (gnus-expunge \"X\"))))))")
1477 (defvar gnus-visual-mark-article-hook
1478 (list 'gnus-highlight-selected-summary)
1479 "*Hook run after selecting an article in the summary buffer.
1480 It is meant to be used for highlighting the article in some way. It
1481 is not run if `gnus-visual' is nil.")
1483 (defvar gnus-parse-headers-hook nil
1484 "*A hook called before parsing the headers.")
1486 (defvar gnus-exit-group-hook nil
1487 "*A hook called when exiting (not quitting) summary mode.")
1489 (defvar gnus-suspend-gnus-hook nil
1490 "*A hook called when suspending (not exiting) Gnus.")
1492 (defvar gnus-exit-gnus-hook nil
1493 "*A hook called when exiting Gnus.")
1495 (defvar gnus-after-exiting-gnus-hook nil
1496 "*A hook called after exiting Gnus.")
1498 (defvar gnus-save-newsrc-hook nil
1499 "*A hook called before saving any of the newsrc files.")
1501 (defvar gnus-save-quick-newsrc-hook nil
1502 "*A hook called just before saving the quick newsrc file.
1503 Can be used to turn version control on or off.")
1505 (defvar gnus-save-standard-newsrc-hook nil
1506 "*A hook called just before saving the standard newsrc file.
1507 Can be used to turn version control on or off.")
1509 (defvar gnus-summary-update-hook
1510 (list 'gnus-summary-highlight-line)
1511 "*A hook called when a summary line is changed.
1512 The hook will not be called if `gnus-visual' is nil.
1514 The default function `gnus-summary-highlight-line' will
1515 highlight the line according to the `gnus-summary-highlight'
1518 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1519 "*A hook called when a group line is changed.
1520 The hook will not be called if `gnus-visual' is nil.
1522 The default function `gnus-group-highlight-line' will
1523 highlight the line according to the `gnus-group-highlight'
1526 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1527 "*A hook called when an article is selected for the first time.
1528 The hook is intended to mark an article as read (or unread)
1529 automatically when it is selected.")
1531 (defvar gnus-group-change-level-function nil
1532 "Function run when a group level is changed.
1533 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1535 ;; Remove any hilit infestation.
1536 (add-hook 'gnus-startup-hook
1538 (remove-hook 'gnus-summary-prepare-hook
1539 'hilit-rehighlight-buffer-quietly)
1540 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1541 (setq gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read))
1542 (remove-hook 'gnus-article-prepare-hook
1543 'hilit-rehighlight-buffer-quietly)))
1546 ;; Internal variables
1548 (defvar gnus-server-alist nil
1549 "List of available servers.")
1551 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1553 (defvar gnus-goto-missing-group-function nil)
1555 (defvar gnus-override-subscribe-method nil)
1557 (defvar gnus-group-goto-next-group-function nil
1558 "Function to override finding the next group after listing groups.")
1560 (defconst gnus-article-mark-lists
1561 '((marked . tick) (replied . reply)
1562 (expirable . expire) (killed . killed)
1563 (bookmarks . bookmark) (dormant . dormant)
1564 (scored . score) (saved . save)
1568 ;; Avoid highlighting in kill files.
1569 (defvar gnus-summary-inhibit-highlight nil)
1570 (defvar gnus-newsgroup-selected-overlay nil)
1572 (defvar gnus-inhibit-hiding nil)
1573 (defvar gnus-group-indentation "")
1574 (defvar gnus-inhibit-limiting nil)
1575 (defvar gnus-created-frames nil)
1577 (defvar gnus-article-mode-map nil)
1578 (defvar gnus-dribble-buffer nil)
1579 (defvar gnus-headers-retrieved-by nil)
1580 (defvar gnus-article-reply nil)
1581 (defvar gnus-override-method nil)
1582 (defvar gnus-article-check-size nil)
1584 (defvar gnus-current-score-file nil)
1585 (defvar gnus-newsgroup-adaptive-score-file nil)
1586 (defvar gnus-scores-exclude-files nil)
1588 (defvar gnus-opened-servers nil)
1590 (defvar gnus-current-move-group nil)
1592 (defvar gnus-newsgroup-dependencies nil)
1593 (defvar gnus-newsgroup-async nil)
1594 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1596 (defvar gnus-newsgroup-adaptive nil)
1598 (defvar gnus-summary-display-table nil)
1599 (defvar gnus-summary-display-article-function nil)
1601 (defvar gnus-summary-highlight-line-function nil
1602 "Function called after highlighting a summary line.")
1604 (defvar gnus-group-line-format-alist
1605 `((?M gnus-tmp-marked-mark ?c)
1606 (?S gnus-tmp-subscribed ?c)
1607 (?L gnus-tmp-level ?d)
1608 (?N (cond ((eq number t) "*" )
1612 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1613 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1615 (?R gnus-tmp-number-of-read ?s)
1616 (?t gnus-tmp-number-total ?d)
1617 (?y gnus-tmp-number-of-unread ?s)
1618 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1619 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1620 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1621 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1622 (?g gnus-tmp-group ?s)
1623 (?G gnus-tmp-qualified-group ?s)
1624 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1625 (?D gnus-tmp-newsgroup-description ?s)
1626 (?o gnus-tmp-moderated ?c)
1627 (?O gnus-tmp-moderated-string ?s)
1628 (?p gnus-tmp-process-marked ?c)
1629 (?s gnus-tmp-news-server ?s)
1630 (?n gnus-tmp-news-method ?s)
1631 (?P gnus-group-indentation ?s)
1632 (?l gnus-tmp-grouplens ?s)
1633 (?z gnus-tmp-news-method-string ?s)
1634 (?u gnus-tmp-user-defined ?s)))
1636 (defvar gnus-summary-line-format-alist
1637 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1638 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1639 (?s gnus-tmp-subject-or-nil ?s)
1640 (?n gnus-tmp-name ?s)
1641 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1643 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1645 (?F gnus-tmp-from ?s)
1646 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1647 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1648 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1649 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1650 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1651 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1652 (?L gnus-tmp-lines ?d)
1653 (?I gnus-tmp-indentation ?s)
1654 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1655 (?R gnus-tmp-replied ?c)
1656 (?\[ gnus-tmp-opening-bracket ?c)
1657 (?\] gnus-tmp-closing-bracket ?c)
1658 (?\> (make-string gnus-tmp-level ? ) ?s)
1659 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1660 (?i gnus-tmp-score ?d)
1661 (?z gnus-tmp-score-char ?c)
1662 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1663 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1664 (?U gnus-tmp-unread ?c)
1665 (?t (gnus-summary-number-of-articles-in-thread
1666 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1668 (?e (gnus-summary-number-of-articles-in-thread
1669 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1671 (?u gnus-tmp-user-defined ?s))
1672 "An alist of format specifications that can appear in summary lines,
1673 and what variables they correspond with, along with the type of the
1674 variable (string, integer, character, etc).")
1676 (defvar gnus-summary-dummy-line-format-alist
1677 `((?S gnus-tmp-subject ?s)
1678 (?N gnus-tmp-number ?d)
1679 (?u gnus-tmp-user-defined ?s)))
1681 (defvar gnus-summary-mode-line-format-alist
1682 `((?G gnus-tmp-group-name ?s)
1683 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1684 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1685 (?A gnus-tmp-article-number ?d)
1686 (?Z gnus-tmp-unread-and-unselected ?s)
1687 (?V gnus-version ?s)
1688 (?U gnus-tmp-unread ?d)
1689 (?S gnus-tmp-subject ?s)
1690 (?e gnus-tmp-unselected ?d)
1691 (?u gnus-tmp-user-defined ?s)
1692 (?d (length gnus-newsgroup-dormant) ?d)
1693 (?t (length gnus-newsgroup-marked) ?d)
1694 (?r (length gnus-newsgroup-reads) ?d)
1695 (?E gnus-newsgroup-expunged-tally ?d)
1696 (?s (gnus-current-score-file-nondirectory) ?s)))
1698 (defvar gnus-article-mode-line-format-alist
1699 gnus-summary-mode-line-format-alist)
1701 (defvar gnus-group-mode-line-format-alist
1702 `((?S gnus-tmp-news-server ?s)
1703 (?M gnus-tmp-news-method ?s)
1704 (?u gnus-tmp-user-defined ?s)))
1706 (defvar gnus-have-read-active-file nil)
1708 (defconst gnus-maintainer
1709 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1710 "The mail address of the Gnus maintainers.")
1712 (defconst gnus-version "September Gnus v0.49"
1713 "Version number for this version of Gnus.")
1715 (defvar gnus-info-nodes
1716 '((gnus-group-mode "(gnus)The Group Buffer")
1717 (gnus-summary-mode "(gnus)The Summary Buffer")
1718 (gnus-article-mode "(gnus)The Article Buffer"))
1719 "Assoc list of major modes and related Info nodes.")
1721 (defvar gnus-group-buffer "*Group*")
1722 (defvar gnus-summary-buffer "*Summary*")
1723 (defvar gnus-article-buffer "*Article*")
1724 (defvar gnus-server-buffer "*Server*")
1726 (defvar gnus-work-buffer " *gnus work*")
1728 (defvar gnus-original-article-buffer " *Original Article*")
1729 (defvar gnus-original-article nil)
1731 (defvar gnus-buffer-list nil
1732 "Gnus buffers that should be killed on exit.")
1734 (defvar gnus-slave nil
1735 "Whether this Gnus is a slave or not.")
1737 (defvar gnus-variable-list
1738 '(gnus-newsrc-options gnus-newsrc-options-n
1739 gnus-newsrc-last-checked-date
1740 gnus-newsrc-alist gnus-server-alist
1741 gnus-killed-list gnus-zombie-list
1742 gnus-topic-topology gnus-topic-alist
1744 "Gnus variables saved in the quick startup file.")
1746 (defvar gnus-newsrc-options nil
1747 "Options line in the .newsrc file.")
1749 (defvar gnus-newsrc-options-n nil
1750 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1752 (defvar gnus-newsrc-last-checked-date nil
1753 "Date Gnus last asked server for new newsgroups.")
1755 (defvar gnus-topic-topology nil
1756 "The complete topic hierarchy.")
1758 (defvar gnus-topic-alist nil
1759 "The complete topic-group alist.")
1761 (defvar gnus-newsrc-alist nil
1762 "Assoc list of read articles.
1763 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1765 (defvar gnus-newsrc-hashtb nil
1766 "Hashtable of gnus-newsrc-alist.")
1768 (defvar gnus-killed-list nil
1769 "List of killed newsgroups.")
1771 (defvar gnus-killed-hashtb nil
1772 "Hash table equivalent of gnus-killed-list.")
1774 (defvar gnus-zombie-list nil
1775 "List of almost dead newsgroups.")
1777 (defvar gnus-description-hashtb nil
1778 "Descriptions of newsgroups.")
1780 (defvar gnus-list-of-killed-groups nil
1781 "List of newsgroups that have recently been killed by the user.")
1783 (defvar gnus-active-hashtb nil
1784 "Hashtable of active articles.")
1786 (defvar gnus-moderated-list nil
1787 "List of moderated newsgroups.")
1789 (defvar gnus-group-marked nil)
1791 (defvar gnus-current-startup-file nil
1792 "Startup file for the current host.")
1794 (defvar gnus-last-search-regexp nil
1795 "Default regexp for article search command.")
1797 (defvar gnus-last-shell-command nil
1798 "Default shell command on article.")
1800 (defvar gnus-current-select-method nil
1801 "The current method for selecting a newsgroup.")
1803 (defvar gnus-group-list-mode nil)
1805 (defvar gnus-article-internal-prepare-hook nil)
1807 (defvar gnus-newsgroup-name nil)
1808 (defvar gnus-newsgroup-begin nil)
1809 (defvar gnus-newsgroup-end nil)
1810 (defvar gnus-newsgroup-last-rmail nil)
1811 (defvar gnus-newsgroup-last-mail nil)
1812 (defvar gnus-newsgroup-last-folder nil)
1813 (defvar gnus-newsgroup-last-file nil)
1814 (defvar gnus-newsgroup-auto-expire nil)
1815 (defvar gnus-newsgroup-active nil)
1817 (defvar gnus-newsgroup-data nil)
1818 (defvar gnus-newsgroup-data-reverse nil)
1819 (defvar gnus-newsgroup-limit nil)
1820 (defvar gnus-newsgroup-limits nil)
1822 (defvar gnus-newsgroup-unreads nil
1823 "List of unread articles in the current newsgroup.")
1825 (defvar gnus-newsgroup-unselected nil
1826 "List of unselected unread articles in the current newsgroup.")
1828 (defvar gnus-newsgroup-reads nil
1829 "Alist of read articles and article marks in the current newsgroup.")
1831 (defvar gnus-newsgroup-expunged-tally nil)
1833 (defvar gnus-newsgroup-marked nil
1834 "List of ticked articles in the current newsgroup (a subset of unread art).")
1836 (defvar gnus-newsgroup-killed nil
1837 "List of ranges of articles that have been through the scoring process.")
1839 (defvar gnus-newsgroup-cached nil
1840 "List of articles that come from the article cache.")
1842 (defvar gnus-newsgroup-saved nil
1843 "List of articles that have been saved.")
1845 (defvar gnus-newsgroup-kill-headers nil)
1847 (defvar gnus-newsgroup-replied nil
1848 "List of articles that have been replied to in the current newsgroup.")
1850 (defvar gnus-newsgroup-expirable nil
1851 "List of articles in the current newsgroup that can be expired.")
1853 (defvar gnus-newsgroup-processable nil
1854 "List of articles in the current newsgroup that can be processed.")
1856 (defvar gnus-newsgroup-bookmarks nil
1857 "List of articles in the current newsgroup that have bookmarks.")
1859 (defvar gnus-newsgroup-dormant nil
1860 "List of dormant articles in the current newsgroup.")
1862 (defvar gnus-newsgroup-scored nil
1863 "List of scored articles in the current newsgroup.")
1865 (defvar gnus-newsgroup-headers nil
1866 "List of article headers in the current newsgroup.")
1868 (defvar gnus-newsgroup-threads nil)
1870 (defvar gnus-newsgroup-prepared nil
1871 "Whether the current group has been prepared properly.")
1873 (defvar gnus-newsgroup-ancient nil
1874 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1876 (defvar gnus-newsgroup-sparse nil)
1878 (defvar gnus-current-article nil)
1879 (defvar gnus-article-current nil)
1880 (defvar gnus-current-headers nil)
1881 (defvar gnus-have-all-headers nil)
1882 (defvar gnus-last-article nil)
1883 (defvar gnus-newsgroup-history nil)
1884 (defvar gnus-current-kill-article nil)
1886 ;; Save window configuration.
1887 (defvar gnus-prev-winconf nil)
1889 (defvar gnus-summary-mark-positions nil)
1890 (defvar gnus-group-mark-positions nil)
1892 (defvar gnus-reffed-article-number nil)
1894 ;;; Let the byte-compiler know that we know about this variable.
1895 (defvar rmail-default-rmail-file)
1897 (defvar gnus-cache-removable-articles nil)
1899 (defvar gnus-dead-summary nil)
1901 (defconst gnus-summary-local-variables
1902 '(gnus-newsgroup-name
1903 gnus-newsgroup-begin gnus-newsgroup-end
1904 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1905 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1906 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1907 gnus-newsgroup-unselected gnus-newsgroup-marked
1908 gnus-newsgroup-reads gnus-newsgroup-saved
1909 gnus-newsgroup-replied gnus-newsgroup-expirable
1910 gnus-newsgroup-processable gnus-newsgroup-killed
1911 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1912 gnus-newsgroup-headers gnus-newsgroup-threads
1913 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1914 gnus-current-article gnus-current-headers gnus-have-all-headers
1915 gnus-last-article gnus-article-internal-prepare-hook
1916 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1917 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1918 gnus-newsgroup-async
1919 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1920 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1921 gnus-newsgroup-history gnus-newsgroup-ancient
1922 gnus-newsgroup-sparse
1923 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1924 gnus-newsgroup-adaptive-score-file
1925 (gnus-newsgroup-expunged-tally . 0)
1926 gnus-cache-removable-articles gnus-newsgroup-cached
1927 gnus-newsgroup-data gnus-newsgroup-data-reverse
1928 gnus-newsgroup-limit gnus-newsgroup-limits)
1929 "Variables that are buffer-local to the summary buffers.")
1931 (defconst gnus-bug-message
1932 "Sending a bug report to the Gnus Towers.
1933 ========================================
1935 The buffer below is a mail buffer. When you press `C-c C-c', it will
1936 be sent to the Gnus Bug Exterminators.
1938 At the bottom of the buffer you'll see lots of variable settings.
1939 Please do not delete those. They will tell the Bug People what your
1940 environment is, so that it will be easier to locate the bugs.
1942 If you have found a bug that makes Emacs go \"beep\", set
1943 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1944 and include the backtrace in your bug report.
1946 Please describe the bug in annoying, painstaking detail.
1948 Thank you for your help in stamping out bugs.
1951 ;;; End of variables.
1953 ;; Define some autoload functions Gnus might use.
1956 ;; This little mapcar goes through the list below and marks the
1957 ;; symbols in question as autoloaded functions.
1960 (let ((interactive (nth 1 (memq ':interactive package))))
1964 (when (consp function)
1965 (setq keymap (car (memq 'keymap function)))
1966 (setq function (car function)))
1967 (autoload function (car package) nil interactive keymap)))
1968 (if (eq (nth 1 package) ':interactive)
1971 '(("metamail" metamail-buffer)
1972 ("info" Info-goto-node)
1973 ("hexl" hexl-hex-string-to-integer)
1974 ("pp" pp pp-to-string pp-eval-expression)
1975 ("mail-extr" mail-extract-address-components)
1976 ("nnmail" nnmail-split-fancy nnmail-article-group)
1977 ("nnvirtual" nnvirtual-catchup-group)
1978 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1979 timezone-make-sortable-date timezone-make-time-string)
1980 ("sendmail" mail-position-on-field mail-setup)
1981 ("rmailout" rmail-output)
1982 ("rnewspost" news-mail-other-window news-reply-yank-original
1983 news-caesar-buffer-body)
1984 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1986 ("gnus-soup" :interactive t
1987 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1988 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1989 ("nnsoup" nnsoup-pack-replies)
1990 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1991 gnus-Folder-save-name gnus-folder-save-name)
1992 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1993 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1994 gnus-server-make-menu-bar gnus-article-make-menu-bar
1995 gnus-browse-make-menu-bar gnus-highlight-selected-summary
1996 gnus-summary-highlight-line gnus-carpal-setup-buffer
1997 gnus-group-highlight-line
1998 gnus-article-add-button gnus-insert-next-page-button
1999 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2000 ("gnus-vis" :interactive t
2001 gnus-article-push-button gnus-article-press-button
2002 gnus-article-highlight gnus-article-highlight-some
2003 gnus-article-highlight-headers gnus-article-highlight-signature
2004 gnus-article-add-buttons gnus-article-add-buttons-to-head
2005 gnus-article-next-button gnus-article-prev-button)
2006 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2007 gnus-demon-add-disconnection gnus-demon-add-handler
2008 gnus-demon-remove-handler)
2009 ("gnus-demon" :interactive t
2010 gnus-demon-init gnus-demon-cancel)
2011 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2012 gnus-tree-open gnus-tree-close)
2013 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2014 gnus-nocem-unwanted-article-p)
2015 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2016 ("gnus-srvr" gnus-browse-foreign-server)
2017 ("gnus-cite" :interactive t
2018 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2019 gnus-article-hide-citation gnus-article-fill-cited-article)
2020 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2021 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2022 gnus-execute gnus-expunge)
2023 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2024 gnus-cache-possibly-remove-articles gnus-cache-request-article
2025 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2026 gnus-cache-enter-remove-article gnus-cached-article-p
2027 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2028 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2029 gnus-cache-remove-article)
2030 ("gnus-score" :interactive t
2031 gnus-summary-increase-score gnus-summary-lower-score
2032 gnus-score-flush-cache gnus-score-close
2033 gnus-score-raise-same-subject-and-select
2034 gnus-score-raise-same-subject gnus-score-default
2035 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2036 gnus-score-lower-same-subject gnus-score-lower-thread
2037 gnus-possibly-score-headers)
2039 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2040 gnus-current-score-file-nondirectory gnus-score-adaptive
2041 gnus-score-find-trace gnus-score-file-name)
2042 ("gnus-edit" :interactive t gnus-score-customize)
2043 ("gnus-topic" :interactive t gnus-topic-mode)
2044 ("gnus-topic" gnus-topic-remove-group)
2045 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2046 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2047 ("gnus-uu" :interactive t
2048 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2049 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2050 gnus-uu-mark-by-regexp gnus-uu-mark-all
2051 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2052 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2053 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2054 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2055 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2056 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2057 gnus-uu-decode-binhex-view)
2058 ("gnus-msg" (gnus-summary-send-map keymap)
2059 gnus-mail-yank-original gnus-mail-send-and-exit
2060 gnus-sendmail-setup-mail gnus-article-mail
2061 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2062 ("gnus-msg" :interactive t
2063 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2064 gnus-summary-followup gnus-summary-followup-with-original
2065 gnus-summary-followup-and-reply
2066 gnus-summary-followup-and-reply-with-original
2067 gnus-summary-cancel-article gnus-summary-supersede-article
2068 gnus-post-news gnus-inews-news gnus-cancel-news
2069 gnus-summary-reply gnus-summary-reply-with-original
2070 gnus-summary-mail-forward gnus-summary-mail-other-window
2072 ("gnus-picon" :interactive t gnus-article-display-picons
2073 gnus-group-display-picons gnus-picons-article-display-x-face)
2074 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2075 gnus-grouplens-mode)
2076 ("gnus-vm" gnus-vm-mail-setup)
2077 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2078 gnus-summary-save-article-vm gnus-yank-article))))
2082 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2083 ;; If you want the cursor to go somewhere else, set these two
2084 ;; functions in some startup hook to whatever you want.
2085 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2086 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2088 ;;; Various macros and substs.
2090 (defun gnus-header-from (header)
2091 (mail-header-from header))
2093 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2094 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2095 `(let ((GnusStartBufferWindow (selected-window)))
2098 (pop-to-buffer ,buffer)
2100 (select-window GnusStartBufferWindow))))
2102 (defmacro gnus-gethash (string hashtable)
2103 "Get hash value of STRING in HASHTABLE."
2104 `(symbol-value (intern-soft ,string ,hashtable)))
2106 (defmacro gnus-sethash (string value hashtable)
2107 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2108 `(set (intern ,string ,hashtable) ,value))
2110 (defmacro gnus-intern-safe (string hashtable)
2111 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2112 `(let ((symbol (intern ,string ,hashtable)))
2117 (defmacro gnus-group-unread (group)
2118 "Get the currently computed number of unread articles in GROUP."
2119 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2121 (defmacro gnus-group-entry (group)
2122 "Get the newsrc entry for GROUP."
2123 `(gnus-gethash ,group gnus-newsrc-hashtb))
2125 (defmacro gnus-active (group)
2126 "Get active info on GROUP."
2127 `(gnus-gethash ,group gnus-active-hashtb))
2129 (defmacro gnus-set-active (group active)
2130 "Set GROUP's active info."
2131 `(gnus-sethash ,group ,active gnus-active-hashtb))
2133 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2134 ;; function `substring' might cut on a middle of multi-octet
2136 (defun gnus-truncate-string (str width)
2137 (substring str 0 width))
2139 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2140 ;; to limit the length of a string. This function is necessary since
2141 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2142 (defsubst gnus-limit-string (str width)
2143 (if (> (length str) width)
2144 (substring str 0 width)
2147 (defsubst gnus-simplify-subject-re (subject)
2148 "Remove \"Re:\" from subject lines."
2149 (if (string-match "^[Rr][Ee]: *" subject)
2150 (substring subject (match-end 0))
2153 (defsubst gnus-goto-char (point)
2154 (and point (goto-char point)))
2156 (defmacro gnus-buffer-exists-p (buffer)
2158 (funcall (if (stringp ,buffer) 'get-buffer 'buffer-name)
2161 (defmacro gnus-kill-buffer (buffer)
2162 `(let ((buf ,buffer))
2163 (if (gnus-buffer-exists-p buf)
2164 (kill-buffer buf))))
2166 (defsubst gnus-point-at-bol ()
2167 "Return point at the beginning of the line."
2174 (defsubst gnus-point-at-eol ()
2175 "Return point at the end of the line."
2182 (defun gnus-alive-p ()
2183 "Say whether Gnus is running or not."
2184 (and gnus-group-buffer
2185 (get-buffer gnus-group-buffer)))
2187 ;; Delete the current line (and the next N lines.);
2188 (defmacro gnus-delete-line (&optional n)
2189 `(delete-region (progn (beginning-of-line) (point))
2190 (progn (forward-line ,(or n 1)) (point))))
2192 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2193 (defvar gnus-init-inhibit nil)
2194 (defun gnus-read-init-file (&optional inhibit-next)
2195 (if gnus-init-inhibit
2196 (setq gnus-init-inhibit nil)
2197 (setq gnus-init-inhibit inhibit-next)
2199 (or (and (file-exists-p gnus-init-file)
2200 ;; Don't try to load a directory.
2201 (not (file-directory-p gnus-init-file)))
2202 (file-exists-p (concat gnus-init-file ".el"))
2203 (file-exists-p (concat gnus-init-file ".elc")))
2205 (load gnus-init-file nil t)
2207 (error "Error in %s: %s" gnus-init-file var))))))
2209 ;; Info access macros.
2211 (defmacro gnus-info-group (info)
2213 (defmacro gnus-info-rank (info)
2215 (defmacro gnus-info-read (info)
2217 (defmacro gnus-info-marks (info)
2219 (defmacro gnus-info-method (info)
2221 (defmacro gnus-info-params (info)
2224 (defmacro gnus-info-level (info)
2225 `(let ((rank (gnus-info-rank ,info)))
2229 (defmacro gnus-info-score (info)
2230 `(let ((rank (gnus-info-rank ,info)))
2231 (or (and (consp rank) (cdr rank)) 0)))
2233 (defmacro gnus-info-set-group (info group)
2234 `(setcar ,info ,group))
2235 (defmacro gnus-info-set-rank (info rank)
2236 `(setcar (nthcdr 1 ,info) ,rank))
2237 (defmacro gnus-info-set-read (info read)
2238 `(setcar (nthcdr 2 ,info) ,read))
2239 (defmacro gnus-info-set-marks (info marks)
2240 `(setcar (nthcdr 3 ,info) ,marks))
2241 (defmacro gnus-info-set-method (info method)
2242 `(setcar (nthcdr 4 ,info) ,method))
2243 (defmacro gnus-info-set-params (info params)
2244 `(setcar (nthcdr 5 ,info) ,params))
2246 (defmacro gnus-info-set-level (info level)
2247 `(let ((rank (cdr ,info)))
2248 (if (consp (car rank))
2249 (setcar (car rank) ,level)
2250 (setcar rank ,level))))
2251 (defmacro gnus-info-set-score (info score)
2252 `(let ((rank (cdr ,info)))
2253 (if (consp (car rank))
2254 (setcdr (car rank) ,score)
2255 (setcar rank (cons (car rank) ,score)))))
2257 (defmacro gnus-get-info (group)
2258 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2260 (defun gnus-byte-code (func)
2261 "Return a form that can be `eval'ed based on FUNC."
2262 (let ((fval (symbol-function func)))
2263 (if (byte-code-function-p fval)
2264 (let ((flist (append fval nil)))
2265 (setcar flist 'byte-code)
2267 (cons 'progn (cddr fval)))))
2269 ;;; Load the compatability functions.
2276 ;; Format specs. The chunks below are the machine-generated forms
2277 ;; that are to be evaled as the result of the default format strings.
2278 ;; We write them in here to get them byte-compiled. That way the
2279 ;; default actions will be quite fast, while still retaining the full
2280 ;; flexibility of the user-defined format specs.
2282 ;; First we have lots of dummy defvars to let the compiler know these
2283 ;; are really dynamic variables.
2285 (defvar gnus-tmp-unread)
2286 (defvar gnus-tmp-replied)
2287 (defvar gnus-tmp-score-char)
2288 (defvar gnus-tmp-indentation)
2289 (defvar gnus-tmp-opening-bracket)
2290 (defvar gnus-tmp-lines)
2291 (defvar gnus-tmp-name)
2292 (defvar gnus-tmp-closing-bracket)
2293 (defvar gnus-tmp-subject-or-nil)
2294 (defvar gnus-tmp-subject)
2295 (defvar gnus-tmp-marked)
2296 (defvar gnus-tmp-marked-mark)
2297 (defvar gnus-tmp-subscribed)
2298 (defvar gnus-tmp-process-marked)
2299 (defvar gnus-tmp-number-of-unread)
2300 (defvar gnus-tmp-group-name)
2301 (defvar gnus-tmp-group)
2302 (defvar gnus-tmp-article-number)
2303 (defvar gnus-tmp-unread-and-unselected)
2304 (defvar gnus-tmp-news-method)
2305 (defvar gnus-tmp-news-server)
2306 (defvar gnus-tmp-article-number)
2307 (defvar gnus-mouse-face)
2308 (defvar gnus-mouse-face-prop)
2310 (defun gnus-summary-line-format-spec ()
2311 (insert gnus-tmp-unread gnus-tmp-replied
2312 gnus-tmp-score-char gnus-tmp-indentation)
2317 gnus-tmp-opening-bracket
2318 (format "%4d: %-20s"
2320 (if (> (length gnus-tmp-name) 20)
2321 (substring gnus-tmp-name 0 20)
2323 gnus-tmp-closing-bracket)
2325 gnus-mouse-face-prop gnus-mouse-face)
2326 (insert " " gnus-tmp-subject-or-nil "\n"))
2328 (defvar gnus-summary-line-format-spec
2329 (gnus-byte-code 'gnus-summary-line-format-spec))
2331 (defun gnus-summary-dummy-line-format-spec ()
2338 gnus-mouse-face-prop gnus-mouse-face)
2339 (insert " " gnus-tmp-subject "\n"))
2341 (defvar gnus-summary-dummy-line-format-spec
2342 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2344 (defun gnus-group-line-format-spec ()
2345 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2346 gnus-tmp-process-marked
2347 gnus-group-indentation
2348 (format "%5s: " gnus-tmp-number-of-unread))
2352 (insert gnus-tmp-group "\n")
2354 gnus-mouse-face-prop gnus-mouse-face))
2355 (defvar gnus-group-line-format-spec
2356 (gnus-byte-code 'gnus-group-line-format-spec))
2358 (defvar gnus-format-specs
2359 `((version . ,emacs-version)
2360 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2361 (summary-dummy ,gnus-summary-dummy-line-format
2362 ,gnus-summary-dummy-line-format-spec)
2363 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2365 (defvar gnus-article-mode-line-format-spec nil)
2366 (defvar gnus-summary-mode-line-format-spec nil)
2367 (defvar gnus-group-mode-line-format-spec nil)
2369 ;;; Phew. All that gruft is over, fortunately.
2373 ;;; Gnus Utility Functions
2376 (defun gnus-extract-address-components (from)
2378 ;; First find the address - the thing with the @ in it. This may
2379 ;; not be accurate in mail addresses, but does the trick most of
2380 ;; the time in news messages.
2381 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2382 (setq address (substring from (match-beginning 0) (match-end 0))))
2383 ;; Then we check whether the "name <address>" format is used.
2385 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2386 ;; Linear white space is not required.
2387 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2388 (and (setq name (substring from 0 (match-beginning 0)))
2389 ;; Strip any quotes from the name.
2390 (string-match "\".*\"" name)
2391 (setq name (substring name 1 (1- (match-end 0))))))
2392 ;; If not, then "address (name)" is used.
2394 (and (string-match "(.+)" from)
2395 (setq name (substring from (1+ (match-beginning 0))
2396 (1- (match-end 0)))))
2397 (and (string-match "()" from)
2398 (setq name address))
2399 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2400 ;; XOVER might not support folded From headers.
2401 (and (string-match "(.*" from)
2402 (setq name (substring from (1+ (match-beginning 0))
2404 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2405 (list (or name from) (or address from))))
2407 (defun gnus-fetch-field (field)
2408 "Return the value of the header FIELD of current article."
2411 (let ((case-fold-search t))
2412 (nnheader-narrow-to-headers)
2413 (mail-fetch-field field)))))
2415 (defun gnus-goto-colon ()
2417 (search-forward ":" (gnus-point-at-eol) t))
2420 (defun gnus-update-format (var)
2421 "Update the format specification near point."
2426 ;; Find the end of the current word.
2427 (re-search-forward "[ \t\n]" nil t)
2429 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2430 (match-string 1)))))
2431 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2432 (match-string 1 var))))
2433 (entry (assq type gnus-format-specs))
2436 (setq gnus-format-specs (delq entry gnus-format-specs)))
2438 (intern (format "%s-spec" var))
2439 (gnus-parse-format (setq value (symbol-value (intern var)))
2440 (symbol-value (intern (format "%s-alist" var)))
2441 (not (string-match "mode" var))))
2442 (setq spec (symbol-value (intern (format "%s-spec" var))))
2443 (push (list type value spec) gnus-format-specs)
2445 (pop-to-buffer "*Gnus Format*")
2447 (lisp-interaction-mode)
2448 (insert (pp-to-string spec))))
2450 (defun gnus-update-format-specifications (&optional force)
2451 "Update all (necessary) format specifications."
2452 ;; Make the indentation array.
2453 (gnus-make-thread-indent-array)
2455 ;; See whether all the stored info needs to be flushed.
2457 (not (equal emacs-version
2458 (cdr (assq 'version gnus-format-specs)))))
2459 (setq gnus-format-specs nil))
2461 ;; Go through all the formats and see whether they need updating.
2462 (let ((types '(summary summary-dummy group
2463 summary-mode group-mode article-mode))
2464 new-format entry type val)
2465 (while (setq type (pop types))
2466 ;; Jump to the proper buffer to find out the value of
2467 ;; the variable, if possible. (It may be buffer-local.)
2469 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2471 (when (and (boundp buffer)
2472 (setq val (symbol-value buffer))
2474 (buffer-name (get-buffer val)))
2475 (set-buffer (get-buffer val)))
2476 (setq new-format (symbol-value
2477 (intern (format "gnus-%s-line-format" type))))))
2478 (setq entry (cdr (assq type gnus-format-specs)))
2480 (equal (car entry) new-format))
2481 ;; Use the old format.
2482 (set (intern (format "gnus-%s-line-format-spec" type))
2484 ;; This is a new format.
2486 (if (not (stringp new-format))
2487 ;; This is a function call or something.
2489 ;; This is a "real" format.
2493 (intern (format "gnus-%s-line-format-alist"
2494 (if (eq type 'article-mode)
2495 'summary-mode type))))
2496 (not (string-match "mode$" (symbol-name type))))))
2497 ;; Enter the new format spec into the list.
2500 (setcar (cdr entry) val)
2501 (setcar entry new-format))
2502 (push (list type new-format val) gnus-format-specs))
2503 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2505 (gnus-update-group-mark-positions)
2506 (gnus-update-summary-mark-positions)
2508 ;; See whether we need to read the description file.
2509 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
2510 (not gnus-description-hashtb)
2511 gnus-read-active-file)
2512 (gnus-read-all-descriptions-files)))
2514 (defun gnus-update-summary-mark-positions ()
2515 "Compute where the summary marks are to go."
2517 (let ((gnus-replied-mark 129)
2518 (gnus-score-below-mark 130)
2519 (gnus-score-over-mark 130)
2523 (gnus-set-work-buffer)
2524 (gnus-summary-insert-line
2525 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2526 (goto-char (point-min))
2527 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2529 (goto-char (point-min))
2530 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2532 (goto-char (point-min))
2533 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2535 (setq gnus-summary-mark-positions pos))))
2537 (defun gnus-update-group-mark-positions ()
2539 (let ((gnus-process-mark 128)
2540 (gnus-group-marked '("dummy.group")))
2541 (gnus-set-active "dummy.group" '(0 . 0))
2542 (gnus-set-work-buffer)
2543 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2544 (goto-char (point-min))
2545 (setq gnus-group-mark-positions
2546 (list (cons 'process (and (search-forward "\200" nil t)
2547 (- (point) 2))))))))
2549 (defvar gnus-mouse-face-0 'highlight)
2550 (defvar gnus-mouse-face-1 'highlight)
2551 (defvar gnus-mouse-face-2 'highlight)
2552 (defvar gnus-mouse-face-3 'highlight)
2553 (defvar gnus-mouse-face-4 'highlight)
2555 (defun gnus-mouse-face-function (form type)
2557 (point) (progn ,@form (point))
2558 gnus-mouse-face-prop
2561 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2563 (defvar gnus-face-0 'bold)
2564 (defvar gnus-face-1 'italic)
2565 (defvar gnus-face-2 'bold-italic)
2566 (defvar gnus-face-3 'bold)
2567 (defvar gnus-face-4 'bold)
2569 (defun gnus-face-face-function (form type)
2571 (point) (progn ,@form (point))
2572 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2574 (defun gnus-max-width-function (el max-width)
2575 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2577 `(if (> (length ,el) ,max-width)
2578 (substring ,el 0 ,max-width)
2580 `(let ((val (eval ,el)))
2582 (setq val (int-to-string val)))
2583 (if (> (length val) ,max-width)
2584 (substring val 0 ,max-width)
2587 (defun gnus-parse-format (format spec-alist &optional insert)
2588 ;; This function parses the FORMAT string with the help of the
2589 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2590 ;; string. If the FORMAT string contains the specifiers %( and %)
2591 ;; the text between them will have the mouse-face text property.
2593 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2595 (gnus-parse-complex-format format spec-alist)
2596 ;; This is a simple format.
2597 (gnus-parse-simple-format format spec-alist insert)))
2599 (defun gnus-parse-complex-format (format spec-alist)
2601 (gnus-set-work-buffer)
2603 (goto-char (point-min))
2604 (while (re-search-forward "\"" nil t)
2605 (replace-match "\\\"" nil t))
2606 (goto-char (point-min))
2608 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2609 (let ((number (if (match-beginning 1)
2610 (match-string 1) "0"))
2611 (delim (aref (match-string 2) 0)))
2612 (if (or (= delim ?\() (= delim ?\{))
2613 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2615 (replace-match "\")\""))))
2616 (goto-char (point-max))
2618 (goto-char (point-min))
2619 (let ((form (read (current-buffer))))
2620 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2622 (defun gnus-complex-form-to-spec (form spec-alist)
2627 (gnus-parse-simple-format sform spec-alist t)
2628 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2629 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2633 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2634 ;; This function parses the FORMAT string with the help of the
2635 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2638 spec flist fstring newspec elem beg result dontinsert)
2640 (gnus-set-work-buffer)
2642 (goto-char (point-min))
2643 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2645 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2647 beg (1+ (match-beginning 0)))
2648 ;; First check if there are any specs that look anything like
2649 ;; "%12,12A", ie. with a "max width specification". These have
2650 ;; to be treated specially.
2651 (if (setq beg (match-beginning 1))
2655 (1+ (match-beginning 1)) (match-end 1))))
2657 (setq beg (match-beginning 2)))
2658 ;; Find the specification from `spec-alist'.
2659 (unless (setq elem (cdr (assq spec spec-alist)))
2660 (setq elem '("*" ?s)))
2661 ;; Treat user defined format specifiers specially.
2662 (when (eq (car elem) 'gnus-tmp-user-defined)
2665 (list (intern (concat "gnus-user-format-function-"
2667 'gnus-tmp-header) ?s))
2668 (delete-region (match-beginning 3) (match-end 3)))
2669 (if (not (zerop max-width))
2670 (let ((el (car elem)))
2671 (cond ((= (cadr elem) ?c)
2672 (setq el (list 'char-to-string el)))
2674 (setq el (list 'int-to-string el))))
2675 (setq flist (cons (gnus-max-width-function el max-width)
2679 (setq flist (cons (car elem) flist))
2680 (setq newspec (cadr elem)))))
2681 ;; Remove the old specification (and possibly a ",12" string).
2682 (delete-region beg (match-end 2))
2683 ;; Insert the new specification.
2686 (setq fstring (buffer-substring 1 (point-max))))
2687 ;; Do some postprocessing to increase efficiency.
2692 ((string= fstring "")
2694 ;; Not a format string.
2695 ((not (string-match "%" fstring))
2697 ;; A format string with just a single string spec.
2698 ((string= fstring "%s")
2700 ;; A single character.
2701 ((string= fstring "%c")
2704 ((string= fstring "%d")
2707 (list `(princ ,(car flist)))
2708 (list `(int-to-string ,(car flist)))))
2709 ;; Just lots of chars and strings.
2710 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2712 ;; A single string spec at the beginning of the spec.
2713 ((string-match "\\`%[sc][^%]+\\'" fstring)
2714 (list (car flist) (substring fstring 2)))
2715 ;; A single string spec in the middle of the spec.
2716 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2717 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2718 ;; A single string spec in the end of the spec.
2719 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2720 (list (match-string 1 fstring) (car flist)))
2721 ;; A more complex spec.
2723 (list (cons 'format (cons fstring (nreverse flist)))))))
2729 (cons 'insert result)))
2730 (cond ((stringp result)
2733 (cons 'concat result))
2736 (defun gnus-eval-format (format &optional alist props)
2737 "Eval the format variable FORMAT, using ALIST.
2738 If PROPS, insert the result."
2739 (let ((form (gnus-parse-format format alist props)))
2741 (add-text-properties (point) (progn (eval form) (point)) props)
2744 (defun gnus-remove-text-with-property (prop)
2745 "Delete all text in the current buffer with text property PROP."
2747 (goto-char (point-min))
2749 (while (get-text-property (point) prop)
2751 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2753 (defun gnus-set-work-buffer ()
2754 (if (get-buffer gnus-work-buffer)
2756 (set-buffer gnus-work-buffer)
2758 (set-buffer (get-buffer-create gnus-work-buffer))
2759 (kill-all-local-variables)
2760 (buffer-disable-undo (current-buffer))
2761 (gnus-add-current-to-buffer-list)))
2763 ;; Article file names when saving.
2765 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2766 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2767 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2768 Otherwise, it is like ~/News/news/group/num."
2771 (concat (if (gnus-use-long-file-name 'not-save)
2772 (gnus-capitalize-newsgroup newsgroup)
2773 (gnus-newsgroup-directory-form newsgroup))
2774 "/" (int-to-string (mail-header-number headers)))
2775 (or gnus-article-save-directory "~/News"))))
2777 (string-equal (file-name-directory default)
2778 (file-name-directory last-file))
2779 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2781 (or last-file default))))
2783 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2784 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2785 If variable `gnus-use-long-file-name' is non-nil, it is
2786 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2789 (concat (if (gnus-use-long-file-name 'not-save)
2791 (gnus-newsgroup-directory-form newsgroup))
2792 "/" (int-to-string (mail-header-number headers)))
2793 (or gnus-article-save-directory "~/News"))))
2795 (string-equal (file-name-directory default)
2796 (file-name-directory last-file))
2797 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2799 (or last-file default))))
2801 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2802 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2803 If variable `gnus-use-long-file-name' is non-nil, it is
2804 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2807 (if (gnus-use-long-file-name 'not-save)
2808 (gnus-capitalize-newsgroup newsgroup)
2809 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2810 (or gnus-article-save-directory "~/News"))))
2812 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2813 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2814 If variable `gnus-use-long-file-name' is non-nil, it is
2815 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2818 (if (gnus-use-long-file-name 'not-save)
2820 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2821 (or gnus-article-save-directory "~/News"))))
2823 ;; For subscribing new newsgroup
2825 (defun gnus-subscribe-hierarchical-interactive (groups)
2826 (let ((groups (sort groups 'string<))
2827 prefixes prefix start ans group starts)
2829 (setq prefixes (list "^"))
2830 (while (and groups prefixes)
2831 (while (not (string-match (car prefixes) (car groups)))
2832 (setq prefixes (cdr prefixes)))
2833 (setq prefix (car prefixes))
2834 (setq start (1- (length prefix)))
2835 (if (and (string-match "[^\\.]\\." (car groups) start)
2838 (concat "^" (substring (car groups) 0 (match-end 0))))
2839 (string-match prefix (cadr groups)))
2841 (setq prefixes (cons prefix prefixes))
2842 (message "Descend hierarchy %s? ([y]nsq): "
2843 (substring prefix 1 (1- (length prefix))))
2844 (setq ans (read-char))
2847 (string-match prefix
2848 (setq group (car groups))))
2849 (setq gnus-killed-list
2850 (cons group gnus-killed-list))
2851 (gnus-sethash group group gnus-killed-hashtb)
2852 (setq groups (cdr groups)))
2853 (setq starts (cdr starts)))
2856 (string-match prefix
2857 (setq group (car groups))))
2858 (gnus-sethash group group gnus-killed-hashtb)
2859 (gnus-subscribe-alphabetically (car groups))
2860 (setq groups (cdr groups)))
2861 (setq starts (cdr starts)))
2864 (setq group (car groups))
2865 (setq gnus-killed-list (cons group gnus-killed-list))
2866 (gnus-sethash group group gnus-killed-hashtb)
2867 (setq groups (cdr groups))))
2869 (message "Subscribe %s? ([n]yq)" (car groups))
2870 (setq ans (read-char))
2871 (setq group (car groups))
2873 (gnus-subscribe-alphabetically (car groups))
2874 (gnus-sethash group group gnus-killed-hashtb))
2877 (setq group (car groups))
2878 (setq gnus-killed-list (cons group gnus-killed-list))
2879 (gnus-sethash group group gnus-killed-hashtb)
2880 (setq groups (cdr groups))))
2882 (setq gnus-killed-list (cons group gnus-killed-list))
2883 (gnus-sethash group group gnus-killed-hashtb)))
2884 (setq groups (cdr groups)))))))
2886 (defun gnus-subscribe-randomly (newsgroup)
2887 "Subscribe new NEWSGROUP by making it the first newsgroup."
2888 (gnus-subscribe-newsgroup newsgroup))
2890 (defun gnus-subscribe-alphabetically (newgroup)
2891 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2892 (let ((groups (cdr gnus-newsrc-alist))
2894 (while (and (not before) groups)
2895 (if (string< newgroup (caar groups))
2896 (setq before (caar groups))
2897 (setq groups (cdr groups))))
2898 (gnus-subscribe-newsgroup newgroup before)))
2900 (defun gnus-subscribe-hierarchically (newgroup)
2901 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2902 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2904 (set-buffer (find-file-noselect gnus-current-startup-file))
2905 (let ((groupkey newgroup)
2907 (while (and (not before) groupkey)
2908 (goto-char (point-min))
2910 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2911 (while (and (re-search-forward groupkey-re nil t)
2913 (setq before (match-string 1))
2914 (string< before newgroup)))))
2915 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2917 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2918 (substring groupkey (match-beginning 1) (match-end 1)))))
2919 (gnus-subscribe-newsgroup newgroup before))))
2921 (defun gnus-subscribe-interactively (group)
2922 "Subscribe the new GROUP interactively.
2923 It is inserted in hierarchical newsgroup order if subscribed. If not,
2925 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2926 (gnus-subscribe-hierarchically group)
2927 (push group gnus-killed-list)))
2929 (defun gnus-subscribe-zombies (group)
2930 "Make the new GROUP into a zombie group."
2931 (push group gnus-zombie-list))
2933 (defun gnus-subscribe-killed (group)
2934 "Make the new GROUP a killed group."
2935 (push group gnus-killed-list))
2937 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2938 "Subscribe new NEWSGROUP.
2939 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2940 the first newsgroup."
2941 ;; We subscribe the group by changing its level to `subscribed'.
2942 (gnus-group-change-level
2943 newsgroup gnus-level-default-subscribed
2944 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2945 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2949 (defun gnus-newsgroup-directory-form (newsgroup)
2950 "Make hierarchical directory name from NEWSGROUP name."
2951 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2952 (len (length newsgroup))
2954 ;; If this is a foreign group, we don't want to translate the
2956 (if (setq idx (string-match ":" newsgroup))
2957 (aset newsgroup idx ?/)
2959 ;; Replace all occurrences of `.' with `/'.
2961 (if (= (aref newsgroup idx) ?.)
2962 (aset newsgroup idx ?/))
2963 (setq idx (1+ idx)))
2966 (defun gnus-newsgroup-savable-name (group)
2967 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2969 (nnheader-replace-chars-in-string group ?/ ?.))
2971 (defun gnus-make-directory (dir)
2972 "Make DIRECTORY recursively."
2973 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2974 ;; of the many mysteries of the universe.
2975 (let* ((dir (expand-file-name dir default-directory))
2977 (if (string-match "/$" dir)
2978 (setq dir (substring dir 0 (match-beginning 0))))
2979 ;; First go down the path until we find a directory that exists.
2980 (while (not (file-exists-p dir))
2981 (setq dirs (cons dir dirs))
2982 (string-match "/[^/]+$" dir)
2983 (setq dir (substring dir 0 (match-beginning 0))))
2984 ;; Then create all the subdirs.
2985 (while (and dirs (not err))
2987 (make-directory (car dirs))
2988 (error (setq err t)))
2989 (setq dirs (cdr dirs)))
2990 ;; We return whether we were successful or not.
2993 (defun gnus-capitalize-newsgroup (newsgroup)
2994 "Capitalize NEWSGROUP name."
2995 (and (not (zerop (length newsgroup)))
2996 (concat (char-to-string (upcase (aref newsgroup 0)))
2997 (substring newsgroup 1))))
2999 ;; Various... things.
3001 (defun gnus-simplify-subject (subject &optional re-only)
3002 "Remove `Re:' and words in parentheses.
3003 If RE-ONLY is non-nil, strip leading `Re:'s only."
3004 (let ((case-fold-search t)) ;Ignore case.
3005 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3006 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3007 (setq subject (substring subject (match-end 0))))
3008 ;; Remove uninteresting prefixes.
3009 (if (and (not re-only)
3010 gnus-simplify-ignored-prefixes
3011 (string-match gnus-simplify-ignored-prefixes subject))
3012 (setq subject (substring subject (match-end 0))))
3013 ;; Remove words in parentheses from end.
3015 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3016 (setq subject (substring subject 0 (match-beginning 0)))))
3017 ;; Return subject string.
3020 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3022 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3023 (defun gnus-simplify-buffer-fuzzy ()
3024 (goto-char (point-min))
3025 (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*" nil t)
3026 (goto-char (match-beginning 0))
3028 (looking-at "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*")
3029 (looking-at "^[[].*:[ \t].*[]]$"))
3030 (goto-char (point-min))
3031 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
3033 (replace-match "" t t))
3034 (goto-char (point-min))
3035 (while (re-search-forward "^[[].*:[ \t].*[]]$" nil t)
3036 (goto-char (match-end 0))
3039 (progn (goto-char (match-beginning 0)))
3040 (re-search-forward ":"))))
3041 (goto-char (point-min))
3042 (while (re-search-forward "[ \t\n]*[[{(][^()]*[]})][ \t]*$" nil t)
3043 (replace-match "" t t))
3044 (goto-char (point-min))
3045 (while (re-search-forward "[ \t]+" nil t)
3046 (replace-match " " t t))
3047 (goto-char (point-min))
3048 (while (re-search-forward "[ \t]+$" nil t)
3049 (replace-match "" t t))
3050 (goto-char (point-min))
3051 (while (re-search-forward "^[ \t]+" nil t)
3052 (replace-match "" t t))
3053 (goto-char (point-min))
3054 (if gnus-simplify-subject-fuzzy-regexp
3055 (if (listp gnus-simplify-subject-fuzzy-regexp)
3056 (let ((list gnus-simplify-subject-fuzzy-regexp))
3058 (goto-char (point-min))
3059 (while (re-search-forward (car list) nil t)
3060 (replace-match "" t t))
3061 (setq list (cdr list))))
3062 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3063 (replace-match "" t t)))))
3065 (defun gnus-simplify-subject-fuzzy (subject)
3066 "Siplify a subject string fuzzily."
3068 (gnus-set-work-buffer)
3069 (let ((case-fold-search t))
3071 (inline (gnus-simplify-buffer-fuzzy))
3074 ;; Add the current buffer to the list of buffers to be killed on exit.
3075 (defun gnus-add-current-to-buffer-list ()
3076 (or (memq (current-buffer) gnus-buffer-list)
3077 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3079 (defun gnus-string> (s1 s2)
3080 (not (or (string< s1 s2)
3083 ;;; General various misc type functions.
3085 (defun gnus-clear-system ()
3086 "Clear all variables and buffers."
3087 ;; Clear Gnus variables.
3088 (let ((variables gnus-variable-list))
3090 (set (car variables) nil)
3091 (setq variables (cdr variables))))
3092 ;; Clear other internal variables.
3093 (setq gnus-list-of-killed-groups nil
3094 gnus-have-read-active-file nil
3095 gnus-newsrc-alist nil
3096 gnus-newsrc-hashtb nil
3097 gnus-killed-list nil
3098 gnus-zombie-list nil
3099 gnus-killed-hashtb nil
3100 gnus-active-hashtb nil
3101 gnus-moderated-list nil
3102 gnus-description-hashtb nil
3103 gnus-newsgroup-headers nil
3104 gnus-newsgroup-name nil
3105 gnus-server-alist nil
3106 gnus-opened-servers nil
3107 gnus-current-select-method nil)
3108 ;; Reset any score variables.
3109 (when gnus-use-scoring
3111 ;; Kill the startup file.
3112 (and gnus-current-startup-file
3113 (get-file-buffer gnus-current-startup-file)
3114 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3115 ;; Save any cache buffers.
3116 (when gnus-use-cache
3117 (gnus-cache-save-buffers))
3118 ;; Clear the dribble buffer.
3119 (gnus-dribble-clear)
3120 ;; Close down NoCeM.
3121 (when gnus-use-nocem
3123 ;; Shut down the demons.
3124 (when gnus-use-demon
3125 (gnus-demon-cancel))
3126 ;; Kill global KILL file buffer.
3127 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3128 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3129 (gnus-kill-buffer nntp-server-buffer)
3131 (when gnus-keep-backlog
3132 (gnus-backlog-shutdown))
3133 ;; Kill Gnus buffers.
3134 (while gnus-buffer-list
3135 (gnus-kill-buffer (pop gnus-buffer-list)))
3136 ;; Remove Gnus frames.
3137 (while gnus-created-frames
3138 (when (frame-live-p (car gnus-created-frames))
3139 ;; We slap a condition-case around this `delete-frame' to ensure
3140 ;; agains errors if we try do delete the single frame that's left.
3142 (delete-frame (car gnus-created-frames))
3144 (pop gnus-created-frames)))
3146 (defun gnus-windows-old-to-new (setting)
3147 ;; First we take care of the really, really old Gnus 3 actions.
3148 (when (symbolp setting)
3150 ;; Take care of ooold GNUS 3.x values.
3151 (cond ((eq setting 'SelectArticle) 'article)
3152 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3153 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3155 (if (or (listp setting)
3156 (not (and gnus-window-configuration
3157 (memq setting '(group summary article)))))
3159 (let* ((setting (if (eq setting 'group)
3160 (if (assq 'newsgroup gnus-window-configuration)
3162 'newsgroups) setting))
3163 (elem (cadr (assq setting gnus-window-configuration)))
3164 (total (apply '+ elem))
3165 (types '(group summary article))
3166 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3171 (or (not (numberp (nth i elem)))
3172 (zerop (nth i elem))
3174 (setq perc (/ (float (nth 0 elem)) total))
3175 (setq out (cons (if (eq pbuf (nth i types))
3176 (vector (nth i types) perc 'point)
3177 (vector (nth i types) perc))
3180 (list (nreverse out)))))
3183 (defun gnus-add-configuration (conf)
3184 "Add the window configuration CONF to `gnus-buffer-configuration'."
3185 (setq gnus-buffer-configuration
3186 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3187 gnus-buffer-configuration))))
3189 (defvar gnus-frame-list nil)
3191 (defun gnus-configure-frame (split &optional window)
3192 "Split WINDOW according to SPLIT."
3194 (setq window (get-buffer-window (current-buffer))))
3195 (select-window window)
3196 ;; This might be an old-stylee buffer config.
3197 (when (vectorp split)
3198 (setq split (append split nil)))
3199 (when (or (consp (car split))
3200 (vectorp (car split)))
3202 (push 'vertical split))
3203 ;; The SPLIT might be something that is to be evaled to
3204 ;; return a new SPLIT.
3205 (while (and (not (assq (car split) gnus-window-to-buffer))
3206 (gnus-functionp (car split)))
3207 (setq split (eval split)))
3208 (let* ((type (car split))
3210 (len (if (eq type 'horizontal) (window-width) (window-height)))
3212 (window-min-width (or gnus-window-min-width window-min-width))
3213 (window-min-height (or gnus-window-min-height window-min-height))
3214 s result new-win rest comp-subs size sub)
3216 ;; Nothing to do here.
3218 ;; Don't switch buffers.
3220 (and (memq 'point split) window))
3221 ;; This is a buffer to be selected.
3222 ((not (memq type '(frame horizontal vertical)))
3223 (let ((buffer (cond ((stringp type) type)
3224 (t (cdr (assq type gnus-window-to-buffer)))))
3227 (error "Illegal buffer type: %s" type))
3228 (unless (setq buf (get-buffer (if (symbolp buffer)
3229 (symbol-value buffer) buffer)))
3230 (setq buf (get-buffer-create (if (symbolp buffer)
3231 (symbol-value buffer) buffer))))
3232 (switch-to-buffer buf)
3233 ;; We return the window if it has the `point' spec.
3234 (and (memq 'point split) window)))
3235 ;; This is a frame split.
3237 (unless gnus-frame-list
3238 (setq gnus-frame-list (list (window-frame
3239 (get-buffer-window (current-buffer))))))
3241 params frame fresult)
3242 (while (< i (length subs))
3243 ;; Frame parameter is gotten from the sub-split.
3244 (setq params (cadr (elt subs i)))
3245 ;; It should be a list.
3246 (unless (listp params)
3248 ;; Create a new frame?
3249 (unless (setq frame (elt gnus-frame-list i))
3250 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3251 (push frame gnus-created-frames))
3252 ;; Is the old frame still alive?
3253 (unless (frame-live-p frame)
3254 (setcar (nthcdr i gnus-frame-list)
3255 (setq frame (make-frame params))))
3256 ;; Select the frame in question and do more splits there.
3257 (select-frame frame)
3258 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3260 ;; Select the frame that has the selected buffer.
3262 (select-frame (window-frame fresult)))))
3263 ;; This is a normal split.
3265 (when (> (length subs) 0)
3266 ;; First we have to compute the sizes of all new windows.
3268 (setq sub (append (pop subs) nil))
3269 (while (and (not (assq (car sub) gnus-window-to-buffer))
3270 (gnus-functionp (car sub)))
3271 (setq sub (eval sub)))
3273 (push sub comp-subs)
3274 (setq size (cadar comp-subs))
3275 (cond ((equal size 1.0)
3276 (setq rest (car comp-subs))
3279 (setq s (floor (* size len))))
3283 (error "Illegal size: %s" size)))
3284 ;; Try to make sure that we are inside the safe limits.
3286 ((eq type 'horizontal)
3287 (setq s (max s window-min-width)))
3288 ((eq type 'vertical)
3289 (setq s (max s window-min-height))))
3290 (setcar (cdar comp-subs) s)
3292 ;; Take care of the "1.0" spec.
3294 (setcar (cdr rest) (- len total))
3295 (error "No 1.0 specs in %s" split))
3296 ;; The we do the actual splitting in a nice recursive
3298 (setq comp-subs (nreverse comp-subs))
3300 (if (null (cdr comp-subs))
3301 (setq new-win window)
3303 (split-window window (cadar comp-subs)
3304 (eq type 'horizontal))))
3305 (setq result (or (gnus-configure-frame
3306 (car comp-subs) window) result))
3307 (select-window new-win)
3308 (setq window new-win)
3309 (setq comp-subs (cdr comp-subs))))
3310 ;; Return the proper window, if any.
3312 (select-window result))))))
3314 (defvar gnus-frame-split-p nil)
3316 (defun gnus-configure-windows (setting &optional force)
3317 (setq setting (gnus-windows-old-to-new setting))
3318 (let ((split (if (symbolp setting)
3319 (cadr (assq setting gnus-buffer-configuration))
3321 (in-buf (current-buffer))
3322 rule val w height hor ohor heights sub jump-buffer
3323 rel total to-buf all-visible)
3325 (setq gnus-frame-split-p nil)
3328 (error "No such setting: %s" setting))
3330 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3332 ;; All the windows mentioned are already visible, so we just
3333 ;; put point in the assigned buffer, and do not touch the
3335 (select-window all-visible)
3337 ;; Either remove all windows or just remove all Gnus windows.
3338 (let ((frame (selected-frame)))
3340 (if gnus-use-full-window
3341 ;; We want to remove all other windows.
3342 (if (not gnus-frame-split-p)
3343 ;; This is not a `frame' split, so we ignore the
3345 (delete-other-windows)
3346 ;; This is a `frame' split, so we delete all windows
3350 (unless (eq (cdr (assq 'minibuffer
3351 (frame-parameters frame)))
3353 (select-frame frame)
3354 (delete-other-windows)))
3356 ;; Just remove some windows.
3357 (gnus-remove-some-windows)
3358 (switch-to-buffer nntp-server-buffer))
3359 (select-frame frame)))
3361 (switch-to-buffer nntp-server-buffer)
3362 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3364 (defun gnus-all-windows-visible-p (split)
3365 (when (vectorp split)
3366 (setq split (append split nil)))
3367 (when (or (consp (car split))
3368 (vectorp (car split)))
3370 (push 'vertical split))
3371 ;; The SPLIT might be something that is to be evaled to
3372 ;; return a new SPLIT.
3373 (while (and (not (assq (car split) gnus-window-to-buffer))
3374 (gnus-functionp (car split)))
3375 (setq split (eval split)))
3376 (let* ((type (elt split 0)))
3380 ((not (or (eq type 'horizontal) (eq type 'vertical) (eq type 'frame)))
3381 (let ((buffer (cond ((stringp type) type)
3382 (t (cdr (assq type gnus-window-to-buffer)))))
3385 (error "Illegal buffer type: %s" type))
3386 (when (setq buf (get-buffer (if (symbolp buffer) (symbol-value buffer)
3388 (setq win (get-buffer-window buf t)))
3390 (if (memq 'point split)
3394 (when (eq type 'frame)
3395 (setq gnus-frame-split-p t))
3396 (let ((n (mapcar 'gnus-all-windows-visible-p
3400 (cond ((windowp (car n))
3407 (defun gnus-window-top-edge (&optional window)
3408 (nth 1 (window-edges window)))
3410 (defun gnus-remove-some-windows ()
3411 (let ((buffers gnus-window-to-buffer)
3412 buf bufs lowest-buf lowest)
3414 ;; Remove windows on all known Gnus buffers.
3416 (setq buf (cdar buffers))
3418 (setq buf (and (boundp buf) (symbol-value buf))))
3420 (get-buffer-window buf)
3422 (setq bufs (cons buf bufs))
3424 (if (or (not lowest)
3425 (< (gnus-window-top-edge) lowest))
3427 (setq lowest (gnus-window-top-edge))
3428 (setq lowest-buf buf)))))
3429 (setq buffers (cdr buffers)))
3430 ;; Remove windows on *all* summary buffers.
3434 (let ((buf (window-buffer win)))
3435 (if (string-match "^\\*Summary" (buffer-name buf))
3437 (setq bufs (cons buf bufs))
3439 (if (or (not lowest)
3440 (< (gnus-window-top-edge) lowest))
3442 (setq lowest-buf buf)
3443 (setq lowest (gnus-window-top-edge))))))))))
3446 (pop-to-buffer lowest-buf)
3447 (switch-to-buffer nntp-server-buffer)))
3449 (and (not (eq (car bufs) lowest-buf))
3450 (delete-windows-on (car bufs)))
3451 (setq bufs (cdr bufs))))))
3453 (defun gnus-version ()
3454 "Version numbers of this version of Gnus."
3456 (let ((methods gnus-valid-select-methods)
3459 ;; Go through all the legal select methods and add their version
3460 ;; numbers to the total version string. Only the backends that are
3461 ;; currently in use will have their message numbers taken into
3464 (setq meth (intern (concat (caar methods) "-version")))
3466 (stringp (symbol-value meth))
3467 (setq mess (concat mess "; " (symbol-value meth))))
3468 (setq methods (cdr methods)))
3469 (gnus-message 2 mess)))
3471 (defun gnus-info-find-node ()
3472 "Find Info documentation of Gnus."
3474 ;; Enlarge info window if needed.
3475 (let ((mode major-mode)
3477 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3478 (setq gnus-info-buffer (current-buffer))
3479 (gnus-configure-windows 'info)))
3481 (defun gnus-days-between (date1 date2)
3482 ;; Return the number of days between date1 and date2.
3483 (- (gnus-day-number date1) (gnus-day-number date2)))
3485 (defun gnus-day-number (date)
3486 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3487 (timezone-parse-date date))))
3488 (timezone-absolute-from-gregorian
3489 (nth 1 dat) (nth 2 dat) (car dat))))
3491 (defun gnus-encode-date (date)
3492 "Convert DATE to internal time."
3493 (let* ((parse (timezone-parse-date date))
3494 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3495 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3496 (encode-time (caddr time) (cadr time) (car time)
3497 (caddr date) (cadr date) (car date) (nth 4 date))))
3499 (defun gnus-time-minus (t1 t2)
3500 "Subtract two internal times."
3501 (let ((borrow (< (cadr t1) (cadr t2))))
3502 (list (- (car t1) (car t2) (if borrow 1 0))
3503 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3505 (defun gnus-file-newer-than (file date)
3506 (let ((fdate (nth 5 (file-attributes file))))
3507 (or (> (car fdate) (car date))
3508 (and (= (car fdate) (car date))
3509 (> (nth 1 fdate) (nth 1 date))))))
3511 (defmacro gnus-local-set-keys (&rest plist)
3512 "Set the keys in PLIST in the current keymap."
3513 `(gnus-define-keys-1 (current-local-map) ',plist))
3515 (defmacro gnus-define-keys (keymap &rest plist)
3516 "Define all keys in PLIST in KEYMAP."
3517 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3519 (put 'gnus-define-keys 'lisp-indent-function 1)
3520 (put 'gnus-define-keys 'lisp-indent-hook 1)
3521 (put 'gnus-define-keymap 'lisp-indent-function 1)
3522 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3524 (defmacro gnus-define-keymap (keymap &rest plist)
3525 "Define all keys in PLIST in KEYMAP."
3526 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3528 (defun gnus-define-keys-1 (keymap plist)
3530 (error "Can't set keys in a null keymap"))
3531 (cond ((symbolp keymap)
3532 (setq keymap (symbol-value keymap)))
3535 (set (car keymap) nil)
3536 (define-prefix-command (car keymap))
3537 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3538 (setq keymap (symbol-value (car keymap)))))
3541 (when (symbolp (setq key (pop plist)))
3542 (setq key (symbol-value key)))
3543 (define-key keymap key (pop plist)))))
3545 (defun gnus-group-read-only-p (&optional group)
3546 "Check whether GROUP supports editing or not.
3547 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3548 that that variable is buffer-local to the summary buffers."
3549 (let ((group (or group gnus-newsgroup-name)))
3550 (not (gnus-check-backend-function 'request-replace-article group))))
3552 (defun gnus-group-total-expirable-p (group)
3553 "Check whether GROUP is total-expirable or not."
3554 (let ((params (gnus-info-params (gnus-get-info group))))
3555 (or (memq 'total-expire params)
3556 (cdr (assq 'total-expire params)) ; (total-expire . t)
3557 (and gnus-total-expirable-newsgroups ; Check var.
3558 (string-match gnus-total-expirable-newsgroups group)))))
3560 (defun gnus-group-auto-expirable-p (group)
3561 "Check whether GROUP is total-expirable or not."
3562 (let ((params (gnus-info-params (gnus-get-info group))))
3563 (or (memq 'auto-expire params)
3564 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3565 (and gnus-auto-expirable-newsgroups ; Check var.
3566 (string-match gnus-auto-expirable-newsgroups group)))))
3568 (defun gnus-virtual-group-p (group)
3569 "Say whether GROUP is virtual or not."
3570 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3571 gnus-valid-select-methods)))
3573 (defsubst gnus-simplify-subject-fully (subject)
3574 "Simplify a subject string according to the user's wishes."
3576 ((null gnus-summary-gather-subject-limit)
3577 (gnus-simplify-subject-re subject))
3578 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3579 (gnus-simplify-subject-fuzzy subject))
3580 ((numberp gnus-summary-gather-subject-limit)
3581 (gnus-limit-string (gnus-simplify-subject-re subject)
3582 gnus-summary-gather-subject-limit))
3586 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3587 "Check whether two subjects are equal. If optional argument
3588 simple-first is t, first argument is already simplified."
3590 ((null simple-first)
3591 (equal (gnus-simplify-subject-fully s1)
3592 (gnus-simplify-subject-fully s2)))
3595 (gnus-simplify-subject-fully s2)))))
3597 ;; Returns a list of writable groups.
3598 (defun gnus-writable-groups ()
3599 (let ((alist gnus-newsrc-alist)
3601 (while (setq group (car (pop alist)))
3602 (unless (gnus-group-read-only-p group)
3603 (push group groups)))
3606 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3608 (defun gnus-y-or-n-p (prompt)
3613 (defun gnus-yes-or-no-p (prompt)
3615 (yes-or-no-p prompt)
3618 ;; Check whether to use long file names.
3619 (defun gnus-use-long-file-name (symbol)
3620 ;; The variable has to be set...
3621 (and gnus-use-long-file-name
3622 ;; If it isn't a list, then we return t.
3623 (or (not (listp gnus-use-long-file-name))
3624 ;; If it is a list, and the list contains `symbol', we
3626 (not (memq symbol gnus-use-long-file-name)))))
3628 ;; I suspect there's a better way, but I haven't taken the time to do
3629 ;; it yet. -erik selberg@cs.washington.edu
3630 (defun gnus-dd-mmm (messy-date)
3631 "Return a string like DD-MMM from a big messy string"
3632 (let ((datevec (timezone-parse-date messy-date)))
3634 (or (aref datevec 2) "??")
3637 (nth (1- (string-to-number (aref datevec 1)))
3638 timezone-months-assoc))
3641 ;; Make a hash table (default and minimum size is 255).
3642 ;; Optional argument HASHSIZE specifies the table size.
3643 (defun gnus-make-hashtable (&optional hashsize)
3644 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3646 ;; Make a number that is suitable for hashing; bigger than MIN and one
3648 (defun gnus-create-hash-size (min)
3654 ;; Show message if message has a lower level than `gnus-verbose'.
3655 ;; Guideline for numbers:
3656 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3657 ;; for things that take a long time, 7 - not very important messages
3658 ;; on stuff, 9 - messages inside loops.
3659 (defun gnus-message (level &rest args)
3660 (if (<= level gnus-verbose)
3661 (apply 'message args)
3662 ;; We have to do this format thingy here even if the result isn't
3663 ;; shown - the return value has to be the same as the return value
3665 (apply 'format args)))
3667 (defun gnus-functionp (form)
3668 "Return non-nil if FORM is funcallable."
3669 (or (and (symbolp form) (fboundp form))
3670 (and (listp form) (eq (car form) 'lambda))))
3672 ;; Generate a unique new group name.
3673 (defun gnus-generate-new-group-name (leaf)
3676 (while (gnus-gethash name gnus-newsrc-hashtb)
3677 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3680 ;; Find out whether the gnus-visual TYPE is wanted.
3681 (defun gnus-visual-p (&optional type class)
3682 (and gnus-visual ; Has to be non-nil, at least.
3683 (if (not type) ; We don't care about type.
3685 (if (listp gnus-visual) ; It's a list, so we check it.
3686 (or (memq type gnus-visual)
3687 (memq class gnus-visual))
3690 (defun gnus-parent-id (references)
3691 "Return the last Message-ID in REFERENCES."
3692 (when (and references
3693 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3694 (substring references (match-beginning 1) (match-end 1))))
3696 (defun gnus-split-references (references)
3697 "Return a list of Message-IDs in REFERENCES."
3700 (while (string-match "<[^>]+>" references beg)
3701 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3705 (defun gnus-ephemeral-group-p (group)
3706 "Say whether GROUP is ephemeral or not."
3707 (gnus-group-get-parameter group 'quit-config))
3709 (defun gnus-group-quit-config (group)
3710 "Return the quit-config of GROUP."
3711 (gnus-group-get-parameter group 'quit-config))
3713 (defun gnus-simplify-mode-line ()
3714 "Make mode lines a bit simpler."
3715 (setq mode-line-modified "-- ")
3716 (when (listp mode-line-format)
3717 (make-local-variable 'mode-line-format)
3718 (setq mode-line-format (copy-sequence mode-line-format))
3719 (when (equal (nth 3 mode-line-format) " ")
3720 (setcar (nthcdr 3 mode-line-format) " "))))
3722 ;;; List and range functions
3724 (defun gnus-last-element (list)
3725 "Return last element of LIST."
3727 (setq list (cdr list)))
3730 (defun gnus-copy-sequence (list)
3731 "Do a complete, total copy of a list."
3732 (if (and (consp list) (not (consp (cdr list))))
3733 (cons (car list) (cdr list))
3734 (mapcar (lambda (elem) (if (consp elem)
3735 (if (consp (cdr elem))
3736 (gnus-copy-sequence elem)
3737 (cons (car elem) (cdr elem)))
3741 (defun gnus-set-difference (list1 list2)
3742 "Return a list of elements of LIST1 that do not appear in LIST2."
3743 (let ((list1 (copy-sequence list1)))
3745 (setq list1 (delq (car list2) list1))
3746 (setq list2 (cdr list2)))
3749 (defun gnus-sorted-complement (list1 list2)
3750 "Return a list of elements of LIST1 that do not appear in LIST2.
3751 Both lists have to be sorted over <."
3753 (if (or (null list1) (null list2))
3755 (while (and list1 list2)
3756 (cond ((= (car list1) (car list2))
3757 (setq list1 (cdr list1)
3759 ((< (car list1) (car list2))
3760 (setq out (cons (car list1) out))
3761 (setq list1 (cdr list1)))
3763 (setq out (cons (car list2) out))
3764 (setq list2 (cdr list2)))))
3765 (nconc (nreverse out) (or list1 list2)))))
3767 (defun gnus-intersection (list1 list2)
3770 (if (memq (car list2) list1)
3771 (setq result (cons (car list2) result)))
3772 (setq list2 (cdr list2)))
3775 (defun gnus-sorted-intersection (list1 list2)
3776 ;; LIST1 and LIST2 have to be sorted over <.
3778 (while (and list1 list2)
3779 (cond ((= (car list1) (car list2))
3780 (setq out (cons (car list1) out)
3783 ((< (car list1) (car list2))
3784 (setq list1 (cdr list1)))
3786 (setq list2 (cdr list2)))))
3789 (defun gnus-set-sorted-intersection (list1 list2)
3790 ;; LIST1 and LIST2 have to be sorted over <.
3791 ;; This function modifies LIST1.
3792 (let* ((top (cons nil list1))
3794 (while (and list1 list2)
3795 (cond ((= (car list1) (car list2))
3799 ((< (car list1) (car list2))
3800 (setcdr prev (cdr list1))
3801 (setq list1 (cdr list1)))
3803 (setq list2 (cdr list2)))))
3807 (defun gnus-compress-sequence (numbers &optional always-list)
3808 "Convert list of numbers to a list of ranges or a single range.
3809 If ALWAYS-LIST is non-nil, this function will always release a list of
3811 (let* ((first (car numbers))
3812 (last (car numbers))
3816 (if (not (listp (cdr numbers)))
3819 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3820 ((= (1+ last) (car numbers)) ;Still in sequence
3821 (setq last (car numbers)))
3822 (t ;End of one sequence
3824 (cons (if (= first last) first
3825 (cons first last)) result))
3826 (setq first (car numbers))
3827 (setq last (car numbers))))
3828 (setq numbers (cdr numbers)))
3829 (if (and (not always-list) (null result))
3830 (if (= first last) (list first) (cons first last))
3831 (nreverse (cons (if (= first last) first (cons first last))
3834 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3835 (defun gnus-uncompress-range (ranges)
3836 "Expand a list of ranges into a list of numbers.
3837 RANGES is either a single range on the form `(num . num)' or a list of
3839 (let (first last result)
3843 ((not (listp (cdr ranges)))
3844 (setq first (car ranges))
3845 (setq last (cdr ranges))
3846 (while (<= first last)
3847 (setq result (cons first result))
3848 (setq first (1+ first)))
3852 (if (atom (car ranges))
3853 (if (numberp (car ranges))
3854 (setq result (cons (car ranges) result)))
3855 (setq first (caar ranges))
3856 (setq last (cdar ranges))
3857 (while (<= first last)
3858 (setq result (cons first result))
3859 (setq first (1+ first))))
3860 (setq ranges (cdr ranges)))
3861 (nreverse result)))))
3863 (defun gnus-add-to-range (ranges list)
3864 "Return a list of ranges that has all articles from both RANGES and LIST.
3865 Note: LIST has to be sorted over `<'."
3867 (gnus-compress-sequence list t)
3868 (setq list (copy-sequence list))
3869 (or (listp (cdr ranges))
3870 (setq ranges (list ranges)))
3872 ilist lowest highest temp)
3873 (while (and ranges list)
3875 (setq lowest (or (and (atom (car ranges)) (car ranges))
3877 (while (and list (cdr list) (< (cadr list) lowest))
3878 (setq list (cdr list)))
3879 (if (< (car ilist) lowest)
3882 (setq list (cdr list))
3884 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3885 (setq highest (or (and (atom (car ranges)) (car ranges))
3887 (while (and list (<= (car list) highest))
3888 (setq list (cdr list)))
3889 (setq ranges (cdr ranges)))
3891 (setq out (nconc (gnus-compress-sequence list t) out)))
3892 (setq out (sort out (lambda (r1 r2)
3893 (< (or (and (atom r1) r1) (car r1))
3894 (or (and (atom r2) r2) (car r2))))))
3897 (if (atom (car ranges))
3899 (if (atom (cadr ranges))
3900 (if (= (1+ (car ranges)) (cadr ranges))
3902 (setcar ranges (cons (car ranges)
3904 (setcdr ranges (cddr ranges))))
3905 (if (= (1+ (car ranges)) (caadr ranges))
3907 (setcar (cadr ranges) (car ranges))
3908 (setcar ranges (cadr ranges))
3909 (setcdr ranges (cddr ranges))))))
3911 (if (atom (cadr ranges))
3912 (if (= (1+ (cdar ranges)) (cadr ranges))
3914 (setcdr (car ranges) (cadr ranges))
3915 (setcdr ranges (cddr ranges))))
3916 (if (= (1+ (cdar ranges)) (caadr ranges))
3918 (setcdr (car ranges) (cdadr ranges))
3919 (setcdr ranges (cddr ranges)))))))
3920 (setq ranges (cdr ranges)))
3923 (defun gnus-remove-from-range (ranges list)
3924 "Return a list of ranges that has all articles from LIST removed from RANGES.
3925 Note: LIST has to be sorted over `<'."
3926 ;; !!! This function shouldn't look like this, but I've got a headache.
3927 (gnus-compress-sequence
3928 (gnus-sorted-complement
3929 (gnus-uncompress-range ranges) list)))
3931 (defun gnus-member-of-range (number ranges)
3932 (if (not (listp (cdr ranges)))
3933 (and (>= number (car ranges))
3934 (<= number (cdr ranges)))
3937 (if (numberp (car ranges))
3938 (>= number (car ranges))
3939 (>= number (caar ranges)))
3941 (if (if (numberp (car ranges))
3942 (= number (car ranges))
3943 (and (>= number (caar ranges))
3944 (<= number (cdar ranges))))
3945 (setq not-stop nil))
3946 (setq ranges (cdr ranges)))
3949 (defun gnus-range-length (range)
3950 "Return the length RANGE would have if uncompressed."
3951 (length (gnus-uncompress-range range)))
3953 (defun gnus-sublist-p (list sublist)
3954 "Test whether all elements in SUBLIST are members of LIST."
3957 (unless (memq (pop sublist) list)
3967 (defvar gnus-group-mode-map nil)
3968 (put 'gnus-group-mode 'mode-class 'special)
3970 (unless gnus-group-mode-map
3971 (setq gnus-group-mode-map (make-keymap))
3972 (suppress-keymap gnus-group-mode-map)
3974 (gnus-define-keys gnus-group-mode-map
3975 " " gnus-group-read-group
3976 "=" gnus-group-select-group
3977 "\M- " gnus-group-unhidden-select-group
3978 "\r" gnus-group-select-group
3979 "\M-\r" gnus-group-quick-select-group
3980 "j" gnus-group-jump-to-group
3981 "n" gnus-group-next-unread-group
3982 "p" gnus-group-prev-unread-group
3983 "\177" gnus-group-prev-unread-group
3984 [delete] gnus-group-prev-unread-group
3985 "N" gnus-group-next-group
3986 "P" gnus-group-prev-group
3987 "\M-n" gnus-group-next-unread-group-same-level
3988 "\M-p" gnus-group-prev-unread-group-same-level
3989 "," gnus-group-best-unread-group
3990 "." gnus-group-first-unread-group
3991 "u" gnus-group-unsubscribe-current-group
3992 "U" gnus-group-unsubscribe-group
3993 "c" gnus-group-catchup-current
3994 "C" gnus-group-catchup-current-all
3995 "l" gnus-group-list-groups
3996 "L" gnus-group-list-all-groups
3998 "g" gnus-group-get-new-news
3999 "\M-g" gnus-group-get-new-news-this-group
4000 "R" gnus-group-restart
4001 "r" gnus-group-read-init-file
4002 "B" gnus-group-browse-foreign-server
4003 "b" gnus-group-check-bogus-groups
4004 "F" gnus-find-new-newsgroups
4005 "\C-c\C-d" gnus-group-describe-group
4006 "\M-d" gnus-group-describe-all-groups
4007 "\C-c\C-a" gnus-group-apropos
4008 "\C-c\M-\C-a" gnus-group-description-apropos
4009 "a" gnus-group-post-news
4010 "\ek" gnus-group-edit-local-kill
4011 "\eK" gnus-group-edit-global-kill
4012 "\C-k" gnus-group-kill-group
4013 "\C-y" gnus-group-yank-group
4014 "\C-w" gnus-group-kill-region
4015 "\C-x\C-t" gnus-group-transpose-groups
4016 "\C-c\C-l" gnus-group-list-killed
4017 "\C-c\C-x" gnus-group-expire-articles
4018 "\C-c\M-\C-x" gnus-group-expire-all-groups
4020 "s" gnus-group-save-newsrc
4021 "z" gnus-group-suspend
4022 "Z" gnus-group-clear-dribble
4025 "?" gnus-group-describe-briefly
4026 "\C-c\C-i" gnus-info-find-node
4027 "\M-e" gnus-group-edit-group-method
4028 "^" gnus-group-enter-server-mode
4029 gnus-mouse-2 gnus-mouse-pick-group
4030 "<" beginning-of-buffer
4033 "\C-c\C-s" gnus-group-sort-groups
4035 "\C-c\M-g" gnus-activate-all-groups
4036 "\M-&" gnus-group-universal-argument
4037 "#" gnus-group-mark-group
4038 "\M-#" gnus-group-unmark-group)
4040 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4041 "m" gnus-group-mark-group
4042 "u" gnus-group-unmark-group
4043 "w" gnus-group-mark-region
4044 "m" gnus-group-mark-buffer
4045 "r" gnus-group-mark-regexp
4046 "U" gnus-group-unmark-all-groups)
4048 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4049 "d" gnus-group-make-directory-group
4050 "h" gnus-group-make-help-group
4051 "a" gnus-group-make-archive-group
4052 "k" gnus-group-make-kiboze-group
4053 "m" gnus-group-make-group
4054 "E" gnus-group-edit-group
4055 "e" gnus-group-edit-group-method
4056 "p" gnus-group-edit-group-parameters
4057 "v" gnus-group-add-to-virtual
4058 "V" gnus-group-make-empty-virtual
4059 "D" gnus-group-enter-directory
4060 "f" gnus-group-make-doc-group
4061 "r" gnus-group-rename-group
4062 "\177" gnus-group-delete-group
4063 [delete] gnus-group-delete-group)
4065 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4066 "b" gnus-group-brew-soup
4067 "w" gnus-soup-save-areas
4068 "s" gnus-soup-send-replies
4069 "p" gnus-soup-pack-packet
4070 "r" nnsoup-pack-replies)
4072 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4073 "s" gnus-group-sort-groups
4074 "a" gnus-group-sort-groups-by-alphabet
4075 "u" gnus-group-sort-groups-by-unread
4076 "l" gnus-group-sort-groups-by-level
4077 "v" gnus-group-sort-groups-by-score
4078 "r" gnus-group-sort-groups-by-rank
4079 "m" gnus-group-sort-groups-by-method)
4081 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4082 "k" gnus-group-list-killed
4083 "z" gnus-group-list-zombies
4084 "s" gnus-group-list-groups
4085 "u" gnus-group-list-all-groups
4086 "A" gnus-group-list-active
4087 "a" gnus-group-apropos
4088 "d" gnus-group-description-apropos
4089 "m" gnus-group-list-matching
4090 "M" gnus-group-list-all-matching
4091 "l" gnus-group-list-level)
4093 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4094 "f" gnus-score-flush-cache)
4096 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4097 "f" gnus-group-fetch-faq)
4099 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4100 "l" gnus-group-set-current-level
4101 "t" gnus-group-unsubscribe-current-group
4102 "s" gnus-group-unsubscribe-group
4103 "k" gnus-group-kill-group
4104 "y" gnus-group-yank-group
4105 "w" gnus-group-kill-region
4106 "\C-k" gnus-group-kill-level
4107 "z" gnus-group-kill-all-zombies))
4109 (defun gnus-group-mode ()
4110 "Major mode for reading news.
4112 All normal editing commands are switched off.
4113 \\<gnus-group-mode-map>
4114 The group buffer lists (some of) the groups available. For instance,
4115 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4116 lists all zombie groups.
4118 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4119 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4121 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4123 The following commands are available:
4125 \\{gnus-group-mode-map}"
4127 (when (and menu-bar-mode
4128 (gnus-visual-p 'group-menu 'menu))
4129 (gnus-group-make-menu-bar))
4130 (kill-all-local-variables)
4131 (gnus-simplify-mode-line)
4132 (setq major-mode 'gnus-group-mode)
4133 (setq mode-name "Group")
4134 (gnus-group-set-mode-line)
4135 (setq mode-line-process nil)
4136 (use-local-map gnus-group-mode-map)
4137 (buffer-disable-undo (current-buffer))
4138 (setq truncate-lines t)
4139 (setq buffer-read-only t)
4140 (run-hooks 'gnus-group-mode-hook))
4142 (defun gnus-mouse-pick-group (e)
4143 "Enter the group under the mouse pointer."
4146 (gnus-group-read-group nil))
4148 ;; Look at LEVEL and find out what the level is really supposed to be.
4149 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4150 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4151 (defun gnus-group-default-level (&optional level number-or-nil)
4153 (gnus-group-use-permanent-levels
4154 (setq gnus-group-default-list-level
4155 (or level gnus-group-default-list-level))
4156 (or gnus-group-default-list-level gnus-level-subscribed))
4160 (or level gnus-group-default-list-level gnus-level-subscribed))))
4163 (defun gnus-slave-no-server (&optional arg)
4164 "Read network news as a slave, without connecting to local server"
4166 (gnus-no-server arg t))
4169 (defun gnus-no-server (&optional arg slave)
4171 If ARG is a positive number, Gnus will use that as the
4172 startup level. If ARG is nil, Gnus will be started at level 2.
4173 If ARG is non-nil and not a positive number, Gnus will
4174 prompt the user for the name of an NNTP server to use.
4175 As opposed to `gnus', this command will not connect to the local server."
4177 (make-local-variable 'gnus-group-use-permanent-levels)
4178 (setq gnus-group-use-permanent-levels t)
4179 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4182 (defun gnus-slave (&optional arg)
4183 "Read news as a slave."
4185 (gnus arg nil 'slave))
4188 (defun gnus-other-frame (&optional arg)
4189 "Pop up a frame to read news."
4191 (if (get-buffer gnus-group-buffer)
4192 (let ((pop-up-frames t))
4194 (select-frame (make-frame))
4198 (defun gnus (&optional arg dont-connect slave)
4200 If ARG is non-nil and a positive number, Gnus will use that as the
4201 startup level. If ARG is non-nil and not a positive number, Gnus will
4202 prompt the user for the name of an NNTP server to use."
4205 (if (get-buffer gnus-group-buffer)
4207 (switch-to-buffer gnus-group-buffer)
4208 (gnus-group-get-new-news))
4211 (nnheader-init-server-buffer)
4212 (gnus-read-init-file)
4213 (setq gnus-slave slave)
4215 (gnus-group-setup-buffer)
4216 (let ((buffer-read-only nil))
4218 (if (not gnus-inhibit-startup-message)
4220 (gnus-group-startup-message)
4223 (let ((level (and (numberp arg) (> arg 0) arg))
4229 (gnus-start-news-server (and arg (not level))))))
4230 (if (and (not dont-connect)
4233 (run-hooks 'gnus-startup-hook)
4234 ;; NNTP server is successfully open.
4236 ;; Find the current startup file name.
4237 (setq gnus-current-startup-file
4238 (gnus-make-newsrc-file gnus-startup-file))
4240 ;; Read the dribble file.
4241 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4243 ;; Allow using GroupLens predictions.
4244 (when gnus-use-grouplens
4246 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4248 (gnus-summary-make-display-table)
4249 ;; Do the actual startup.
4250 (gnus-setup-news nil level)
4251 ;; Generate the group buffer.
4252 (gnus-group-list-groups level)
4253 (gnus-group-first-unread-group)
4254 (gnus-configure-windows 'group)
4255 (gnus-group-set-mode-line))))))
4257 (defun gnus-unload ()
4258 "Unload all Gnus features."
4260 (or (boundp 'load-history)
4261 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4262 (let ((history load-history)
4265 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4266 (setq feature (cdr (assq 'provide (car history))))
4267 (unload-feature feature 'force))
4268 (setq history (cdr history)))))
4270 (defun gnus-compile ()
4271 "Byte-compile the user-defined format specs."
4273 (let ((entries gnus-format-specs)
4274 entry gnus-tmp-func)
4276 (gnus-message 7 "Compiling format specs...")
4279 (setq entry (pop entries))
4280 (if (eq (car entry) 'version)
4281 (setq gnus-format-specs (delq entry gnus-format-specs))
4282 (when (and (listp (caddr entry))
4283 (not (eq 'byte-code (caaddr entry))))
4284 (fset 'gnus-tmp-func
4285 `(lambda () ,(caddr entry)))
4286 (byte-compile 'gnus-tmp-func)
4287 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4289 (push (cons 'version emacs-version) gnus-format-specs)
4291 (gnus-message 7 "Compiling user specs...done"))))
4293 (defun gnus-indent-rigidly (start end arg)
4294 "Indent rigidly using only spaces and no tabs."
4297 (narrow-to-region start end)
4298 (indent-rigidly start end arg)
4299 (goto-char (point-min))
4300 (while (search-forward "\t" nil t)
4301 (replace-match " " t t)))))
4303 (defun gnus-group-startup-message (&optional x y)
4304 "Insert startup message in current buffer."
4305 ;; Insert the message.
4310 _ ___ __ ___ __ _ ___
4329 ;; And then hack it.
4330 (gnus-indent-rigidly (point-min) (point-max)
4331 (/ (max (- (window-width) (or x 46)) 0) 2))
4332 (goto-char (point-min))
4334 (let* ((pheight (count-lines (point-min) (point-max)))
4335 (wheight (window-height))
4336 (rest (- wheight pheight)))
4337 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4339 (goto-char (point-min))
4340 (and (search-forward "Praxis" nil t)
4341 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4342 (goto-char (point-min))
4343 (let* ((mode-string (gnus-group-set-mode-line)))
4344 (setq mode-line-buffer-identification
4345 (list (concat gnus-version (substring (car mode-string) 4))))
4346 (set-buffer-modified-p t)))
4348 (defun gnus-group-setup-buffer ()
4349 (or (get-buffer gnus-group-buffer)
4351 (switch-to-buffer gnus-group-buffer)
4352 (gnus-add-current-to-buffer-list)
4354 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4356 (defun gnus-group-list-groups (&optional level unread lowest)
4357 "List newsgroups with level LEVEL or lower that have unread articles.
4358 Default is all subscribed groups.
4359 If argument UNREAD is non-nil, groups with no unread articles are also
4361 (interactive (list (if current-prefix-arg
4362 (prefix-numeric-value current-prefix-arg)
4364 (gnus-group-default-level nil t)
4365 gnus-group-default-list-level
4366 gnus-level-subscribed))))
4368 (setq level (car gnus-group-list-mode)
4369 unread (cdr gnus-group-list-mode)))
4370 (setq level (gnus-group-default-level level))
4371 (gnus-group-setup-buffer) ;May call from out of group buffer
4372 (gnus-update-format-specifications)
4373 (let ((case-fold-search nil)
4374 (props (text-properties-at (gnus-point-at-bol)))
4375 (group (gnus-group-group-name)))
4376 (funcall gnus-group-prepare-function level unread lowest)
4377 (if (zerop (buffer-size))
4378 (gnus-message 5 gnus-no-groups-message)
4379 (goto-char (point-max))
4380 (when (or (not gnus-group-goto-next-group-function)
4381 (not (funcall gnus-group-goto-next-group-function
4384 ;; Go to the first group with unread articles.
4385 (gnus-group-search-forward t)
4386 ;; Find the right group to put point on. If the current group
4387 ;; has disappeared in the new listing, try to find the next
4388 ;; one. If no next one can be found, just leave point at the
4389 ;; first newsgroup in the buffer.
4390 (if (not (gnus-goto-char
4392 (point-min) (point-max)
4393 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4394 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4396 (not (gnus-goto-char
4398 (point-min) (point-max) 'gnus-group
4400 (caar newsrc) gnus-active-hashtb)))))
4401 (setq newsrc (cdr newsrc)))
4402 (or newsrc (progn (goto-char (point-max))
4403 (forward-line -1)))))))
4404 ;; Adjust cursor point.
4405 (gnus-group-position-point))))
4407 (defun gnus-group-list-level (level &optional all)
4408 "List groups on LEVEL.
4409 If ALL (the prefix), also list groups that have no unread articles."
4410 (interactive "nList groups on level: \nP")
4411 (gnus-group-list-groups level all level))
4413 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4414 "List all newsgroups with unread articles of level LEVEL or lower.
4415 If ALL is non-nil, list groups that have no unread articles.
4416 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4417 If REGEXP, only list groups matching REGEXP."
4418 (set-buffer gnus-group-buffer)
4419 (let ((buffer-read-only nil)
4420 (newsrc (cdr gnus-newsrc-alist))
4421 (lowest (or lowest 1))
4422 info clevel unread group params)
4424 (if (< lowest gnus-level-zombie)
4425 ;; List living groups.
4427 (setq info (car newsrc)
4428 group (gnus-info-group info)
4429 params (gnus-info-params info)
4431 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4432 (and unread ; This group might be bogus
4434 (string-match regexp group))
4435 (<= (setq clevel (gnus-info-level info)) level)
4437 (or all ; We list all groups?
4438 (and gnus-group-list-inactive-groups
4439 (eq unread t)) ; We list unactivated groups
4440 (> unread 0) ; We list groups with unread articles
4441 (and gnus-list-groups-with-ticked-articles
4442 (cdr (assq 'tick (gnus-info-marks info))))
4443 ; And groups with tickeds
4444 ;; Check for permanent visibility.
4445 (and gnus-permanently-visible-groups
4446 (string-match gnus-permanently-visible-groups
4448 (memq 'visible params)
4449 (cdr (assq 'visible params)))
4450 (gnus-group-insert-group-line
4451 group (gnus-info-level info)
4452 (gnus-info-marks info) unread (gnus-info-method info)))))
4454 ;; List dead groups.
4455 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4456 (gnus-group-prepare-flat-list-dead
4457 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4458 gnus-level-zombie ?Z
4460 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4461 (gnus-group-prepare-flat-list-dead
4462 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4463 gnus-level-killed ?K regexp))
4465 (gnus-group-set-mode-line)
4466 (setq gnus-group-list-mode (cons level all))
4467 (run-hooks 'gnus-group-prepare-hook)))
4469 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4470 ;; List zombies and killed lists somewhat faster, which was
4471 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4472 ;; this by ignoring the group format specification altogether.
4475 ;; This loop is used when listing groups that match some
4478 (setq group (pop groups))
4479 (when (string-match regexp group)
4480 (add-text-properties
4481 (point) (prog1 (1+ (point))
4482 (insert " " mark " *: " group "\n"))
4483 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4485 'gnus-level level))))
4486 ;; This loop is used when listing all groups.
4488 (add-text-properties
4489 (point) (prog1 (1+ (point))
4490 (insert " " mark " *: "
4491 (setq group (pop groups)) "\n"))
4492 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4494 'gnus-level level))))))
4496 (defmacro gnus-group-real-name (group)
4497 "Find the real name of a foreign newsgroup."
4498 `(let ((gname ,group))
4499 (if (string-match ":[^:]+$" gname)
4500 (substring gname (1+ (match-beginning 0)))
4503 (defsubst gnus-server-add-address (method)
4504 (let ((method-name (symbol-name (car method))))
4505 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4506 (not (assq (intern (concat method-name "-address")) method)))
4507 (append method (list (list (intern (concat method-name "-address"))
4511 (defsubst gnus-server-get-method (group method)
4512 ;; Input either a server name, and extended server name, or a
4513 ;; select method, and return a select method.
4514 (cond ((stringp method)
4515 (gnus-server-to-method method))
4516 ((and (stringp (car method)) group)
4517 (gnus-server-extend-method group method))
4519 (gnus-server-add-address method))))
4521 (defun gnus-server-to-method (server)
4522 "Map virtual server names to select methods."
4524 ;; Perhaps this is the native server?
4525 (and (equal server "native") gnus-select-method)
4526 ;; It should be in the server alist.
4527 (cdr (assoc server gnus-server-alist))
4528 ;; If not, we look through all the opened server
4529 ;; to see whether we can find it there.
4530 (let ((opened gnus-opened-servers))
4532 (not (equal server (format "%s:%s" (caaar opened)
4537 (defmacro gnus-method-equal (ss1 ss2)
4538 "Say whether two servers are equal."
4542 (and (= (length s1) (length s2))
4544 (while (and s1 (member (car s1) s2))
4548 (defun gnus-server-equal (m1 m2)
4549 "Say whether two methods are equal."
4550 (let ((m1 (cond ((null m1) gnus-select-method)
4551 ((stringp m1) (gnus-server-to-method m1))
4553 (m2 (cond ((null m2) gnus-select-method)
4554 ((stringp m2) (gnus-server-to-method m2))
4556 (gnus-method-equal m1 m2)))
4558 (defun gnus-group-prefixed-name (group method)
4559 "Return the whole name from GROUP and METHOD."
4560 (and (stringp method) (setq method (gnus-server-to-method method)))
4561 (concat (format "%s" (car method))
4563 (or (assoc (format "%s" (car method))
4564 (gnus-methods-using 'address))
4565 (gnus-server-equal method gnus-message-archive-method))
4567 (not (string= (nth 1 method) "")))
4568 (concat "+" (nth 1 method)))
4571 (defun gnus-group-real-prefix (group)
4572 "Return the prefix of the current group name."
4573 (if (string-match "^[^:]+:" group)
4574 (substring group 0 (match-end 0))
4577 (defun gnus-group-method (group)
4578 "Return the server or method used for selecting GROUP."
4579 (let ((prefix (gnus-group-real-prefix group)))
4580 (if (equal prefix "")
4582 (let ((servers gnus-opened-servers)
4584 backend possible found)
4585 (if (string-match "^[^\\+]+\\+" prefix)
4586 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4587 server (substring prefix (match-end 0) (1- (length prefix))))
4588 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4590 (when (eq (caaar servers) backend)
4591 (setq possible (caar servers))
4592 (when (equal (cadaar servers) server)
4593 (setq found (caar servers))))
4595 (or (car (rassoc found gnus-server-alist))
4597 (car (rassoc possible gnus-server-alist))
4599 (list backend server))))))
4601 (defsubst gnus-secondary-method-p (method)
4602 "Return whether METHOD is a secondary select method."
4603 (let ((methods gnus-secondary-select-methods)
4604 (gmethod (gnus-server-get-method nil method)))
4606 (not (equal (gnus-server-get-method nil (car methods))
4608 (setq methods (cdr methods)))
4611 (defun gnus-group-foreign-p (group)
4612 "Say whether a group is foreign or not."
4613 (and (not (gnus-group-native-p group))
4614 (not (gnus-group-secondary-p group))))
4616 (defun gnus-group-native-p (group)
4617 "Say whether the group is native or not."
4618 (not (string-match ":" group)))
4620 (defun gnus-group-secondary-p (group)
4621 "Say whether the group is secondary or not."
4622 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4624 (defun gnus-group-get-parameter (group &optional symbol)
4625 "Returns the group parameters for GROUP.
4626 If SYMBOL, return the value of that symbol in the group parameters."
4627 (let ((params (gnus-info-params (gnus-get-info group))))
4629 (gnus-group-parameter-value params symbol)
4632 (defun gnus-group-parameter-value (params symbol)
4633 "Return the value of SYMBOL in group PARAMS."
4634 (or (car (memq symbol params)) ; It's either a simple symbol
4635 (cdr (assq symbol params)))) ; or a cons.
4637 (defun gnus-group-add-parameter (group param)
4638 "Add parameter PARAM to GROUP."
4639 (let ((info (gnus-get-info group)))
4641 () ; This is a dead group. We just ignore it.
4642 ;; Cons the new param to the old one and update.
4643 (gnus-group-set-info (cons param (gnus-info-params info))
4646 (defun gnus-group-set-parameter (group name value)
4647 "Set parameter NAME to VALUE in GROUP."
4648 (let ((info (gnus-get-info group)))
4650 () ; This is a dead group. We just ignore it.
4651 (let ((old-params (gnus-info-params info))
4652 (new-params (list (cons name value))))
4654 (if (or (not (listp (car old-params)))
4655 (not (eq (caar old-params) name)))
4656 (setq new-params (append new-params (list (car old-params)))))
4657 (setq old-params (cdr old-params)))
4658 (gnus-group-set-info new-params group 'params)))))
4660 (defun gnus-group-add-score (group &optional score)
4661 "Add SCORE to the GROUP score.
4662 If SCORE is nil, add 1 to the score of GROUP."
4663 (let ((info (gnus-get-info group)))
4664 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))
4666 (defun gnus-summary-bubble-group ()
4667 "Increase the score of the current group.
4668 This is a handy function to add to `gnus-summary-exit-hook' to
4669 increase the score of each group you read."
4670 (gnus-group-add-score gnus-newsgroup-name))
4672 (defun gnus-group-set-info (info &optional method-only-group part)
4673 (let* ((entry (gnus-gethash
4674 (or method-only-group (gnus-info-group info))
4675 gnus-newsrc-hashtb))
4677 (info (if method-only-group (nth 2 entry) info))
4679 (when method-only-group
4681 (error "Trying to change non-existent group %s" method-only-group))
4682 ;; We have received parts of the actual group info - either the
4683 ;; select method or the group parameters. We first check
4684 ;; whether we have to extend the info, and if so, do that.
4685 (let ((len (length info))
4686 (total (if (eq part 'method) 5 6)))
4688 (setcdr (nthcdr (1- len) info)
4689 (make-list (- total len) nil)))
4690 ;; Then we enter the new info.
4691 (setcar (nthcdr (1- total) info) part-info)))
4693 ;; This is a new group, so we just create it.
4695 (set-buffer gnus-group-buffer)
4696 (setq method (gnus-info-method info))
4697 (when (gnus-server-equal method "native")
4700 ;; It's a foreign group...
4701 (gnus-group-make-group
4702 (gnus-group-real-name (gnus-info-group info))
4703 (if (stringp method) method
4704 (prin1-to-string (car method)))
4706 (nth 1 (gnus-info-method info))))
4707 ;; It's a native group.
4708 (gnus-group-make-group (gnus-info-group info)))
4709 (gnus-message 6 "Note: New group created")
4711 (gnus-gethash (gnus-group-prefixed-name
4712 (gnus-group-real-name (gnus-info-group info))
4713 (or (gnus-info-method info) gnus-select-method))
4714 gnus-newsrc-hashtb))))
4715 ;; Whether it was a new group or not, we now have the entry, so we
4716 ;; can do the update.
4719 (setcar (nthcdr 2 entry) info)
4720 (when (and (not (eq (car entry) t))
4721 (gnus-active (gnus-info-group info)))
4722 (let ((marked (gnus-info-marks info)))
4723 (setcar entry (length (gnus-list-of-unread-articles
4725 (error "No such group: %s" (gnus-info-group info)))))
4727 (defun gnus-group-set-method-info (group select-method)
4728 (gnus-group-set-info select-method group 'method))
4730 (defun gnus-group-set-params-info (group params)
4731 (gnus-group-set-info params group 'params))
4733 (defun gnus-group-update-group-line ()
4734 "Update the current line in the group buffer."
4735 (let* ((buffer-read-only nil)
4736 (group (gnus-group-group-name))
4737 (gnus-group-indentation (gnus-group-group-indentation))
4738 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4740 (not (gnus-ephemeral-group-p group))
4742 (concat "(gnus-group-set-info '"
4743 (prin1-to-string (nth 2 entry)) ")")))
4745 (gnus-group-insert-group-line-info group)
4747 (gnus-group-position-point)))
4749 (defun gnus-group-insert-group-line-info (group)
4750 "Insert GROUP on the current line."
4751 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4755 ;; (Un)subscribed group.
4756 (setq info (nth 2 entry))
4757 (gnus-group-insert-group-line
4758 group (gnus-info-level info) (gnus-info-marks info)
4759 (or (car entry) t) (gnus-info-method info)))
4760 ;; This group is dead.
4761 (gnus-group-insert-group-line
4763 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4765 (if (setq active (gnus-active group))
4766 (- (1+ (cdr active)) (car active)) 0)
4769 (defun gnus-group-insert-group-line
4770 (gnus-tmp-group gnus-tmp-level gnus-tmp-marked number
4772 "Insert a group line in the group buffer."
4773 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4774 (gnus-tmp-number-total
4776 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4778 (gnus-tmp-number-of-unread
4779 (if (numberp number) (int-to-string (max 0 number))
4781 (gnus-tmp-number-of-read
4782 (if (numberp number)
4783 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4785 (gnus-tmp-subscribed
4786 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4787 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4788 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4790 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4791 (gnus-tmp-newsgroup-description
4792 (if gnus-description-hashtb
4793 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4796 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4797 (gnus-tmp-moderated-string
4798 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4800 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4801 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4802 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4803 (gnus-tmp-news-method-string
4805 (format "(%s:%s)" (car gnus-tmp-method)
4806 (cadr gnus-tmp-method)) ""))
4807 (gnus-tmp-marked-mark
4808 (if (and (numberp number)
4810 (cdr (assq 'tick gnus-tmp-marked)))
4812 (gnus-tmp-process-marked
4813 (if (member gnus-tmp-group gnus-group-marked)
4814 gnus-process-mark ? ))
4816 (or (and gnus-use-grouplens
4817 (bbb-grouplens-group-p gnus-tmp-group))
4819 (buffer-read-only nil)
4820 header gnus-tmp-header) ; passed as parameter to user-funcs.
4822 (add-text-properties
4826 (eval gnus-group-line-format-spec))
4827 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4828 gnus-unread ,(if (numberp number)
4829 (string-to-int gnus-tmp-number-of-unread)
4831 gnus-marked ,gnus-tmp-marked-mark
4832 gnus-indentation ,gnus-group-indentation
4833 gnus-level ,gnus-tmp-level))
4834 (when (gnus-visual-p 'group-highlight 'highlight)
4836 (run-hooks 'gnus-group-update-hook)
4838 ;; Allow XEmacs to remove front-sticky text properties.
4839 (gnus-group-remove-excess-properties)))
4841 (defun gnus-group-update-group (group &optional visible-only)
4842 "Update all lines where GROUP appear.
4843 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4846 (set-buffer gnus-group-buffer)
4847 ;; The buffer may be narrowed.
4850 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4852 found buffer-read-only visible)
4853 ;; Enter the current status into the dribble buffer.
4854 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4855 (if (and entry (not (gnus-ephemeral-group-p group)))
4857 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4859 ;; Find all group instances. If topics are in use, each group
4860 ;; may be listed in more than once.
4861 (while (setq loc (text-property-any
4862 loc (point-max) 'gnus-group ident))
4865 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4867 (gnus-group-insert-group-line-info group))
4868 (setq loc (1+ loc)))
4869 (unless (or found visible-only)
4870 ;; No such line in the buffer, find out where it's supposed to
4871 ;; go, and insert it there (or at the end of the buffer).
4872 (if gnus-goto-missing-group-function
4873 (funcall gnus-goto-missing-group-function group)
4874 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4875 (while (and entry (car entry)
4879 (point-min) (point-max)
4880 'gnus-group (gnus-intern-safe
4881 (caar entry) gnus-active-hashtb)))))
4882 (setq entry (cdr entry)))
4883 (or entry (goto-char (point-max)))))
4884 ;; Finally insert the line.
4885 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4886 (gnus-group-insert-group-line-info group)))
4887 (gnus-group-set-mode-line)))))
4889 (defun gnus-group-set-mode-line ()
4890 (when (memq 'group gnus-updated-mode-lines)
4891 (let* ((gformat (or gnus-group-mode-line-format-spec
4892 (setq gnus-group-mode-line-format-spec
4894 gnus-group-mode-line-format
4895 gnus-group-mode-line-format-alist))))
4896 (gnus-tmp-news-server (cadr gnus-select-method))
4897 (gnus-tmp-news-method (car gnus-select-method))
4899 gnus-tmp-header ;Dummy binding for user-defined formats
4900 ;; Get the resulting string.
4901 (mode-string (eval gformat)))
4902 ;; If the line is too long, we chop it off.
4903 (when (> (length mode-string) max-len)
4904 (setq mode-string (substring mode-string 0 (- max-len 4))))
4906 (setq mode-line-buffer-identification (list mode-string))
4907 (set-buffer-modified-p t)))))
4909 (defun gnus-group-group-name ()
4910 "Get the name of the newsgroup on the current line."
4911 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4912 (and group (symbol-name group))))
4914 (defun gnus-group-group-level ()
4915 "Get the level of the newsgroup on the current line."
4916 (get-text-property (gnus-point-at-bol) 'gnus-level))
4918 (defun gnus-group-group-indentation ()
4919 "Get the indentation of the newsgroup on the current line."
4920 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation) ""))
4922 (defun gnus-group-group-unread ()
4923 "Get the number of unread articles of the newsgroup on the current line."
4924 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4926 (defun gnus-group-search-forward (&optional backward all level first-too)
4927 "Find the next newsgroup with unread articles.
4928 If BACKWARD is non-nil, find the previous newsgroup instead.
4929 If ALL is non-nil, just find any newsgroup.
4930 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4932 If FIRST-TOO, the current line is also eligible as a target."
4933 (let ((way (if backward -1 1))
4934 (low gnus-level-killed)
4937 (if (and backward (progn (beginning-of-line)) (bobp))
4939 (or first-too (forward-line way))
4947 (get-text-property (point) 'gnus-unread)))
4948 (and (numberp unread) (> unread 0)))
4949 (setq lev (get-text-property (point)
4951 (<= lev gnus-level-subscribed)))
4953 (and (setq lev (get-text-property (point)
4962 (zerop (forward-line way)))))
4964 (progn (gnus-group-position-point) t)
4965 (goto-char (or pos beg))
4968 ;;; Gnus group mode commands
4972 (defun gnus-group-mark-group (n &optional unmark no-advance)
4973 "Mark the current group."
4975 (let ((buffer-read-only nil)
4979 (setq group (gnus-group-group-name))
4983 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
4988 (setq gnus-group-marked (delete group gnus-group-marked)))
4990 (setq gnus-group-marked
4991 (cons group (delete group gnus-group-marked))))
4993 (or no-advance (zerop (gnus-group-next-group 1))))
4995 (gnus-summary-position-point)
4998 (defun gnus-group-unmark-group (n)
4999 "Remove the mark from the current group."
5001 (gnus-group-mark-group n 'unmark)
5002 (gnus-group-position-point))
5004 (defun gnus-group-unmark-all-groups ()
5005 "Unmark all groups."
5006 (let ((groups gnus-group-marked))
5009 (gnus-group-remove-mark (pop groups)))))
5010 (gnus-group-position-point))
5012 (defun gnus-group-mark-region (unmark beg end)
5013 "Mark all groups between point and mark.
5014 If UNMARK, remove the mark instead."
5015 (interactive "P\nr")
5016 (let ((num (count-lines beg end)))
5019 (- num (gnus-group-mark-group num unmark)))))
5021 (defun gnus-group-mark-buffer (&optional unmark)
5022 "Mark all groups in the buffer.
5023 If UNMARK, remove the mark instead."
5025 (gnus-group-mark-region unmark (point-min) (point-max)))
5027 (defun gnus-group-mark-regexp (regexp)
5028 "Mark all groups that match some regexp."
5029 (interactive "sMark (regexp): ")
5030 (let ((alist (cdr gnus-newsrc-alist))
5033 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5034 (gnus-group-set-mark group))))
5035 (gnus-group-position-point))
5037 (defun gnus-group-remove-mark (group)
5038 "Remove the process mark from GROUP and move point there.
5039 Return nil if the group isn't displayed."
5040 (if (gnus-group-goto-group group)
5042 (gnus-group-mark-group 1 'unmark t)
5044 (setq gnus-group-marked
5045 (delete group gnus-group-marked))
5048 (defun gnus-group-set-mark (group)
5049 "Set the process mark on GROUP."
5050 (if (gnus-group-goto-group group)
5052 (gnus-group-mark-group 1 nil t))
5053 (setq gnus-group-marked
5054 (cons group (delete group gnus-group-marked)))))
5056 (defun gnus-group-universal-argument (arg &optional groups func)
5057 "Perform any command on all groups accoring to the process/prefix convention."
5059 (let ((groups (or groups (gnus-group-process-prefix arg)))
5061 (if (eq (setq func (or func
5064 (substitute-command-keys
5065 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5068 (message "Undefined key")
5071 (gnus-group-remove-mark (setq group (pop groups)))
5072 (command-execute func))))
5073 (gnus-group-position-point))
5075 (defun gnus-group-process-prefix (n)
5076 "Return a list of groups to work on.
5077 Take into consideration N (the prefix) and the list of marked groups."
5080 (setq n (prefix-numeric-value n))
5081 ;; There is a prefix, so we return a list of the N next
5083 (let ((way (if (< n 0) -1 1))
5088 (setq group (gnus-group-group-name)))
5089 (setq groups (cons group groups))
5091 (gnus-group-next-group way)))
5093 ((and (boundp 'transient-mark-mode)
5096 ;; Work on the region between point and mark.
5097 (let ((max (max (point) (mark)))
5100 (goto-char (min (point) (mark)))
5103 (push (gnus-group-group-name) groups)
5104 (zerop (gnus-group-next-group 1))
5106 (nreverse groups))))
5108 ;; No prefix, but a list of marked articles.
5109 (reverse gnus-group-marked))
5111 ;; Neither marked articles or a prefix, so we return the
5113 (let ((group (gnus-group-group-name)))
5114 (and group (list group))))))
5116 ;; Selecting groups.
5118 (defun gnus-group-read-group (&optional all no-article group)
5119 "Read news in this newsgroup.
5120 If the prefix argument ALL is non-nil, already read articles become
5121 readable. IF ALL is a number, fetch this number of articles. If the
5122 optional argument NO-ARTICLE is non-nil, no article will be
5123 auto-selected upon group entry. If GROUP is non-nil, fetch that
5126 (let ((group (or group (gnus-group-group-name)))
5127 number active marked entry)
5128 (or group (error "No group on current line"))
5129 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5130 group gnus-newsrc-hashtb)))))
5131 ;; This group might be a dead group. In that case we have to get
5132 ;; the number of unread articles from `gnus-active-hashtb'.
5134 (cond ((numberp all) all)
5136 ((setq active (gnus-active group))
5137 (- (1+ (cdr active)) (car active)))))
5138 (gnus-summary-read-group
5139 group (or all (and (numberp number)
5140 (zerop (+ number (length (cdr (assq 'tick marked)))
5141 (length (cdr (assq 'dormant marked)))))))
5144 (defun gnus-group-select-group (&optional all)
5145 "Select this newsgroup.
5146 No article is selected automatically.
5147 If ALL is non-nil, already read articles become readable.
5148 If ALL is a number, fetch this number of articles."
5150 (gnus-group-read-group all t))
5152 (defun gnus-group-quick-select-group (&optional all)
5153 "Select the current group \"quickly\".
5154 This means that no highlighting or scoring will be performed."
5157 gnus-score-find-score-files-function
5158 gnus-apply-kill-hook
5159 gnus-summary-expunge-below)
5160 (gnus-group-read-group all t)))
5162 (defun gnus-group-visible-select-group (&optional all)
5163 "Select the current group without hiding any articles."
5165 (let ((gnus-inhibit-limiting t))
5166 (gnus-group-read-group all t)))
5169 (defun gnus-fetch-group (group)
5170 "Start Gnus if necessary and enter GROUP.
5171 Returns whether the fetching was successful or not."
5172 (interactive "sGroup name: ")
5173 (or (get-buffer gnus-group-buffer)
5175 (gnus-group-read-group nil nil group))
5177 ;; Enter a group that is not in the group buffer. Non-nil is returned
5178 ;; if selection was successful.
5179 (defun gnus-group-read-ephemeral-group
5180 (group method &optional activate quit-config)
5181 (let ((group (if (gnus-group-foreign-p group) group
5182 (gnus-group-prefixed-name group method))))
5185 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5186 ((quit-config . ,(if quit-config quit-config
5187 (cons (current-buffer) 'summary))))))
5189 (set-buffer gnus-group-buffer)
5190 (or (gnus-check-server method)
5191 (error "Unable to contact server: %s" (gnus-status-message method)))
5192 (if activate (or (gnus-request-group group)
5193 (error "Couldn't request group")))
5195 (gnus-group-read-group t t group)
5199 (defun gnus-group-jump-to-group (group)
5200 "Jump to newsgroup GROUP."
5202 (list (completing-read
5203 "Group: " gnus-active-hashtb nil
5204 (memq gnus-select-method gnus-have-read-active-file))))
5206 (if (equal group "")
5207 (error "Empty group name"))
5209 (let ((b (text-property-any
5210 (point-min) (point-max)
5211 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5212 (unless (gnus-ephemeral-group-p group)
5214 ;; Either go to the line in the group buffer...
5216 ;; ... or insert the line.
5219 (gnus-activate-group group)
5220 (error "%s error: %s" group (gnus-status-message group)))
5222 (gnus-group-update-group group)
5223 (goto-char (text-property-any
5224 (point-min) (point-max)
5225 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5226 ;; Adjust cursor point.
5227 (gnus-group-position-point)))
5229 (defun gnus-group-goto-group (group)
5230 "Goto to newsgroup GROUP."
5232 (let ((b (text-property-any (point-min) (point-max)
5233 'gnus-group (gnus-intern-safe
5234 group gnus-active-hashtb))))
5235 (and b (goto-char b)))))
5237 (defun gnus-group-next-group (n)
5238 "Go to next N'th newsgroup.
5239 If N is negative, search backward instead.
5240 Returns the difference between N and the number of skips actually
5243 (gnus-group-next-unread-group n t))
5245 (defun gnus-group-next-unread-group (n &optional all level)
5246 "Go to next N'th unread newsgroup.
5247 If N is negative, search backward instead.
5248 If ALL is non-nil, choose any newsgroup, unread or not.
5249 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5250 such group can be found, the next group with a level higher than
5252 Returns the difference between N and the number of skips actually
5255 (let ((backward (< n 0))
5258 (gnus-group-search-forward
5259 backward (or (not gnus-group-goto-unread) all) level))
5261 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5262 (if level " on this level or higher" "")))
5265 (defun gnus-group-prev-group (n)
5266 "Go to previous N'th newsgroup.
5267 Returns the difference between N and the number of skips actually
5270 (gnus-group-next-unread-group (- n) t))
5272 (defun gnus-group-prev-unread-group (n)
5273 "Go to previous N'th unread newsgroup.
5274 Returns the difference between N and the number of skips actually
5277 (gnus-group-next-unread-group (- n)))
5279 (defun gnus-group-next-unread-group-same-level (n)
5280 "Go to next N'th unread newsgroup on the same level.
5281 If N is negative, search backward instead.
5282 Returns the difference between N and the number of skips actually
5285 (gnus-group-next-unread-group n t (gnus-group-group-level))
5286 (gnus-group-position-point))
5288 (defun gnus-group-prev-unread-group-same-level (n)
5289 "Go to next N'th unread newsgroup on the same level.
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-best-unread-group (&optional exclude-group)
5297 "Go to the group with the highest level.
5298 If EXCLUDE-GROUP, do not go to that group."
5300 (goto-char (point-min))
5303 (while (setq unread (get-text-property (point) 'gnus-unread))
5304 (if (and (numberp unread) (> unread 0))
5306 (if (and (< (get-text-property (point) 'gnus-level) best)
5307 (or (not exclude-group)
5308 (not (equal exclude-group (gnus-group-group-name)))))
5310 (setq best (get-text-property (point) 'gnus-level))
5311 (setq best-point (point))))))
5313 (if best-point (goto-char best-point))
5314 (gnus-summary-position-point)
5315 (and best-point (gnus-group-group-name))))
5317 (defun gnus-group-first-unread-group ()
5318 "Go to the first group with unread articles."
5321 (let ((opoint (point))
5323 (goto-char (point-min))
5324 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5325 (and (numberp unread) ; Not a topic.
5326 (not (zerop unread))) ; Has unread articles.
5327 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5330 nil)) ; Not success.
5331 (gnus-group-position-point)))
5333 (defun gnus-group-enter-server-mode ()
5334 "Jump to the server buffer."
5336 (gnus-enter-server-buffer))
5338 (defun gnus-group-make-group (name &optional method address)
5339 "Add a new newsgroup.
5340 The user will be prompted for a NAME, for a select METHOD, and an
5344 (read-string "Group name: ")
5347 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5349 (if (assoc method gnus-valid-select-methods)
5351 (if (memq 'prompt-address
5352 (assoc method gnus-valid-select-methods))
5353 (read-string "Address: ")
5355 (list method "")))))
5358 (set-buffer gnus-group-buffer)
5359 (let* ((meth (and method (if address (list (intern method) address)
5361 (nname (if method (gnus-group-prefixed-name name meth) name))
5363 (and (gnus-gethash nname gnus-newsrc-hashtb)
5364 (error "Group %s already exists" nname))
5365 (gnus-group-change-level
5366 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5367 gnus-level-default-subscribed gnus-level-killed
5368 (and (gnus-group-group-name)
5369 (gnus-gethash (gnus-group-group-name)
5370 gnus-newsrc-hashtb))
5372 (gnus-set-active nname (cons 1 0))
5373 (or (gnus-ephemeral-group-p name)
5375 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5376 (gnus-group-insert-group-line-info nname)
5378 (when (assoc (symbol-name (car meth)) gnus-valid-select-methods)
5379 (require (car meth)))
5380 (gnus-check-server meth)
5381 (and (gnus-check-backend-function 'request-create-group nname)
5382 (gnus-request-create-group nname))
5385 (defun gnus-group-delete-group (group &optional force)
5386 "Delete the current group.
5387 If FORCE (the prefix) is non-nil, all the articles in the group will
5388 be deleted. This is \"deleted\" as in \"removed forever from the face
5389 of the Earth\". There is no undo."
5391 (list (gnus-group-group-name)
5392 current-prefix-arg))
5393 (or group (error "No group to rename"))
5394 (or (gnus-check-backend-function 'request-delete-group group)
5395 (error "This backend does not support group deletion"))
5397 (if (not (gnus-yes-or-no-p
5399 "Do you really want to delete %s%s? "
5400 group (if force " and all its contents" ""))))
5402 (gnus-message 6 "Deleting group %s..." group)
5403 (if (not (gnus-request-delete-group group force))
5405 (gnus-message 3 "Couldn't delete group %s" group)
5407 (gnus-message 6 "Deleting group %s...done" group)
5408 (gnus-group-goto-group group)
5409 (gnus-group-kill-group 1 t)
5411 (gnus-group-position-point)))
5413 (defun gnus-group-rename-group (group new-name)
5416 (gnus-group-group-name)
5418 (or (gnus-check-backend-function
5419 'request-rename-group (gnus-group-group-name))
5420 (error "This backend does not support renaming groups"))
5421 (read-string "New group name: "))))
5423 (or (gnus-check-backend-function 'request-rename-group group)
5424 (error "This backend does not support renaming groups"))
5426 (or group (error "No group to rename"))
5427 (and (string-match "^[ \t]*$" new-name)
5428 (error "Not a valid group name"))
5430 ;; We find the proper prefixed name.
5432 (gnus-group-prefixed-name
5433 (gnus-group-real-name new-name)
5434 (gnus-info-method (gnus-get-info group))))
5436 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5438 (if (not (gnus-request-rename-group group new-name))
5440 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5442 ;; We rename the group internally by killing it...
5443 (gnus-group-goto-group group)
5444 (gnus-group-kill-group)
5445 ;; ... changing its name ...
5446 (setcar (cdar gnus-list-of-killed-groups) new-name)
5447 ;; ... and then yanking it. Magic!
5448 (gnus-group-yank-group)
5449 (gnus-set-active new-name (gnus-active group))
5450 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5452 (gnus-group-position-point)))
5454 (defun gnus-group-edit-group (group &optional part)
5455 "Edit the group on the current line."
5456 (interactive (list (gnus-group-group-name)))
5457 (let* ((part (or part 'info))
5458 (done-func `(lambda ()
5459 "Exit editing mode and update the information."
5461 (gnus-group-edit-group-done ',part ,group)))
5462 (winconf (current-window-configuration))
5464 (or group (error "No group on current line"))
5465 (or (setq info (gnus-get-info group))
5466 (error "Killed group; can't be edited"))
5467 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5468 (gnus-configure-windows 'edit-group)
5469 (gnus-add-current-to-buffer-list)
5471 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5472 (use-local-map (copy-keymap emacs-lisp-mode-map))
5473 (local-set-key "\C-c\C-c" done-func)
5474 (make-local-variable 'gnus-prev-winconf)
5475 (setq gnus-prev-winconf winconf)
5480 ";; Type `C-c C-c' after editing the select method.\n\n")
5482 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5484 ";; Type `C-c C-c' after editing the group info.\n\n")))
5487 (cond ((eq part 'method)
5488 (or (gnus-info-method info) "native"))
5490 (gnus-info-params info))
5494 (defun gnus-group-edit-group-method (group)
5495 "Edit the select method of GROUP."
5496 (interactive (list (gnus-group-group-name)))
5497 (gnus-group-edit-group group 'method))
5499 (defun gnus-group-edit-group-parameters (group)
5500 "Edit the group parameters of GROUP."
5501 (interactive (list (gnus-group-group-name)))
5502 (gnus-group-edit-group group 'params))
5504 (defun gnus-group-edit-group-done (part group)
5505 "Get info from buffer, update variables and jump to the group buffer."
5506 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5507 (goto-char (point-min))
5508 (let* ((form (read (current-buffer)))
5509 (winconf gnus-prev-winconf)
5510 (method (cond ((eq part 'info) (nth 4 form))
5511 ((eq part 'method) form)
5513 (info (cond ((eq part 'info) form)
5514 ((eq part 'method) (gnus-get-info group))
5517 (if (or (not method)
5519 gnus-select-method method))
5520 (gnus-group-real-name (car info))
5521 (gnus-group-prefixed-name
5522 (gnus-group-real-name (car info)) method))
5524 (when (and new-group
5525 (not (equal new-group group)))
5526 (when (gnus-group-goto-group group)
5527 (gnus-group-kill-group 1))
5528 (gnus-activate-group new-group))
5530 (if (and info new-group)
5532 (setq info (gnus-copy-sequence info))
5533 (setcar info new-group)
5534 (unless (gnus-server-equal method "native")
5535 (unless (nthcdr 3 info)
5536 (nconc info (list nil nil)))
5537 (unless (nthcdr 4 info)
5538 (nconc info (list nil)))
5539 (gnus-info-set-method info method))
5540 (gnus-group-set-info info))
5541 (gnus-group-set-info form (or new-group group) part))
5542 (kill-buffer (current-buffer))
5543 (and winconf (set-window-configuration winconf))
5544 (set-buffer gnus-group-buffer)
5545 (gnus-group-update-group (or new-group group))
5546 (gnus-group-position-point)))
5548 (defun gnus-group-make-help-group ()
5549 "Create the Gnus documentation group."
5551 (let ((path load-path)
5552 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5554 (and (gnus-gethash name gnus-newsrc-hashtb)
5555 (error "Documentation group already exists"))
5557 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5559 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5561 (setq file (concat (file-name-directory
5562 (directory-file-name dir))
5563 "etc/gnus-tut.txt"))))
5566 (message "Couldn't find doc group")
5567 (gnus-group-make-group
5568 (gnus-group-real-name name)
5570 (list 'nndoc-address file)
5571 (list 'nndoc-article-type 'mbox)))))
5572 (gnus-group-position-point))
5574 (defun gnus-group-make-doc-group (file type)
5575 "Create a group that uses a single file as the source."
5577 (list (read-file-name "File name: ")
5578 (and current-prefix-arg 'ask)))
5579 (when (eq type 'ask)
5584 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5586 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5587 ((= char ?b) 'babyl)
5588 ((= char ?d) 'digest)
5589 ((= char ?f) 'forward)
5591 (t (setq err (format "%c unknown. " char))
5594 (let* ((file (expand-file-name file))
5595 (name (gnus-generate-new-group-name
5596 (gnus-group-prefixed-name
5597 (file-name-nondirectory file) '(nndoc "")))))
5598 (gnus-group-make-group
5599 (gnus-group-real-name name)
5601 (list 'nndoc-address file)
5602 (list 'nndoc-article-type (or type 'guess))))
5604 (gnus-group-position-point)))
5606 (defun gnus-group-make-archive-group (&optional all)
5607 "Create the (ding) Gnus archive group of the most recent articles.
5608 Given a prefix, create a full group."
5610 (let ((group (gnus-group-prefixed-name
5611 (if all "ding.archives" "ding.recent") '(nndir ""))))
5612 (and (gnus-gethash group gnus-newsrc-hashtb)
5613 (error "Archive group already exists"))
5614 (gnus-group-make-group
5615 (gnus-group-real-name group)
5616 (list 'nndir (if all "hpc" "edu")
5617 (list 'nndir-directory
5618 (if all gnus-group-archive-directory
5619 gnus-group-recent-archive-directory)))))
5621 (gnus-group-position-point))
5623 (defun gnus-group-make-directory-group (dir)
5624 "Create an nndir group.
5625 The user will be prompted for a directory. The contents of this
5626 directory will be used as a newsgroup. The directory should contain
5627 mail messages or news articles in files that have numeric names."
5629 (list (read-file-name "Create group from directory: ")))
5630 (or (file-exists-p dir) (error "No such directory"))
5631 (or (file-directory-p dir) (error "Not a directory"))
5635 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5637 (gnus-group-prefixed-name
5638 (concat (file-name-as-directory (directory-file-name dir))
5641 (setq ext (format "<%d>" (setq i (1+ i)))))
5642 (gnus-group-make-group
5643 (gnus-group-real-name group)
5644 (list 'nndir group (list 'nndir-directory dir))))
5646 (gnus-group-position-point))
5648 (defun gnus-group-make-kiboze-group (group address scores)
5649 "Create an nnkiboze group.
5650 The user will be prompted for a name, a regexp to match groups, and
5651 score file entries for articles to include in the group."
5654 (read-string "nnkiboze group name: ")
5655 (read-string "Source groups (regexp): ")
5656 (let ((headers (mapcar (lambda (group) (list group))
5657 '("subject" "from" "number" "date" "message-id"
5658 "references" "chars" "lines" "xref"
5659 "followup" "all" "body" "head")))
5660 scores header regexp regexps)
5661 (while (not (equal "" (setq header (completing-read
5662 "Match on header: " headers nil t))))
5664 (while (not (equal "" (setq regexp (read-string
5665 (format "Match on %s (string): "
5667 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5668 (setq scores (cons (cons header regexps) scores)))
5670 (gnus-group-make-group group "nnkiboze" address)
5672 (gnus-set-work-buffer)
5673 (let (emacs-lisp-mode-hook)
5674 (pp scores (current-buffer)))
5675 (write-region (point-min) (point-max)
5676 (gnus-score-file-name (concat "nnkiboze:" group))))
5678 (gnus-group-position-point))
5680 (defun gnus-group-add-to-virtual (n vgroup)
5681 "Add the current group to a virtual group."
5683 (list current-prefix-arg
5684 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5686 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5687 (error "%s is not an nnvirtual group" vgroup))
5688 (let* ((groups (gnus-group-process-prefix n))
5689 (method (gnus-info-method (gnus-get-info vgroup))))
5690 (setcar (cdr method)
5692 (nth 1 method) "\\|"
5695 (gnus-group-remove-mark s)
5696 (concat "\\(^" (regexp-quote s) "$\\)"))
5698 (gnus-group-position-point))
5700 (defun gnus-group-make-empty-virtual (group)
5701 "Create a new, fresh, empty virtual group."
5702 (interactive "sCreate new, empty virtual group: ")
5703 (let* ((method (list 'nnvirtual "^$"))
5704 (pgroup (gnus-group-prefixed-name group method)))
5705 ;; Check whether it exists already.
5706 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5707 (error "Group %s already exists." pgroup))
5708 ;; Subscribe the new group after the group on the current line.
5709 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5710 (gnus-group-update-group pgroup)
5712 (gnus-group-position-point)))
5714 (defun gnus-group-enter-directory (dir)
5715 "Enter an ephemeral nneething group."
5716 (interactive "DDirectory to read: ")
5717 (let* ((method (list 'nneething dir))
5718 (leaf (gnus-group-prefixed-name
5719 (file-name-nondirectory (directory-file-name dir))
5721 (name (gnus-generate-new-group-name leaf)))
5722 (let ((nneething-read-only t))
5723 (or (gnus-group-read-ephemeral-group
5725 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5727 (error "Couldn't enter %s" dir)))))
5729 ;; Group sorting commands
5730 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5732 (defun gnus-group-sort-groups (func &optional reverse)
5733 "Sort the group buffer according to FUNC.
5734 If REVERSE, reverse the sorting order."
5735 (interactive (list gnus-group-sort-function
5736 current-prefix-arg))
5738 ((not (listp func)) func)
5740 ((= 1 (length func)) (car func))
5742 ,(gnus-make-sort-function
5743 (reverse func)))))))
5744 ;; We peel off the dummy group from the alist.
5746 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5747 (pop gnus-newsrc-alist))
5749 (setq gnus-newsrc-alist
5750 (sort gnus-newsrc-alist func))
5752 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5753 ;; Regenerate the hash table.
5754 (gnus-make-hashtable-from-newsrc-alist)
5755 (gnus-group-list-groups))))
5757 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5758 "Sort the group buffer alphabetically by group name.
5759 If REVERSE, sort in reverse order."
5761 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5763 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5764 "Sort the group buffer by number of unread articles.
5765 If REVERSE, sort in reverse order."
5767 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5769 (defun gnus-group-sort-groups-by-level (&optional reverse)
5770 "Sort the group buffer by group level.
5771 If REVERSE, sort in reverse order."
5773 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5775 (defun gnus-group-sort-groups-by-score (&optional reverse)
5776 "Sort the group buffer by group score.
5777 If REVERSE, sort in reverse order."
5779 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5781 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5782 "Sort the group buffer by group rank.
5783 If REVERSE, sort in reverse order."
5785 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5787 (defun gnus-group-sort-groups-by-method (&optional reverse)
5788 "Sort the group buffer alphabetically by backend name.
5789 If REVERSE, sort in reverse order."
5791 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5793 (defun gnus-group-sort-by-alphabet (info1 info2)
5794 "Sort alphabetically."
5795 (string< (gnus-info-group info1) (gnus-info-group info2)))
5797 (defun gnus-group-sort-by-unread (info1 info2)
5798 "Sort by number of unread articles."
5799 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5800 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5801 (< (or (and (numberp n1) n1) 0)
5802 (or (and (numberp n2) n2) 0))))
5804 (defun gnus-group-sort-by-level (info1 info2)
5806 (< (gnus-info-level info1) (gnus-info-level info2)))
5808 (defun gnus-group-sort-by-method (info1 info2)
5809 "Sort alphabetically by backend name."
5810 (string< (symbol-name (car (gnus-find-method-for-group
5811 (gnus-info-group info1) info1)))
5812 (symbol-name (car (gnus-find-method-for-group
5813 (gnus-info-group info2) info2)))))
5815 (defun gnus-group-sort-by-score (info1 info2)
5816 "Sort by group score."
5817 (< (gnus-info-score info1) (gnus-info-score info2)))
5819 (defun gnus-group-sort-by-rank (info1 info2)
5820 "Sort by level and score."
5821 (let ((level1 (gnus-info-level info1))
5822 (level2 (gnus-info-level info2)))
5823 (or (< level1 level2)
5824 (and (= level1 level2)
5825 (< (gnus-info-score info1) (gnus-info-score info2))))))
5827 ;; Group catching up.
5829 (defun gnus-group-catchup-current (&optional n all)
5830 "Mark all articles not marked as unread in current newsgroup as read.
5831 If prefix argument N is numeric, the ARG next newsgroups will be
5832 caught up. If ALL is non-nil, marked articles will also be marked as
5833 read. Cross references (Xref: header) of articles are ignored.
5834 The difference between N and actual number of newsgroups that were
5835 caught up is returned."
5837 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5841 "Do you really want to mark all articles as read? "
5842 "Mark all unread articles as read? "))))
5844 (let ((groups (gnus-group-process-prefix n))
5847 ;; Virtual groups have to be given special treatment.
5848 (let ((method (gnus-find-method-for-group (car groups))))
5849 (if (eq 'nnvirtual (car method))
5850 (nnvirtual-catchup-group
5851 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5852 (gnus-group-remove-mark (car groups))
5854 (gnus-group-goto-group (car groups))
5855 (gnus-group-catchup (car groups) all))
5856 (gnus-group-update-group-line)
5857 (setq ret (1+ ret)))
5858 (setq groups (cdr groups)))
5859 (gnus-group-next-unread-group 1)
5862 (defun gnus-group-catchup-current-all (&optional n)
5863 "Mark all articles in current newsgroup as read.
5864 Cross references (Xref: header) of articles are ignored."
5866 (gnus-group-catchup-current n 'all))
5868 (defun gnus-group-catchup (group &optional all)
5869 "Mark all articles in GROUP as read.
5870 If ALL is non-nil, all articles are marked as read.
5871 The return value is the number of articles that were marked as read,
5872 or nil if no action could be taken."
5873 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5875 ;; Do the updating only if the newsgroup isn't killed.
5876 (if (not (numberp (car entry)))
5877 (gnus-message 1 "Can't catch up; non-active group")
5878 ;; Do auto-expirable marks if that's required.
5879 (when (gnus-group-auto-expirable-p group)
5880 (gnus-add-marked-articles
5881 group 'expire (gnus-list-of-unread-articles group))
5883 (let ((marks (nth 3 (nth 2 entry))))
5884 (gnus-add-marked-articles
5885 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5886 (gnus-add-marked-articles
5887 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5889 (gnus-update-read-articles group nil)
5890 ;; Also nix out the lists of marks and dormants.
5892 (gnus-add-marked-articles group 'tick nil nil 'force)
5893 (gnus-add-marked-articles group 'dormant nil nil 'force))
5894 (run-hooks 'gnus-group-catchup-group-hook)
5897 (defun gnus-group-expire-articles (&optional n)
5898 "Expire all expirable articles in the current newsgroup."
5900 (let ((groups (gnus-group-process-prefix n))
5903 (error "No groups to expire"))
5904 (while (setq group (pop groups))
5905 (gnus-group-remove-mark group)
5906 (when (gnus-check-backend-function 'request-expire-articles group)
5907 (gnus-message 6 "Expiring articles in %s..." group)
5908 (let* ((info (gnus-get-info group))
5909 (expirable (if (gnus-group-total-expirable-p group)
5910 (cons nil (gnus-list-of-read-articles group))
5911 (assq 'expire (gnus-info-marks info))))
5912 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5916 (gnus-compress-sequence
5918 ;; We set the expiry variables to the groupp
5920 (let ((nnmail-expiry-wait-function nil)
5921 (nnmail-expiry-wait expiry-wait))
5922 (gnus-request-expire-articles
5923 (gnus-uncompress-sequence (cdr expirable)) group))
5924 ;; Just expire using the normal expiry values.
5925 (gnus-request-expire-articles
5926 (gnus-uncompress-sequence (cdr expirable)) group)))))
5927 (gnus-message 6 "Expiring articles in %s...done" group)))
5928 (gnus-group-position-point))))
5930 (defun gnus-group-expire-all-groups ()
5931 "Expire all expirable articles in all newsgroups."
5934 (gnus-message 5 "Expiring...")
5935 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5936 (cdr gnus-newsrc-alist))))
5937 (gnus-group-expire-articles nil)))
5938 (gnus-group-position-point)
5939 (gnus-message 5 "Expiring...done"))
5941 (defun gnus-group-set-current-level (n level)
5942 "Set the level of the next N groups to LEVEL."
5946 (if (not (gnus-group-group-name))
5947 (error "No group on the current line")
5949 (let ((s (read-string
5950 (format "Level (default %s): " (gnus-group-group-level)))))
5951 (if (string-match "^\\s-*$" s)
5952 (int-to-string (gnus-group-group-level))
5954 (or (and (>= level 1) (<= level gnus-level-killed))
5955 (error "Illegal level: %d" level))
5956 (let ((groups (gnus-group-process-prefix n))
5958 (while (setq group (pop groups))
5959 (gnus-group-remove-mark group)
5960 (gnus-message 6 "Changed level of %s from %d to %d"
5961 group (or (gnus-group-group-level) gnus-level-killed)
5963 (gnus-group-change-level
5964 group level (or (gnus-group-group-level) gnus-level-killed))
5965 (gnus-group-update-group-line)))
5966 (gnus-group-position-point))
5968 (defun gnus-group-unsubscribe-current-group (&optional n)
5969 "Toggle subscription of the current group.
5970 If given numerical prefix, toggle the N next groups."
5972 (let ((groups (gnus-group-process-prefix n))
5975 (setq group (car groups)
5976 groups (cdr groups))
5977 (gnus-group-remove-mark group)
5978 (gnus-group-unsubscribe-group
5979 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
5980 gnus-level-default-unsubscribed
5981 gnus-level-default-subscribed) t)
5982 (gnus-group-update-group-line))
5983 (gnus-group-next-group 1)))
5985 (defun gnus-group-unsubscribe-group (group &optional level silent)
5986 "Toggle subscription to GROUP.
5987 Killed newsgroups are subscribed. If SILENT, don't try to update the
5990 (list (completing-read
5991 "Group: " gnus-active-hashtb nil
5992 (memq gnus-select-method gnus-have-read-active-file))))
5993 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
5995 ((string-match "^[ \t]$" group)
5996 (error "Empty group name"))
5998 ;; Toggle subscription flag.
5999 (gnus-group-change-level
6000 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6001 gnus-level-subscribed)
6002 (1+ gnus-level-subscribed)
6003 gnus-level-default-subscribed)))
6005 (gnus-group-update-group group)))
6006 ((and (stringp group)
6007 (or (not (memq gnus-select-method gnus-have-read-active-file))
6008 (gnus-active group)))
6009 ;; Add new newsgroup.
6010 (gnus-group-change-level
6012 (if level level gnus-level-default-subscribed)
6013 (or (and (member group gnus-zombie-list)
6016 (and (gnus-group-group-name)
6017 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6019 (gnus-group-update-group group)))
6020 (t (error "No such newsgroup: %s" group)))
6021 (gnus-group-position-point)))
6023 (defun gnus-group-transpose-groups (n)
6024 "Move the current newsgroup up N places.
6025 If given a negative prefix, move down instead. The difference between
6026 N and the number of steps taken is returned."
6028 (or (gnus-group-group-name)
6029 (error "No group on current line"))
6030 (gnus-group-kill-group 1)
6032 (forward-line (- n))
6033 (gnus-group-yank-group)
6034 (gnus-group-position-point)))
6036 (defun gnus-group-kill-all-zombies ()
6037 "Kill all zombie newsgroups."
6039 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6040 (setq gnus-zombie-list nil)
6041 (gnus-group-list-groups))
6043 (defun gnus-group-kill-region (begin end)
6044 "Kill newsgroups in current region (excluding current point).
6045 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6060 (beginning-of-line) ;Important when LINES < 1
6061 (gnus-group-kill-group lines)))
6063 (defun gnus-group-kill-group (&optional n discard)
6064 "Kill the next N groups.
6065 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6066 However, only groups that were alive can be yanked; already killed
6067 groups or zombie groups can't be yanked.
6068 The return value is the name of the group that was killed, or a list
6071 (let ((buffer-read-only nil)
6072 (groups (gnus-group-process-prefix n))
6073 group entry level out)
6074 (if (< (length groups) 10)
6075 ;; This is faster when there are few groups.
6077 (push (setq group (pop groups)) out)
6078 (gnus-group-remove-mark group)
6079 (setq level (gnus-group-group-level))
6081 (when (and (not discard)
6082 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6083 (push (cons (car entry) (nth 2 entry))
6084 gnus-list-of-killed-groups))
6085 (gnus-group-change-level
6086 (if entry entry group) gnus-level-killed (if entry nil level)))
6087 ;; If there are lots and lots of groups to be killed, we use
6088 ;; this thing instead.
6090 (setq groups (nreverse groups))
6092 (gnus-group-remove-mark (setq group (pop groups)))
6095 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6096 (push (cons (car entry) (nth 2 entry))
6097 gnus-list-of-killed-groups)
6098 (setcdr (cdr entry) (cdddr entry)))
6099 ((member group gnus-zombie-list)
6100 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6101 (gnus-make-hashtable-from-newsrc-alist)))
6103 (gnus-group-position-point)
6104 (if (< (length out) 2) (car out) (nreverse out))))
6106 (defun gnus-group-yank-group (&optional arg)
6107 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6108 inserting it before the current newsgroup. The numeric ARG specifies
6109 how many newsgroups are to be yanked. The name of the newsgroup yanked
6110 is returned, or (if several groups are yanked) a list of yanked groups
6113 (setq arg (or arg 1))
6114 (let (info group prev out)
6115 (while (>= (decf arg) 0)
6116 (if (not (setq info (pop gnus-list-of-killed-groups)))
6117 (error "No more newsgroups to yank"))
6118 (push (setq group (nth 1 info)) out)
6119 ;; Find which newsgroup to insert this one before - search
6120 ;; backward until something suitable is found. If there are no
6121 ;; other newsgroups in this buffer, just make this newsgroup the
6123 (setq prev (gnus-group-group-name))
6124 (gnus-group-change-level
6125 info (nth 2 info) gnus-level-killed
6126 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6128 (gnus-group-insert-group-line-info group))
6130 (gnus-group-position-point)
6131 (if (< (length out) 2) (car out) (nreverse out))))
6133 (defun gnus-group-kill-level (level)
6134 "Kill all groups that is on a certain LEVEL."
6135 (interactive "nKill all groups on level: ")
6137 ((= level gnus-level-zombie)
6138 (setq gnus-killed-list
6139 (nconc gnus-zombie-list gnus-killed-list))
6140 (setq gnus-zombie-list nil))
6141 ((and (< level gnus-level-zombie)
6143 (or gnus-expert-user
6146 "Do you really want to kill all groups on level %d? "
6148 (let* ((prev gnus-newsrc-alist)
6151 (if (= (gnus-info-level level) level)
6152 (setcdr prev (cdr alist))
6154 (setq alist (cdr alist)))
6155 (gnus-make-hashtable-from-newsrc-alist)
6156 (gnus-group-list-groups)))
6158 (error "Can't kill; illegal level: %d" level))))
6160 (defun gnus-group-list-all-groups (&optional arg)
6161 "List all newsgroups with level ARG or lower.
6162 Default is gnus-level-unsubscribed, which lists all subscribed and most
6163 unsubscribed groups."
6165 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6167 ;; Redefine this to list ALL killed groups if prefix arg used.
6168 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6169 (defun gnus-group-list-killed (&optional arg)
6170 "List all killed newsgroups in the group buffer.
6171 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6172 entail asking the server for the groups."
6174 ;; Find all possible killed newsgroups if arg.
6176 ;; First make sure active file has been read.
6177 (unless gnus-have-read-active-file
6178 (let ((gnus-read-active-file t))
6179 (gnus-read-active-file)))
6180 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6181 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6185 (group (symbol-name sym)))
6186 (if (or (null group)
6187 (gnus-gethash group gnus-killed-hashtb)
6188 (gnus-gethash group gnus-newsrc-hashtb))
6190 (let ((do-sub (gnus-matches-options-n group)))
6191 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6193 (setq groups (1+ groups))
6194 (setq gnus-killed-list
6195 (cons group gnus-killed-list))
6196 (gnus-sethash group group gnus-killed-hashtb))))))
6197 gnus-active-hashtb))
6198 (if (not gnus-killed-list)
6199 (gnus-message 6 "No killed groups")
6200 (let (gnus-group-list-mode)
6201 (funcall gnus-group-prepare-function
6202 gnus-level-killed t gnus-level-killed))
6203 (goto-char (point-min)))
6204 (gnus-group-position-point))
6206 (defun gnus-group-list-zombies ()
6207 "List all zombie newsgroups in the group buffer."
6209 (if (not gnus-zombie-list)
6210 (gnus-message 6 "No zombie groups")
6211 (let (gnus-group-list-mode)
6212 (funcall gnus-group-prepare-function
6213 gnus-level-zombie t gnus-level-zombie))
6214 (goto-char (point-min)))
6215 (gnus-group-position-point))
6217 (defun gnus-group-list-active ()
6218 "List all groups that are available from the server(s)."
6220 ;; First we make sure that we have really read the active file.
6221 (unless gnus-have-read-active-file
6222 (let ((gnus-read-active-file t))
6223 (gnus-read-active-file)))
6224 ;; Find all groups and sort them.
6230 (and (symbol-value sym)
6231 (setq list (cons (symbol-name sym) list))))
6235 (buffer-read-only nil))
6238 (gnus-group-insert-group-line-info (car groups))
6239 (setq groups (cdr groups)))
6240 (goto-char (point-min))))
6242 (defun gnus-activate-all-groups (level)
6243 "Activate absolutely all groups."
6244 (interactive (list 7))
6245 (let ((gnus-activate-level level)
6246 (gnus-activate-foreign-newsgroups level))
6247 (gnus-group-get-new-news)))
6249 (defun gnus-group-get-new-news (&optional arg)
6250 "Get newly arrived articles.
6251 If ARG is a number, it specifies which levels you are interested in
6252 re-scanning. If ARG is non-nil and not a number, this will force
6253 \"hard\" re-reading of the active files from all servers."
6255 (run-hooks 'gnus-get-new-news-hook)
6256 ;; We might read in new NoCeM messages here.
6257 (when (and gnus-use-nocem
6259 (gnus-nocem-scan-groups))
6260 ;; If ARG is not a number, then we read the active file.
6261 (when (and arg (not (numberp arg)))
6262 (let ((gnus-read-active-file t))
6263 (gnus-read-active-file))
6266 (setq arg (gnus-group-default-level arg t))
6267 (if (and gnus-read-active-file (not arg))
6269 (gnus-read-active-file)
6270 (gnus-get-unread-articles arg))
6271 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6272 (gnus-get-unread-articles arg)))
6273 (run-hooks 'gnus-after-getting-new-news-hook)
6274 (gnus-group-list-groups))
6276 (defun gnus-group-get-new-news-this-group (&optional n)
6277 "Check for newly arrived news in the current group (and the N-1 next groups).
6278 The difference between N and the number of newsgroup checked is returned.
6279 If N is negative, this group and the N-1 previous groups will be checked."
6281 (let* ((groups (gnus-group-process-prefix n))
6282 (ret (if (numberp n) (- n (length groups)) 0))
6285 (setq group (car groups)
6286 groups (cdr groups))
6287 (gnus-group-remove-mark group)
6288 (unless (gnus-get-new-news-in-group group)
6290 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6291 (when gnus-goto-next-group-when-activating
6292 (gnus-group-next-unread-group 1 t))
6293 (gnus-summary-position-point)
6296 (defun gnus-get-new-news-in-group (group)
6297 (when (and group (gnus-activate-group group 'scan))
6298 (gnus-get-unread-articles-in-group
6299 (gnus-get-info group) (gnus-active group) t)
6300 (when (gnus-group-goto-group group)
6301 (gnus-group-update-group-line))
6304 (defun gnus-group-fetch-faq (group &optional faq-dir)
6305 "Fetch the FAQ for the current group."
6308 (gnus-group-real-name (gnus-group-group-name))
6309 (cond (current-prefix-arg
6311 "Faq dir: " (and (listp gnus-group-faq-directory)
6312 gnus-group-faq-directory))))))
6314 (setq faq-dir (if (listp gnus-group-faq-directory)
6315 (car gnus-group-faq-directory)
6316 gnus-group-faq-directory)))
6317 (or group (error "No group name given"))
6318 (let ((file (concat (file-name-as-directory faq-dir)
6319 (gnus-group-real-name group))))
6320 (if (not (file-exists-p file))
6321 (error "No such file: %s" file)
6324 (defun gnus-group-describe-group (force &optional group)
6325 "Display a description of the current newsgroup."
6326 (interactive (list current-prefix-arg (gnus-group-group-name)))
6327 (and force (setq gnus-description-hashtb nil))
6328 (let ((method (gnus-find-method-for-group group))
6330 (or group (error "No group name given"))
6331 (and (or (and gnus-description-hashtb
6332 ;; We check whether this group's method has been
6333 ;; queried for a description file.
6335 (gnus-group-prefixed-name "" method)
6336 gnus-description-hashtb))
6337 (setq desc (gnus-group-get-description group))
6338 (gnus-read-descriptions-file method))
6340 (or desc (gnus-gethash group gnus-description-hashtb)
6341 "No description available")))))
6343 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6344 (defun gnus-group-describe-all-groups (&optional force)
6345 "Pop up a buffer with descriptions of all newsgroups."
6347 (and force (setq gnus-description-hashtb nil))
6348 (if (not (or gnus-description-hashtb
6349 (gnus-read-all-descriptions-files)))
6350 (error "Couldn't request descriptions file"))
6351 (let ((buffer-read-only nil)
6357 (insert (format " *: %-20s %s\n" (symbol-name group)
6358 (symbol-value group)))
6359 (add-text-properties
6360 b (1+ b) (list 'gnus-group group
6361 'gnus-unread t 'gnus-marked nil
6362 'gnus-level (1+ gnus-level-subscribed))))
6363 gnus-description-hashtb)
6364 (goto-char (point-min))
6365 (gnus-group-position-point)))
6367 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6368 (defun gnus-group-apropos (regexp &optional search-description)
6369 "List all newsgroups that have names that match a regexp."
6370 (interactive "sGnus apropos (regexp): ")
6372 (obuf (current-buffer))
6374 ;; Go through all newsgroups that are known to Gnus.
6377 (and (symbol-name group)
6378 (string-match regexp (symbol-name group))
6379 (setq groups (cons (symbol-name group) groups))))
6381 ;; Go through all descriptions that are known to Gnus.
6382 (if search-description
6385 (and (string-match regexp (symbol-value group))
6386 (gnus-active (symbol-name group))
6387 (setq groups (cons (symbol-name group) groups))))
6388 gnus-description-hashtb))
6390 (gnus-message 3 "No groups matched \"%s\"." regexp)
6391 ;; Print out all the groups.
6393 (pop-to-buffer "*Gnus Help*")
6394 (buffer-disable-undo (current-buffer))
6396 (setq groups (sort groups 'string<))
6398 ;; Groups may be entered twice into the list of groups.
6399 (if (not (string= (car groups) prev))
6401 (insert (setq prev (car groups)) "\n")
6402 (if (and gnus-description-hashtb
6403 (setq des (gnus-gethash (car groups)
6404 gnus-description-hashtb)))
6405 (insert " " des "\n"))))
6406 (setq groups (cdr groups)))
6407 (goto-char (point-min))))
6408 (pop-to-buffer obuf)))
6410 (defun gnus-group-description-apropos (regexp)
6411 "List all newsgroups that have names or descriptions that match a regexp."
6412 (interactive "sGnus description apropos (regexp): ")
6413 (if (not (or gnus-description-hashtb
6414 (gnus-read-all-descriptions-files)))
6415 (error "Couldn't request descriptions file"))
6416 (gnus-group-apropos regexp t))
6418 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6419 (defun gnus-group-list-matching (level regexp &optional all lowest)
6420 "List all groups with unread articles that match REGEXP.
6421 If the prefix LEVEL is non-nil, it should be a number that says which
6422 level to cut off listing groups.
6423 If ALL, also list groups with no unread articles.
6424 If LOWEST, don't list groups with level lower than LOWEST."
6425 (interactive "P\nsList newsgroups matching: ")
6426 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6427 all (or lowest 1) regexp)
6428 (goto-char (point-min))
6429 (gnus-group-position-point))
6431 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6432 "List all groups that match REGEXP.
6433 If the prefix LEVEL is non-nil, it should be a number that says which
6434 level to cut off listing groups.
6435 If LOWEST, don't list groups with level lower than LOWEST."
6436 (interactive "P\nsList newsgroups matching: ")
6437 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6439 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6440 (defun gnus-group-save-newsrc (&optional force)
6441 "Save the Gnus startup files.
6442 If FORCE, force saving whether it is necessary or not."
6444 (gnus-save-newsrc-file force))
6446 (defun gnus-group-restart (&optional arg)
6447 "Force Gnus to read the .newsrc file."
6449 (when (gnus-yes-or-no-p
6450 (format "Are you sure you want to read %s? "
6451 gnus-current-startup-file))
6452 (gnus-save-newsrc-file)
6453 (gnus-setup-news 'force)
6454 (gnus-group-list-groups arg)))
6456 (defun gnus-group-read-init-file ()
6457 "Read the Gnus elisp init file."
6459 (gnus-read-init-file))
6461 (defun gnus-group-check-bogus-groups (&optional silent)
6462 "Check bogus newsgroups.
6463 If given a prefix, don't ask for confirmation before removing a bogus
6466 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6467 (gnus-group-list-groups))
6469 (defun gnus-group-edit-global-kill (&optional article group)
6470 "Edit the global kill file.
6471 If GROUP, edit that local kill file instead."
6473 (setq gnus-current-kill-article article)
6474 (gnus-kill-file-edit-file group)
6477 (substitute-command-keys
6478 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6479 (if group "local" "global")))))
6481 (defun gnus-group-edit-local-kill (article group)
6482 "Edit a local kill file."
6483 (interactive (list nil (gnus-group-group-name)))
6484 (gnus-group-edit-global-kill article group))
6486 (defun gnus-group-force-update ()
6487 "Update `.newsrc' file."
6489 (gnus-save-newsrc-file))
6491 (defun gnus-group-suspend ()
6492 "Suspend the current Gnus session.
6493 In fact, cleanup buffers except for group mode buffer.
6494 The hook gnus-suspend-gnus-hook is called before actually suspending."
6496 (run-hooks 'gnus-suspend-gnus-hook)
6497 ;; Kill Gnus buffers except for group mode buffer.
6498 (let ((group-buf (get-buffer gnus-group-buffer)))
6499 ;; Do this on a separate list in case the user does a ^G before we finish
6500 (let ((gnus-buffer-list
6501 (delq group-buf (delq gnus-dribble-buffer
6502 (append gnus-buffer-list nil)))))
6503 (while gnus-buffer-list
6504 (gnus-kill-buffer (car gnus-buffer-list))
6505 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6508 (setq gnus-buffer-list (list group-buf))
6509 (bury-buffer group-buf)
6510 (delete-windows-on group-buf t)))))
6512 (defun gnus-group-clear-dribble ()
6513 "Clear all information from the dribble buffer."
6515 (gnus-dribble-clear)
6516 (gnus-message 7 "Cleared dribble buffer"))
6518 (defun gnus-group-exit ()
6519 "Quit reading news after updating .newsrc.eld and .newsrc.
6520 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6523 (or noninteractive ;For gnus-batch-kill
6524 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6525 (not gnus-interactive-exit) ;Without confirmation
6527 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6528 (run-hooks 'gnus-exit-gnus-hook)
6529 ;; Close down GroupLens.
6530 (when gnus-use-grouplens
6532 ;; Offer to save data from non-quitted summary buffers.
6533 (gnus-offer-save-summaries)
6534 ;; Save the newsrc file(s).
6535 (gnus-save-newsrc-file)
6537 (gnus-close-backends)
6538 ;; Shut down the cache.
6539 (when gnus-use-cache
6541 ;; Reset everything.
6543 ;; Allow the user to do things after cleaning up.
6544 (run-hooks 'gnus-after-exiting-gnus-hook)))
6546 (defun gnus-close-backends ()
6547 ;; Send a close request to all backends that support such a request.
6548 (let ((methods gnus-valid-select-methods)
6551 (if (fboundp (setq func (intern (concat (caar methods)
6552 "-request-close"))))
6554 (setq methods (cdr methods)))))
6556 (defun gnus-group-quit ()
6557 "Quit reading news without updating .newsrc.eld or .newsrc.
6558 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6560 (when (or noninteractive ;For gnus-batch-kill
6561 (zerop (buffer-size))
6562 (not (gnus-server-opened gnus-select-method))
6564 (not gnus-current-startup-file)
6566 (format "Quit reading news without saving %s? "
6567 (file-name-nondirectory gnus-current-startup-file))))
6568 (run-hooks 'gnus-exit-gnus-hook)
6569 (if gnus-use-full-window
6570 (delete-other-windows)
6571 (gnus-remove-some-windows))
6573 (gnus-close-backends)
6574 ;; Shut down the cache.
6575 (when gnus-use-cache
6578 ;; Allow the user to do things after cleaning up.
6579 (run-hooks 'gnus-after-exiting-gnus-hook)))
6581 (defun gnus-offer-save-summaries ()
6582 "Offer to save all active summary buffers."
6584 (let ((buflist (buffer-list))
6586 ;; Go through all buffers and find all summaries.
6588 (and (setq bufname (buffer-name (car buflist)))
6589 (string-match "Summary" bufname)
6591 (set-buffer bufname)
6592 ;; We check that this is, indeed, a summary buffer.
6593 (and (eq major-mode 'gnus-summary-mode)
6594 ;; Also make sure this isn't bogus.
6595 gnus-newsgroup-prepared))
6596 (push bufname buffers))
6597 (setq buflist (cdr buflist)))
6598 ;; Go through all these summary buffers and offer to save them.
6601 "Update summary buffer %s? "
6602 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6605 (defun gnus-group-describe-briefly ()
6606 "Give a one line description of the group mode commands."
6608 (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")))
6610 (defun gnus-group-browse-foreign-server (method)
6611 "Browse a foreign news server.
6612 If called interactively, this function will ask for a select method
6613 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6614 If not, METHOD should be a list where the first element is the method
6615 and the second element is the address."
6617 (list (let ((how (completing-read
6619 (append gnus-valid-select-methods gnus-server-alist)
6620 nil t (cons "nntp" 0))))
6621 ;; We either got a backend name or a virtual server name.
6622 ;; If the first, we also need an address.
6623 (if (assoc how gnus-valid-select-methods)
6625 ;; Suggested by mapjph@bath.ac.uk.
6628 (mapcar (lambda (server) (list server))
6629 gnus-secondary-servers)))
6630 ;; We got a server name, so we find the method.
6631 (gnus-server-to-method how)))))
6632 (gnus-browse-foreign-server method))
6636 ;;; Gnus summary mode
6639 (defvar gnus-summary-mode-map nil)
6641 (put 'gnus-summary-mode 'mode-class 'special)
6643 (unless gnus-summary-mode-map
6644 (setq gnus-summary-mode-map (make-keymap))
6645 (suppress-keymap gnus-summary-mode-map)
6647 ;; Non-orthogonal keys
6649 (gnus-define-keys gnus-summary-mode-map
6650 " " gnus-summary-next-page
6651 "\177" gnus-summary-prev-page
6652 [delete] gnus-summary-prev-page
6653 "\r" gnus-summary-scroll-up
6654 "n" gnus-summary-next-unread-article
6655 "p" gnus-summary-prev-unread-article
6656 "N" gnus-summary-next-article
6657 "P" gnus-summary-prev-article
6658 "\M-\C-n" gnus-summary-next-same-subject
6659 "\M-\C-p" gnus-summary-prev-same-subject
6660 "\M-n" gnus-summary-next-unread-subject
6661 "\M-p" gnus-summary-prev-unread-subject
6662 "." gnus-summary-first-unread-article
6663 "," gnus-summary-best-unread-article
6664 "\M-s" gnus-summary-search-article-forward
6665 "\M-r" gnus-summary-search-article-backward
6666 "<" gnus-summary-beginning-of-article
6667 ">" gnus-summary-end-of-article
6668 "j" gnus-summary-goto-article
6669 "^" gnus-summary-refer-parent-article
6670 "\M-^" gnus-summary-refer-article
6671 "u" gnus-summary-tick-article-forward
6672 "!" gnus-summary-tick-article-forward
6673 "U" gnus-summary-tick-article-backward
6674 "d" gnus-summary-mark-as-read-forward
6675 "D" gnus-summary-mark-as-read-backward
6676 "E" gnus-summary-mark-as-expirable
6677 "\M-u" gnus-summary-clear-mark-forward
6678 "\M-U" gnus-summary-clear-mark-backward
6679 "k" gnus-summary-kill-same-subject-and-select
6680 "\C-k" gnus-summary-kill-same-subject
6681 "\M-\C-k" gnus-summary-kill-thread
6682 "\M-\C-l" gnus-summary-lower-thread
6683 "e" gnus-summary-edit-article
6684 "#" gnus-summary-mark-as-processable
6685 "\M-#" gnus-summary-unmark-as-processable
6686 "\M-\C-t" gnus-summary-toggle-threads
6687 "\M-\C-s" gnus-summary-show-thread
6688 "\M-\C-h" gnus-summary-hide-thread
6689 "\M-\C-f" gnus-summary-next-thread
6690 "\M-\C-b" gnus-summary-prev-thread
6691 "\M-\C-u" gnus-summary-up-thread
6692 "\M-\C-d" gnus-summary-down-thread
6693 "&" gnus-summary-execute-command
6694 "c" gnus-summary-catchup-and-exit
6695 "\C-w" gnus-summary-mark-region-as-read
6696 "\C-t" gnus-summary-toggle-truncation
6697 "?" gnus-summary-mark-as-dormant
6698 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6699 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6700 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6701 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6702 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6703 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6704 "=" gnus-summary-expand-window
6705 "\C-x\C-s" gnus-summary-reselect-current-group
6706 "\M-g" gnus-summary-rescan-group
6707 "w" gnus-summary-stop-page-breaking
6708 "\C-c\C-r" gnus-summary-caesar-message
6709 "\M-t" gnus-summary-toggle-mime
6710 "f" gnus-summary-followup
6711 "F" gnus-summary-followup-with-original
6712 "C" gnus-summary-cancel-article
6713 "r" gnus-summary-reply
6714 "R" gnus-summary-reply-with-original
6715 "\C-c\C-f" gnus-summary-mail-forward
6716 "o" gnus-summary-save-article
6717 "\C-o" gnus-summary-save-article-mail
6718 "|" gnus-summary-pipe-output
6719 "\M-k" gnus-summary-edit-local-kill
6720 "\M-K" gnus-summary-edit-global-kill
6722 "\C-c\C-d" gnus-summary-describe-group
6723 "q" gnus-summary-exit
6724 "Q" gnus-summary-exit-no-update
6725 "\C-c\C-i" gnus-info-find-node
6726 gnus-mouse-2 gnus-mouse-pick-article
6727 "m" gnus-summary-mail-other-window
6728 "a" gnus-summary-post-news
6729 "x" gnus-summary-limit-to-unread
6730 "s" gnus-summary-isearch-article
6731 "t" gnus-article-hide-headers
6732 "g" gnus-summary-show-article
6733 "l" gnus-summary-goto-last-article
6734 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6735 "\C-d" gnus-summary-enter-digest-group
6737 "*" gnus-cache-enter-article
6738 "\M-*" gnus-cache-remove-article
6739 "\M-&" gnus-summary-universal-argument
6740 "\C-l" gnus-recenter
6741 "I" gnus-summary-increase-score
6742 "L" gnus-summary-lower-score
6744 "V" gnus-summary-score-map
6745 "X" gnus-uu-extract-map
6746 "S" gnus-summary-send-map)
6748 ;; Sort of orthogonal keymap
6749 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6750 "t" gnus-summary-tick-article-forward
6751 "!" gnus-summary-tick-article-forward
6752 "d" gnus-summary-mark-as-read-forward
6753 "r" gnus-summary-mark-as-read-forward
6754 "c" gnus-summary-clear-mark-forward
6755 " " gnus-summary-clear-mark-forward
6756 "e" gnus-summary-mark-as-expirable
6757 "x" gnus-summary-mark-as-expirable
6758 "?" gnus-summary-mark-as-dormant
6759 "b" gnus-summary-set-bookmark
6760 "B" gnus-summary-remove-bookmark
6761 "#" gnus-summary-mark-as-processable
6762 "\M-#" gnus-summary-unmark-as-processable
6763 "S" gnus-summary-limit-include-expunged
6764 "C" gnus-summary-catchup
6765 "H" gnus-summary-catchup-to-here
6766 "\C-c" gnus-summary-catchup-all
6767 "k" gnus-summary-kill-same-subject-and-select
6768 "K" gnus-summary-kill-same-subject
6769 "P" gnus-uu-mark-map)
6771 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6772 "c" gnus-summary-clear-above
6773 "u" gnus-summary-tick-above
6774 "m" gnus-summary-mark-above
6775 "k" gnus-summary-kill-below)
6777 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6778 "/" gnus-summary-limit-to-subject
6779 "n" gnus-summary-limit-to-articles
6780 "w" gnus-summary-pop-limit
6781 "s" gnus-summary-limit-to-subject
6782 "a" gnus-summary-limit-to-author
6783 "u" gnus-summary-limit-to-unread
6784 "m" gnus-summary-limit-to-marks
6785 "v" gnus-summary-limit-to-score
6786 "D" gnus-summary-limit-include-dormant
6787 "d" gnus-summary-limit-exclude-dormant
6788 ;; "t" gnus-summary-limit-exclude-thread
6789 "E" gnus-summary-limit-include-expunged
6790 "c" gnus-summary-limit-exclude-childless-dormant
6791 "C" gnus-summary-limit-mark-excluded-as-read)
6793 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6794 "n" gnus-summary-next-unread-article
6795 "p" gnus-summary-prev-unread-article
6796 "N" gnus-summary-next-article
6797 "P" gnus-summary-prev-article
6798 "\C-n" gnus-summary-next-same-subject
6799 "\C-p" gnus-summary-prev-same-subject
6800 "\M-n" gnus-summary-next-unread-subject
6801 "\M-p" gnus-summary-prev-unread-subject
6802 "f" gnus-summary-first-unread-article
6803 "b" gnus-summary-best-unread-article
6804 "g" gnus-summary-goto-subject
6805 "l" gnus-summary-goto-last-article
6806 "p" gnus-summary-pop-article)
6808 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6809 "k" gnus-summary-kill-thread
6810 "l" gnus-summary-lower-thread
6811 "i" gnus-summary-raise-thread
6812 "T" gnus-summary-toggle-threads
6813 "t" gnus-summary-rethread-current
6814 "^" gnus-summary-reparent-thread
6815 "s" gnus-summary-show-thread
6816 "S" gnus-summary-show-all-threads
6817 "h" gnus-summary-hide-thread
6818 "H" gnus-summary-hide-all-threads
6819 "n" gnus-summary-next-thread
6820 "p" gnus-summary-prev-thread
6821 "u" gnus-summary-up-thread
6822 "o" gnus-summary-top-thread
6823 "d" gnus-summary-down-thread
6824 "#" gnus-uu-mark-thread
6825 "\M-#" gnus-uu-unmark-thread)
6827 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6828 "c" gnus-summary-catchup-and-exit
6829 "C" gnus-summary-catchup-all-and-exit
6830 "E" gnus-summary-exit-no-update
6831 "Q" gnus-summary-exit
6832 "Z" gnus-summary-exit
6833 "n" gnus-summary-catchup-and-goto-next-group
6834 "R" gnus-summary-reselect-current-group
6835 "G" gnus-summary-rescan-group
6836 "N" gnus-summary-next-group
6837 "P" gnus-summary-prev-group)
6839 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6840 " " gnus-summary-next-page
6841 "n" gnus-summary-next-page
6842 "\177" gnus-summary-prev-page
6843 [delete] gnus-summary-prev-page
6844 "p" gnus-summary-prev-page
6845 "\r" gnus-summary-scroll-up
6846 "<" gnus-summary-beginning-of-article
6847 ">" gnus-summary-end-of-article
6848 "b" gnus-summary-beginning-of-article
6849 "e" gnus-summary-end-of-article
6850 "^" gnus-summary-refer-parent-article
6851 "r" gnus-summary-refer-parent-article
6852 "R" gnus-summary-refer-references
6853 "g" gnus-summary-show-article
6854 "s" gnus-summary-isearch-article)
6856 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6857 "b" gnus-article-add-buttons
6858 "B" gnus-article-add-buttons-to-head
6859 "o" gnus-article-treat-overstrike
6860 ;; "w" gnus-article-word-wrap
6861 "w" gnus-article-fill-cited-article
6862 "c" gnus-article-remove-cr
6863 "L" gnus-article-remove-trailing-blank-lines
6864 "q" gnus-article-de-quoted-unreadable
6865 "f" gnus-article-display-x-face
6866 "l" gnus-summary-stop-page-breaking
6867 "r" gnus-summary-caesar-message
6868 "t" gnus-article-hide-headers
6869 "v" gnus-summary-verbose-headers
6870 "m" gnus-summary-toggle-mime)
6872 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6873 "a" gnus-article-hide
6874 "h" gnus-article-hide-headers
6875 "b" gnus-article-hide-boring-headers
6876 "s" gnus-article-hide-signature
6877 "c" gnus-article-hide-citation
6878 "p" gnus-article-hide-pgp
6879 "\C-c" gnus-article-hide-citation-maybe)
6881 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6882 "a" gnus-article-highlight
6883 "h" gnus-article-highlight-headers
6884 "c" gnus-article-highlight-citation
6885 "s" gnus-article-highlight-signature)
6887 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6888 "z" gnus-article-date-ut
6889 "u" gnus-article-date-ut
6890 "l" gnus-article-date-local
6891 "e" gnus-article-date-lapsed
6892 "o" gnus-article-date-original)
6894 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
6896 "f" gnus-summary-fetch-faq
6897 "d" gnus-summary-describe-group
6898 "h" gnus-summary-describe-briefly
6899 "i" gnus-info-find-node)
6901 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
6902 "e" gnus-summary-expire-articles
6903 "\M-\C-e" gnus-summary-expire-articles-now
6904 "\177" gnus-summary-delete-article
6905 [delete] gnus-summary-delete-article
6906 "m" gnus-summary-move-article
6907 "r" gnus-summary-respool-article
6908 "w" gnus-summary-edit-article
6909 "c" gnus-summary-copy-article
6910 "B" gnus-summary-crosspost-article
6911 "q" gnus-summary-respool-query
6912 "i" gnus-summary-import-article)
6914 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
6915 "o" gnus-summary-save-article
6916 "m" gnus-summary-save-article-mail
6917 "r" gnus-summary-save-article-rmail
6918 "f" gnus-summary-save-article-file
6919 "b" gnus-summary-save-article-body-file
6920 "h" gnus-summary-save-article-folder
6921 "v" gnus-summary-save-article-vm
6922 "p" gnus-summary-pipe-output
6923 "s" gnus-soup-add-article)
6928 (defun gnus-summary-mode (&optional group)
6929 "Major mode for reading articles.
6931 All normal editing commands are switched off.
6932 \\<gnus-summary-mode-map>
6933 Each line in this buffer represents one article. To read an
6934 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6935 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6938 You can also post articles and send mail from this buffer. To
6939 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6940 of an article, type `\\[gnus-summary-reply]'.
6942 There are approx. one gazillion commands you can execute in this
6943 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6945 The following commands are available:
6947 \\{gnus-summary-mode-map}"
6949 (when (and menu-bar-mode
6950 (gnus-visual-p 'summary-menu 'menu))
6951 (gnus-summary-make-menu-bar))
6952 (kill-all-local-variables)
6953 (let ((locals gnus-summary-local-variables))
6955 (if (consp (car locals))
6957 (make-local-variable (caar locals))
6958 (set (caar locals) (eval (cdar locals))))
6959 (make-local-variable (car locals))
6960 (set (car locals) nil))
6961 (setq locals (cdr locals))))
6962 (gnus-make-thread-indent-array)
6963 (gnus-simplify-mode-line)
6964 (setq major-mode 'gnus-summary-mode)
6965 (setq mode-name "Summary")
6966 (make-local-variable 'minor-mode-alist)
6967 (use-local-map gnus-summary-mode-map)
6968 (buffer-disable-undo (current-buffer))
6969 (setq buffer-read-only t) ;Disable modification
6970 (setq truncate-lines t)
6971 (setq selective-display t)
6972 (setq selective-display-ellipses t) ;Display `...'
6973 (setq buffer-display-table gnus-summary-display-table)
6974 (setq gnus-newsgroup-name group)
6975 (run-hooks 'gnus-summary-mode-hook))
6977 (defun gnus-summary-make-display-table ()
6978 ;; Change the display table. Odd characters have a tendency to mess
6979 ;; up nicely formatted displays - we make all possible glyphs
6980 ;; display only a single character.
6982 ;; We start from the standard display table, if any.
6983 (setq gnus-summary-display-table
6984 (or (copy-sequence standard-display-table)
6985 (make-display-table)))
6986 ;; Nix out all the control chars...
6988 (while (>= (setq i (1- i)) 0)
6989 (aset gnus-summary-display-table i [??])))
6990 ;; ... but not newline and cr, of course. (cr is necessary for the
6991 ;; selective display).
6992 (aset gnus-summary-display-table ?\n nil)
6993 (aset gnus-summary-display-table ?\r nil)
6994 ;; We nix out any glyphs over 126 that are not set already.
6996 (while (>= (setq i (1- i)) 127)
6997 ;; Only modify if the entry is nil.
6998 (or (aref gnus-summary-display-table i)
6999 (aset gnus-summary-display-table i [??])))))
7001 (defun gnus-summary-clear-local-variables ()
7002 (let ((locals gnus-summary-local-variables))
7004 (if (consp (car locals))
7005 (and (vectorp (caar locals))
7006 (set (caar locals) nil))
7007 (and (vectorp (car locals))
7008 (set (car locals) nil)))
7009 (setq locals (cdr locals)))))
7011 ;; Summary data functions.
7013 (defmacro gnus-data-number (data)
7016 (defmacro gnus-data-set-number (data number)
7017 `(setcar ,data ,number))
7019 (defmacro gnus-data-mark (data)
7022 (defmacro gnus-data-set-mark (data mark)
7023 `(setcar (nthcdr 1 ,data) ,mark))
7025 (defmacro gnus-data-pos (data)
7028 (defmacro gnus-data-set-pos (data pos)
7029 `(setcar (nthcdr 2 ,data) ,pos))
7031 (defmacro gnus-data-header (data)
7034 (defmacro gnus-data-level (data)
7037 (defmacro gnus-data-unread-p (data)
7038 `(= (nth 1 ,data) gnus-unread-mark))
7040 (defmacro gnus-data-pseudo-p (data)
7041 `(consp (nth 3 ,data)))
7043 (defmacro gnus-data-find (number)
7044 `(assq ,number gnus-newsgroup-data))
7046 (defmacro gnus-data-find-list (number &optional data)
7047 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7048 (memq (assq ,number bdata)
7051 (defmacro gnus-data-make (number mark pos header level)
7052 `(list ,number ,mark ,pos ,header ,level))
7054 (defun gnus-data-enter (after-article number mark pos header level offset)
7055 (let ((data (gnus-data-find-list after-article)))
7056 (or data (error "No such article: %d" after-article))
7057 (setcdr data (cons (gnus-data-make number mark pos header level)
7059 (setq gnus-newsgroup-data-reverse nil)
7060 (gnus-data-update-list (cddr data) offset)))
7062 (defun gnus-data-enter-list (after-article list &optional offset)
7064 (let ((data (and after-article (gnus-data-find-list after-article)))
7066 (or data (not after-article) (error "No such article: %d" after-article))
7067 ;; Find the last element in the list to be spliced into the main
7070 (setq list (cdr list)))
7073 (setcdr list gnus-newsgroup-data)
7074 (setq gnus-newsgroup-data ilist)
7075 (and offset (gnus-data-update-list (cdr list) offset)))
7076 (setcdr list (cdr data))
7078 (and offset (gnus-data-update-list (cdr data) offset)))
7079 (setq gnus-newsgroup-data-reverse nil))))
7081 (defun gnus-data-remove (article &optional offset)
7082 (let ((data gnus-newsgroup-data))
7083 (if (= (gnus-data-number (car data)) article)
7084 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7085 gnus-newsgroup-data-reverse nil)
7087 (and (= (gnus-data-number (cadr data)) article)
7089 (setcdr data (cddr data))
7090 (and offset (gnus-data-update-list (cdr data) offset))
7092 gnus-newsgroup-data-reverse nil)))
7093 (setq data (cdr data))))))
7095 (defmacro gnus-data-list (backward)
7097 (or gnus-newsgroup-data-reverse
7098 (setq gnus-newsgroup-data-reverse
7099 (reverse gnus-newsgroup-data)))
7100 gnus-newsgroup-data))
7102 (defun gnus-data-update-list (data offset)
7103 "Add OFFSET to the POS of all data entries in DATA."
7105 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7106 (setq data (cdr data))))
7108 (defun gnus-data-compute-positions ()
7109 "Compute the positions of all articles."
7110 (let ((data gnus-newsgroup-data)
7113 (when (setq pos (text-property-any
7114 (point-min) (point-max)
7115 'gnus-number (gnus-data-number (car data))))
7116 (gnus-data-set-pos (car data) (+ pos 3)))
7117 (setq data (cdr data)))))
7119 (defun gnus-summary-article-pseudo-p (article)
7120 "Say whether this article is a pseudo article or not."
7121 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7123 (defun gnus-article-parent-p (number)
7124 "Say whether this article is a parent or not."
7125 (let ((data (gnus-data-find-list number)))
7126 (and (cdr data) ; There has to be an article after...
7127 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7128 (gnus-data-level (nth 1 data))))))
7130 (defun gnus-article-children (number)
7131 "Return a list of all children to NUMBER."
7132 (let* ((data (gnus-data-find-list number))
7133 (level (gnus-data-level (car data)))
7135 (setq data (cdr data))
7137 (= (gnus-data-level (car data)) (1+ level)))
7138 (push (gnus-data-number (car data)) children)
7139 (setq data (cdr data)))
7142 (defmacro gnus-summary-skip-intangible ()
7143 "If the current article is intangible, then jump to a different article."
7144 '(let ((to (get-text-property (point) 'gnus-intangible)))
7145 (and to (gnus-summary-goto-subject to))))
7147 (defmacro gnus-summary-article-intangible-p ()
7148 "Say whether this article is intangible or not."
7149 '(get-text-property (point) 'gnus-intangible))
7151 ;; Some summary mode macros.
7153 (defmacro gnus-summary-article-number ()
7154 "The article number of the article on the current line.
7155 If there isn's an article number here, then we return the current
7158 (gnus-summary-skip-intangible)
7159 (or (get-text-property (point) 'gnus-number)
7160 (gnus-summary-last-subject))))
7162 (defmacro gnus-summary-article-header (&optional number)
7163 `(gnus-data-header (gnus-data-find
7164 ,(or number '(gnus-summary-article-number)))))
7166 (defmacro gnus-summary-thread-level (&optional number)
7167 `(if (and (eq gnus-summary-make-false-root 'dummy)
7168 (get-text-property (point) 'gnus-intangible))
7170 (gnus-data-level (gnus-data-find
7171 ,(or number '(gnus-summary-article-number))))))
7173 (defmacro gnus-summary-article-mark (&optional number)
7174 `(gnus-data-mark (gnus-data-find
7175 ,(or number '(gnus-summary-article-number)))))
7177 (defmacro gnus-summary-article-pos (&optional number)
7178 `(gnus-data-pos (gnus-data-find
7179 ,(or number '(gnus-summary-article-number)))))
7181 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7182 (defmacro gnus-summary-article-subject (&optional number)
7183 "Return current subject string or nil if nothing."
7186 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7187 '(gnus-data-header (assq (gnus-summary-article-number)
7188 gnus-newsgroup-data)))))
7191 (mail-header-subject headers))))
7193 (defmacro gnus-summary-article-score (&optional number)
7194 "Return current article score."
7195 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7196 gnus-newsgroup-scored))
7197 gnus-summary-default-score 0))
7199 (defun gnus-summary-article-children (&optional number)
7200 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7201 (level (gnus-data-level (car data)))
7203 (while (and (setq data (cdr data))
7204 (> (setq l (gnus-data-level (car data))) level))
7205 (and (= (1+ level) l)
7206 (setq children (cons (gnus-data-number (car data))
7208 (nreverse children)))
7210 (defun gnus-summary-article-parent (&optional number)
7211 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7212 (gnus-data-list t)))
7213 (level (gnus-data-level (car data)))
7216 () ; This is a root.
7217 ;; We search until we find an article with a level less than
7218 ;; this one. That function has to be the parent.
7219 (while (and (setq data (cdr data))
7220 (not (< (gnus-data-level (car data)) level))))
7221 (and data (gnus-data-number (car data))))))
7223 (defun gnus-unread-mark-p (mark)
7224 "Say whether MARK is the unread mark."
7225 (= mark gnus-unread-mark))
7227 (defun gnus-read-mark-p (mark)
7228 "Say whether MARK is one of the marks that mark as read.
7229 This is all marks except unread, ticked, dormant, and expirable."
7230 (not (or (= mark gnus-unread-mark)
7231 (= mark gnus-ticked-mark)
7232 (= mark gnus-dormant-mark)
7233 (= mark gnus-expirable-mark))))
7235 ;; Various summary mode internalish functions.
7237 (defun gnus-mouse-pick-article (e)
7240 (gnus-summary-next-page nil t))
7242 (defun gnus-summary-setup-buffer (group)
7243 "Initialize summary buffer."
7244 (let ((buffer (concat "*Summary " group "*")))
7245 (if (get-buffer buffer)
7248 (setq gnus-summary-buffer (current-buffer))
7249 (not gnus-newsgroup-prepared))
7250 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7251 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7252 (gnus-add-current-to-buffer-list)
7253 (gnus-summary-mode group)
7255 (gnus-carpal-setup-buffer 'summary))
7256 (unless gnus-single-article-buffer
7257 (make-local-variable 'gnus-article-buffer)
7258 (make-local-variable 'gnus-original-article-buffer))
7259 (setq gnus-newsgroup-name group)
7262 (defun gnus-set-global-variables ()
7263 ;; Set the global equivalents of the summary buffer-local variables
7264 ;; to the latest values they had. These reflect the summary buffer
7265 ;; that was in action when the last article was fetched.
7266 (when (eq major-mode 'gnus-summary-mode)
7267 (setq gnus-summary-buffer (current-buffer))
7268 (let ((name gnus-newsgroup-name)
7269 (marked gnus-newsgroup-marked)
7270 (unread gnus-newsgroup-unreads)
7271 (headers gnus-current-headers)
7272 (data gnus-newsgroup-data)
7273 (summary gnus-summary-buffer)
7274 (article-buffer gnus-article-buffer)
7275 (original gnus-original-article-buffer)
7276 (score-file gnus-current-score-file))
7278 (set-buffer gnus-group-buffer)
7279 (setq gnus-newsgroup-name name)
7280 (setq gnus-newsgroup-marked marked)
7281 (setq gnus-newsgroup-unreads unread)
7282 (setq gnus-current-headers headers)
7283 (setq gnus-newsgroup-data data)
7284 (setq gnus-summary-buffer summary)
7285 (setq gnus-article-buffer article-buffer)
7286 (setq gnus-original-article-buffer original)
7287 (setq gnus-current-score-file score-file)))))
7289 (defun gnus-summary-last-article-p (&optional article)
7290 "Return whether ARTICLE is the last article in the buffer."
7291 (if (not (setq article (or article (gnus-summary-article-number))))
7292 t ; All non-existant numbers are the last article. :-)
7293 (cdr (gnus-data-find-list article))))
7295 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7296 "Insert a dummy root in the summary buffer."
7298 (add-text-properties
7299 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7300 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7302 (defvar gnus-thread-indent-array nil)
7303 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7304 (defun gnus-make-thread-indent-array ()
7306 (if (and gnus-thread-indent-array
7307 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7309 (setq gnus-thread-indent-array (make-vector 201 "")
7310 gnus-thread-indent-array-level gnus-thread-indent-level)
7312 (aset gnus-thread-indent-array n
7313 (make-string (* n gnus-thread-indent-level) ? ))
7316 (defun gnus-summary-insert-line
7317 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7318 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7319 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7320 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7321 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7322 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7323 (gnus-tmp-score-char
7324 (if (or (null gnus-summary-default-score)
7325 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7326 gnus-summary-zcore-fuzz)) ?
7327 (if (< gnus-tmp-score gnus-summary-default-score)
7328 gnus-score-below-mark gnus-score-over-mark)))
7329 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7330 ((memq gnus-tmp-current gnus-newsgroup-cached)
7332 (gnus-tmp-replied gnus-replied-mark)
7333 ((memq gnus-tmp-current gnus-newsgroup-saved)
7335 (t gnus-unread-mark)))
7336 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7339 ((string-match "(.+)" gnus-tmp-from)
7340 (substring gnus-tmp-from
7341 (1+ (match-beginning 0)) (1- (match-end 0))))
7342 ((string-match "<[^>]+> *$" gnus-tmp-from)
7343 (let ((beg (match-beginning 0)))
7344 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7345 (substring gnus-tmp-from (1+ (match-beginning 0))
7346 (1- (match-end 0))))
7347 (substring gnus-tmp-from 0 beg))))
7349 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7350 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7351 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7352 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7353 (buffer-read-only nil))
7354 (when (string= gnus-tmp-name "")
7355 (setq gnus-tmp-name gnus-tmp-from))
7356 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7359 (progn (eval gnus-summary-line-format-spec) (point))
7360 'gnus-number gnus-tmp-number)
7361 (when (gnus-visual-p 'summary-highlight 'highlight)
7363 (run-hooks 'gnus-summary-update-hook)
7366 (defun gnus-summary-update-line (&optional dont-update)
7367 ;; Update summary line after change.
7368 (when (and gnus-summary-default-score
7369 (not gnus-summary-inhibit-highlight))
7370 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7371 (article (gnus-summary-article-number))
7372 (score (gnus-summary-article-score article)))
7374 (if (and gnus-summary-mark-below
7375 (< (gnus-summary-article-score)
7376 gnus-summary-mark-below))
7377 ;; This article has a low score, so we mark it as read.
7378 (when (memq article gnus-newsgroup-unreads)
7379 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7380 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7381 ;; This article was previously marked as read on account
7382 ;; of a low score, but now it has risen, so we mark it as
7384 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7385 (gnus-summary-update-mark
7386 (if (or (null gnus-summary-default-score)
7387 (<= (abs (- score gnus-summary-default-score))
7388 gnus-summary-zcore-fuzz)) ?
7389 (if (< score gnus-summary-default-score)
7390 gnus-score-below-mark gnus-score-over-mark)) 'score))
7391 ;; Do visual highlighting.
7392 (when (gnus-visual-p 'summary-highlight 'highlight)
7393 (run-hooks 'gnus-summary-update-hook)))))
7395 (defvar gnus-tmp-new-adopts nil)
7397 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7398 ;; Sum up all elements (and sub-elements) in a list.
7400 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7402 ((and (consp thread) (cdr thread))
7405 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7408 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7411 (when (and level (zerop level) gnus-tmp-new-adopts)
7414 'gnus-summary-number-of-articles-in-thread
7415 gnus-tmp-new-adopts))))
7417 (if (> number 1) gnus-not-empty-thread-mark
7418 gnus-empty-thread-mark)
7421 (defun gnus-summary-set-local-parameters (group)
7422 "Go through the local params of GROUP and set all variable specs in that list."
7423 (let ((params (gnus-info-params (gnus-get-info group)))
7426 (setq elem (car params)
7427 params (cdr params))
7428 (and (consp elem) ; Has to be a cons.
7429 (consp (cdr elem)) ; The cdr has to be a list.
7430 (symbolp (car elem)) ; Has to be a symbol in there.
7431 (not (memq (car elem)
7432 '(quit-config to-address to-list to-group)))
7433 (progn ; So we set it.
7434 (make-local-variable (car elem))
7435 (set (car elem) (eval (nth 1 elem))))))))
7437 (defun gnus-summary-read-group
7438 (group &optional show-all no-article kill-buffer no-display)
7439 "Start reading news in newsgroup GROUP.
7440 If SHOW-ALL is non-nil, already read articles are also listed.
7441 If NO-ARTICLE is non-nil, no article is selected initially.
7442 If NO-DISPLAY, don't generate a summary buffer."
7443 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7444 (let* ((new-group (gnus-summary-setup-buffer group))
7445 (quit-config (gnus-group-quit-config group))
7446 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7448 ;; This summary buffer exists already, so we just select it.
7450 (gnus-set-global-variables)
7452 (gnus-kill-or-deaden-summary kill-buffer))
7453 (gnus-configure-windows 'summary 'force)
7454 (gnus-set-mode-line 'summary)
7455 (gnus-summary-position-point)
7458 ;; We couldn't select this group.
7460 (when (and (eq major-mode 'gnus-summary-mode)
7461 (not (equal (current-buffer) kill-buffer)))
7462 (kill-buffer (current-buffer))
7463 (if (not quit-config)
7465 (set-buffer gnus-group-buffer)
7466 (gnus-group-jump-to-group group)
7467 (gnus-group-next-unread-group 1))
7468 (if (not (buffer-name (car quit-config)))
7469 (gnus-configure-windows 'group 'force)
7470 (set-buffer (car quit-config))
7471 (and (eq major-mode 'gnus-summary-mode)
7472 (gnus-set-global-variables))
7473 (gnus-configure-windows (cdr quit-config)))))
7474 (gnus-message 3 "Can't select group")
7476 ;; The user did a `C-g' while prompting for number of articles,
7477 ;; so we exit this group.
7478 ((eq did-select 'quit)
7479 (and (eq major-mode 'gnus-summary-mode)
7480 (not (equal (current-buffer) kill-buffer))
7481 (kill-buffer (current-buffer)))
7483 (gnus-kill-or-deaden-summary kill-buffer))
7484 (if (not quit-config)
7486 (set-buffer gnus-group-buffer)
7487 (gnus-group-jump-to-group group)
7488 (gnus-group-next-unread-group 1)
7489 (gnus-configure-windows 'group 'force))
7490 (if (not (buffer-name (car quit-config)))
7491 (gnus-configure-windows 'group 'force)
7492 (set-buffer (car quit-config))
7493 (and (eq major-mode 'gnus-summary-mode)
7494 (gnus-set-global-variables))
7495 (gnus-configure-windows (cdr quit-config))))
7496 ;; Finally signal the quit.
7498 ;; The group was successfully selected.
7500 (gnus-set-global-variables)
7501 ;; Save the active value in effect when the group was entered.
7502 (setq gnus-newsgroup-active
7504 (gnus-active gnus-newsgroup-name)))
7505 ;; You can change the summary buffer in some way with this hook.
7506 (run-hooks 'gnus-select-group-hook)
7507 ;; Set any local variables in the group parameters.
7508 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7509 (gnus-update-format-specifications)
7510 ;; Do score processing.
7511 (when gnus-use-scoring
7512 (gnus-possibly-score-headers))
7513 ;; Check whether to fill in the gaps in the threads.
7514 (when gnus-build-sparse-threads
7515 (gnus-build-sparse-threads))
7516 ;; Find the initial limit.
7518 (let ((gnus-newsgroup-dormant nil))
7519 (gnus-summary-initial-limit show-all))
7520 (gnus-summary-initial-limit show-all))
7521 ;; Generate the summary buffer.
7523 (gnus-summary-prepare))
7524 (when gnus-use-trees
7525 (gnus-tree-open group)
7526 (setq gnus-summary-highlight-line-function
7527 'gnus-tree-highlight-article))
7528 ;; If the summary buffer is empty, but there are some low-scored
7529 ;; articles or some excluded dormants, we include these in the
7531 (when (and (zerop (buffer-size))
7533 (cond (gnus-newsgroup-dormant
7534 (gnus-summary-limit-include-dormant))
7535 ((and gnus-newsgroup-scored show-all)
7536 (gnus-summary-limit-include-expunged))))
7537 ;; Function `gnus-apply-kill-file' must be called in this hook.
7538 (run-hooks 'gnus-apply-kill-hook)
7539 (if (and (zerop (buffer-size))
7542 ;; This newsgroup is empty.
7543 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7544 (gnus-message 6 "No unread news")
7546 (gnus-kill-or-deaden-summary kill-buffer))
7547 ;; Return nil from this function.
7549 ;; Hide conversation thread subtrees. We cannot do this in
7550 ;; gnus-summary-prepare-hook since kill processing may not
7551 ;; work with hidden articles.
7552 (and gnus-show-threads
7553 gnus-thread-hide-subtree
7554 (gnus-summary-hide-all-threads))
7555 ;; Show first unread article if requested.
7556 (if (and (not no-article)
7558 gnus-newsgroup-unreads
7559 gnus-auto-select-first)
7560 (if (eq gnus-auto-select-first 'best)
7561 (gnus-summary-best-unread-article)
7562 (gnus-summary-first-unread-article))
7563 ;; Don't select any articles, just move point to the first
7564 ;; article in the group.
7565 (goto-char (point-min))
7566 (gnus-summary-position-point)
7567 (gnus-set-mode-line 'summary)
7568 (gnus-configure-windows 'summary 'force))
7569 ;; If we are in async mode, we send some info to the backend.
7570 (when gnus-newsgroup-async
7571 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7573 (gnus-kill-or-deaden-summary kill-buffer))
7574 (when (get-buffer-window gnus-group-buffer t)
7575 ;; Gotta use windows, because recenter does wierd stuff if
7576 ;; the current buffer ain't the displayed window.
7577 (let ((owin (selected-window)))
7578 (select-window (get-buffer-window gnus-group-buffer t))
7579 (when (gnus-group-goto-group group)
7581 (select-window owin))))
7582 ;; Mark this buffer as "prepared".
7583 (setq gnus-newsgroup-prepared t)
7586 (defun gnus-summary-prepare ()
7587 "Generate the summary buffer."
7588 (let ((buffer-read-only nil))
7590 (setq gnus-newsgroup-data nil
7591 gnus-newsgroup-data-reverse nil)
7592 (run-hooks 'gnus-summary-generate-hook)
7593 ;; Generate the buffer, either with threads or without.
7594 (when gnus-newsgroup-headers
7595 (gnus-summary-prepare-threads
7596 (if gnus-show-threads
7597 (gnus-sort-gathered-threads
7598 (funcall gnus-summary-thread-gathering-function
7600 (gnus-cut-threads (gnus-make-threads)))))
7601 ;; Unthreaded display.
7602 (gnus-sort-articles gnus-newsgroup-headers))))
7603 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7604 ;; Call hooks for modifying summary buffer.
7605 (goto-char (point-min))
7606 (run-hooks 'gnus-summary-prepare-hook)))
7608 (defun gnus-gather-threads-by-subject (threads)
7609 "Gather threads by looking at Subject headers."
7610 (if (not gnus-summary-make-false-root)
7612 (let ((hashtb (gnus-make-hashtable 1023))
7615 subject hthread whole-subject)
7617 (setq whole-subject (mail-header-subject (caar threads)))
7618 (if (and gnus-summary-gather-exclude-subject
7619 (string-match gnus-summary-gather-exclude-subject
7621 () ; We don't want to do anything with this article.
7622 ;; We simplify the subject before looking it up in the
7626 ;; Truncate the subject.
7627 ((numberp gnus-summary-gather-subject-limit)
7628 (setq subject (gnus-simplify-subject-re whole-subject))
7629 (if (> (length subject) gnus-summary-gather-subject-limit)
7630 (substring subject 0 gnus-summary-gather-subject-limit)
7632 ;; Fuzzily simplify it.
7633 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7634 (gnus-simplify-subject-fuzzy whole-subject))
7635 ;; Just remove the leading "Re:".
7637 (gnus-simplify-subject-re whole-subject))))
7639 (if (setq hthread (gnus-gethash subject hashtb))
7641 ;; We enter a dummy root into the thread, if we
7642 ;; haven't done that already.
7643 (unless (stringp (caar hthread))
7644 (setcar hthread (list whole-subject (car hthread))))
7645 ;; We add this new gathered thread to this gathered
7647 (setcdr (car hthread)
7648 (nconc (cdar hthread) (list (car threads))))
7649 ;; Remove it from the list of threads.
7650 (setcdr prev (cdr threads))
7651 (setq threads prev))
7652 ;; Enter this thread into the hash table.
7653 (gnus-sethash subject threads hashtb)))
7655 (setq threads (cdr threads)))
7658 (defun gnus-gather-threads-by-references (threads)
7659 "Gather threads by looking at References headers."
7660 (let ((idhashtb (gnus-make-hashtable 1023))
7661 (thhashtb (gnus-make-hashtable 1023))
7664 ids references id gthread gid entered)
7666 (when (setq references (mail-header-references (caar threads)))
7667 (setq id (mail-header-id (caar threads)))
7668 (setq ids (gnus-split-references references))
7671 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7673 (gnus-sethash (car ids) id idhashtb)
7674 (gnus-sethash id threads thhashtb))
7675 (setq gthread (gnus-gethash gid thhashtb))
7677 ;; We enter a dummy root into the thread, if we
7678 ;; haven't done that already.
7679 (unless (stringp (caar gthread))
7680 (setcar gthread (list (mail-header-subject (caar gthread))
7682 ;; We add this new gathered thread to this gathered
7684 (setcdr (car gthread)
7685 (nconc (cdar gthread) (list (car threads)))))
7686 ;; Add it into the thread hash table.
7687 (gnus-sethash id gthread thhashtb)
7689 ;; Remove it from the list of threads.
7690 (setcdr prev (cdr threads))
7691 (setq threads prev))
7692 (setq ids (cdr ids))))
7694 (setq threads (cdr threads)))
7697 (defun gnus-sort-gathered-threads (threads)
7698 "Sort subtreads inside each gathered thread by article number."
7699 (let ((result threads))
7701 (when (stringp (caar threads))
7702 (setcdr (car threads)
7703 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7704 (setq threads (cdr threads)))
7707 (defun gnus-make-threads ()
7708 "Go through the dependency hashtb and find the roots. Return all threads."
7712 (unless (car (symbol-value refs))
7713 ;; These threads do not refer back to any other articles,
7714 ;; so they're roots.
7715 (setq threads (append (cdr (symbol-value refs)) threads))))
7716 gnus-newsgroup-dependencies)
7719 (defun gnus-build-sparse-threads ()
7720 (let ((headers gnus-newsgroup-headers)
7721 (deps gnus-newsgroup-dependencies)
7722 header references generation relations
7723 cthread subject child end pthread relation)
7724 ;; First we create an alist of generations/relations, where
7725 ;; generations is how much we trust the ralation, and the relation
7727 (gnus-message 7 "Making sparse threads...")
7729 (nnheader-set-temp-buffer " *gnus sparse threads*")
7730 (while (setq header (pop headers))
7731 (when (and (setq references (mail-header-references header))
7732 (not (string= references "")))
7734 (setq child (downcase (mail-header-id header))
7735 subject (mail-header-subject header))
7737 (while (search-backward ">" nil t)
7738 (setq end (1+ (point)))
7739 (when (search-backward "<" nil t)
7740 (push (list (incf generation)
7741 child (setq child (downcase
7742 (buffer-substring (point) end)))
7745 (push (list (1+ generation) child nil subject) relations)
7747 (kill-buffer (current-buffer)))
7748 ;; Sort over trustworthiness.
7749 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7750 (while (setq relation (pop relations))
7751 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7752 (unless (car (symbol-value cthread))
7753 ;; Make this article the parent of these threads.
7754 (setcar (symbol-value cthread)
7755 (vector gnus-reffed-article-number
7759 (or (caddr relation) "") 0 0 "")))
7760 (set cthread (list (vector gnus-reffed-article-number
7762 "" "" (cadr relation)
7763 (or (caddr relation) "") 0 0 ""))))
7764 (push gnus-reffed-article-number gnus-newsgroup-limit)
7765 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7766 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7767 gnus-newsgroup-reads)
7768 (decf gnus-reffed-article-number)
7769 ;; Make this new thread the child of its parent.
7770 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7771 (setcdr (symbol-value pthread)
7772 (nconc (cdr (symbol-value pthread))
7773 (list (symbol-value cthread))))
7774 (set pthread (list nil (symbol-value cthread))))))
7775 (gnus-message 7 "Making sparse threads...done")))
7777 (defun gnus-build-old-threads ()
7778 ;; Look at all the articles that refer back to old articles, and
7779 ;; fetch the headers for the articles that aren't there. This will
7780 ;; build complete threads - if the roots haven't been expired by the
7785 (when (not (car (symbol-value refs)))
7786 (setq heads (cdr (symbol-value refs)))
7788 (if (memq (mail-header-number (caar heads))
7789 gnus-newsgroup-dormant)
7790 (setq heads (cdr heads))
7791 (setq id (symbol-name refs))
7792 (while (and (setq id (gnus-build-get-header id))
7793 (not (car (gnus-gethash
7794 id gnus-newsgroup-dependencies)))))
7795 (setq heads nil)))))
7796 gnus-newsgroup-dependencies)))
7798 (defun gnus-build-get-header (id)
7799 ;; Look through the buffer of NOV lines and find the header to
7800 ;; ID. Enter this line into the dependencies hash table, and return
7801 ;; the id of the parent article (if any).
7802 (let ((deps gnus-newsgroup-dependencies)
7806 (set-buffer nntp-server-buffer)
7807 (goto-char (point-min))
7808 (while (and (not found) (search-forward id nil t))
7810 (setq found (looking-at
7811 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7812 (regexp-quote id))))
7813 (or found (beginning-of-line 2)))
7818 (setq header (gnus-nov-parse-line
7819 (read (current-buffer)) deps))
7820 (gnus-parent-id (mail-header-references header))))))
7822 (let ((number (mail-header-number header)))
7823 (push number gnus-newsgroup-limit)
7824 (push header gnus-newsgroup-headers)
7825 (if (memq number gnus-newsgroup-unselected)
7827 (push number gnus-newsgroup-unreads)
7828 (setq gnus-newsgroup-unselected
7829 (delq number gnus-newsgroup-unselected)))
7830 (push number gnus-newsgroup-ancient)))))))
7832 (defun gnus-summary-update-article (article &optional header)
7833 "Update ARTICLE in the summary buffer."
7834 (let ((id (mail-header-id (gnus-summary-article-header article)))
7835 (data (gnus-data-find article)))
7836 (setcar (gnus-id-to-thread id) nil)
7837 (gnus-summary-insert-subject id)
7838 ;; Set the (possibly) new article number in the data structure.
7839 (gnus-data-set-number data (gnus-id-to-article id))))
7841 (defun gnus-rebuild-thread (id)
7842 "Rebuild the thread containing ID."
7843 (let ((dep gnus-newsgroup-dependencies)
7844 (buffer-read-only nil)
7845 current headers refs thread art data)
7846 (if (not gnus-show-threads)
7847 (setq thread (list (car (gnus-id-to-thread id))))
7848 ;; Get the thread this article is part of.
7849 (setq thread (gnus-remove-thread id)))
7850 (setq current (save-excursion
7851 (and (zerop (forward-line -1))
7852 (gnus-summary-article-number))))
7853 ;; If this is a gathered thread, we have to go some re-gathering.
7854 (when (stringp (car thread))
7855 (let ((subject (car thread))
7857 (setq thread (cdr thread))
7859 (unless (memq (setq thr (gnus-id-to-thread
7861 (mail-header-id (caar thread)))))
7864 (setq thread (cdr thread)))
7865 ;; We now have all (unique) roots.
7866 (if (= (length roots) 1)
7867 ;; All the loose roots are now one solid root.
7868 (setq thread (car roots))
7869 (setq thread (cons subject (gnus-sort-threads roots))))))
7872 ;; We then insert this thread into the summary buffer.
7873 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7874 (gnus-summary-prepare-threads (list thread))
7875 (setq data (nreverse gnus-newsgroup-data))
7876 (setq threads gnus-newsgroup-threads))
7877 ;; We splice the new data into the data structure.
7878 (gnus-data-enter-list current data)
7879 (gnus-data-compute-positions)
7880 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7882 (defun gnus-id-to-thread (id)
7883 "Return the (sub-)thread where ID appears."
7884 (gnus-gethash (downcase id) gnus-newsgroup-dependencies))
7886 (defun gnus-id-to-article (id)
7887 "Return the article number of ID."
7888 (let ((thread (gnus-id-to-thread id)))
7890 (mail-header-number (car thread)))))
7892 (defun gnus-id-to-header (id)
7893 "Return the article headers of ID."
7894 (car (gnus-id-to-thread id)))
7896 (defun gnus-article-displayed-root-p (article)
7897 "Say whether ARTICLE is a root(ish) article."
7898 (let ((level (gnus-summary-thread-level article))
7904 (null (setq particle (gnus-id-to-article
7906 (mail-header-references
7907 (gnus-summary-article-header article))))))
7908 (null (gnus-summary-thread-level particle)))))))
7910 (defun gnus-root-id (id)
7911 "Return the id of the root of the thread where ID appears."
7913 (while (and id (setq prev (car (gnus-gethash
7915 gnus-newsgroup-dependencies))))
7917 id (gnus-parent-id (mail-header-references prev))))
7920 (defun gnus-remove-thread (id &optional dont-remove)
7921 "Remove the thread that has ID in it."
7922 (let ((dep gnus-newsgroup-dependencies)
7923 headers thread prev last-id)
7924 ;; First go up in this thread until we find the root.
7925 (setq last-id (gnus-root-id id))
7926 (setq headers (list (car (gnus-id-to-thread last-id))
7927 (caadr (gnus-id-to-thread last-id))))
7928 ;; We have now found the real root of this thread. It might have
7929 ;; been gathered into some loose thread, so we have to search
7930 ;; through the threads to find the thread we wanted.
7931 (let ((threads gnus-newsgroup-threads)
7934 (setq sub (car threads))
7935 (if (stringp (car sub))
7936 ;; This is a gathered threads, so we look at the roots
7937 ;; below it to find whether this article in in this
7940 (setq sub (cdr sub))
7942 (when (member (caar sub) headers)
7943 (setq thread (car threads)
7946 (setq sub (cdr sub))))
7947 ;; It's an ordinary thread, so we check it.
7948 (when (eq (car sub) (car headers))
7951 (setq threads (cdr threads)))
7952 ;; If this article is in no thread, then it's a root.
7955 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
7956 (setq thread (gnus-gethash (downcase last-id) dep)))
7959 thread ; We return this thread.
7961 (if (stringp (car thread))
7963 ;; If we use dummy roots, then we have to remove the
7964 ;; dummy root as well.
7965 (when (eq gnus-summary-make-false-root 'dummy)
7968 (setq thread (cdr thread))
7970 (gnus-remove-thread-1 (car thread))
7971 (setq thread (cdr thread))))
7972 (gnus-remove-thread-1 thread))))))))
7974 (defun gnus-remove-thread-1 (thread)
7975 "Remove the thread THREAD recursively."
7976 (let ((number (mail-header-number (car thread)))
7978 (when (setq pos (text-property-any
7979 (point-min) (point-max) 'gnus-number number))
7982 (gnus-data-remove number))
7983 (setq thread (cdr thread))
7985 (gnus-remove-thread-1 (car thread))
7986 (setq thread (cdr thread)))))
7988 (defun gnus-sort-threads (threads)
7990 (if (not gnus-thread-sort-functions)
7992 (let ((func (if (= 1 (length gnus-thread-sort-functions))
7993 (car gnus-thread-sort-functions)
7995 ,(gnus-make-sort-function
7996 (reverse gnus-thread-sort-functions))))))
7997 (gnus-message 7 "Sorting threads...")
8000 (gnus-message 7 "Sorting threads...done")))))
8002 (defun gnus-sort-articles (articles)
8004 (when gnus-article-sort-functions
8005 (let ((func (if (= 1 (length gnus-article-sort-functions))
8006 (car gnus-article-sort-functions)
8008 ,(gnus-make-sort-function
8009 (reverse gnus-article-sort-functions))))))
8010 (gnus-message 7 "Sorting articles...")
8012 (setq gnus-newsgroup-headers (sort articles func))
8013 (gnus-message 7 "Sorting articles...done")))))
8015 (defun gnus-make-sort-function (funs)
8016 "Return a composite sort condition based on the functions in FUNC."
8018 `(or (,(car funs) t1 t2)
8019 (and (not (,(car funs) t2 t1))
8020 ,(gnus-make-sort-function (cdr funs))))
8021 `(,(car funs) t1 t2)))
8023 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8024 (defmacro gnus-thread-header (thread)
8025 ;; Return header of first article in THREAD.
8026 ;; Note that THREAD must never, ever be anything else than a variable -
8027 ;; using some other form will lead to serious barfage.
8028 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8029 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8030 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8033 (defsubst gnus-article-sort-by-number (h1 h2)
8034 "Sort articles by article number."
8035 (< (mail-header-number h1)
8036 (mail-header-number h2)))
8038 (defun gnus-thread-sort-by-number (h1 h2)
8039 "Sort threads by root article number."
8040 (gnus-article-sort-by-number
8041 (gnus-thread-header h1) (gnus-thread-header h2)))
8043 (defsubst gnus-article-sort-by-author (h1 h2)
8044 "Sort articles by root author."
8046 (let ((extract (funcall
8047 gnus-extract-address-components
8048 (mail-header-from h1))))
8049 (or (car extract) (cdr extract)))
8050 (let ((extract (funcall
8051 gnus-extract-address-components
8052 (mail-header-from h2))))
8053 (or (car extract) (cdr extract)))))
8055 (defun gnus-thread-sort-by-author (h1 h2)
8056 "Sort threads by root author."
8057 (gnus-article-sort-by-author
8058 (gnus-thread-header h1) (gnus-thread-header h2)))
8060 (defsubst gnus-article-sort-by-subject (h1 h2)
8061 "Sort articles by root subject."
8063 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8064 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8066 (defun gnus-thread-sort-by-subject (h1 h2)
8067 "Sort threads by root subject."
8068 (gnus-article-sort-by-subject
8069 (gnus-thread-header h1) (gnus-thread-header h2)))
8071 (defsubst gnus-article-sort-by-date (h1 h2)
8072 "Sort articles by root article date."
8074 (gnus-sortable-date (mail-header-date h1))
8075 (gnus-sortable-date (mail-header-date h2))))
8077 (defun gnus-thread-sort-by-date (h1 h2)
8078 "Sort threads by root article date."
8079 (gnus-article-sort-by-date
8080 (gnus-thread-header h1) (gnus-thread-header h2)))
8082 (defsubst gnus-article-sort-by-score (h1 h2)
8083 "Sort articles by root article score.
8084 Unscored articles will be counted as having a score of zero."
8085 (> (or (cdr (assq (mail-header-number h1)
8086 gnus-newsgroup-scored))
8087 gnus-summary-default-score 0)
8088 (or (cdr (assq (mail-header-number h2)
8089 gnus-newsgroup-scored))
8090 gnus-summary-default-score 0)))
8092 (defun gnus-thread-sort-by-score (h1 h2)
8093 "Sort threads by root article score."
8094 (gnus-article-sort-by-score
8095 (gnus-thread-header h1) (gnus-thread-header h2)))
8097 (defun gnus-thread-sort-by-total-score (h1 h2)
8098 "Sort threads by the sum of all scores in the thread.
8099 Unscored articles will be counted as having a score of zero."
8100 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8102 (defun gnus-thread-total-score (thread)
8103 ;; This function find the total score of THREAD.
8105 (if (stringp (car thread))
8106 (apply gnus-thread-score-function 0
8107 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8108 (gnus-thread-total-score-1 thread))
8109 (gnus-thread-total-score-1 (list thread))))
8111 (defun gnus-thread-total-score-1 (root)
8112 ;; This function find the total score of the thread below ROOT.
8113 (setq root (car root))
8114 (apply gnus-thread-score-function
8115 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8116 gnus-summary-default-score 0)
8117 (mapcar 'gnus-thread-total-score
8118 (cdr (gnus-gethash (downcase (mail-header-id root))
8119 gnus-newsgroup-dependencies)))))
8121 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8122 (defvar gnus-tmp-prev-subject nil)
8123 (defvar gnus-tmp-false-parent nil)
8124 (defvar gnus-tmp-root-expunged nil)
8125 (defvar gnus-tmp-dummy-line nil)
8127 (defun gnus-summary-prepare-threads (threads)
8128 "Prepare summary buffer from THREADS and indentation LEVEL.
8129 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8130 or a straight list of headers."
8131 (gnus-message 7 "Generating summary...")
8133 (setq gnus-newsgroup-threads threads)
8136 (let ((gnus-tmp-level 0)
8137 (default-score (or gnus-summary-default-score 0))
8138 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8139 thread number subject stack state gnus-tmp-gathered beg-match
8140 new-roots gnus-tmp-new-adopts thread-end
8141 gnus-tmp-header gnus-tmp-unread
8142 gnus-tmp-replied gnus-tmp-subject-or-nil
8143 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8144 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8145 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8147 (setq gnus-tmp-prev-subject nil)
8149 (if (vectorp (car threads))
8150 ;; If this is a straight (sic) list of headers, then a
8151 ;; threaded summary display isn't required, so we just create
8152 ;; an unthreaded one.
8153 (gnus-summary-prepare-unthreaded threads)
8155 ;; Do the threaded display.
8157 (while (or threads stack gnus-tmp-new-adopts new-roots)
8159 (if (and (= gnus-tmp-level 0)
8160 (not (setq gnus-tmp-dummy-line nil))
8163 (not gnus-tmp-false-parent)
8164 (or gnus-tmp-new-adopts new-roots))
8165 (if gnus-tmp-new-adopts
8166 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8167 thread (list (car gnus-tmp-new-adopts))
8168 gnus-tmp-header (caar thread)
8169 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8171 (setq thread (list (car new-roots))
8172 gnus-tmp-header (caar thread)
8173 new-roots (cdr new-roots))))
8176 ;; If there are some threads, we do them before the
8177 ;; threads on the stack.
8178 (setq thread threads
8179 gnus-tmp-header (caar thread))
8180 ;; There were no current threads, so we pop something off
8182 (setq state (car stack)
8183 gnus-tmp-level (car state)
8186 gnus-tmp-header (caar thread))))
8188 (setq gnus-tmp-false-parent nil)
8189 (setq gnus-tmp-root-expunged nil)
8190 (setq thread-end nil)
8192 (if (stringp gnus-tmp-header)
8193 ;; The header is a dummy root.
8195 ((eq gnus-summary-make-false-root 'adopt)
8196 ;; We let the first article adopt the rest.
8197 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8199 (setq gnus-tmp-gathered
8201 (lambda (h) (mail-header-number (car h)))
8204 (setq thread (cons (list (caar thread)
8207 (setq gnus-tmp-level -1
8208 gnus-tmp-false-parent t))
8209 ((eq gnus-summary-make-false-root 'empty)
8210 ;; We print adopted articles with empty subject fields.
8211 (setq gnus-tmp-gathered
8213 (lambda (h) (mail-header-number (car h)))
8216 (setq gnus-tmp-level -1))
8217 ((eq gnus-summary-make-false-root 'dummy)
8218 ;; We remember that we probably want to output a dummy
8220 (setq gnus-tmp-dummy-line gnus-tmp-header)
8221 (setq gnus-tmp-prev-subject gnus-tmp-header))
8223 ;; We do not make a root for the gathered
8224 ;; sub-threads at all.
8225 (setq gnus-tmp-level -1)))
8227 (setq number (mail-header-number gnus-tmp-header)
8228 subject (mail-header-subject gnus-tmp-header))
8231 ;; If the thread has changed subject, we might want to make
8232 ;; this subthread into a root.
8233 ((and (null gnus-thread-ignore-subject)
8234 (not (zerop gnus-tmp-level))
8235 gnus-tmp-prev-subject
8237 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8238 (setq new-roots (nconc new-roots (list (car thread)))
8240 gnus-tmp-header nil))
8241 ;; If the article lies outside the current limit,
8242 ;; then we do not display it.
8243 ((and (not (memq number gnus-newsgroup-limit))
8244 (not gnus-tmp-dummy-line))
8245 (setq gnus-tmp-gathered
8247 (lambda (h) (mail-header-number (car h)))
8250 (setq gnus-tmp-new-adopts (if (cdar thread)
8251 (append gnus-tmp-new-adopts
8253 gnus-tmp-new-adopts)
8255 gnus-tmp-header nil)
8256 (when (zerop gnus-tmp-level)
8257 (setq gnus-tmp-root-expunged t)))
8258 ;; Perhaps this article is to be marked as read?
8259 ((and gnus-summary-mark-below
8260 (< (or (cdr (assq number gnus-newsgroup-scored))
8262 gnus-summary-mark-below)
8263 ;; Don't touch sparse articles.
8264 (not (memq number gnus-newsgroup-sparse)))
8265 (setq gnus-newsgroup-unreads
8266 (delq number gnus-newsgroup-unreads))
8267 (if gnus-newsgroup-auto-expire
8268 (push number gnus-newsgroup-expirable)
8269 (push (cons number gnus-low-score-mark)
8270 gnus-newsgroup-reads))))
8272 (when gnus-tmp-header
8273 ;; We may have an old dummy line to output before this
8275 (when gnus-tmp-dummy-line
8276 (gnus-summary-insert-dummy-line
8277 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8278 (setq gnus-tmp-dummy-line nil))
8280 ;; Compute the mark.
8284 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8285 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8286 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8287 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8288 (t (or (cdr (assq number gnus-newsgroup-reads))
8289 gnus-ancient-mark))))
8291 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8292 gnus-tmp-header gnus-tmp-level)
8293 gnus-newsgroup-data)
8295 ;; Actually insert the line.
8297 gnus-tmp-subject-or-nil
8299 ((and gnus-thread-ignore-subject
8300 gnus-tmp-prev-subject
8301 (not (inline (gnus-subject-equal
8302 gnus-tmp-prev-subject subject))))
8304 ((zerop gnus-tmp-level)
8305 (if (and (eq gnus-summary-make-false-root 'empty)
8306 (memq number gnus-tmp-gathered)
8307 gnus-tmp-prev-subject
8308 (inline (gnus-subject-equal
8309 gnus-tmp-prev-subject subject)))
8310 gnus-summary-same-subject
8312 (t gnus-summary-same-subject)))
8313 (if (and (eq gnus-summary-make-false-root 'adopt)
8314 (= gnus-tmp-level 1)
8315 (memq number gnus-tmp-gathered))
8316 (setq gnus-tmp-opening-bracket ?\<
8317 gnus-tmp-closing-bracket ?\>)
8318 (setq gnus-tmp-opening-bracket ?\[
8319 gnus-tmp-closing-bracket ?\]))
8321 gnus-tmp-indentation
8322 (aref gnus-thread-indent-array gnus-tmp-level)
8323 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8324 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8325 gnus-summary-default-score 0)
8327 (if (or (null gnus-summary-default-score)
8328 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8329 gnus-summary-zcore-fuzz)) ?
8330 (if (< gnus-tmp-score gnus-summary-default-score)
8331 gnus-score-below-mark gnus-score-over-mark))
8333 (cond ((memq number gnus-newsgroup-processable)
8335 ((memq number gnus-newsgroup-cached)
8337 ((memq number gnus-newsgroup-replied)
8339 (t gnus-unread-mark))
8340 gnus-tmp-from (mail-header-from gnus-tmp-header)
8343 ((string-match "(.+)" gnus-tmp-from)
8344 (substring gnus-tmp-from
8345 (1+ (match-beginning 0)) (1- (match-end 0))))
8346 ((string-match "<[^>]+> *$" gnus-tmp-from)
8347 (setq beg-match (match-beginning 0))
8348 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8349 (substring gnus-tmp-from (1+ (match-beginning 0))
8350 (1- (match-end 0))))
8351 (substring gnus-tmp-from 0 beg-match)))
8353 (when (string= gnus-tmp-name "")
8354 (setq gnus-tmp-name gnus-tmp-from))
8355 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8358 (progn (eval gnus-summary-line-format-spec) (point))
8359 'gnus-number number)
8362 (run-hooks 'gnus-summary-update-hook)
8365 (setq gnus-tmp-prev-subject subject)))
8367 (when (nth 1 thread)
8368 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8369 (incf gnus-tmp-level)
8370 (setq threads (if thread-end nil (cdar thread)))
8372 (setq gnus-tmp-level 0)))))
8373 (gnus-message 7 "Generating summary...done"))
8375 (defun gnus-summary-prepare-unthreaded (headers)
8376 "Generate an unthreaded summary buffer based on HEADERS."
8377 (let (header number mark)
8380 (setq header (car headers)
8381 headers (cdr headers)
8382 number (mail-header-number header))
8384 ;; We may have to root out some bad articles...
8385 (when (memq number gnus-newsgroup-limit)
8386 (when (and gnus-summary-mark-below
8387 (< (or (cdr (assq number gnus-newsgroup-scored))
8388 gnus-summary-default-score 0)
8389 gnus-summary-mark-below))
8390 (setq gnus-newsgroup-unreads
8391 (delq number gnus-newsgroup-unreads))
8392 (if gnus-newsgroup-auto-expire
8393 (push number gnus-newsgroup-expirable)
8394 (push (cons number gnus-low-score-mark)
8395 gnus-newsgroup-reads)))
8399 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8400 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8401 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8402 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8403 (t (or (cdr (assq number gnus-newsgroup-reads))
8404 gnus-ancient-mark))))
8405 (setq gnus-newsgroup-data
8406 (cons (gnus-data-make number mark (1+ (point)) header 0)
8407 gnus-newsgroup-data))
8408 (gnus-summary-insert-line
8409 header 0 nil mark (memq number gnus-newsgroup-replied)
8410 (memq number gnus-newsgroup-expirable)
8411 (mail-header-subject header) nil
8412 (cdr (assq number gnus-newsgroup-scored))
8413 (memq number gnus-newsgroup-processable))))))
8415 (defun gnus-select-newsgroup (group &optional read-all)
8416 "Select newsgroup GROUP.
8417 If READ-ALL is non-nil, all articles in the group are selected."
8418 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8419 (info (nth 2 entry))
8420 articles fetched-articles cached)
8422 (or (gnus-check-server
8423 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8424 (error "Couldn't open server"))
8426 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8427 (gnus-activate-group group) ; Or we can activate it...
8428 (progn ; Or we bug out.
8429 (kill-buffer (current-buffer))
8430 (error "Couldn't request group %s: %s"
8431 group (gnus-status-message group))))
8433 (setq gnus-newsgroup-name group)
8434 (setq gnus-newsgroup-unselected nil)
8435 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8437 (and gnus-asynchronous
8438 (gnus-check-backend-function
8439 'request-asynchronous gnus-newsgroup-name)
8440 (setq gnus-newsgroup-async
8441 (gnus-request-asynchronous gnus-newsgroup-name)))
8443 ;; Adjust and set lists of article marks.
8445 (gnus-adjust-marked-articles info))
8447 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8448 (when (gnus-virtual-group-p group)
8449 (setq cached gnus-newsgroup-cached))
8451 (setq gnus-newsgroup-unreads
8452 (gnus-set-difference
8453 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8454 gnus-newsgroup-dormant))
8456 (setq gnus-newsgroup-processable nil)
8458 (setq articles (gnus-articles-to-read group read-all))
8462 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8464 ((eq articles 0) nil)
8466 ;; Init the dependencies hash table.
8467 (setq gnus-newsgroup-dependencies
8468 (gnus-make-hashtable (length articles)))
8469 ;; Retrieve the headers and read them in.
8470 (gnus-message 5 "Fetching headers...")
8471 (setq gnus-newsgroup-headers
8473 (setq gnus-headers-retrieved-by
8474 (gnus-retrieve-headers
8475 articles gnus-newsgroup-name
8476 ;; We might want to fetch old headers, but
8477 ;; not if there is only 1 article.
8478 (and gnus-fetch-old-headers
8480 (not (eq gnus-fetch-old-headers 'some))
8481 (not (numberp gnus-fetch-old-headers)))
8482 (> (length articles) 1))))))
8483 (gnus-get-newsgroup-headers-xover articles)
8484 (gnus-get-newsgroup-headers)))
8485 (gnus-message 5 "Fetching headers...done")
8487 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8489 (setq gnus-newsgroup-cached cached))
8491 ;; Set the initial limit.
8492 (setq gnus-newsgroup-limit (copy-sequence articles))
8493 ;; Remove canceled articles from the list of unread articles.
8494 (setq gnus-newsgroup-unreads
8495 (gnus-set-sorted-intersection
8496 gnus-newsgroup-unreads
8497 (setq fetched-articles
8498 (mapcar (lambda (headers) (mail-header-number headers))
8499 gnus-newsgroup-headers))))
8500 ;; Removed marked articles that do not exist.
8501 (gnus-update-missing-marks
8502 (gnus-sorted-complement fetched-articles articles))
8503 ;; We might want to build some more threads first.
8504 (and gnus-fetch-old-headers
8505 (eq gnus-headers-retrieved-by 'nov)
8506 (gnus-build-old-threads))
8507 ;; Check whether auto-expire is to be done in this group.
8508 (setq gnus-newsgroup-auto-expire
8509 (gnus-group-auto-expirable-p group))
8510 ;; First and last article in this newsgroup.
8511 (and gnus-newsgroup-headers
8512 (setq gnus-newsgroup-begin
8513 (mail-header-number (car gnus-newsgroup-headers)))
8514 (setq gnus-newsgroup-end
8516 (gnus-last-element gnus-newsgroup-headers))))
8517 (setq gnus-reffed-article-number -1)
8518 ;; GROUP is successfully selected.
8519 (or gnus-newsgroup-headers t)))))
8521 (defun gnus-articles-to-read (group read-all)
8522 ;; Find out what articles the user wants to read.
8524 ;; Select all articles if `read-all' is non-nil, or if there
8525 ;; are no unread articles.
8527 (and (zerop (length gnus-newsgroup-marked))
8528 (zerop (length gnus-newsgroup-unreads))))
8529 (gnus-uncompress-range (gnus-active group))
8530 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8531 (copy-sequence gnus-newsgroup-unreads))
8533 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8534 (scored (length scored-list))
8535 (number (length articles))
8536 (marked (+ (length gnus-newsgroup-marked)
8537 (length gnus-newsgroup-dormant)))
8545 ((and (or (<= scored marked) (= scored number))
8546 (numberp gnus-large-newsgroup)
8547 (> number gnus-large-newsgroup))
8551 "How many articles from %s (default %d): "
8552 gnus-newsgroup-name number))))
8553 (if (string-match "^[ \t]*$" input) number input)))
8554 ((and (> scored marked) (< scored number))
8557 (format "%s %s (%d scored, %d total): "
8558 "How many articles from"
8559 group scored number))))
8560 (if (string-match "^[ \t]*$" input)
8564 (setq select (if (stringp select) (string-to-number select) select))
8565 (if (or (null select) (zerop select))
8567 (if (and (not (zerop scored)) (<= (abs select) scored))
8569 (setq articles (sort scored-list '<))
8570 (setq number (length articles)))
8571 (setq articles (copy-sequence articles)))
8573 (if (< (abs select) number)
8575 ;; Select the N oldest articles.
8576 (setcdr (nthcdr (1- (abs select)) articles) nil)
8577 ;; Select the N most recent articles.
8578 (setq articles (nthcdr (- number select) articles))))
8579 (setq gnus-newsgroup-unselected
8580 (gnus-sorted-intersection
8581 gnus-newsgroup-unreads
8582 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8585 (defun gnus-killed-articles (killed articles)
8588 (if (inline (gnus-member-of-range (car articles) killed))
8589 (setq out (cons (car articles) out)))
8590 (setq articles (cdr articles)))
8593 (defun gnus-uncompress-marks (marks)
8594 "Uncompress the mark ranges in MARKS."
8595 (let ((uncompressed '(score bookmark))
8598 (if (memq (caar marks) uncompressed)
8599 (push (car marks) out)
8600 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8601 (setq marks (cdr marks)))
8604 (defun gnus-adjust-marked-articles (info)
8605 "Set all article lists and remove all marks that are no longer legal."
8606 (let* ((marked-lists (gnus-info-marks info))
8607 (active (gnus-active (gnus-info-group info)))
8610 (types gnus-article-mark-lists)
8611 (uncompressed '(score bookmark))
8612 marks var articles article mark)
8615 (setq marks (pop marked-lists))
8616 (set (setq var (intern (format "gnus-newsgroup-%s"
8617 (car (rassq (setq mark (car marks))
8619 (if (memq (car marks) uncompressed) (cdr marks)
8620 (gnus-uncompress-range (cdr marks))))
8622 (setq articles (symbol-value var))
8624 ;; All articles have to be subsets of the active articles.
8626 ;; Adjust "simple" lists.
8627 ((memq mark '(tick dormant expirable reply killed save))
8629 (when (or (< (setq article (pop articles)) min) (> article max))
8630 (set var (delq article (symbol-value var))))))
8632 ((memq mark '(score bookmark))
8634 (when (or (< (car (setq article (pop articles))) min)
8635 (> (car article) max))
8636 (set var (delq article (symbol-value var))))))))))
8638 (defun gnus-update-missing-marks (missing)
8639 "Go through the list of MISSING articles and remove them mark lists."
8641 (let ((types gnus-article-mark-lists)
8643 ;; Go through all types.
8645 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8646 (when (symbol-value var)
8647 ;; This list has articles. So we delete all missing articles
8651 (set var (delq (pop m) (symbol-value var)))))))))
8653 (defun gnus-update-marks ()
8654 "Enter the various lists of marked articles into the newsgroup info list."
8655 (let ((types gnus-article-mark-lists)
8656 (info (gnus-get-info gnus-newsgroup-name))
8657 (uncompressed '(score bookmark killed))
8658 var type list newmarked symbol)
8660 ;; Add all marks lists that are non-nil to the list of marks lists.
8662 (setq type (pop types))
8663 (when (setq list (symbol-value
8665 (intern (format "gnus-newsgroup-%s"
8667 (push (cons (cdr type)
8668 (if (memq (cdr type) uncompressed) list
8669 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8672 ;; Enter these new marks into the info of the group.
8674 (setcar (nthcdr 3 info) newmarked)
8675 ;; Add the marks lists to the end of the info.
8677 (setcdr (nthcdr 2 info) (list newmarked))))
8679 ;; Cut off the end of the info if there's nothing else there.
8683 (when (nthcdr (decf i) info)
8684 (setcdr (nthcdr i info) nil)))))))
8686 (defun gnus-add-marked-articles (group type articles &optional info force)
8687 ;; Add ARTICLES of TYPE to the info of GROUP.
8688 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8689 ;; add, but replace marked articles of TYPE with ARTICLES.
8690 (let ((info (or info (gnus-get-info group)))
8691 (uncompressed '(score bookmark killed))
8694 (and (not (setq marked (nthcdr 3 info)))
8696 (setcdr (nthcdr 2 info)
8697 (list (list (cons type (gnus-compress-sequence
8699 (and (not (setq m (assq type (car marked))))
8702 (cons (cons type (gnus-compress-sequence articles t) )
8706 (setcar (nthcdr 3 info)
8707 (delq (assq type (car marked)) (car marked)))
8708 (setcdr m (gnus-compress-sequence articles t)))
8709 (setcdr m (gnus-compress-sequence
8710 (sort (nconc (gnus-uncompress-range m)
8711 (copy-sequence articles)) '<) t))))))
8713 (defun gnus-set-mode-line (where)
8714 "This function sets the mode line of the article or summary buffers.
8715 If WHERE is `summary', the summary mode line format will be used."
8716 ;; Is this mode line one we keep updated?
8717 (when (memq where gnus-updated-mode-lines)
8720 ;; We evaluate this in the summary buffer since these
8721 ;; variables are buffer-local to that buffer.
8722 (set-buffer gnus-summary-buffer)
8723 ;; We bind all these variables that are used in the `eval' form
8725 (let* ((mformat (symbol-value
8727 (format "gnus-%s-mode-line-format-spec" where))))
8728 (gnus-tmp-group-name gnus-newsgroup-name)
8729 (gnus-tmp-article-number (or gnus-current-article 0))
8730 (gnus-tmp-unread gnus-newsgroup-unreads)
8731 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8732 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8733 (gnus-tmp-unread-and-unselected
8734 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8735 (zerop gnus-tmp-unselected)) "")
8736 ((zerop gnus-tmp-unselected)
8737 (format "{%d more}" gnus-tmp-unread-and-unticked))
8738 (t (format "{%d(+%d) more}"
8739 gnus-tmp-unread-and-unticked
8740 gnus-tmp-unselected))))
8742 (if (and gnus-current-headers
8743 (vectorp gnus-current-headers))
8744 (mail-header-subject gnus-current-headers) ""))
8746 gnus-tmp-header);; passed as argument to any user-format-funcs
8747 (setq mode-string (eval mformat))
8748 (setq max-len (max 4 (if gnus-mode-non-string-length
8750 gnus-mode-non-string-length)
8751 (length mode-string))))
8752 ;; We might have to chop a bit of the string off...
8753 (when (> (length mode-string) max-len)
8755 (concat (gnus-truncate-string mode-string (- max-len 3))
8757 ;; Pad the mode string a bit.
8758 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8759 ;; Update the mode line.
8760 (setq mode-line-buffer-identification (list mode-string))
8761 (set-buffer-modified-p t))))
8763 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8764 "Go through the HEADERS list and add all Xrefs to a hash table.
8765 The resulting hash table is returned, or nil if no Xrefs were found."
8766 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
8767 (virtual (gnus-virtual-group-p from-newsgroup))
8768 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8769 (xref-hashtb (make-vector 63 0))
8770 start group entry number xrefs header)
8772 (setq header (pop headers))
8773 (when (and (setq xrefs (mail-header-xref header))
8774 (not (memq (setq number (mail-header-number header))
8777 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8778 (setq start (match-end 0))
8779 (setq group (concat prefix (substring xrefs (match-beginning 1)
8782 (string-to-int (substring xrefs (match-beginning 2)
8784 (if (setq entry (gnus-gethash group xref-hashtb))
8785 (setcdr entry (cons number (cdr entry)))
8786 (gnus-sethash group (cons number nil) xref-hashtb)))))
8787 (and start xref-hashtb)))
8789 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8790 "Look through all the headers and mark the Xrefs as read."
8791 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8792 name entry info xref-hashtb idlist method nth4)
8794 (set-buffer gnus-group-buffer)
8795 (when (setq xref-hashtb
8796 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8799 (unless (string= from-newsgroup (setq name (symbol-name group)))
8800 (setq idlist (symbol-value group))
8801 ;; Dead groups are not updated.
8803 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8805 (if (stringp (setq nth4 (gnus-info-method info)))
8806 (setq nth4 (gnus-server-to-method nth4))))
8807 ;; Only do the xrefs if the group has the same
8808 ;; select method as the group we have just read.
8809 (or (gnus-methods-equal-p
8810 nth4 (gnus-find-method-for-group from-newsgroup))
8812 (equal nth4 (setq method (gnus-find-method-for-group
8814 (and (equal (car nth4) (car method))
8815 (equal (nth 1 nth4) (nth 1 method))))
8816 gnus-use-cross-reference
8817 (or (not (eq gnus-use-cross-reference t))
8819 ;; Only do cross-references on subscribed
8820 ;; groups, if that is what is wanted.
8821 (<= (gnus-info-level info) gnus-level-subscribed))
8822 (gnus-group-make-articles-read name idlist))))
8825 (defun gnus-group-make-articles-read (group articles)
8827 (entry (gnus-gethash group gnus-newsrc-hashtb))
8828 (info (nth 2 entry))
8829 (active (gnus-active group))
8831 ;; First peel off all illegal article numbers.
8833 (let ((ids articles)
8837 (if (and first (> id (cdr active)))
8839 ;; We'll end up in this situation in one particular
8840 ;; obscure situation. If you re-scan a group and get
8841 ;; a new article that is cross-posted to a different
8842 ;; group that has not been re-scanned, you might get
8843 ;; crossposted article that has a higher number than
8844 ;; Gnus believes possible. So we re-activate this
8845 ;; group as well. This might mean doing the
8846 ;; crossposting thingy will *increase* the number
8847 ;; of articles in some groups. Tsk, tsk.
8848 (setq active (or (gnus-activate-group group) active))))
8849 (if (or (> id (cdr active))
8850 (< id (car active)))
8851 (setq articles (delq id articles)))
8852 (setq ids (cdr ids)))))
8853 ;; If the read list is nil, we init it.
8855 (null (gnus-info-read info))
8857 (gnus-info-set-read info (cons 1 (1- (car active)))))
8858 ;; Then we add the read articles to the range.
8863 (gnus-info-read info) (setq articles (sort articles '<)))))
8864 ;; Then we have to re-compute how many unread
8865 ;; articles there are in this group.
8870 (setq num (- (1+ (cdr active)) (car active))))
8871 ((not (listp (cdr range)))
8872 (setq num (- (cdr active) (- (1+ (cdr range))
8876 (if (numberp (car range))
8878 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
8879 (setq range (cdr range)))
8880 (setq num (- (cdr active) num))))
8881 ;; Update the number of unread articles.
8883 ;; Update the group buffer.
8884 (gnus-group-update-group group t)))))
8886 (defun gnus-methods-equal-p (m1 m2)
8887 (let ((m1 (or m1 gnus-select-method))
8888 (m2 (or m2 gnus-select-method)))
8890 (and (eq (car m1) (car m2))
8891 (or (not (memq 'address (assoc (symbol-name (car m1))
8892 gnus-valid-select-methods)))
8893 (equal (nth 1 m1) (nth 1 m2)))))))
8895 (defsubst gnus-header-value ()
8896 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8898 (defvar gnus-newsgroup-none-id 0)
8900 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8901 (let ((cur nntp-server-buffer)
8904 (save-excursion (set-buffer gnus-summary-buffer)
8905 gnus-newsgroup-dependencies)))
8906 headers id id-dep ref-dep end ref)
8908 (set-buffer nntp-server-buffer)
8909 (let ((case-fold-search t)
8910 in-reply-to header number p lines)
8911 (goto-char (point-min))
8912 ;; Search to the beginning of the next header. Error messages
8913 ;; do not begin with 2 or 3.
8914 (while (re-search-forward "^[23][0-9]+ " nil t)
8917 ;; This implementation of this function, with nine
8918 ;; search-forwards instead of the one re-search-forward and
8919 ;; a case (which basically was the old function) is actually
8920 ;; about twice as fast, even though it looks messier. You
8921 ;; can't have everything, I guess. Speed and elegance
8922 ;; doesn't always go hand in hand.
8931 (narrow-to-region (point)
8932 (or (and (search-forward "\n.\n" nil t)
8938 (if (search-forward "\nsubject: " nil t)
8939 (gnus-header-value) "(none)"))
8943 (if (search-forward "\nfrom: " nil t)
8944 (gnus-header-value) "(nobody)"))
8948 (if (search-forward "\ndate: " nil t)
8949 (gnus-header-value) ""))
8953 (if (search-forward "\nmessage-id: " nil t)
8954 (setq id (gnus-header-value))
8955 ;; If there was no message-id, we just fake one to make
8956 ;; subsequent routines simpler.
8957 (setq id (concat "none+"
8959 (setq gnus-newsgroup-none-id
8960 (1+ gnus-newsgroup-none-id)))))))
8964 (if (search-forward "\nreferences: " nil t)
8967 (setq end (match-end 0))
8974 (search-backward ">" end t)
8977 (search-backward "<" end t)
8979 ;; Get the references from the in-reply-to header if there
8980 ;; were no references and the in-reply-to header looks
8982 (if (and (search-forward "\nin-reply-to: " nil t)
8983 (setq in-reply-to (gnus-header-value))
8984 (string-match "<[^>]+>" in-reply-to))
8986 (setq ref (substring in-reply-to (match-beginning 0)
8988 (setq ref (downcase ref))))
8995 (if (search-forward "\nlines: " nil t)
8996 (if (numberp (setq lines (read cur)))
9002 (and (search-forward "\nxref: " nil t)
9003 (gnus-header-value)))))
9004 ;; We do the threading while we read the headers. The
9005 ;; message-id and the last reference are both entered into
9006 ;; the same hash table. Some tippy-toeing around has to be
9007 ;; done in case an article has arrived before the article
9008 ;; which it refers to.
9009 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
9010 (if (and (car (symbol-value id-dep))
9012 ;; An article with this Message-ID has already
9013 ;; been seen, so we ignore this one, except we add
9014 ;; any additional Xrefs (in case the two articles
9015 ;; came from different servers).
9017 (mail-header-set-xref
9018 (car (symbol-value id-dep))
9019 (concat (or (mail-header-xref
9020 (car (symbol-value id-dep))) "")
9021 (or (mail-header-xref header) "")))
9023 (setcar (symbol-value id-dep) header))
9024 (set id-dep (list header)))
9026 (if (boundp (setq ref-dep (intern ref dependencies)))
9027 (setcdr (symbol-value ref-dep)
9028 (nconc (cdr (symbol-value ref-dep))
9029 (list (symbol-value id-dep))))
9030 (set ref-dep (list nil (symbol-value id-dep))))
9031 (setq headers (cons header headers)))
9032 (goto-char (point-max))
9034 (nreverse headers)))))
9036 ;; The following macros and functions were written by Felix Lee
9037 ;; <flee@cse.psu.edu>.
9039 (defmacro gnus-nov-read-integer ()
9041 (if (= (following-char) ?\t)
9043 (let ((num (condition-case nil (read buffer) (error nil))))
9044 (if (numberp num) num 0)))
9045 (or (eobp) (forward-char 1))))
9047 (defmacro gnus-nov-skip-field ()
9048 '(search-forward "\t" eol 'move))
9050 (defmacro gnus-nov-field ()
9051 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9053 ;; Goes through the xover lines and returns a list of vectors
9054 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
9055 "Parse the news overview data in the server buffer, and return a
9056 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9057 ;; Get the Xref when the users reads the articles since most/some
9058 ;; NNTP servers do not include Xrefs when using XOVER.
9059 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9060 (let ((cur nntp-server-buffer)
9061 (dependencies gnus-newsgroup-dependencies)
9062 number headers header)
9064 (set-buffer nntp-server-buffer)
9065 ;; Allow the user to mangle the headers before parsing them.
9066 (run-hooks 'gnus-parse-headers-hook)
9067 ;; Allow the user to mangle the headers before parsing them.
9068 (run-hooks 'gnus-parse-headers-hook)
9069 (goto-char (point-min))
9070 (while (and sequence (not (eobp)))
9071 (setq number (read cur))
9072 (while (and sequence (< (car sequence) number))
9073 (setq sequence (cdr sequence)))
9075 (eq number (car sequence))
9077 (setq sequence (cdr sequence))
9079 (inline (gnus-nov-parse-line
9080 number dependencies force-new)))
9081 (setq headers (cons header headers)))))
9083 (setq headers (nreverse headers)))
9086 ;; This function has to be called with point after the article number
9087 ;; on the beginning of the line.
9088 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9090 (eol (gnus-point-at-eol))
9091 (buffer (current-buffer))
9092 header ref id id-dep ref-dep)
9094 ;; overview: [num subject from date id refs chars lines misc]
9095 (narrow-to-region (point) eol)
9096 (or (eobp) (forward-char))
9102 (gnus-nov-field) ; subject
9103 (gnus-nov-field) ; from
9104 (gnus-nov-field) ; date
9105 (setq id (or (gnus-nov-field)
9108 (setq none (1+ none)))))) ; id
9111 (let ((beg (point)))
9112 (search-forward "\t" eol)
9113 (if (search-backward ">" beg t)
9119 (search-backward "<" beg t)
9122 (gnus-nov-field)) ; refs
9123 (gnus-nov-read-integer) ; chars
9124 (gnus-nov-read-integer) ; lines
9125 (if (= (following-char) ?\n)
9127 (gnus-nov-field)) ; misc
9131 (gnus-message 4 "Strange nov line")
9137 ;; We build the thread tree.
9139 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
9140 (if (and (car (symbol-value id-dep))
9142 ;; An article with this Message-ID has already been seen,
9143 ;; so we ignore this one, except we add any additional
9144 ;; Xrefs (in case the two articles came from different
9147 (mail-header-set-xref
9148 (car (symbol-value id-dep))
9149 (concat (or (mail-header-xref
9150 (car (symbol-value id-dep))) "")
9151 (or (mail-header-xref header) "")))
9153 (setcar (symbol-value id-dep) header))
9154 (set id-dep (list header))))
9157 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9158 (setcdr (symbol-value ref-dep)
9159 (nconc (cdr (symbol-value ref-dep))
9160 (list (symbol-value id-dep))))
9161 (set ref-dep (list nil (symbol-value id-dep))))))
9164 (defun gnus-article-get-xrefs ()
9165 "Fill in the Xref value in `gnus-current-headers', if necessary.
9166 This is meant to be called in `gnus-article-internal-prepare-hook'."
9167 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9168 gnus-current-headers)))
9169 (or (not gnus-use-cross-reference)
9171 (and (mail-header-xref headers)
9172 (not (string= (mail-header-xref headers) "")))
9173 (let ((case-fold-search t)
9176 (nnheader-narrow-to-headers)
9177 (goto-char (point-min))
9178 (if (or (and (eq (downcase (following-char)) ?x)
9179 (looking-at "Xref:"))
9180 (search-forward "\nXref:" nil t))
9182 (goto-char (1+ (match-end 0)))
9183 (setq xref (buffer-substring (point)
9184 (progn (end-of-line) (point))))
9185 (mail-header-set-xref headers xref))))))))
9187 (defun gnus-summary-insert-subject (id)
9188 "Find article ID and insert the summary line for that article."
9189 (let ((header (gnus-read-header id))
9190 (number (and (numberp id) id)))
9192 ;; Rebuild the thread that this article is part of and go to the
9193 ;; article we have fetched.
9194 (gnus-rebuild-thread (mail-header-id header))
9195 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9196 (when (and (numberp number)
9198 ;; We have to update the boundaries even if we can't fetch the
9199 ;; article if ID is a number -- so that the next `P' or `N'
9200 ;; command will fetch the previous (or next) article even
9201 ;; if the one we tried to fetch this time has been canceled.
9202 (and (> number gnus-newsgroup-end)
9203 (setq gnus-newsgroup-end number))
9204 (and (< number gnus-newsgroup-begin)
9205 (setq gnus-newsgroup-begin number))
9206 (setq gnus-newsgroup-unselected
9207 (delq number gnus-newsgroup-unselected)))
9208 ;; Report back a success?
9209 (and header number)))
9211 (defun gnus-summary-work-articles (n)
9212 "Return a list of articles to be worked upon. The prefix argument,
9213 the list of process marked articles, and the current article will be
9214 taken into consideration."
9216 ((and n (numberp n))
9217 ;; A numerical prefix has been given.
9218 (let ((backward (< n 0))
9224 (push (setq article (gnus-summary-article-number))
9227 (gnus-summary-find-prev nil article)
9228 (gnus-summary-find-next nil article)))
9230 (nreverse articles)))
9231 ((and (boundp 'transient-mark-mode)
9234 ;; Work on the region between point and mark.
9235 (let ((max (max (point) (mark)))
9238 (goto-char (min (point) (mark)))
9241 (push (setq article (gnus-summary-article-number)) articles)
9242 (gnus-summary-find-next nil article)
9244 (nreverse articles))))
9245 (gnus-newsgroup-processable
9246 ;; There are process-marked articles present.
9247 (reverse gnus-newsgroup-processable))
9249 ;; Just return the current article.
9250 (list (gnus-summary-article-number)))))
9252 (defun gnus-summary-search-group (&optional backward use-level)
9253 "Search for next unread newsgroup.
9254 If optional argument BACKWARD is non-nil, search backward instead."
9256 (set-buffer gnus-group-buffer)
9257 (if (gnus-group-search-forward
9258 backward nil (if use-level (gnus-group-group-level) nil))
9259 (gnus-group-group-name))))
9261 (defun gnus-summary-best-group (&optional exclude-group)
9262 "Find the name of the best unread group.
9263 If EXCLUDE-GROUP, do not go to this group."
9265 (set-buffer gnus-group-buffer)
9267 (gnus-group-best-unread-group exclude-group))))
9269 (defun gnus-summary-find-next (&optional unread article backward)
9270 (if backward (gnus-summary-find-prev)
9271 (let* ((article (or article (gnus-summary-article-number)))
9272 (arts (gnus-data-find-list article))
9274 (when (or (not gnus-summary-check-current)
9276 (not (gnus-data-unread-p (car arts))))
9277 (setq arts (cdr arts)))
9282 (when (gnus-data-unread-p (car arts))
9283 (setq result (car arts)
9285 (setq arts (cdr arts)))
9288 (goto-char (gnus-data-pos result))
9289 (gnus-data-number result)))))
9291 (defun gnus-summary-find-prev (&optional unread article)
9292 (let* ((article (or article (gnus-summary-article-number)))
9293 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9295 (when (or (not gnus-summary-check-current)
9297 (not (gnus-data-unread-p (car arts))))
9298 (setq arts (cdr arts)))
9303 (and (gnus-data-unread-p (car arts))
9304 (setq result (car arts)
9306 (setq arts (cdr arts)))
9310 (goto-char (gnus-data-pos result))
9311 (gnus-data-number result)))))
9313 (defun gnus-summary-find-subject (subject &optional unread backward article)
9314 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9315 (article (or article (gnus-summary-article-number)))
9316 (articles (gnus-data-list backward))
9317 (arts (gnus-data-find-list article articles))
9319 (when (or (not gnus-summary-check-current)
9321 (not (gnus-data-unread-p (car arts))))
9322 (setq arts (cdr arts)))
9324 (and (or (not unread)
9325 (gnus-data-unread-p (car arts)))
9326 (vectorp (gnus-data-header (car arts)))
9328 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9329 (setq result (car arts)
9331 (setq arts (cdr arts)))
9333 (goto-char (gnus-data-pos result))
9334 (gnus-data-number result))))
9336 (defun gnus-summary-search-forward (&optional unread subject backward)
9337 "Search forward for an article.
9338 If UNREAD, look for unread articles. If SUBJECT, look for
9339 articles with that subject. If BACKWARD, search backward instead."
9340 (cond (subject (gnus-summary-find-subject subject unread backward))
9341 (backward (gnus-summary-find-prev unread))
9342 (t (gnus-summary-find-next unread))))
9344 (defun gnus-recenter (&optional n)
9345 "Center point in window and redisplay frame.
9346 Also do horizontal recentering."
9348 (when (and gnus-auto-center-summary
9349 (not (eq gnus-auto-center-summary 'vertical)))
9350 (gnus-horizontal-recenter))
9353 (defun gnus-summary-recenter ()
9354 "Center point in the summary window.
9355 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9356 displayed, no centering will be performed."
9357 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9358 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9359 (let* ((top (cond ((< (window-height) 4) 0)
9360 ((< (window-height) 7) 1)
9362 (height (1- (window-height)))
9363 (bottom (save-excursion (goto-char (point-max))
9364 (forward-line (- height))
9366 (window (get-buffer-window (current-buffer))))
9367 ;; The user has to want it.
9368 (when gnus-auto-center-summary
9369 (when (get-buffer-window gnus-article-buffer)
9370 ;; Only do recentering when the article buffer is displayed,
9371 ;; Set the window start to either `bottom', which is the biggest
9372 ;; possible valid number, or the second line from the top,
9373 ;; whichever is the least.
9375 window (min bottom (save-excursion
9376 (forward-line (- top)) (point)))))
9377 ;; Do horizontal recentering while we're at it.
9378 (when (and (get-buffer-window (current-buffer) t)
9379 (not (eq gnus-auto-center-summary 'vertical)))
9380 (let ((selected (selected-window)))
9381 (select-window (get-buffer-window (current-buffer) t))
9382 (gnus-summary-position-point)
9383 (gnus-horizontal-recenter)
9384 (select-window selected))))))
9386 (defun gnus-horizontal-recenter ()
9387 "Recenter the current buffer horizontally."
9388 (if (< (current-column) (/ (window-width) 2))
9389 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9390 (let* ((orig (point))
9391 (end (window-end (get-buffer-window (current-buffer) t)))
9393 ;; Find the longest line currently displayed in the window.
9394 (goto-char (window-start))
9395 (while (and (not (eobp))
9398 (setq max (max max (current-column)))
9401 ;; Scroll horizontally to center (sort of) the point.
9402 (if (> max (window-width))
9404 (get-buffer-window (current-buffer) t)
9405 (min (- (current-column) (/ (window-width) 3))
9406 (+ 2 (- max (window-width)))))
9407 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9410 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9411 (defun gnus-short-group-name (group &optional levels)
9412 "Collapse GROUP name LEVELS."
9419 (while (string-match "\\." group skip)
9420 (setq skip (match-end 0)
9423 (if (string-match ":" group)
9424 (setq foreign (substring group 0 (match-end 0))
9425 group (substring group (match-end 0))))
9427 (if (and (string-match "\\." group)
9428 (> levels (- gnus-group-uncollapsed-levels 1)))
9429 (setq name (concat name (substring group 0 1))
9430 group (substring group (match-end 0))
9432 name (concat name "."))
9433 (setq name (concat foreign name group)
9437 (defun gnus-summary-jump-to-group (newsgroup)
9438 "Move point to NEWSGROUP in group mode buffer."
9439 ;; Keep update point of group mode buffer if visible.
9440 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9441 (save-window-excursion
9442 ;; Take care of tree window mode.
9443 (if (get-buffer-window gnus-group-buffer)
9444 (pop-to-buffer gnus-group-buffer))
9445 (gnus-group-jump-to-group newsgroup))
9447 ;; Take care of tree window mode.
9448 (if (get-buffer-window gnus-group-buffer)
9449 (pop-to-buffer gnus-group-buffer)
9450 (set-buffer gnus-group-buffer))
9451 (gnus-group-jump-to-group newsgroup))))
9453 ;; This function returns a list of article numbers based on the
9454 ;; difference between the ranges of read articles in this group and
9455 ;; the range of active articles.
9456 (defun gnus-list-of-unread-articles (group)
9457 (let* ((read (gnus-info-read (gnus-get-info group)))
9458 (active (gnus-active group))
9461 ;; If none are read, then all are unread.
9463 (setq first (car active))
9464 ;; If the range of read articles is a single range, then the
9465 ;; first unread article is the article after the last read
9466 ;; article. Sounds logical, doesn't it?
9467 (if (not (listp (cdr read)))
9468 (setq first (1+ (cdr read)))
9469 ;; `read' is a list of ranges.
9470 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9475 (while (< first nlast)
9476 (setq unread (cons first unread))
9477 (setq first (1+ first))))
9478 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9479 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9480 (setq read (cdr read)))))
9481 ;; And add the last unread articles.
9482 (while (<= first last)
9483 (setq unread (cons first unread))
9484 (setq first (1+ first)))
9485 ;; Return the list of unread articles.
9488 (defun gnus-list-of-read-articles (group)
9489 "Return a list of unread, unticked and non-dormant articles."
9490 (let* ((info (gnus-get-info group))
9491 (marked (gnus-info-marks info))
9492 (active (gnus-active group)))
9494 (gnus-set-difference
9495 (gnus-sorted-complement
9496 (gnus-uncompress-range active)
9497 (gnus-list-of-unread-articles group))
9499 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9500 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9502 ;; Various summary commands
9504 (defun gnus-summary-universal-argument (arg)
9505 "Perform any operation on all articles that are process/prefixed."
9507 (gnus-set-global-variables)
9508 (let ((articles (gnus-summary-work-articles arg))
9515 (substitute-command-keys
9516 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9520 (message "Undefined key")
9524 (gnus-summary-goto-subject (setq article (pop articles)))
9525 (command-execute func)
9526 (gnus-summary-remove-process-mark article)))))
9527 (gnus-summary-position-point))
9529 (defun gnus-summary-toggle-truncation (&optional arg)
9530 "Toggle truncation of summary lines.
9531 With arg, turn line truncation on iff arg is positive."
9533 (setq truncate-lines
9534 (if (null arg) (not truncate-lines)
9535 (> (prefix-numeric-value arg) 0)))
9538 (defun gnus-summary-reselect-current-group (&optional all rescan)
9539 "Exit and then reselect the current newsgroup.
9540 The prefix argument ALL means to select all articles."
9542 (gnus-set-global-variables)
9543 (let ((current-subject (gnus-summary-article-number))
9544 (group gnus-newsgroup-name))
9545 (setq gnus-newsgroup-begin nil)
9547 ;; We have to adjust the point of group mode buffer because the
9548 ;; current point was moved to the next unread newsgroup by
9550 (gnus-summary-jump-to-group group)
9553 (gnus-group-get-new-news-this-group 1)))
9554 (gnus-group-read-group all t)
9555 (gnus-summary-goto-subject current-subject)))
9557 (defun gnus-summary-rescan-group (&optional all)
9558 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9560 (gnus-summary-reselect-current-group all t))
9562 (defun gnus-summary-update-info ()
9563 (let* ((group gnus-newsgroup-name))
9564 (when gnus-newsgroup-kill-headers
9565 (setq gnus-newsgroup-killed
9566 (gnus-compress-sequence
9568 (gnus-set-sorted-intersection
9569 (gnus-uncompress-range gnus-newsgroup-killed)
9570 (setq gnus-newsgroup-unselected
9571 (sort gnus-newsgroup-unselected '<)))
9572 (setq gnus-newsgroup-unreads
9573 (sort gnus-newsgroup-unreads '<))) t)))
9574 (unless (listp (cdr gnus-newsgroup-killed))
9575 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9576 (let ((headers gnus-newsgroup-headers))
9577 (gnus-close-group group)
9578 (run-hooks 'gnus-exit-group-hook)
9579 (unless gnus-save-score
9580 (setq gnus-newsgroup-scored nil))
9581 ;; Set the new ranges of read articles.
9582 (gnus-update-read-articles
9583 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9584 ;; Set the current article marks.
9586 ;; Do the cross-ref thing.
9587 (when gnus-use-cross-reference
9588 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9589 ;; Do adaptive scoring, and possibly save score files.
9590 (when gnus-newsgroup-adaptive
9591 (gnus-score-adaptive))
9592 (when gnus-use-scoring
9594 ;; Do not switch windows but change the buffer to work.
9595 (set-buffer gnus-group-buffer)
9596 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9597 (gnus-group-update-group group)))))
9599 (defun gnus-summary-exit (&optional temporary)
9600 "Exit reading current newsgroup, and then return to group selection mode.
9601 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9603 (gnus-set-global-variables)
9604 (gnus-kill-save-kill-buffer)
9605 (let* ((group gnus-newsgroup-name)
9606 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9608 (buf (current-buffer)))
9609 (run-hooks 'gnus-summary-prepare-exit-hook)
9610 ;; If we have several article buffers, we kill them at exit.
9611 (unless gnus-single-article-buffer
9612 (gnus-kill-buffer gnus-article-buffer)
9613 (gnus-kill-buffer gnus-original-article-buffer))
9614 (when gnus-use-cache
9615 (gnus-cache-possibly-remove-articles)
9616 (gnus-cache-save-buffers))
9617 (when gnus-use-trees
9618 (gnus-tree-close group))
9619 ;; Make all changes in this group permanent.
9621 (gnus-summary-update-info))
9622 ;; Make sure where I was, and go to next newsgroup.
9623 (set-buffer gnus-group-buffer)
9625 (gnus-group-jump-to-group group)
9626 (gnus-group-next-unread-group 1))
9627 (run-hooks 'gnus-summary-exit-hook)
9630 ;; If we have several article buffers, we kill them at exit.
9631 (unless gnus-single-article-buffer
9632 (gnus-kill-buffer gnus-article-buffer)
9633 (gnus-kill-buffer gnus-original-article-buffer))
9635 (if (not gnus-kill-summary-on-exit)
9636 (gnus-deaden-summary)
9637 ;; We set all buffer-local variables to nil. It is unclear why
9638 ;; this is needed, but if we don't, buffer-local variables are
9639 ;; not garbage-collected, it seems. This would the lead to en
9640 ;; ever-growing Emacs.
9641 (gnus-summary-clear-local-variables)
9642 (when (get-buffer gnus-article-buffer)
9643 (bury-buffer gnus-article-buffer))
9644 ;; We clear the global counterparts of the buffer-local
9645 ;; variables as well, just to be on the safe side.
9646 (gnus-configure-windows 'group 'force)
9647 (gnus-summary-clear-local-variables)
9648 ;; Return to group mode buffer.
9649 (if (eq mode 'gnus-summary-mode)
9650 (gnus-kill-buffer buf)))
9651 (setq gnus-current-select-method gnus-select-method)
9652 (pop-to-buffer gnus-group-buffer)
9653 ;; Clear the current group name.
9654 (if (not quit-config)
9656 (gnus-group-jump-to-group group)
9657 (gnus-group-next-unread-group 1)
9658 (gnus-configure-windows 'group 'force))
9659 (if (not (buffer-name (car quit-config)))
9660 (gnus-configure-windows 'group 'force)
9661 (set-buffer (car quit-config))
9662 (and (eq major-mode 'gnus-summary-mode)
9663 (gnus-set-global-variables))
9664 (gnus-configure-windows (cdr quit-config))))
9666 (setq gnus-newsgroup-name nil)))))
9668 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9669 (defun gnus-summary-exit-no-update (&optional no-questions)
9670 "Quit reading current newsgroup without updating read article info."
9672 (gnus-set-global-variables)
9673 (let* ((group gnus-newsgroup-name)
9674 (quit-config (gnus-group-quit-config group)))
9675 (when (or no-questions
9677 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9678 ;; If we have several article buffers, we kill them at exit.
9679 (unless gnus-single-article-buffer
9680 (gnus-kill-buffer gnus-article-buffer)
9681 (gnus-kill-buffer gnus-original-article-buffer))
9682 (if (not gnus-kill-summary-on-exit)
9683 (gnus-deaden-summary)
9684 (gnus-close-group group)
9685 (gnus-summary-clear-local-variables)
9686 (set-buffer gnus-group-buffer)
9687 (gnus-summary-clear-local-variables)
9688 (when (get-buffer gnus-summary-buffer)
9689 (kill-buffer gnus-summary-buffer)))
9690 (when gnus-use-trees
9691 (gnus-tree-close group))
9692 (when (get-buffer gnus-article-buffer)
9693 (bury-buffer gnus-article-buffer))
9694 ;; Return to the group buffer.
9695 (gnus-configure-windows 'group 'force)
9696 ;; Clear the current group name.
9697 (setq gnus-newsgroup-name nil)
9698 (when (equal (gnus-group-group-name) group)
9699 (gnus-group-next-unread-group 1))
9701 (if (not (buffer-name (car quit-config)))
9702 (gnus-configure-windows 'group 'force)
9703 (set-buffer (car quit-config))
9704 (when (eq major-mode 'gnus-summary-mode)
9705 (gnus-set-global-variables))
9706 (gnus-configure-windows (cdr quit-config)))))))
9710 (defvar gnus-dead-summary-mode-map nil)
9712 (if gnus-dead-summary-mode-map
9714 (setq gnus-dead-summary-mode-map (make-keymap))
9715 (suppress-keymap gnus-dead-summary-mode-map)
9716 (substitute-key-definition
9717 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9718 (let ((keys '("\C-d" "\r" "\177")))
9720 (define-key gnus-dead-summary-mode-map
9721 (pop keys) 'gnus-summary-wake-up-the-dead))))
9723 (defvar gnus-dead-summary-mode nil
9724 "Minor mode for Gnus summary buffers.")
9726 (defun gnus-dead-summary-mode (&optional arg)
9727 "Minor mode for Gnus summary buffers."
9729 (when (eq major-mode 'gnus-summary-mode)
9730 (make-local-variable 'gnus-dead-summary-mode)
9731 (setq gnus-dead-summary-mode
9732 (if (null arg) (not gnus-dead-summary-mode)
9733 (> (prefix-numeric-value arg) 0)))
9734 (when gnus-dead-summary-mode
9735 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9736 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9737 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9738 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9739 minor-mode-map-alist)))))
9741 (defun gnus-deaden-summary ()
9742 "Make the current summary buffer into a dead summary buffer."
9743 ;; Kill any previous dead summary buffer.
9744 (when (and gnus-dead-summary
9745 (buffer-name gnus-dead-summary))
9747 (set-buffer gnus-dead-summary)
9748 (when gnus-dead-summary-mode
9749 (kill-buffer (current-buffer)))))
9750 ;; Make this the current dead summary.
9751 (setq gnus-dead-summary (current-buffer))
9752 (gnus-dead-summary-mode 1)
9753 (let ((name (buffer-name)))
9754 (when (string-match "Summary" name)
9756 (concat (substring name 0 (match-beginning 0)) "Dead "
9757 (substring name (match-beginning 0))) t))))
9759 (defun gnus-kill-or-deaden-summary (buffer)
9760 "Kill or deaden the summary BUFFER."
9761 (cond (gnus-kill-summary-on-exit
9762 (when (and gnus-use-trees
9763 (and (get-buffer buffer)
9764 (buffer-name (get-buffer buffer))))
9766 (set-buffer (get-buffer buffer))
9767 (gnus-tree-close gnus-newsgroup-name)))
9768 (gnus-kill-buffer buffer))
9769 ((and (get-buffer buffer)
9770 (buffer-name (get-buffer buffer)))
9773 (gnus-deaden-summary)))))
9775 (defun gnus-summary-wake-up-the-dead (&rest args)
9776 "Wake up the dead summary buffer."
9778 (gnus-dead-summary-mode -1)
9779 (let ((name (buffer-name)))
9780 (when (string-match "Dead " name)
9782 (concat (substring name 0 (match-beginning 0))
9783 (substring name (match-end 0))) t)))
9784 (gnus-message 3 "This dead summary is now alive again"))
9786 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9787 (defun gnus-summary-fetch-faq (&optional faq-dir)
9788 "Fetch the FAQ for the current group.
9789 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9793 (if current-prefix-arg
9795 "Faq dir: " (and (listp gnus-group-faq-directory)
9796 gnus-group-faq-directory)))))
9797 (let (gnus-faq-buffer)
9798 (and (setq gnus-faq-buffer
9799 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9800 (gnus-configure-windows 'summary-faq))))
9802 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9803 (defun gnus-summary-describe-group (&optional force)
9804 "Describe the current newsgroup."
9806 (gnus-group-describe-group force gnus-newsgroup-name))
9808 (defun gnus-summary-describe-briefly ()
9809 "Describe summary mode commands briefly."
9812 (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")))
9814 ;; Walking around group mode buffer from summary mode.
9816 (defun gnus-summary-next-group (&optional no-article target-group backward)
9817 "Exit current newsgroup and then select next unread newsgroup.
9818 If prefix argument NO-ARTICLE is non-nil, no article is selected
9819 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9820 previous group instead."
9822 (gnus-set-global-variables)
9823 (let ((current-group gnus-newsgroup-name)
9824 (current-buffer (current-buffer))
9826 ;; First we semi-exit this group to update Xrefs and all variables.
9827 ;; We can't do a real exit, because the window conf must remain
9828 ;; the same in case the user is prompted for info, and we don't
9829 ;; want the window conf to change before that...
9830 (gnus-summary-exit t)
9831 (while (not entered)
9832 ;; Then we find what group we are supposed to enter.
9833 (set-buffer gnus-group-buffer)
9834 (gnus-group-jump-to-group current-group)
9837 (if (eq gnus-keep-same-level 'best)
9838 (gnus-summary-best-group gnus-newsgroup-name)
9839 (gnus-summary-search-group backward gnus-keep-same-level))))
9840 (if (not target-group)
9841 ;; There are no further groups, so we return to the group
9844 (gnus-message 5 "Returning to the group buffer")
9846 (set-buffer current-buffer)
9847 (gnus-summary-exit))
9848 ;; We try to enter the target group.
9849 (gnus-group-jump-to-group target-group)
9850 (let ((unreads (gnus-group-group-unread)))
9851 (if (and (or (eq t unreads)
9852 (and unreads (not (zerop unreads))))
9853 (gnus-summary-read-group
9854 target-group nil no-article current-buffer))
9856 (setq current-group target-group
9857 target-group nil)))))))
9859 (defun gnus-summary-prev-group (&optional no-article)
9860 "Exit current newsgroup and then select previous unread newsgroup.
9861 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9863 (gnus-summary-next-group no-article nil t))
9865 ;; Walking around summary lines.
9867 (defun gnus-summary-first-subject (&optional unread)
9868 "Go to the first unread subject.
9869 If UNREAD is non-nil, go to the first unread article.
9870 Returns the article selected or nil if there are no unread articles."
9875 ((null gnus-newsgroup-data)
9876 (gnus-message 3 "No articles in the group")
9878 ;; Pick the first article.
9880 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9881 (gnus-data-number (car gnus-newsgroup-data)))
9882 ;; No unread articles.
9883 ((null gnus-newsgroup-unreads)
9884 (gnus-message 3 "No more unread articles")
9886 ;; Find the first unread article.
9888 (let ((data gnus-newsgroup-data))
9890 (not (gnus-data-unread-p (car data))))
9891 (setq data (cdr data)))
9894 (goto-char (gnus-data-pos (car data)))
9895 (gnus-data-number (car data)))))))
9896 (gnus-summary-position-point)))
9898 (defun gnus-summary-next-subject (n &optional unread dont-display)
9899 "Go to next N'th summary line.
9900 If N is negative, go to the previous N'th subject line.
9901 If UNREAD is non-nil, only unread articles are selected.
9902 The difference between N and the actual number of steps taken is
9905 (let ((backward (< n 0))
9909 (gnus-summary-find-prev unread)
9910 (gnus-summary-find-next unread)))
9912 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9913 (if unread " unread" "")))
9916 (gnus-summary-recenter)
9917 (gnus-summary-position-point)))
9920 (defun gnus-summary-next-unread-subject (n)
9921 "Go to next N'th unread summary line."
9923 (gnus-summary-next-subject n t))
9925 (defun gnus-summary-prev-subject (n &optional unread)
9926 "Go to previous N'th summary line.
9927 If optional argument UNREAD is non-nil, only unread article is selected."
9929 (gnus-summary-next-subject (- n) unread))
9931 (defun gnus-summary-prev-unread-subject (n)
9932 "Go to previous N'th unread summary line."
9934 (gnus-summary-next-subject (- n) t))
9936 (defun gnus-summary-goto-subject (article &optional force silent)
9937 "Go the subject line of ARTICLE.
9938 If FORCE, also allow jumping to articles not currently shown."
9940 (data (gnus-data-find article)))
9941 ;; We read in the article if we have to.
9944 (gnus-summary-insert-subject article)
9945 (setq data (gnus-data-find article)))
9950 (gnus-message 3 "Can't find article %d" article))
9952 (goto-char (gnus-data-pos data))
9955 ;; Walking around summary lines with displaying articles.
9957 (defun gnus-summary-expand-window (&optional arg)
9958 "Make the summary buffer take up the entire Emacs frame.
9959 Given a prefix, will force an `article' buffer configuration."
9961 (gnus-set-global-variables)
9963 (gnus-configure-windows 'article 'force)
9964 (gnus-configure-windows 'summary 'force)))
9966 (defun gnus-summary-display-article (article &optional all-header)
9967 "Display ARTICLE in article buffer."
9968 (gnus-set-global-variables)
9972 (if gnus-summary-display-article-function
9973 (funcall gnus-summary-display-article-function article all-header)
9974 (gnus-article-prepare article all-header))
9975 (run-hooks 'gnus-select-article-hook)
9976 (gnus-summary-recenter)
9977 (gnus-summary-goto-subject article)
9978 (when gnus-use-trees
9979 (gnus-possibly-generate-tree article)
9980 (gnus-highlight-selected-tree article))
9981 ;; Successfully display article.
9982 (gnus-article-set-window-start
9983 (cdr (assq article gnus-newsgroup-bookmarks)))
9986 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
9987 "Select the current article.
9988 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
9989 non-nil, the article will be re-fetched even if it already present in
9990 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
9992 (let ((article (or article (gnus-summary-article-number)))
9993 (all-headers (not (not all-headers))) ;Must be T or NIL.
9994 gnus-summary-display-article-function
9997 (gnus-summary-article-pseudo-p article)
9998 (error "This is a pseudo-article."))
10001 (set-buffer gnus-summary-buffer)
10002 (if (or (and gnus-single-article-buffer
10003 (or (null gnus-current-article)
10004 (null gnus-article-current)
10005 (null (get-buffer gnus-article-buffer))
10006 (not (eq article (cdr gnus-article-current)))
10007 (not (equal (car gnus-article-current)
10008 gnus-newsgroup-name))))
10009 (and (not gnus-single-article-buffer)
10010 (null gnus-current-article))
10012 ;; The requested article is different from the current article.
10014 (gnus-summary-display-article article all-headers)
10015 (setq did article))
10016 (if (or all-headers gnus-show-all-headers)
10017 (gnus-article-show-all-headers))
10020 (gnus-article-set-window-start
10021 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10023 (defun gnus-summary-set-current-mark (&optional current-mark)
10024 "Obsolete function."
10027 (defun gnus-summary-next-article (&optional unread subject backward push)
10028 "Select the next article.
10029 If UNREAD, only unread articles are selected.
10030 If SUBJECT, only articles with SUBJECT are selected.
10031 If BACKWARD, the previous article is selected instead of the next."
10033 (gnus-set-global-variables)
10036 ;; Is there such an article?
10037 ((and (gnus-summary-search-forward unread subject backward)
10038 (or (gnus-summary-display-article (gnus-summary-article-number))
10039 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10040 (gnus-summary-position-point))
10041 ;; If not, we try the first unread, if that is wanted.
10043 gnus-auto-select-same
10044 (or (gnus-summary-first-unread-article)
10045 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10046 (gnus-summary-position-point)
10047 (gnus-message 6 "Wrapped"))
10048 ;; Try to get next/previous article not displayed in this group.
10049 ((and gnus-auto-extend-newsgroup
10050 (not unread) (not subject))
10051 (gnus-summary-goto-article
10052 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10054 ;; Go to next/previous group.
10056 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10057 (gnus-summary-jump-to-group gnus-newsgroup-name))
10058 (let ((cmd last-command-char)
10060 (if (eq gnus-keep-same-level 'best)
10061 (gnus-summary-best-group gnus-newsgroup-name)
10062 (gnus-summary-search-group backward gnus-keep-same-level))))
10063 ;; For some reason, the group window gets selected. We change
10065 (select-window (get-buffer-window (current-buffer)))
10066 ;; Select next unread newsgroup automagically.
10068 ((not gnus-auto-select-next)
10069 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10070 ((or (eq gnus-auto-select-next 'quietly)
10071 (and (eq gnus-auto-select-next 'slightly-quietly)
10073 (and (eq gnus-auto-select-next 'almost-quietly)
10074 (gnus-summary-last-article-p)))
10076 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10077 (gnus-summary-exit)
10078 (gnus-message 7 "No more%s articles (%s)..."
10079 (if unread " unread" "")
10080 (if group (concat "selecting " group)
10082 (gnus-summary-next-group nil group backward)))
10084 (gnus-summary-walk-group-buffer
10085 gnus-newsgroup-name cmd unread backward))))))))
10087 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10088 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10089 (?\C-p (gnus-group-prev-unread-group 1))))
10090 keve key group ended)
10092 (set-buffer gnus-group-buffer)
10093 (gnus-summary-jump-to-group from-group)
10095 (if (eq gnus-keep-same-level 'best)
10096 (gnus-summary-best-group gnus-newsgroup-name)
10097 (gnus-summary-search-group backward gnus-keep-same-level))))
10100 5 "No more%s articles%s" (if unread " unread" "")
10102 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10103 (format " (Type %s for %s [%s])"
10104 (single-key-description cmd) group
10105 (car (gnus-gethash group gnus-newsrc-hashtb)))
10106 (format " (Type %s to exit %s)"
10107 (single-key-description cmd)
10108 gnus-newsgroup-name)))
10109 ;; Confirm auto selection.
10110 (setq key (car (setq keve (gnus-read-event-char))))
10113 ((assq key keystrokes)
10114 (let ((obuf (current-buffer)))
10115 (switch-to-buffer gnus-group-buffer)
10117 (gnus-group-jump-to-group group))
10118 (eval (cadr (assq key keystrokes)))
10119 (setq group (gnus-group-group-name))
10120 (switch-to-buffer obuf))
10123 (if (or (not group)
10124 (gnus-ephemeral-group-p gnus-newsgroup-name))
10125 (gnus-summary-exit)
10126 (gnus-summary-next-group nil group backward)))
10128 (push (cdr keve) unread-command-events))))))
10130 (defun gnus-read-event-char ()
10131 "Get the next event."
10132 (let ((event (read-event)))
10133 (cons (and (numberp event) event) event)))
10135 (defun gnus-summary-next-unread-article ()
10136 "Select unread article after current one."
10138 (gnus-summary-next-article t (and gnus-auto-select-same
10139 (gnus-summary-article-subject))))
10141 (defun gnus-summary-prev-article (&optional unread subject)
10142 "Select the article after the current one.
10143 If UNREAD is non-nil, only unread articles are selected."
10145 (gnus-summary-next-article unread subject t))
10147 (defun gnus-summary-prev-unread-article ()
10148 "Select unred article before current one."
10150 (gnus-summary-prev-article t (and gnus-auto-select-same
10151 (gnus-summary-article-subject))))
10153 (defun gnus-summary-next-page (&optional lines circular)
10154 "Show next page of the selected article.
10155 If at the end of the current article, select the next article.
10156 LINES says how many lines should be scrolled up.
10158 If CIRCULAR is non-nil, go to the start of the article instead of
10159 selecting the next article when reaching the end of the current
10162 (setq gnus-summary-buffer (current-buffer))
10163 (gnus-set-global-variables)
10164 (let ((article (gnus-summary-article-number))
10166 (gnus-configure-windows 'article)
10167 (if (or (null gnus-current-article)
10168 (null gnus-article-current)
10169 (/= article (cdr gnus-article-current))
10170 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10171 ;; Selected subject is different from current article's.
10172 (gnus-summary-display-article article)
10173 (gnus-eval-in-buffer-window
10174 gnus-article-buffer
10175 (setq endp (gnus-article-next-page lines)))
10178 (gnus-summary-beginning-of-article))
10180 (gnus-message 3 "End of message"))
10182 (if (and (eq gnus-summary-goto-unread 'never)
10183 (not (eq article gnus-newsgroup-end)))
10184 (gnus-summary-next-article)
10185 (gnus-summary-next-unread-article))))))
10186 (gnus-summary-recenter)
10187 (gnus-summary-position-point)))
10189 (defun gnus-summary-prev-page (&optional lines)
10190 "Show previous page of selected article.
10191 Argument LINES specifies lines to be scrolled down."
10193 (gnus-set-global-variables)
10194 (let ((article (gnus-summary-article-number)))
10195 (gnus-configure-windows 'article)
10196 (if (or (null gnus-current-article)
10197 (null gnus-article-current)
10198 (/= article (cdr gnus-article-current))
10199 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10200 ;; Selected subject is different from current article's.
10201 (gnus-summary-display-article article)
10202 (gnus-summary-recenter)
10203 (gnus-eval-in-buffer-window gnus-article-buffer
10204 (gnus-article-prev-page lines))))
10205 (gnus-summary-position-point))
10207 (defun gnus-summary-scroll-up (lines)
10208 "Scroll up (or down) one line current article.
10209 Argument LINES specifies lines to be scrolled up (or down if negative)."
10211 (gnus-set-global-variables)
10212 (gnus-configure-windows 'article)
10213 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10214 (gnus-eval-in-buffer-window
10215 gnus-article-buffer
10217 (if (gnus-article-next-page lines)
10218 (gnus-message 3 "End of message")))
10220 (gnus-article-prev-page (- lines))))))
10221 (gnus-summary-recenter)
10222 (gnus-summary-position-point))
10224 (defun gnus-summary-next-same-subject ()
10225 "Select next article which has the same subject as current one."
10227 (gnus-set-global-variables)
10228 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10230 (defun gnus-summary-prev-same-subject ()
10231 "Select previous article which has the same subject as current one."
10233 (gnus-set-global-variables)
10234 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10236 (defun gnus-summary-next-unread-same-subject ()
10237 "Select next unread article which has the same subject as current one."
10239 (gnus-set-global-variables)
10240 (gnus-summary-next-article t (gnus-summary-article-subject)))
10242 (defun gnus-summary-prev-unread-same-subject ()
10243 "Select previous unread article which has the same subject as current one."
10245 (gnus-set-global-variables)
10246 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10248 (defun gnus-summary-first-unread-article ()
10249 "Select the first unread article.
10250 Return nil if there are no unread articles."
10252 (gnus-set-global-variables)
10254 (if (gnus-summary-first-subject t)
10256 (gnus-summary-show-thread)
10257 (gnus-summary-first-subject t)
10258 (gnus-summary-display-article (gnus-summary-article-number))))
10259 (gnus-summary-position-point)))
10261 (defun gnus-summary-best-unread-article ()
10262 "Select the unread article with the highest score."
10264 (gnus-set-global-variables)
10265 (let ((best -1000000)
10266 (data gnus-newsgroup-data)
10269 (and (gnus-data-unread-p (car data))
10271 (gnus-summary-article-score (gnus-data-number (car data))))
10274 article (gnus-data-number (car data))))
10275 (setq data (cdr data)))
10277 (gnus-summary-goto-article article)
10278 (error "No unread articles"))
10279 (gnus-summary-position-point)))
10281 (defun gnus-summary-last-subject ()
10282 "Go to the last displayed subject line in the group."
10283 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10285 (gnus-summary-goto-subject article))))
10287 (defun gnus-summary-goto-article (article &optional all-headers force)
10288 "Fetch ARTICLE and display it if it exists.
10289 If ALL-HEADERS is non-nil, no header lines are hidden."
10295 (mapcar (lambda (number) (list (int-to-string number)))
10296 gnus-newsgroup-limit)))
10300 (if (gnus-summary-goto-subject article force)
10301 (gnus-summary-display-article article all-headers)
10302 (gnus-message 4 "Couldn't go to article %s" article) nil)
10303 (gnus-summary-position-point)))
10305 (defun gnus-summary-goto-last-article ()
10306 "Go to the previously read article."
10309 (and gnus-last-article
10310 (gnus-summary-goto-article gnus-last-article))
10311 (gnus-summary-position-point)))
10313 (defun gnus-summary-pop-article (number)
10314 "Pop one article off the history and go to the previous.
10315 NUMBER articles will be popped off."
10318 (setq gnus-newsgroup-history
10319 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10321 (gnus-summary-goto-article (car to))
10322 (error "Article history empty")))
10323 (gnus-summary-position-point))
10325 ;; Summary commands and functions for limiting the summary buffer.
10327 (defun gnus-summary-limit-to-articles (n)
10328 "Limit the summary buffer to the next N articles.
10329 If not given a prefix, use the process marked articles instead."
10331 (gnus-set-global-variables)
10333 (let ((articles (gnus-summary-work-articles n)))
10334 (setq gnus-newsgroup-processable nil)
10335 (gnus-summary-limit articles))
10336 (gnus-summary-position-point)))
10338 (defun gnus-summary-pop-limit (&optional total)
10339 "Restore the previous limit.
10340 If given a prefix, remove all limits."
10342 (gnus-set-global-variables)
10344 (setq gnus-newsgroup-limits
10345 (list (mapcar (lambda (h) (mail-header-number h))
10346 gnus-newsgroup-headers))))
10347 (unless gnus-newsgroup-limits
10348 (error "No limit to pop"))
10350 (gnus-summary-limit nil 'pop)
10351 (gnus-summary-position-point)))
10353 (defun gnus-summary-limit-to-subject (subject &optional header)
10354 "Limit the summary buffer to articles that have subjects that match a regexp."
10355 (interactive "sRegexp: ")
10357 (setq header "subject"))
10358 (when (not (equal "" subject))
10360 (let ((articles (gnus-summary-find-matching
10361 (or header "subject") subject 'all)))
10362 (or articles (error "Found no matches for \"%s\"" subject))
10363 (gnus-summary-limit articles))
10364 (gnus-summary-position-point))))
10366 (defun gnus-summary-limit-to-author (from)
10367 "Limit the summary buffer to articles that have authors that match a regexp."
10368 (interactive "sRegexp: ")
10369 (gnus-summary-limit-to-subject from "from"))
10371 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10373 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10375 (defun gnus-summary-limit-to-unread (&optional all)
10376 "Limit the summary buffer to articles that are not marked as read.
10377 If ALL is non-nil, limit strictly to unread articles."
10380 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10381 (gnus-summary-limit-to-marks
10382 ;; Concat all the marks that say that an article is read and have
10384 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10385 gnus-killed-mark gnus-kill-file-mark
10386 gnus-low-score-mark gnus-expirable-mark
10387 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10390 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10391 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10393 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10394 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10395 If REVERSE, limit the summary buffer to articles that are not marked
10396 with MARKS. MARKS can either be a string of marks or a list of marks.
10397 Returns how many articles were removed."
10398 (interactive "sMarks: ")
10399 (gnus-set-global-variables)
10401 (let ((data gnus-newsgroup-data)
10402 (marks (if (listp marks) marks
10403 (append marks nil))) ; Transform to list.
10406 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10407 (memq (gnus-data-mark (car data)) marks))
10408 (setq articles (cons (gnus-data-number (car data)) articles)))
10409 (setq data (cdr data)))
10410 (gnus-summary-limit articles))
10411 (gnus-summary-position-point)))
10413 (defun gnus-summary-limit-to-score (&optional score)
10414 "Limit to articles with score at or above SCORE."
10416 (gnus-set-global-variables)
10417 (setq score (if score
10418 (prefix-numeric-value score)
10419 (or gnus-summary-default-score 0)))
10420 (let ((data gnus-newsgroup-data)
10423 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10425 (push (gnus-data-number (car data)) articles))
10426 (setq data (cdr data)))
10428 (gnus-summary-limit articles)
10429 (gnus-summary-position-point))))
10431 (defun gnus-summary-limit-include-dormant ()
10432 "Display all the hidden articles that are marked as dormant."
10434 (gnus-set-global-variables)
10435 (or gnus-newsgroup-dormant
10436 (error "There are no dormant articles in this group"))
10438 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10439 (gnus-summary-position-point)))
10441 (defun gnus-summary-limit-exclude-dormant ()
10442 "Hide all dormant articles."
10444 (gnus-set-global-variables)
10446 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10447 (gnus-summary-position-point)))
10449 (defun gnus-summary-limit-exclude-childless-dormant ()
10450 "Hide all dormant articles that have no children."
10452 (gnus-set-global-variables)
10453 (let ((data (gnus-data-list t))
10454 articles d children)
10455 ;; Find all articles that are either not dormant or have
10457 (while (setq d (pop data))
10458 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10459 (and (setq children
10460 (gnus-article-children (gnus-data-number d)))
10463 (when (memq (car children) articles)
10468 (push (gnus-data-number d) articles)))
10469 ;; Do the limiting.
10471 (gnus-summary-limit articles)
10472 (gnus-summary-position-point))))
10474 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10475 "Mark all unread excluded articles as read.
10476 If ALL, mark even excluded ticked and dormants as read."
10478 (let ((articles (gnus-sorted-complement
10480 (mapcar (lambda (h) (mail-header-number h))
10481 gnus-newsgroup-headers)
10483 (sort gnus-newsgroup-limit '<)))
10485 (setq gnus-newsgroup-unreads nil)
10487 (setq gnus-newsgroup-dormant nil
10488 gnus-newsgroup-marked nil
10489 gnus-newsgroup-reads
10491 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10492 gnus-newsgroup-reads))
10493 (while (setq article (pop articles))
10494 (unless (or (memq article gnus-newsgroup-dormant)
10495 (memq article gnus-newsgroup-marked))
10496 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10498 (defun gnus-summary-limit (articles &optional pop)
10500 ;; We pop the previous limit off the stack and use that.
10501 (setq articles (car gnus-newsgroup-limits)
10502 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10503 ;; We use the new limit, so we push the old limit on the stack.
10504 (setq gnus-newsgroup-limits
10505 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10507 (setq gnus-newsgroup-limit articles)
10508 (let ((total (length gnus-newsgroup-data))
10509 (data (gnus-data-find-list (gnus-summary-article-number)))
10511 ;; This will do all the work of generating the new summary buffer
10512 ;; according to the new limit.
10513 (gnus-summary-prepare)
10514 ;; Hide any threads, possibly.
10515 (and gnus-show-threads
10516 gnus-thread-hide-subtree
10517 (gnus-summary-hide-all-threads))
10518 ;; Try to return to the article you were at, or one in the
10521 ;; We try to find some article after the current one.
10523 (and (gnus-summary-goto-subject
10524 (gnus-data-number (car data)) nil t)
10527 (setq data (cdr data))))
10529 ;; If there is no data, that means that we were after the last
10530 ;; article. The same goes when we can't find any articles
10531 ;; after the current one.
10533 (goto-char (point-max))
10534 (gnus-summary-find-prev)))
10535 ;; We return how many articles were removed from the summary
10536 ;; buffer as a result of the new limit.
10537 (- total (length gnus-newsgroup-data))))
10539 (defsubst gnus-cut-thread (thread)
10540 "Go forwards in the thread until we find an article that we want to display."
10541 (if (eq gnus-fetch-old-headers 'some)
10543 (memq (mail-header-number (car thread))
10544 gnus-newsgroup-ancient)
10545 (<= (length (cdr thread)) 1))
10546 (setq thread (cadr thread)))
10548 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10549 (= (length (cdr thread)) 1))
10550 (setq thread (cadr thread))))
10553 (defun gnus-cut-threads (threads)
10554 "Cut off all uninteresting articles from the beginning of threads."
10555 (when (or (eq gnus-fetch-old-headers 'some)
10556 (eq gnus-build-sparse-threads 'some)
10557 (eq gnus-build-sparse-threads 'more))
10558 (let ((th threads))
10560 (setcar th (gnus-cut-thread (car th)))
10561 (setq th (cdr th)))))
10564 (defun gnus-summary-initial-limit (&optional show-if-empty)
10565 "Figure out what the initial limit is supposed to be on group entry.
10566 This entails weeding out unwanted dormants, low-scored articles,
10567 fetch-old-headers verbiage, and so on."
10568 ;; Most groups have nothing to remove.
10569 (if (or gnus-inhibit-limiting
10570 (and (null gnus-newsgroup-dormant)
10571 (not (eq gnus-fetch-old-headers 'some))
10572 (null gnus-summary-expunge-below)
10573 (not (eq gnus-build-sparse-threads 'some))
10574 (not (eq gnus-build-sparse-threads 'more))
10575 (null gnus-thread-expunge-below)
10576 (not gnus-use-nocem)))
10578 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10579 (setq gnus-newsgroup-limit nil)
10582 (unless (car (symbol-value node))
10583 ;; These threads have no parents -- they are roots.
10584 (let ((nodes (cdr (symbol-value node)))
10587 (if (and gnus-thread-expunge-below
10588 (< (gnus-thread-total-score (car nodes))
10589 gnus-thread-expunge-below))
10590 (gnus-expunge-thread (pop nodes))
10591 (setq thread (pop nodes))
10592 (gnus-summary-limit-children thread))))))
10593 gnus-newsgroup-dependencies)
10594 ;; If this limitation resulted in an empty group, we might
10595 ;; pop the previous limit and use it instead.
10596 (when (and (not gnus-newsgroup-limit)
10598 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10599 gnus-newsgroup-limit))
10601 (defun gnus-summary-limit-children (thread)
10602 "Return 1 if this subthread is visible and 0 if it is not."
10603 ;; First we get the number of visible children to this thread. This
10604 ;; is done by recursing down the thread using this function, so this
10605 ;; will really go down to a leaf article first, before slowly
10606 ;; working its way up towards the root.
10610 (apply '+ (mapcar 'gnus-summary-limit-children
10613 (number (mail-header-number (car thread)))
10616 ;; If this article is dormant and has absolutely no visible
10617 ;; children, then this article isn't visible.
10618 (and (memq number gnus-newsgroup-dormant)
10620 ;; If this is a "fetch-old-headered" and there is only one
10621 ;; visible child (or less), then we don't want this article.
10622 (and (eq gnus-fetch-old-headers 'some)
10623 (memq number gnus-newsgroup-ancient)
10625 ;; If this is a sparsely inserted article with no children,
10626 ;; we don't want it.
10627 (and (eq gnus-build-sparse-threads 'some)
10628 (memq number gnus-newsgroup-sparse)
10630 ;; If we use expunging, and this article is really
10631 ;; low-scored, then we don't want this article.
10632 (when (and gnus-summary-expunge-below
10634 (or (cdr (assq number gnus-newsgroup-scored))
10635 gnus-summary-default-score))
10636 gnus-summary-expunge-below))
10637 ;; We increase the expunge-tally here, but that has
10638 ;; nothing to do with the limits, really.
10639 (incf gnus-newsgroup-expunged-tally)
10640 ;; We also mark as read here, if that's wanted.
10641 (when (and gnus-summary-mark-below
10642 (< score gnus-summary-mark-below))
10643 (setq gnus-newsgroup-unreads
10644 (delq number gnus-newsgroup-unreads))
10645 (if gnus-newsgroup-auto-expire
10646 (push number gnus-newsgroup-expirable)
10647 (push (cons number gnus-low-score-mark)
10648 gnus-newsgroup-reads)))
10650 (and gnus-use-nocem
10651 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10652 ;; Nope, invisible article.
10654 ;; Ok, this article is to be visible, so we add it to the limit
10656 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10659 (defun gnus-expunge-thread (thread)
10660 "Mark all articles in THREAD as read."
10661 (let* ((number (mail-header-number (car thread))))
10662 (incf gnus-newsgroup-expunged-tally)
10663 ;; We also mark as read here, if that's wanted.
10664 (setq gnus-newsgroup-unreads
10665 (delq number gnus-newsgroup-unreads))
10666 (if gnus-newsgroup-auto-expire
10667 (push number gnus-newsgroup-expirable)
10668 (push (cons number gnus-low-score-mark)
10669 gnus-newsgroup-reads)))
10670 ;; Go recursively through all subthreads.
10671 (mapcar 'gnus-expunge-thread (cdr thread)))
10673 ;; Summary article oriented commands
10675 (defun gnus-summary-refer-parent-article (n)
10676 "Refer parent article N times.
10677 The difference between N and the number of articles fetched is returned."
10679 (gnus-set-global-variables)
10683 (let* ((header (gnus-summary-article-header))
10685 ;; If we try to find the parent of the currently
10686 ;; displayed article, then we take a look at the actual
10687 ;; References header, since this is slightly more
10688 ;; reliable than the References field we got from the
10690 (if (and (eq (mail-header-number header)
10691 (cdr gnus-article-current))
10692 (equal gnus-newsgroup-name
10693 (car gnus-article-current)))
10695 (set-buffer gnus-original-article-buffer)
10696 (nnheader-narrow-to-headers)
10698 (mail-fetch-field "references")
10700 ;; It's not the current article, so we take a bet on
10701 ;; the value we got from the server.
10702 (mail-header-references header))))
10703 (if (setq ref (or ref (mail-header-references header)))
10704 (or (gnus-summary-refer-article (gnus-parent-id ref))
10705 (gnus-message 1 "Couldn't find parent"))
10706 (gnus-message 1 "No references in article %d"
10707 (gnus-summary-article-number))
10710 (gnus-summary-position-point)
10713 (defun gnus-summary-refer-references ()
10714 "Fetch all articles mentioned in the References header.
10715 Return how many articles were fetched."
10717 (gnus-set-global-variables)
10718 (let ((ref (mail-header-references (gnus-summary-article-header)))
10719 (current (gnus-summary-article-number))
10721 ;; For each Message-ID in the References header...
10722 (while (string-match "<[^>]*>" ref)
10724 ;; ... fetch that article.
10725 (gnus-summary-refer-article
10726 (prog1 (match-string 0 ref)
10727 (setq ref (substring ref (match-end 0))))))
10728 (gnus-summary-goto-subject current)
10729 (gnus-summary-position-point)
10732 (defun gnus-summary-refer-article (message-id)
10733 "Fetch an article specified by MESSAGE-ID."
10734 (interactive "sMessage-ID: ")
10735 (when (and (stringp message-id)
10736 (not (zerop (length message-id))))
10737 ;; Construct the correct Message-ID if necessary.
10738 ;; Suggested by tale@pawl.rpi.edu.
10739 (unless (string-match "^<" message-id)
10740 (setq message-id (concat "<" message-id)))
10741 (unless (string-match ">$" message-id)
10742 (setq message-id (concat message-id ">")))
10743 (let ((header (car (gnus-gethash (downcase message-id)
10744 gnus-newsgroup-dependencies))))
10746 ;; The article is present in the buffer, to we just go to it.
10747 (gnus-summary-goto-article (mail-header-number header) nil t)
10748 ;; We fetch the article
10749 (let ((gnus-override-method gnus-refer-article-method)
10751 ;; Start the special refer-article method, if necessary.
10752 (when gnus-refer-article-method
10753 (gnus-check-server gnus-refer-article-method))
10754 ;; Fetch the header, and display the article.
10755 (if (setq number (gnus-summary-insert-subject message-id))
10756 (gnus-summary-select-article nil nil nil number)
10757 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10759 (defun gnus-summary-enter-digest-group (&optional force)
10760 "Enter a digest group based on the current article."
10762 (gnus-set-global-variables)
10763 (gnus-summary-select-article)
10764 (let ((name (format "%s-%d"
10765 (gnus-group-prefixed-name
10766 gnus-newsgroup-name (list 'nndoc ""))
10767 gnus-current-article))
10768 (ogroup gnus-newsgroup-name)
10769 (case-fold-search t)
10770 (buf (current-buffer))
10773 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10774 (insert-buffer-substring gnus-original-article-buffer)
10776 (goto-char (point-min))
10777 (or (search-forward "\n\n" nil t) (point)))
10778 (goto-char (point-min))
10779 (delete-matching-lines "^\\(Path\\):\\|^From ")
10782 (if (gnus-group-read-ephemeral-group
10783 name `(nndoc ,name (nndoc-address
10785 (nndoc-article-type ,(if force 'digest 'guess))) t)
10786 ;; Make all postings to this group go to the parent group.
10787 (nconc (gnus-info-params (gnus-get-info name))
10788 (list (cons 'to-group ogroup)))
10789 ;; Couldn't select this doc group.
10790 (switch-to-buffer buf)
10791 (gnus-set-global-variables)
10792 (gnus-configure-windows 'summary)
10793 (gnus-message 3 "Article couldn't be entered?"))
10794 (kill-buffer dig))))
10796 (defun gnus-summary-isearch-article (&optional regexp-p)
10797 "Do incremental search forward on the current article.
10798 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10800 (gnus-set-global-variables)
10801 (gnus-summary-select-article)
10802 (gnus-configure-windows 'article)
10803 (gnus-eval-in-buffer-window
10804 gnus-article-buffer
10805 (goto-char (point-min))
10806 (isearch-forward regexp-p)))
10808 (defun gnus-summary-search-article-forward (regexp &optional backward)
10809 "Search for an article containing REGEXP forward.
10810 If BACKWARD, search backward instead."
10813 (format "Search article %s (regexp%s): "
10814 (if current-prefix-arg "backward" "forward")
10815 (if gnus-last-search-regexp
10816 (concat ", default " gnus-last-search-regexp)
10818 current-prefix-arg))
10819 (gnus-set-global-variables)
10820 (if (string-equal regexp "")
10821 (setq regexp (or gnus-last-search-regexp ""))
10822 (setq gnus-last-search-regexp regexp))
10823 (if (gnus-summary-search-article regexp backward)
10824 (gnus-article-set-window-start
10825 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10826 (error "Search failed: \"%s\"" regexp)))
10828 (defun gnus-summary-search-article-backward (regexp)
10829 "Search for an article containing REGEXP backward."
10832 (format "Search article backward (regexp%s): "
10833 (if gnus-last-search-regexp
10834 (concat ", default " gnus-last-search-regexp)
10836 (gnus-summary-search-article-forward regexp 'backward))
10838 (defun gnus-summary-search-article (regexp &optional backward)
10839 "Search for an article containing REGEXP.
10840 Optional argument BACKWARD means do search for backward.
10841 gnus-select-article-hook is not called during the search."
10842 (let ((gnus-select-article-hook nil) ;Disable hook.
10843 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10846 (function re-search-backward) (function re-search-forward)))
10849 ;; Hidden thread subtrees must be searched for ,too.
10850 (gnus-summary-show-all-threads)
10851 ;; First of all, search current article.
10852 ;; We don't want to read article again from NNTP server nor reset
10854 (gnus-summary-select-article)
10855 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10856 (setq last gnus-current-article)
10857 (gnus-eval-in-buffer-window
10858 gnus-article-buffer
10861 ;; Begin search from current point.
10862 (setq found (funcall re-search regexp nil t))))
10863 ;; Then search next articles.
10864 (while (and (not found)
10865 (gnus-summary-display-article
10866 (if backward (gnus-summary-find-prev)
10867 (gnus-summary-find-next))))
10868 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10869 (gnus-eval-in-buffer-window
10870 gnus-article-buffer
10873 (goto-char (if backward (point-max) (point-min)))
10874 (setq found (funcall re-search regexp nil t)))))
10876 ;; Adjust article pointer.
10877 (or (eq last gnus-current-article)
10878 (setq gnus-last-article last))
10879 ;; Return T if found such article.
10882 (defun gnus-summary-find-matching (header regexp &optional backward unread
10884 "Return a list of all articles that match REGEXP on HEADER.
10885 The search stars on the current article and goes forwards unless
10886 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10887 If UNREAD is non-nil, only unread articles will
10888 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10889 in the comparisons."
10890 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10891 (gnus-data-find-list
10892 (gnus-summary-article-number) (gnus-data-list backward))))
10893 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10894 (case-fold-search (not not-case-fold))
10896 (or (fboundp (intern (concat "mail-header-" header)))
10897 (error "%s is not a valid header" header))
10899 (setq d (car data))
10900 (and (or (not unread) ; We want all articles...
10901 (gnus-data-unread-p d)) ; Or just unreads.
10902 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10903 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10904 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10905 (setq data (cdr data)))
10906 (nreverse articles)))
10908 (defun gnus-summary-execute-command (header regexp command &optional backward)
10909 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10910 If HEADER is an empty string (or nil), the match is done on the entire
10911 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10913 (list (let ((completion-ignore-case t))
10916 (mapcar (lambda (string) (list string))
10917 '("Number" "Subject" "From" "Lines" "Date"
10918 "Message-ID" "Xref" "References" "Body"))
10919 nil 'require-match))
10920 (read-string "Regexp: ")
10921 (read-key-sequence "Command: ")
10922 current-prefix-arg))
10923 (when (equal header "Body")
10925 (gnus-set-global-variables)
10926 ;; Hidden thread subtrees must be searched as well.
10927 (gnus-summary-show-all-threads)
10928 ;; We don't want to change current point nor window configuration.
10930 (save-window-excursion
10931 (gnus-message 6 "Executing %s..." (key-description command))
10932 ;; We'd like to execute COMMAND interactively so as to give arguments.
10933 (gnus-execute header regexp
10934 `(lambda () (call-interactively ',(key-binding command)))
10936 (gnus-message 6 "Executing %s...done" (key-description command)))))
10938 (defun gnus-summary-beginning-of-article ()
10939 "Scroll the article back to the beginning."
10941 (gnus-set-global-variables)
10942 (gnus-summary-select-article)
10943 (gnus-configure-windows 'article)
10944 (gnus-eval-in-buffer-window
10945 gnus-article-buffer
10947 (goto-char (point-min))
10948 (and gnus-break-pages (gnus-narrow-to-page))))
10950 (defun gnus-summary-end-of-article ()
10951 "Scroll to the end of the article."
10953 (gnus-set-global-variables)
10954 (gnus-summary-select-article)
10955 (gnus-configure-windows 'article)
10956 (gnus-eval-in-buffer-window
10957 gnus-article-buffer
10959 (goto-char (point-max))
10961 (and gnus-break-pages (gnus-narrow-to-page))))
10963 (defun gnus-summary-show-article (&optional arg)
10964 "Force re-fetching of the current article.
10965 If ARG (the prefix) is non-nil, show the raw article without any
10966 article massaging functions being run."
10968 (gnus-set-global-variables)
10970 ;; Select the article the normal way.
10971 (gnus-summary-select-article nil 'force)
10972 ;; Bind the article treatment functions to nil.
10973 (let ((gnus-have-all-headers t)
10974 gnus-article-display-hook
10975 gnus-article-prepare-hook
10977 (gnus-summary-select-article nil 'force)))
10978 ; (gnus-configure-windows 'article)
10979 (gnus-summary-position-point))
10981 (defun gnus-summary-verbose-headers (&optional arg)
10982 "Toggle permanent full header display.
10983 If ARG is a positive number, turn header display on.
10984 If ARG is a negative number, turn header display off."
10986 (gnus-set-global-variables)
10987 (gnus-summary-toggle-header arg)
10988 (setq gnus-show-all-headers
10989 (cond ((or (not (numberp arg))
10991 (not gnus-show-all-headers))
10995 (defun gnus-summary-toggle-header (&optional arg)
10996 "Show the headers if they are hidden, or hide them if they are shown.
10997 If ARG is a positive number, show the entire header.
10998 If ARG is a negative number, hide the unwanted header lines."
11000 (gnus-set-global-variables)
11002 (set-buffer gnus-article-buffer)
11003 (let* ((buffer-read-only nil)
11004 (inhibit-point-motion-hooks t)
11005 (hidden (text-property-any
11006 (goto-char (point-min)) (search-forward "\n\n")
11009 (goto-char (point-min))
11010 (when (search-forward "\n\n" nil t)
11011 (delete-region (point-min) (1- (point))))
11012 (goto-char (point-min))
11014 (set-buffer gnus-original-article-buffer)
11015 (goto-char (point-min))
11016 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11017 (insert-buffer-substring gnus-original-article-buffer 1 e)
11018 (let ((gnus-inhibit-hiding t))
11019 (run-hooks 'gnus-article-display-hook))
11020 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11021 (gnus-article-hide-headers)))))
11023 (defun gnus-summary-show-all-headers ()
11024 "Make all header lines visible."
11026 (gnus-set-global-variables)
11027 (gnus-article-show-all-headers))
11029 (defun gnus-summary-toggle-mime (&optional arg)
11030 "Toggle MIME processing.
11031 If ARG is a positive number, turn MIME processing on."
11033 (gnus-set-global-variables)
11034 (setq gnus-show-mime
11035 (if (null arg) (not gnus-show-mime)
11036 (> (prefix-numeric-value arg) 0)))
11037 (gnus-summary-select-article t 'force))
11039 (defun gnus-summary-caesar-message (&optional arg)
11040 "Caesar rotate the current article by 13.
11041 The numerical prefix specifies how manu places to rotate each letter
11044 (gnus-set-global-variables)
11045 (gnus-summary-select-article)
11046 (let ((mail-header-separator ""))
11047 (gnus-eval-in-buffer-window
11048 gnus-article-buffer
11051 (let ((start (window-start)))
11052 (news-caesar-buffer-body arg)
11053 (set-window-start (get-buffer-window (current-buffer)) start))))))
11055 (defun gnus-summary-stop-page-breaking ()
11056 "Stop page breaking in the current article."
11058 (gnus-set-global-variables)
11059 (gnus-summary-select-article)
11060 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11062 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11063 "Move the current article to a different newsgroup.
11064 If N is a positive number, move the N next articles.
11065 If N is a negative number, move the N previous articles.
11066 If N is nil and any articles have been marked with the process mark,
11067 move those articles instead.
11068 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11069 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11070 re-spool using this method.
11072 For this function to work, both the current newsgroup and the
11073 newsgroup that you want to move to have to support the `request-move'
11074 and `request-accept' functions."
11076 (unless action (setq action 'move))
11077 (gnus-set-global-variables)
11078 ;; Check whether the source group supports the required functions.
11079 (cond ((and (eq action 'move)
11080 (not (gnus-check-backend-function
11081 'request-move-article gnus-newsgroup-name)))
11082 (error "The current group does not support article moving"))
11083 ((and (eq action 'crosspost)
11084 (not (gnus-check-backend-function
11085 'request-replace-article gnus-newsgroup-name)))
11086 (error "The current group does not support article editing")))
11087 (let ((articles (gnus-summary-work-articles n))
11088 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11089 (names '((move "move" "Moving")
11090 (copy "copy" "Copying")
11091 (crosspost "crosspost" "Crossposting")))
11092 (copy-buf (save-excursion
11093 (nnheader-set-temp-buffer " *copy article*")))
11094 art-group to-method new-xref article)
11095 (unless (assq action names)
11096 (error "Unknown action %s" action))
11097 ;; Read the newsgroup name.
11098 (when (and (not to-newsgroup)
11099 (not select-method))
11101 (gnus-read-move-group-name
11102 (cadr (assq action names))
11103 gnus-current-move-group articles prefix))
11104 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11105 (setq to-method (if select-method (list select-method "")
11106 (gnus-find-method-for-group to-newsgroup)))
11107 ;;(when (equal to-newsgroup gnus-newsgroup-name)
11108 ;;(error "Can't %s to the same group you're already in" action))
11109 ;; Check the method we are to move this article to...
11110 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11111 (error "%s does not support article copying" (car to-method)))
11112 (or (gnus-check-server to-method)
11113 (error "Can't open server %s" (car to-method)))
11114 (gnus-message 6 "%s to %s: %s..."
11115 (caddr (assq action names))
11116 (or select-method to-newsgroup) articles)
11118 (setq article (pop articles))
11122 ;; Move the article.
11124 (gnus-request-move-article
11125 article ; Article to move
11126 gnus-newsgroup-name ; From newsgrouo
11127 (nth 1 (gnus-find-method-for-group
11128 gnus-newsgroup-name)) ; Server
11129 (list 'gnus-request-accept-article
11131 (list 'quote select-method)
11133 (not articles)) ; Accept form
11134 (not articles))) ; Only save nov last time
11135 ;; Copy the article.
11138 (set-buffer copy-buf)
11139 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11140 (gnus-request-accept-article
11141 (if select-method select-method to-newsgroup)
11143 ;; Crosspost the article.
11144 ((eq action 'crosspost)
11145 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11146 (setq new-xref (concat gnus-newsgroup-name ":" article))
11147 (if (and xref (not (string= xref "")))
11149 (when (string-match "^Xref: " xref)
11150 (setq xref (substring xref (match-end 0))))
11151 (setq new-xref (concat xref " " new-xref)))
11152 (setq new-xref (concat (system-name) " " new-xref)))
11154 (set-buffer copy-buf)
11155 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11156 (nnheader-replace-header "xref" new-xref)
11157 (gnus-request-accept-article
11158 (if select-method select-method to-newsgroup)
11159 (not articles)))))))
11160 (if (not art-group)
11161 (gnus-message 1 "Couldn't %s article %s"
11162 (cadr (assq action names)) article)
11165 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11167 (gnus-group-prefixed-name
11169 (if select-method (list select-method "")
11170 (gnus-find-method-for-group to-newsgroup)))
11171 gnus-newsrc-hashtb)))
11172 (info (nth 2 entry)))
11173 ;; Update the group that has been moved to.
11175 (memq action '(move copy)))
11176 (unless (memq article gnus-newsgroup-unreads)
11177 (gnus-info-set-read
11178 info (gnus-add-to-range (gnus-info-read info)
11179 (list (cdr art-group)))))
11181 ;; Copy any marks over to the new group.
11182 (let ((marks gnus-article-mark-lists)
11183 (to-article (cdr art-group)))
11185 ;; See whether the article is to be put in the cache.
11186 (when gnus-use-cache
11187 (gnus-cache-possibly-enter-article
11188 (gnus-info-group info) to-article
11189 (let ((header (copy-sequence
11190 (gnus-summary-article-header article))))
11191 (mail-header-set-number header to-article)
11193 (memq article gnus-newsgroup-marked)
11194 (memq article gnus-newsgroup-dormant)
11195 (memq article gnus-newsgroup-unreads)))
11198 (when (memq article (symbol-value
11199 (intern (format "gnus-newsgroup-%s"
11201 (gnus-add-marked-articles
11202 (gnus-info-group info) (cdar marks)
11203 (list to-article) info))
11204 (setq marks (cdr marks)))))
11206 ;; Update the Xref header in this article to point to
11207 ;; the new crossposted article we have just created.
11208 (when (eq action 'crosspost)
11210 (set-buffer copy-buf)
11211 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11212 (nnheader-replace-header
11213 "xref" (concat new-xref " " (gnus-group-prefixed-name
11214 (car art-group) to-method)
11215 ":" (cdr art-group)))
11216 (gnus-request-replace-article
11217 article gnus-newsgroup-name (current-buffer)))))
11219 (gnus-summary-goto-subject article)
11220 (when (eq action 'move)
11221 (gnus-summary-mark-article article gnus-canceled-mark)))
11222 (gnus-summary-remove-process-mark article))
11223 (gnus-kill-buffer copy-buf)
11224 (gnus-summary-position-point)
11225 (gnus-set-mode-line 'summary)))
11227 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11228 "Move the current article to a different newsgroup.
11229 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11230 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11231 re-spool using this method."
11233 (gnus-summary-move-article n nil nil 'copy))
11235 (defun gnus-summary-crosspost-article (&optional n)
11236 "Crosspost the current article to some other group."
11238 (gnus-summary-move-article n nil nil 'crosspost))
11240 (defun gnus-summary-respool-article (&optional n respool-method)
11241 "Respool the current article.
11242 The article will be squeezed through the mail spooling process again,
11243 which means that it will be put in some mail newsgroup or other
11244 depending on `nnmail-split-methods'.
11245 If N is a positive number, respool the N next articles.
11246 If N is a negative number, respool the N previous articles.
11247 If N is nil and any articles have been marked with the process mark,
11248 respool those articles instead.
11250 Respooling can be done both from mail groups and \"real\" newsgroups.
11251 In the former case, the articles in question will be moved from the
11252 current group into whatever groups they are destined to. In the
11253 latter case, they will be copied into the relevant groups."
11255 (gnus-set-global-variables)
11256 (let ((respool-methods (gnus-methods-using 'respool))
11258 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11260 (setq respool-method
11262 "What method do you want to use when respooling? "
11263 respool-methods nil t methname)))
11264 (or (string= respool-method "")
11265 (if (assoc (symbol-name
11266 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11268 (gnus-summary-move-article n nil (intern respool-method))
11269 (gnus-summary-copy-article n nil (intern respool-method))))))
11271 (defun gnus-summary-import-article (file)
11272 "Import a random file into a mail newsgroup."
11273 (interactive "fImport file: ")
11274 (gnus-set-global-variables)
11275 (let ((group gnus-newsgroup-name)
11276 (now (current-time))
11278 (or (gnus-check-backend-function 'request-accept-article group)
11279 (error "%s does not support article importing" group))
11280 (or (file-readable-p file)
11281 (not (file-regular-p file))
11282 (error "Can't read %s" file))
11284 (set-buffer (get-buffer-create " *import file*"))
11285 (buffer-disable-undo (current-buffer))
11287 (insert-file-contents file)
11288 (goto-char (point-min))
11289 (unless (nnheader-article-p)
11290 ;; This doesn't look like an article, so we fudge some headers.
11291 (setq atts (file-attributes file)
11292 lines (count-lines (point-min) (point-max)))
11293 (insert "From: " (read-string "From: ") "\n"
11294 "Subject: " (read-string "Subject: ") "\n"
11295 "Date: " (timezone-make-date-arpa-standard
11296 (current-time-string (nth 5 atts))
11297 (current-time-zone now)
11298 (current-time-zone now)) "\n"
11299 "Message-ID: " (gnus-inews-message-id) "\n"
11300 "Lines: " (int-to-string lines) "\n"
11301 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11302 (gnus-request-accept-article group t)
11303 (kill-buffer (current-buffer)))))
11305 (defun gnus-summary-expire-articles ()
11306 "Expire all articles that are marked as expirable in the current group."
11308 (gnus-set-global-variables)
11309 (when (gnus-check-backend-function
11310 'request-expire-articles gnus-newsgroup-name)
11311 ;; This backend supports expiry.
11312 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11313 (expirable (if total
11314 (gnus-list-of-read-articles gnus-newsgroup-name)
11315 (setq gnus-newsgroup-expirable
11316 (sort gnus-newsgroup-expirable '<))))
11317 (expiry-wait (gnus-group-get-parameter
11318 gnus-newsgroup-name 'expiry-wait))
11321 ;; There are expirable articles in this group, so we run them
11322 ;; through the expiry process.
11323 (gnus-message 6 "Expiring articles...")
11324 ;; The list of articles that weren't expired is returned.
11326 (let ((nnmail-expiry-wait-function nil)
11327 (nnmail-expiry-wait expiry-wait))
11328 (setq es (gnus-request-expire-articles
11329 expirable gnus-newsgroup-name)))
11330 (setq es (gnus-request-expire-articles
11331 expirable gnus-newsgroup-name)))
11332 (or total (setq gnus-newsgroup-expirable es))
11333 ;; We go through the old list of expirable, and mark all
11334 ;; really expired articles as nonexistent.
11335 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11336 (let ((gnus-use-cache nil))
11338 (unless (memq (car expirable) es)
11339 (when (gnus-data-find (car expirable))
11340 (gnus-summary-mark-article
11341 (car expirable) gnus-canceled-mark)))
11342 (setq expirable (cdr expirable)))))
11343 (gnus-message 6 "Expiring articles...done")))))
11345 (defun gnus-summary-expire-articles-now ()
11346 "Expunge all expirable articles in the current group.
11347 This means that *all* articles that are marked as expirable will be
11348 deleted forever, right now."
11350 (gnus-set-global-variables)
11351 (or gnus-expert-user
11353 "Are you really, really, really sure you want to expunge? ")
11355 (let ((nnmail-expiry-wait 'immediate)
11356 (nnmail-expiry-wait-function nil))
11357 (gnus-summary-expire-articles)))
11359 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11360 (defun gnus-summary-delete-article (&optional n)
11361 "Delete the N next (mail) articles.
11362 This command actually deletes articles. This is not a marking
11363 command. The article will disappear forever from your life, never to
11365 If N is negative, delete backwards.
11366 If N is nil and articles have been marked with the process mark,
11367 delete these instead."
11369 (gnus-set-global-variables)
11370 (or (gnus-check-backend-function 'request-expire-articles
11371 gnus-newsgroup-name)
11372 (error "The current newsgroup does not support article deletion."))
11373 ;; Compute the list of articles to delete.
11374 (let ((articles (gnus-summary-work-articles n))
11376 (if (and gnus-novice-user
11377 (not (gnus-y-or-n-p
11378 (format "Do you really want to delete %s forever? "
11379 (if (> (length articles) 1) "these articles"
11380 "this article")))))
11382 ;; Delete the articles.
11383 (setq not-deleted (gnus-request-expire-articles
11384 articles gnus-newsgroup-name 'force))
11386 (gnus-summary-remove-process-mark (car articles))
11387 ;; The backend might not have been able to delete the article
11389 (or (memq (car articles) not-deleted)
11390 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11391 (setq articles (cdr articles))))
11392 (gnus-summary-position-point)
11393 (gnus-set-mode-line 'summary)
11396 (defun gnus-summary-edit-article (&optional force)
11397 "Enter into a buffer and edit the current article.
11398 This will have permanent effect only in mail groups.
11399 If FORCE is non-nil, allow editing of articles even in read-only
11403 (set-buffer gnus-summary-buffer)
11404 (gnus-set-global-variables)
11405 (when (and (not force)
11406 (gnus-group-read-only-p))
11407 (error "The current newsgroup does not support article editing."))
11408 (gnus-summary-select-article t nil t)
11409 (gnus-configure-windows 'article)
11410 (select-window (get-buffer-window gnus-article-buffer))
11411 (gnus-message 6 "C-c C-c to end edits")
11412 (setq buffer-read-only nil)
11414 (use-local-map (copy-keymap (current-local-map)))
11415 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11416 (buffer-enable-undo)
11418 (goto-char (point-min))
11419 (search-forward "\n\n" nil t)))
11421 (defun gnus-summary-edit-article-done ()
11422 "Make edits to the current article permanent."
11424 (if (gnus-group-read-only-p)
11426 (gnus-summary-edit-article-postpone)
11428 1 "The current newsgroup does not support article editing.")
11430 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
11433 (if (not (gnus-request-replace-article
11434 (cdr gnus-article-current) (car gnus-article-current)
11436 (error "Couldn't replace article.")
11437 (gnus-article-mode)
11438 (use-local-map gnus-article-mode-map)
11439 (setq buffer-read-only t)
11440 (buffer-disable-undo (current-buffer))
11441 (gnus-configure-windows 'summary)
11442 (gnus-summary-update-article (cdr gnus-article-current))
11443 (when gnus-use-cache
11444 (gnus-cache-update-article
11445 (cdr gnus-article-current) (car gnus-article-current))))
11446 (run-hooks 'gnus-article-display-hook)
11447 (and (gnus-visual-p 'summary-highlight 'highlight)
11448 (run-hooks 'gnus-visual-mark-article-hook)))))
11450 (defun gnus-summary-edit-article-postpone ()
11451 "Postpone changes to the current article."
11453 (gnus-article-mode)
11454 (use-local-map gnus-article-mode-map)
11455 (setq buffer-read-only t)
11456 (buffer-disable-undo (current-buffer))
11457 (gnus-configure-windows 'summary)
11458 (and (gnus-visual-p 'summary-highlight 'highlight)
11459 (run-hooks 'gnus-visual-mark-article-hook)))
11461 (defun gnus-summary-respool-query ()
11462 "Query where the respool algorithm would put this article."
11464 (gnus-set-global-variables)
11465 (gnus-summary-select-article)
11467 (set-buffer gnus-article-buffer)
11469 (goto-char (point-min))
11470 (search-forward "\n\n")
11471 (narrow-to-region (point-min) (point))
11472 (pp-eval-expression
11473 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11475 ;; Summary score commands.
11477 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11479 (defun gnus-summary-raise-score (n)
11480 "Raise the score of the current article by N."
11482 (gnus-set-global-variables)
11483 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11485 (defun gnus-summary-set-score (n)
11486 "Set the score of the current article to N."
11488 (gnus-set-global-variables)
11490 (gnus-summary-show-thread)
11491 (let ((buffer-read-only nil))
11493 (gnus-summary-update-mark
11494 (if (= n (or gnus-summary-default-score 0)) ?
11495 (if (< n (or gnus-summary-default-score 0))
11496 gnus-score-below-mark gnus-score-over-mark)) 'score))
11497 (let* ((article (gnus-summary-article-number))
11498 (score (assq article gnus-newsgroup-scored)))
11499 (if score (setcdr score n)
11500 (setq gnus-newsgroup-scored
11501 (cons (cons article n) gnus-newsgroup-scored))))
11502 (gnus-summary-update-line)))
11504 (defun gnus-summary-current-score ()
11505 "Return the score of the current article."
11507 (gnus-set-global-variables)
11508 (message "%s" (gnus-summary-article-score)))
11510 ;; Summary marking commands.
11512 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11513 "Mark articles which has the same subject as read, and then select the next.
11514 If UNMARK is positive, remove any kind of mark.
11515 If UNMARK is negative, tick articles."
11517 (gnus-set-global-variables)
11519 (setq unmark (prefix-numeric-value unmark)))
11521 (gnus-summary-mark-same-subject
11522 (gnus-summary-article-subject) unmark)))
11523 ;; Select next unread article. If auto-select-same mode, should
11524 ;; select the first unread article.
11525 (gnus-summary-next-article t (and gnus-auto-select-same
11526 (gnus-summary-article-subject)))
11527 (gnus-message 7 "%d article%s marked as %s"
11528 count (if (= count 1) " is" "s are")
11529 (if unmark "unread" "read"))))
11531 (defun gnus-summary-kill-same-subject (&optional unmark)
11532 "Mark articles which has the same subject as read.
11533 If UNMARK is positive, remove any kind of mark.
11534 If UNMARK is negative, tick articles."
11536 (gnus-set-global-variables)
11538 (setq unmark (prefix-numeric-value unmark)))
11540 (gnus-summary-mark-same-subject
11541 (gnus-summary-article-subject) unmark)))
11542 ;; If marked as read, go to next unread subject.
11544 ;; Go to next unread subject.
11545 (gnus-summary-next-subject 1 t))
11546 (gnus-message 7 "%d articles are marked as %s"
11547 count (if unmark "unread" "read"))))
11549 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11550 "Mark articles with same SUBJECT as read, and return marked number.
11551 If optional argument UNMARK is positive, remove any kinds of marks.
11552 If optional argument UNMARK is negative, mark articles as unread instead."
11556 ((null unmark) ; Mark as read.
11559 (gnus-summary-mark-article-as-read gnus-killed-mark)
11560 (gnus-summary-show-thread) t)
11561 (gnus-summary-find-subject subject))
11562 (setq count (1+ count))))
11563 ((> unmark 0) ; Tick.
11566 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11567 (gnus-summary-show-thread) t)
11568 (gnus-summary-find-subject subject))
11569 (setq count (1+ count))))
11570 (t ; Mark as unread.
11573 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11574 (gnus-summary-show-thread) t)
11575 (gnus-summary-find-subject subject))
11576 (setq count (1+ count)))))
11577 (gnus-set-mode-line 'summary)
11578 ;; Return the number of marked articles.
11581 (defun gnus-summary-mark-as-processable (n &optional unmark)
11582 "Set the process mark on the next N articles.
11583 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11584 the process mark instead. The difference between N and the actual
11585 number of articles marked is returned."
11587 (gnus-set-global-variables)
11588 (let ((backward (< n 0))
11593 (gnus-summary-remove-process-mark
11594 (gnus-summary-article-number))
11595 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11596 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11598 (if (/= 0 n) (gnus-message 7 "No more articles"))
11599 (gnus-summary-recenter)
11600 (gnus-summary-position-point)
11603 (defun gnus-summary-unmark-as-processable (n)
11604 "Remove the process mark from the next N articles.
11605 If N is negative, mark backward instead. The difference between N and
11606 the actual number of articles marked is returned."
11608 (gnus-set-global-variables)
11609 (gnus-summary-mark-as-processable n t))
11611 (defun gnus-summary-unmark-all-processable ()
11612 "Remove the process mark from all articles."
11614 (gnus-set-global-variables)
11616 (while gnus-newsgroup-processable
11617 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11618 (gnus-summary-position-point))
11620 (defun gnus-summary-mark-as-expirable (n)
11621 "Mark N articles forward as expirable.
11622 If N is negative, mark backward instead. The difference between N and
11623 the actual number of articles marked is returned."
11625 (gnus-set-global-variables)
11626 (gnus-summary-mark-forward n gnus-expirable-mark))
11628 (defun gnus-summary-mark-article-as-replied (article)
11629 "Mark ARTICLE replied and update the summary line."
11630 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11631 (let ((buffer-read-only nil))
11632 (when (gnus-summary-goto-subject article)
11633 (gnus-summary-update-secondary-mark article))))
11635 (defun gnus-summary-set-bookmark (article)
11636 "Set a bookmark in current article."
11637 (interactive (list (gnus-summary-article-number)))
11638 (gnus-set-global-variables)
11639 (if (or (not (get-buffer gnus-article-buffer))
11640 (not gnus-current-article)
11641 (not gnus-article-current)
11642 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11643 (error "No current article selected"))
11644 ;; Remove old bookmark, if one exists.
11645 (let ((old (assq article gnus-newsgroup-bookmarks)))
11646 (if old (setq gnus-newsgroup-bookmarks
11647 (delq old gnus-newsgroup-bookmarks))))
11648 ;; Set the new bookmark, which is on the form
11649 ;; (article-number . line-number-in-body).
11650 (setq gnus-newsgroup-bookmarks
11654 (set-buffer gnus-article-buffer)
11658 (goto-char (point-min))
11659 (search-forward "\n\n" nil t)
11662 gnus-newsgroup-bookmarks))
11663 (gnus-message 6 "A bookmark has been added to the current article."))
11665 (defun gnus-summary-remove-bookmark (article)
11666 "Remove the bookmark from the current article."
11667 (interactive (list (gnus-summary-article-number)))
11668 (gnus-set-global-variables)
11669 ;; Remove old bookmark, if one exists.
11670 (let ((old (assq article gnus-newsgroup-bookmarks)))
11673 (setq gnus-newsgroup-bookmarks
11674 (delq old gnus-newsgroup-bookmarks))
11675 (gnus-message 6 "Removed bookmark."))
11676 (gnus-message 6 "No bookmark in current article."))))
11678 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11679 (defun gnus-summary-mark-as-dormant (n)
11680 "Mark N articles forward as dormant.
11681 If N is negative, mark backward instead. The difference between N and
11682 the actual number of articles marked is returned."
11684 (gnus-set-global-variables)
11685 (gnus-summary-mark-forward n gnus-dormant-mark))
11687 (defun gnus-summary-set-process-mark (article)
11688 "Set the process mark on ARTICLE and update the summary line."
11689 (setq gnus-newsgroup-processable
11691 (delq article gnus-newsgroup-processable)))
11692 (when (gnus-summary-goto-subject article)
11693 (gnus-summary-show-thread)
11694 (gnus-summary-update-secondary-mark article)))
11696 (defun gnus-summary-remove-process-mark (article)
11697 "Remove the process mark from ARTICLE and update the summary line."
11698 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11699 (when (gnus-summary-goto-subject article)
11700 (gnus-summary-show-thread)
11701 (gnus-summary-update-secondary-mark article)))
11703 (defun gnus-summary-set-saved-mark (article)
11704 "Set the process mark on ARTICLE and update the summary line."
11705 (push article gnus-newsgroup-saved)
11706 (when (gnus-summary-goto-subject article)
11707 (gnus-summary-update-secondary-mark article)))
11709 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11710 "Mark N articles as read forwards.
11711 If N is negative, mark backwards instead.
11712 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11714 The difference between N and the actual number of articles marked is
11717 (gnus-set-global-variables)
11718 (let ((backward (< n 0))
11719 (gnus-summary-goto-unread
11720 (and gnus-summary-goto-unread
11721 (not (eq gnus-summary-goto-unread 'never))
11722 (not (memq mark (list gnus-unread-mark
11723 gnus-ticked-mark gnus-dormant-mark)))))
11725 (mark (or mark gnus-del-mark)))
11726 (while (and (> n 0)
11727 (gnus-summary-mark-article nil mark no-expire)
11728 (zerop (gnus-summary-next-subject
11730 (and gnus-summary-goto-unread
11731 (not (eq gnus-summary-goto-unread 'never)))
11734 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11735 (gnus-summary-recenter)
11736 (gnus-summary-position-point)
11737 (gnus-set-mode-line 'summary)
11740 (defun gnus-summary-mark-article-as-read (mark)
11741 "Mark the current article quickly as read with MARK."
11742 (let ((article (gnus-summary-article-number)))
11743 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11744 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11745 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11746 (setq gnus-newsgroup-reads
11747 (cons (cons article mark) gnus-newsgroup-reads))
11748 ;; Possibly remove from cache, if that is used.
11749 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11750 ;; Allow the backend to change the mark.
11751 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11752 ;; Check for auto-expiry.
11753 (when (and gnus-newsgroup-auto-expire
11754 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11755 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11756 (= mark gnus-ancient-mark)
11757 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11758 (setq mark gnus-expirable-mark)
11759 (push article gnus-newsgroup-expirable))
11760 ;; Set the mark in the buffer.
11761 (gnus-summary-update-mark mark 'unread)
11764 (defun gnus-summary-mark-article-as-unread (mark)
11765 "Mark the current article quickly as unread with MARK."
11766 (let ((article (gnus-summary-article-number)))
11767 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11768 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11769 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11770 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11771 (cond ((= mark gnus-ticked-mark)
11772 (push article gnus-newsgroup-marked))
11773 ((= mark gnus-dormant-mark)
11774 (push article gnus-newsgroup-dormant))
11776 (push article gnus-newsgroup-unreads)))
11777 (setq gnus-newsgroup-reads
11778 (delq (assq article gnus-newsgroup-reads)
11779 gnus-newsgroup-reads))
11781 ;; See whether the article is to be put in the cache.
11782 (and gnus-use-cache
11783 (vectorp (gnus-summary-article-header article))
11785 (gnus-cache-possibly-enter-article
11786 gnus-newsgroup-name article
11787 (gnus-summary-article-header article)
11788 (= mark gnus-ticked-mark)
11789 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11792 (gnus-summary-update-mark mark 'unread)
11795 (defun gnus-summary-mark-article (&optional article mark no-expire)
11796 "Mark ARTICLE with MARK. MARK can be any character.
11797 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11798 `??' (dormant) and `?E' (expirable).
11799 If MARK is nil, then the default character `?D' is used.
11800 If ARTICLE is nil, then the article on the current line will be
11802 ;; The mark might be a string.
11803 (and (stringp mark)
11804 (setq mark (aref mark 0)))
11805 ;; If no mark is given, then we check auto-expiring.
11806 (and (not no-expire)
11807 gnus-newsgroup-auto-expire
11809 (and (numberp mark)
11810 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11811 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11812 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11813 (setq mark gnus-expirable-mark))
11814 (let* ((mark (or mark gnus-del-mark))
11815 (article (or article (gnus-summary-article-number))))
11816 (or article (error "No article on current line"))
11817 (if (or (= mark gnus-unread-mark)
11818 (= mark gnus-ticked-mark)
11819 (= mark gnus-dormant-mark))
11820 (gnus-mark-article-as-unread article mark)
11821 (gnus-mark-article-as-read article mark))
11823 ;; See whether the article is to be put in the cache.
11824 (and gnus-use-cache
11825 (not (= mark gnus-canceled-mark))
11826 (vectorp (gnus-summary-article-header article))
11828 (gnus-cache-possibly-enter-article
11829 gnus-newsgroup-name article
11830 (gnus-summary-article-header article)
11831 (= mark gnus-ticked-mark)
11832 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11834 (if (gnus-summary-goto-subject article nil t)
11835 (let ((buffer-read-only nil))
11836 (gnus-summary-show-thread)
11838 (gnus-summary-update-mark mark 'unread)
11841 (defun gnus-summary-update-secondary-mark (article)
11842 "Update the secondary (read, process, cache) mark."
11843 (gnus-summary-update-mark
11844 (cond ((memq article gnus-newsgroup-processable)
11846 ((memq article gnus-newsgroup-cached)
11848 ((memq article gnus-newsgroup-replied)
11850 ((memq article gnus-newsgroup-saved)
11852 (t gnus-unread-mark))
11854 (when (gnus-visual-p 'summary-highlight 'highlight)
11855 (run-hooks 'gnus-summary-update-hook))
11858 (defun gnus-summary-update-mark (mark type)
11859 (beginning-of-line)
11860 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11861 (buffer-read-only nil))
11863 ;; Go to the right position on the line.
11864 (forward-char forward)
11865 ;; Replace the old mark with the new mark.
11866 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11867 ;; Optionally update the marks by some user rule.
11868 (when (eq type 'unread)
11869 (gnus-data-set-mark
11870 (gnus-data-find (gnus-summary-article-number)) mark)
11871 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11873 (defun gnus-mark-article-as-read (article &optional mark)
11874 "Enter ARTICLE in the pertinent lists and remove it from others."
11875 ;; Make the article expirable.
11876 (let ((mark (or mark gnus-del-mark)))
11877 (if (= mark gnus-expirable-mark)
11878 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11879 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11880 ;; Remove from unread and marked lists.
11881 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11882 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11883 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11884 (push (cons article mark) gnus-newsgroup-reads)
11885 ;; Possibly remove from cache, if that is used.
11886 (when gnus-use-cache
11887 (gnus-cache-enter-remove-article article))))
11889 (defun gnus-mark-article-as-unread (article &optional mark)
11890 "Enter ARTICLE in the pertinent lists and remove it from others."
11891 (let ((mark (or mark gnus-ticked-mark)))
11892 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11893 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11894 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11895 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11896 (cond ((= mark gnus-ticked-mark)
11897 (push article gnus-newsgroup-marked))
11898 ((= mark gnus-dormant-mark)
11899 (push article gnus-newsgroup-dormant))
11901 (push article gnus-newsgroup-unreads)))
11902 (setq gnus-newsgroup-reads
11903 (delq (assq article gnus-newsgroup-reads)
11904 gnus-newsgroup-reads))))
11906 (defalias 'gnus-summary-mark-as-unread-forward
11907 'gnus-summary-tick-article-forward)
11908 (make-obsolete 'gnus-summary-mark-as-unread-forward
11909 'gnus-summary-tick-article-forward)
11910 (defun gnus-summary-tick-article-forward (n)
11911 "Tick N articles forwards.
11912 If N is negative, tick backwards instead.
11913 The difference between N and the number of articles ticked is returned."
11915 (gnus-summary-mark-forward n gnus-ticked-mark))
11917 (defalias 'gnus-summary-mark-as-unread-backward
11918 'gnus-summary-tick-article-backward)
11919 (make-obsolete 'gnus-summary-mark-as-unread-backward
11920 'gnus-summary-tick-article-backward)
11921 (defun gnus-summary-tick-article-backward (n)
11922 "Tick N articles backwards.
11923 The difference between N and the number of articles ticked is returned."
11925 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11927 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11928 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11929 (defun gnus-summary-tick-article (&optional article clear-mark)
11930 "Mark current article as unread.
11931 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11932 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11934 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11935 gnus-ticked-mark)))
11937 (defun gnus-summary-mark-as-read-forward (n)
11938 "Mark N articles as read forwards.
11939 If N is negative, mark backwards instead.
11940 The difference between N and the actual number of articles marked is
11943 (gnus-summary-mark-forward n gnus-del-mark t))
11945 (defun gnus-summary-mark-as-read-backward (n)
11946 "Mark the N articles as read backwards.
11947 The difference between N and the actual number of articles marked is
11950 (gnus-summary-mark-forward (- n) gnus-del-mark t))
11952 (defun gnus-summary-mark-as-read (&optional article mark)
11953 "Mark current article as read.
11954 ARTICLE specifies the article to be marked as read.
11955 MARK specifies a string to be inserted at the beginning of the line."
11956 (gnus-summary-mark-article article mark))
11958 (defun gnus-summary-clear-mark-forward (n)
11959 "Clear marks from N articles forward.
11960 If N is negative, clear backward instead.
11961 The difference between N and the number of marks cleared is returned."
11963 (gnus-summary-mark-forward n gnus-unread-mark))
11965 (defun gnus-summary-clear-mark-backward (n)
11966 "Clear marks from N articles backward.
11967 The difference between N and the number of marks cleared is returned."
11969 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11971 (defun gnus-summary-mark-unread-as-read ()
11972 "Intended to be used by `gnus-summary-mark-article-hook'."
11973 (when (memq gnus-current-article gnus-newsgroup-unreads)
11974 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11976 (defun gnus-summary-mark-read-and-unread-as-read ()
11977 "Intended to be used by `gnus-summary-mark-article-hook'."
11978 (let ((mark (gnus-summary-article-mark)))
11979 (when (or (gnus-unread-mark-p mark)
11980 (gnus-read-mark-p mark))
11981 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
11983 (defun gnus-summary-mark-region-as-read (point mark all)
11984 "Mark all unread articles between point and mark as read.
11985 If given a prefix, mark all articles between point and mark as read,
11986 even ticked and dormant ones."
11987 (interactive "r\nP")
11991 (beginning-of-line)
11996 (memq (setq article (gnus-summary-article-number))
11997 gnus-newsgroup-unreads))
11998 (gnus-summary-mark-article article gnus-del-mark))
12000 (gnus-summary-find-next))))))
12002 (defun gnus-summary-mark-below (score mark)
12003 "Mark articles with score less than SCORE with MARK."
12004 (interactive "P\ncMark: ")
12005 (gnus-set-global-variables)
12006 (setq score (if score
12007 (prefix-numeric-value score)
12008 (or gnus-summary-default-score 0)))
12010 (set-buffer gnus-summary-buffer)
12011 (goto-char (point-min))
12014 (and (< (gnus-summary-article-score) score)
12015 (gnus-summary-mark-article nil mark))
12016 (gnus-summary-find-next)))))
12018 (defun gnus-summary-kill-below (&optional score)
12019 "Mark articles with score below SCORE as read."
12021 (gnus-set-global-variables)
12022 (gnus-summary-mark-below score gnus-killed-mark))
12024 (defun gnus-summary-clear-above (&optional score)
12025 "Clear all marks from articles with score above SCORE."
12027 (gnus-set-global-variables)
12028 (gnus-summary-mark-above score gnus-unread-mark))
12030 (defun gnus-summary-tick-above (&optional score)
12031 "Tick all articles with score above SCORE."
12033 (gnus-set-global-variables)
12034 (gnus-summary-mark-above score gnus-ticked-mark))
12036 (defun gnus-summary-mark-above (score mark)
12037 "Mark articles with score over SCORE with MARK."
12038 (interactive "P\ncMark: ")
12039 (gnus-set-global-variables)
12040 (setq score (if score
12041 (prefix-numeric-value score)
12042 (or gnus-summary-default-score 0)))
12044 (set-buffer gnus-summary-buffer)
12045 (goto-char (point-min))
12047 (if (> (gnus-summary-article-score) score)
12048 (gnus-summary-mark-article nil mark))
12050 (gnus-summary-find-next)))))
12052 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12053 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12054 (defun gnus-summary-limit-include-expunged ()
12055 "Display all the hidden articles that were expunged for low scores."
12057 (gnus-set-global-variables)
12058 (let ((buffer-read-only nil))
12059 (let ((scored gnus-newsgroup-scored)
12062 (or (gnus-summary-goto-subject (caar scored))
12063 (and (setq h (gnus-summary-article-header (caar scored)))
12064 (< (cdar scored) gnus-summary-expunge-below)
12065 (setq headers (cons h headers))))
12066 (setq scored (cdr scored)))
12067 (or headers (error "No expunged articles hidden."))
12068 (goto-char (point-min))
12069 (gnus-summary-prepare-unthreaded (nreverse headers)))
12070 (goto-char (point-min))
12071 (gnus-summary-position-point)))
12073 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12074 "Mark all articles not marked as unread in this newsgroup as read.
12075 If prefix argument ALL is non-nil, all articles are marked as read.
12076 If QUIETLY is non-nil, no questions will be asked.
12077 If TO-HERE is non-nil, it should be a point in the buffer. All
12078 articles before this point will be marked as read.
12079 The number of articles marked as read is returned."
12081 (gnus-set-global-variables)
12084 (not gnus-interactive-catchup) ;Without confirmation?
12088 "Mark absolutely all articles as read? "
12089 "Mark all unread articles as read? ")))
12091 (not gnus-newsgroup-adaptive)
12092 (not gnus-newsgroup-auto-expire))
12095 (setq gnus-newsgroup-marked nil
12096 gnus-newsgroup-dormant nil))
12097 (setq gnus-newsgroup-unreads nil))
12098 ;; We actually mark all articles as canceled, which we
12099 ;; have to do when using auto-expiry or adaptive scoring.
12100 (gnus-summary-show-all-threads)
12101 (if (gnus-summary-first-subject (not all))
12103 (if to-here (< (point) to-here) t)
12104 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12105 (gnus-summary-find-next (not all)))))
12107 (setq gnus-newsgroup-unreads nil))
12108 (gnus-set-mode-line 'summary)))
12109 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12110 (if (and (not to-here) (eq 'nnvirtual (car method)))
12111 (nnvirtual-catchup-group
12112 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12113 (gnus-summary-position-point)))
12115 (defun gnus-summary-catchup-to-here (&optional all)
12116 "Mark all unticked articles before the current one as read.
12117 If ALL is non-nil, also mark ticked and dormant articles as read."
12119 (gnus-set-global-variables)
12121 (let ((beg (point)))
12122 ;; We check that there are unread articles.
12123 (when (or all (gnus-summary-find-prev))
12124 (gnus-summary-catchup all t beg))))
12125 (gnus-summary-position-point))
12127 (defun gnus-summary-catchup-all (&optional quietly)
12128 "Mark all articles in this newsgroup as read."
12130 (gnus-set-global-variables)
12131 (gnus-summary-catchup t quietly))
12133 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12134 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12135 If prefix argument ALL is non-nil, all articles are marked as read."
12137 (gnus-set-global-variables)
12138 (gnus-summary-catchup all quietly nil 'fast)
12139 ;; Select next newsgroup or exit.
12140 (if (eq gnus-auto-select-next 'quietly)
12141 (gnus-summary-next-group nil)
12142 (gnus-summary-exit)))
12144 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12145 "Mark all articles in this newsgroup as read, and then exit."
12147 (gnus-set-global-variables)
12148 (gnus-summary-catchup-and-exit t quietly))
12150 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12151 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12152 "Mark all articles in this group as read and select the next group.
12153 If given a prefix, mark all articles, unread as well as ticked, as
12156 (gnus-set-global-variables)
12158 (gnus-summary-catchup all))
12159 (gnus-summary-next-article t nil nil t))
12161 ;; Thread-based commands.
12163 (defun gnus-summary-articles-in-thread (&optional article)
12164 "Return a list of all articles in the current thread.
12165 If ARTICLE is non-nil, return all articles in the thread that starts
12166 with that article."
12167 (let* ((article (or article (gnus-summary-article-number)))
12168 (data (gnus-data-find-list article))
12169 (top-level (gnus-data-level (car data)))
12171 (cond ((null gnus-thread-operation-ignore-subject)
12172 (gnus-simplify-subject-re
12173 (mail-header-subject (gnus-data-header (car data)))))
12174 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12175 (gnus-simplify-subject-fuzzy
12176 (mail-header-subject (gnus-data-header (car data)))))
12180 () ; This article doesn't exist.
12182 (and (or (not top-subject)
12183 (string= top-subject
12184 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12185 (gnus-simplify-subject-fuzzy
12186 (mail-header-subject
12187 (gnus-data-header (car data))))
12188 (gnus-simplify-subject-re
12189 (mail-header-subject
12190 (gnus-data-header (car data)))))))
12191 (setq articles (cons (gnus-data-number (car data)) articles)))
12192 (if (and (setq data (cdr data))
12193 (> (gnus-data-level (car data)) top-level))
12196 ;; Return the list of articles.
12197 (nreverse articles))))
12199 (defun gnus-summary-rethread-current ()
12200 "Rethread the thread the current article is part of."
12202 (gnus-set-global-variables)
12203 (let* ((gnus-show-threads t)
12204 (article (gnus-summary-article-number))
12205 (id (mail-header-id (gnus-summary-article-header)))
12206 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12208 (error "No article on the current line"))
12209 (gnus-rebuild-thread id)
12210 (gnus-summary-goto-subject article)))
12212 (defun gnus-summary-reparent-thread ()
12213 "Make current article child of the marked (or previous) article.
12215 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12216 is non-nil or the Subject: of both articles are the same."
12218 (or (not (gnus-group-read-only-p))
12219 (error "The current newsgroup does not support article editing."))
12220 (or (<= (length gnus-newsgroup-processable) 1)
12221 (error "No more than one article may be marked."))
12222 (save-window-excursion
12223 (let ((gnus-article-buffer " *reparent*")
12224 (current-article (gnus-summary-article-number))
12225 ; first grab the marked article, otherwise one line up.
12226 (parent-article (if (not (null gnus-newsgroup-processable))
12227 (car gnus-newsgroup-processable)
12229 (if (eq (forward-line -1) 0)
12230 (gnus-summary-article-number)
12231 (error "Beginning of summary buffer."))))))
12232 (or (not (eq current-article parent-article))
12233 (error "An article may not be self-referential."))
12234 (let ((message-id (mail-header-id
12235 (gnus-summary-article-header parent-article))))
12236 (or (and message-id (not (equal message-id "")))
12237 (error "No message-id in desired parent."))
12238 (gnus-summary-select-article t t nil current-article)
12239 (set-buffer gnus-article-buffer)
12240 (setq buffer-read-only nil)
12241 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
12244 (goto-char (point-min))
12245 (if (search-forward-regexp "^References: " nil t)
12246 (insert message-id " " )
12247 (insert "References: " message-id "\n"))
12248 (or (gnus-request-replace-article current-article
12249 (car gnus-article-current)
12250 gnus-article-buffer)
12251 (error "Couldn't replace article."))
12252 (set-buffer gnus-summary-buffer)
12253 (gnus-summary-unmark-all-processable)
12254 (gnus-summary-rethread-current)
12255 (message "Article %d is now the child of article %d."
12256 current-article parent-article)))))
12258 (defun gnus-summary-toggle-threads (&optional arg)
12259 "Toggle showing conversation threads.
12260 If ARG is positive number, turn showing conversation threads on."
12262 (gnus-set-global-variables)
12263 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12264 (setq gnus-show-threads
12265 (if (null arg) (not gnus-show-threads)
12266 (> (prefix-numeric-value arg) 0)))
12267 (gnus-summary-prepare)
12268 (gnus-summary-goto-subject current)
12269 (gnus-summary-position-point)))
12271 (defun gnus-summary-show-all-threads ()
12272 "Show all threads."
12274 (gnus-set-global-variables)
12276 (let ((buffer-read-only nil))
12277 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12278 (gnus-summary-position-point))
12280 (defun gnus-summary-show-thread ()
12281 "Show thread subtrees.
12282 Returns nil if no thread was there to be shown."
12284 (gnus-set-global-variables)
12285 (let ((buffer-read-only nil)
12287 ;; first goto end then to beg, to have point at beg after let
12288 (end (progn (end-of-line) (point)))
12289 (beg (progn (beginning-of-line) (point))))
12291 ;; Any hidden lines here?
12292 (search-forward "\r" end t)
12293 (subst-char-in-region beg end ?\^M ?\n t)
12295 (gnus-summary-position-point))))
12297 (defun gnus-summary-hide-all-threads ()
12298 "Hide all thread subtrees."
12300 (gnus-set-global-variables)
12302 (goto-char (point-min))
12303 (gnus-summary-hide-thread)
12304 (while (zerop (gnus-summary-next-thread 1 t))
12305 (gnus-summary-hide-thread)))
12306 (gnus-summary-position-point))
12308 (defun gnus-summary-hide-thread ()
12309 "Hide thread subtrees.
12310 Returns nil if no threads were there to be hidden."
12312 (gnus-set-global-variables)
12313 (let ((buffer-read-only nil)
12315 (article (gnus-summary-article-number))
12318 ;; Go forward until either the buffer ends or the subthread
12320 (when (and (not (eobp))
12321 (or (zerop (gnus-summary-next-thread 1 t))
12322 (goto-char (point-max))))
12325 (if (and (> (point) start)
12326 (search-backward "\n" start t))
12328 (subst-char-in-region start (point) ?\n ?\^M)
12329 (gnus-summary-goto-subject article))
12332 ;;(gnus-summary-position-point)
12335 (defun gnus-summary-go-to-next-thread (&optional previous)
12336 "Go to the same level (or less) next thread.
12337 If PREVIOUS is non-nil, go to previous thread instead.
12338 Return the article number moved to, or nil if moving was impossible."
12339 (let* ((level (gnus-summary-thread-level))
12340 (article (gnus-summary-article-number))
12341 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12344 (if (<= (gnus-data-level (car data)) level)
12345 (setq oart (gnus-data-number (car data))
12347 (setq data (cdr data))))
12349 (gnus-summary-goto-subject oart))))
12351 (defun gnus-summary-next-thread (n &optional silent)
12352 "Go to the same level next N'th thread.
12353 If N is negative, search backward instead.
12354 Returns the difference between N and the number of skips actually
12357 If SILENT, don't output messages."
12359 (gnus-set-global-variables)
12360 (let ((backward (< n 0))
12363 (while (and (> n 0)
12364 (setq old (save-excursion
12366 (setq int (gnus-summary-article-intangible-p))
12369 (gnus-summary-go-to-next-thread backward)))
12370 (when (and (eq gnus-summary-make-false-root 'dummy)
12371 (setq dum (text-property-not-all
12372 old (point) 'gnus-intangible nil)))
12376 (gnus-summary-position-point))
12377 (when (and (not silent) (/= 0 n))
12378 (gnus-message 7 "No more threads"))
12381 (defun gnus-summary-prev-thread (n)
12382 "Go to the same level previous N'th thread.
12383 Returns the difference between N and the number of skips actually
12386 (gnus-set-global-variables)
12387 (gnus-summary-next-thread (- n)))
12389 (defun gnus-summary-go-down-thread ()
12390 "Go down one level in the current thread."
12391 (let ((children (gnus-summary-article-children)))
12393 (gnus-summary-goto-subject (car children)))))
12395 (defun gnus-summary-go-up-thread ()
12396 "Go up one level in the current thread."
12397 (let ((parent (gnus-summary-article-parent)))
12399 (gnus-summary-goto-subject parent))))
12401 (defun gnus-summary-down-thread (n)
12402 "Go down thread N steps.
12403 If N is negative, go up instead.
12404 Returns the difference between N and how many steps down that were
12407 (gnus-set-global-variables)
12410 (while (and (> n 0)
12411 (if up (gnus-summary-go-up-thread)
12412 (gnus-summary-go-down-thread)))
12414 (gnus-summary-position-point)
12415 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12418 (defun gnus-summary-up-thread (n)
12419 "Go up thread N steps.
12420 If N is negative, go up instead.
12421 Returns the difference between N and how many steps down that were
12424 (gnus-set-global-variables)
12425 (gnus-summary-down-thread (- n)))
12427 (defun gnus-summary-top-thread ()
12428 "Go to the top of the thread."
12430 (gnus-set-global-variables)
12431 (while (gnus-summary-go-up-thread))
12432 (gnus-summary-article-number))
12434 (defun gnus-summary-kill-thread (&optional unmark)
12435 "Mark articles under current thread as read.
12436 If the prefix argument is positive, remove any kinds of marks.
12437 If the prefix argument is negative, tick articles instead."
12439 (gnus-set-global-variables)
12441 (setq unmark (prefix-numeric-value unmark)))
12442 (let ((articles (gnus-summary-articles-in-thread)))
12444 ;; Expand the thread.
12445 (gnus-summary-show-thread)
12446 ;; Mark all the articles.
12448 (gnus-summary-goto-subject (car articles))
12449 (cond ((null unmark)
12450 (gnus-summary-mark-article-as-read gnus-killed-mark))
12452 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12454 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12455 (setq articles (cdr articles))))
12456 ;; Hide killed subtrees.
12458 gnus-thread-hide-killed
12459 (gnus-summary-hide-thread))
12460 ;; If marked as read, go to next unread subject.
12462 ;; Go to next unread subject.
12463 (gnus-summary-next-subject 1 t)))
12464 (gnus-set-mode-line 'summary))
12466 ;; Summary sorting commands
12468 (defun gnus-summary-sort-by-number (&optional reverse)
12469 "Sort summary buffer by article number.
12470 Argument REVERSE means reverse order."
12472 (gnus-summary-sort 'number reverse))
12474 (defun gnus-summary-sort-by-author (&optional reverse)
12475 "Sort summary buffer by author name alphabetically.
12476 If case-fold-search is non-nil, case of letters is ignored.
12477 Argument REVERSE means reverse order."
12479 (gnus-summary-sort 'author reverse))
12481 (defun gnus-summary-sort-by-subject (&optional reverse)
12482 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12483 If case-fold-search is non-nil, case of letters is ignored.
12484 Argument REVERSE means reverse order."
12486 (gnus-summary-sort 'subject reverse))
12488 (defun gnus-summary-sort-by-date (&optional reverse)
12489 "Sort summary buffer by date.
12490 Argument REVERSE means reverse order."
12492 (gnus-summary-sort 'date reverse))
12494 (defun gnus-summary-sort-by-score (&optional reverse)
12495 "Sort summary buffer by score.
12496 Argument REVERSE means reverse order."
12498 (gnus-summary-sort 'score reverse))
12500 (defun gnus-summary-sort (predicate reverse)
12501 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12502 (gnus-set-global-variables)
12503 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12504 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12505 (gnus-thread-sort-functions
12510 (,thread t2 t1)))))
12511 (gnus-article-sort-functions
12516 (,article t2 t1)))))
12518 (gnus-summary-prepare-hook nil))
12519 ;; We do the sorting by regenerating the threads.
12520 (gnus-summary-prepare)
12521 ;; Hide subthreads if needed.
12522 (when (and gnus-show-threads gnus-thread-hide-subtree)
12523 (gnus-summary-hide-all-threads)))
12524 ;; If in async mode, we send some info to the backend.
12525 (when gnus-newsgroup-async
12526 (gnus-request-asynchronous
12527 gnus-newsgroup-name gnus-newsgroup-data)))
12529 (defun gnus-sortable-date (date)
12530 "Make sortable string by string-lessp from DATE.
12531 Timezone package is used."
12532 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12533 (year (aref date 0))
12534 (month (aref date 1))
12535 (day (aref date 2)))
12536 (timezone-make-sortable-date
12538 (timezone-make-time-string
12539 (aref date 3) (aref date 4) (aref date 5)))))
12541 ;; Summary saving commands.
12543 (defun gnus-summary-save-article (&optional n not-saved)
12544 "Save the current article using the default saver function.
12545 If N is a positive number, save the N next articles.
12546 If N is a negative number, save the N previous articles.
12547 If N is nil and any articles have been marked with the process mark,
12548 save those articles instead.
12549 The variable `gnus-default-article-saver' specifies the saver function."
12551 (gnus-set-global-variables)
12552 (let ((articles (gnus-summary-work-articles n))
12553 file header article)
12555 (setq header (gnus-summary-article-header
12556 (setq article (pop articles))))
12557 (if (not (vectorp header))
12558 ;; This is a pseudo-article.
12559 (if (assq 'name header)
12560 (gnus-copy-file (cdr (assq 'name header)))
12561 (gnus-message 1 "Article %d is unsaveable" article))
12562 ;; This is a real article.
12563 (save-window-excursion
12564 (gnus-summary-select-article t nil nil article))
12565 (unless gnus-save-all-headers
12566 ;; Remove headers accoring to `gnus-saved-headers'.
12567 (let ((gnus-visible-headers
12568 (or gnus-saved-headers gnus-visible-headers)))
12569 (gnus-article-hide-headers nil t)))
12570 ;; Remove any X-Gnus lines.
12572 (set-buffer gnus-article-buffer)
12574 (let ((buffer-read-only nil))
12575 (nnheader-narrow-to-headers)
12576 (while (re-search-forward "^X-Gnus" nil t)
12577 (gnus-delete-line)))))
12578 (save-window-excursion
12579 (if (not gnus-default-article-saver)
12580 (error "No default saver is defined.")
12581 (setq file (funcall
12582 gnus-default-article-saver
12584 ((not gnus-prompt-before-saving)
12586 ((eq gnus-prompt-before-saving 'always)
12589 (gnus-summary-remove-process-mark article)
12591 (gnus-summary-set-saved-mark article))))
12592 (gnus-summary-position-point)
12595 (defun gnus-summary-pipe-output (&optional arg)
12596 "Pipe the current article to a subprocess.
12597 If N is a positive number, pipe the N next articles.
12598 If N is a negative number, pipe the N previous articles.
12599 If N is nil and any articles have been marked with the process mark,
12600 pipe those articles instead."
12602 (gnus-set-global-variables)
12603 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12604 (gnus-summary-save-article arg t))
12605 (gnus-configure-windows 'pipe))
12607 (defun gnus-summary-save-article-mail (&optional arg)
12608 "Append the current article to an mail file.
12609 If N is a positive number, save the N next articles.
12610 If N is a negative number, save the N previous articles.
12611 If N is nil and any articles have been marked with the process mark,
12612 save those articles instead."
12614 (gnus-set-global-variables)
12615 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12616 (gnus-summary-save-article arg)))
12618 (defun gnus-summary-save-article-rmail (&optional arg)
12619 "Append the current article to an rmail file.
12620 If N is a positive number, save the N next articles.
12621 If N is a negative number, save the N previous articles.
12622 If N is nil and any articles have been marked with the process mark,
12623 save those articles instead."
12625 (gnus-set-global-variables)
12626 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12627 (gnus-summary-save-article arg)))
12629 (defun gnus-summary-save-article-file (&optional arg)
12630 "Append the current article to a file.
12631 If N is a positive number, save the N next articles.
12632 If N is a negative number, save the N previous articles.
12633 If N is nil and any articles have been marked with the process mark,
12634 save those articles instead."
12636 (gnus-set-global-variables)
12637 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12638 (gnus-summary-save-article arg)))
12640 (defun gnus-summary-save-article-body-file (&optional arg)
12641 "Append the current article body to a file.
12642 If N is a positive number, save the N next articles.
12643 If N is a negative number, save the N previous articles.
12644 If N is nil and any articles have been marked with the process mark,
12645 save those articles instead."
12647 (gnus-set-global-variables)
12648 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12649 (gnus-summary-save-article arg)))
12651 (defun gnus-get-split-value (methods)
12652 "Return a value based on the split METHODS."
12653 (let (split-name method result match)
12656 (set-buffer gnus-original-article-buffer)
12658 (nnheader-narrow-to-headers)
12660 (goto-char (point-min))
12661 (setq method (pop methods))
12662 (setq match (pop method))
12665 ;; Regular expression.
12667 (re-search-forward match nil t)
12669 ((gnus-functionp match)
12673 (setq result (funcall match gnus-newsgroup-name))))
12678 (setq result (eval match)))))
12679 (setq split-name (append (cdr methods) split-name))
12680 (cond ((stringp result)
12681 (push result split-name))
12683 (setq split-name (append result split-name)))))))))
12686 (defun gnus-read-move-group-name (prompt default articles prefix)
12687 "Read a group name."
12688 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12690 (format "Where do you want to %s %s? "
12692 (if (> (length articles) 1)
12693 (format "these %d articles" (length articles))
12701 (format "(default %s) " default)
12703 gnus-active-hashtb nil nil prefix))
12704 ((= 1 (length split-name))
12705 (completing-read prom gnus-active-hashtb
12706 nil nil (cons (car split-name) 0)))
12709 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12712 (if (or (string= to-newsgroup "")
12713 (string= to-newsgroup prefix))
12714 (setq to-newsgroup (or default "")))
12715 (or (gnus-active to-newsgroup)
12716 (gnus-activate-group to-newsgroup)
12717 (error "No such group: %s" to-newsgroup)))
12720 (defun gnus-read-save-file-name (prompt default-name)
12721 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12723 ;; Let the split methods have their say.
12725 ;; No split name was found.
12728 (concat prompt " (default "
12729 (file-name-nondirectory default-name) ") ")
12730 (file-name-directory default-name)
12732 ;; A single split name was found
12733 ((= 1 (length split-name))
12735 (concat prompt " (default " (car split-name) ") ")
12736 gnus-article-save-directory
12737 (concat gnus-article-save-directory (car split-name))))
12738 ;; A list of splits was found.
12740 (setq split-name (mapcar (lambda (el) (list el))
12741 (nreverse split-name)))
12742 (let ((result (completing-read
12743 (concat prompt " ") split-name nil nil)))
12744 (concat gnus-article-save-directory
12745 (if (string= result "")
12748 ;; If we have read a directory, we append the default file name.
12749 (when (file-directory-p file)
12750 (setq file (concat (file-name-as-directory file)
12751 (file-name-nondirectory default-name))))
12752 ;; Possibly translate some charaters.
12753 (nnheader-translate-file-chars file)))
12755 (defun gnus-article-archive-name (group)
12756 "Return the first instance of an \"Archive-name\" in the current buffer."
12757 (let ((case-fold-search t))
12758 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12759 (match-string 1))))
12761 (defun gnus-summary-save-in-rmail (&optional filename)
12762 "Append this article to Rmail file.
12763 Optional argument FILENAME specifies file name.
12764 Directory to save to is default to `gnus-article-save-directory' which
12765 is initialized from the SAVEDIR environment variable."
12767 (gnus-set-global-variables)
12768 (let ((default-name
12769 (funcall gnus-rmail-save-name gnus-newsgroup-name
12770 gnus-current-headers gnus-newsgroup-last-rmail)))
12772 (cond ((eq filename 'default)
12774 (filename filename)
12775 (t (gnus-read-save-file-name
12776 "Save in rmail file:" default-name))))
12777 (gnus-make-directory (file-name-directory filename))
12778 (gnus-eval-in-buffer-window
12779 gnus-original-article-buffer
12783 (gnus-output-to-rmail filename))))
12784 ;; Remember the directory name to save articles
12785 (setq gnus-newsgroup-last-rmail filename)))
12787 (defun gnus-summary-save-in-mail (&optional filename)
12788 "Append this article to Unix mail file.
12789 Optional argument FILENAME specifies file name.
12790 Directory to save to is default to `gnus-article-save-directory' which
12791 is initialized from the SAVEDIR environment variable."
12793 (gnus-set-global-variables)
12794 (let ((default-name
12795 (funcall gnus-mail-save-name gnus-newsgroup-name
12796 gnus-current-headers gnus-newsgroup-last-mail)))
12798 (cond ((eq filename 'default)
12800 (filename filename)
12801 (t (gnus-read-save-file-name
12802 "Save in Unix mail file:" default-name))))
12804 (expand-file-name filename
12806 (file-name-directory default-name))))
12807 (gnus-make-directory (file-name-directory filename))
12808 (gnus-eval-in-buffer-window
12809 gnus-original-article-buffer
12813 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12814 (gnus-output-to-rmail filename)
12815 (let ((mail-use-rfc822 t))
12816 (rmail-output filename 1 t t))))))
12817 ;; Remember the directory name to save articles.
12818 (setq gnus-newsgroup-last-mail filename)))
12820 (defun gnus-summary-save-in-file (&optional filename)
12821 "Append this article to file.
12822 Optional argument FILENAME specifies file name.
12823 Directory to save to is default to `gnus-article-save-directory' which
12824 is initialized from the SAVEDIR environment variable."
12826 (gnus-set-global-variables)
12827 (let ((default-name
12828 (funcall gnus-file-save-name gnus-newsgroup-name
12829 gnus-current-headers gnus-newsgroup-last-file)))
12831 (cond ((eq filename 'default)
12833 (filename filename)
12834 (t (gnus-read-save-file-name
12835 "Save in file:" default-name))))
12836 (gnus-make-directory (file-name-directory filename))
12837 (gnus-eval-in-buffer-window
12838 gnus-original-article-buffer
12842 (gnus-output-to-file filename))))
12843 ;; Remember the directory name to save articles.
12844 (setq gnus-newsgroup-last-file filename)))
12846 (defun gnus-summary-save-body-in-file (&optional filename)
12847 "Append this article body to a file.
12848 Optional argument FILENAME specifies file name.
12849 The directory to save in defaults to `gnus-article-save-directory' which
12850 is initialized from the SAVEDIR environment variable."
12852 (gnus-set-global-variables)
12853 (let ((default-name
12854 (funcall gnus-file-save-name gnus-newsgroup-name
12855 gnus-current-headers gnus-newsgroup-last-file)))
12857 (cond ((eq filename 'default)
12859 (filename filename)
12860 (t (gnus-read-save-file-name
12861 "Save body in file:" default-name))))
12862 (gnus-make-directory (file-name-directory filename))
12863 (gnus-eval-in-buffer-window
12864 gnus-article-buffer
12868 (goto-char (point-min))
12869 (and (search-forward "\n\n" nil t)
12870 (narrow-to-region (point) (point-max)))
12871 (gnus-output-to-file filename))))
12872 ;; Remember the directory name to save articles.
12873 (setq gnus-newsgroup-last-file filename)))
12875 (defun gnus-summary-save-in-pipe (&optional command)
12876 "Pipe this article to subprocess."
12878 (gnus-set-global-variables)
12880 (cond ((eq command 'default)
12881 gnus-last-shell-command)
12883 (t (read-string "Shell command on article: "
12884 gnus-last-shell-command))))
12885 (if (string-equal command "")
12886 (setq command gnus-last-shell-command))
12887 (gnus-eval-in-buffer-window
12888 gnus-article-buffer
12891 (shell-command-on-region (point-min) (point-max) command nil)))
12892 (setq gnus-last-shell-command command))
12894 ;; Summary extract commands
12896 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12897 (let ((buffer-read-only nil)
12898 (article (gnus-summary-article-number))
12900 (or (gnus-summary-goto-subject article)
12901 (error (format "No such article: %d" article)))
12902 (gnus-summary-position-point)
12903 ;; If all commands are to be bunched up on one line, we collect
12905 (if gnus-view-pseudos-separately
12907 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12910 (setq action (cdr (assq 'action (car ps))))
12911 (setq files (list (cdr (assq 'name (car ps)))))
12912 (while (and ps (cdr ps)
12913 (string= (or action "1")
12914 (or (cdr (assq 'action (cadr ps))) "2")))
12915 (setq files (cons (cdr (assq 'name (cadr ps))) files))
12916 (setcdr ps (cddr ps)))
12919 (if (not (string-match "%s" action))
12920 (setq files (cons " " files)))
12921 (setq files (cons " " files))
12922 (and (assq 'execute (car ps))
12923 (setcdr (assq 'execute (car ps))
12924 (funcall (if (string-match "%s" action)
12927 (mapconcat (lambda (f) f) files " ")))))
12928 (setq ps (cdr ps)))))
12929 (if (and gnus-view-pseudos (not not-view))
12931 (and (assq 'execute (car pslist))
12932 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12933 (eq gnus-view-pseudos 'not-confirm)))
12934 (setq pslist (cdr pslist)))
12937 (setq after-article (or (cdr (assq 'article (car pslist)))
12938 (gnus-summary-article-number)))
12939 (gnus-summary-goto-subject after-article)
12942 (insert " " (file-name-nondirectory
12943 (cdr (assq 'name (car pslist))))
12944 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12946 (forward-line -1) ; back to `b'
12947 (add-text-properties
12948 b e (list 'gnus-number gnus-reffed-article-number
12949 gnus-mouse-face-prop gnus-mouse-face))
12951 after-article gnus-reffed-article-number
12952 gnus-unread-mark b (car pslist) 0 (- e b))
12953 (push gnus-reffed-article-number gnus-newsgroup-unreads)
12954 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12955 (setq pslist (cdr pslist)))))))
12957 (defun gnus-pseudos< (p1 p2)
12958 (let ((c1 (cdr (assq 'action p1)))
12959 (c2 (cdr (assq 'action p2))))
12960 (and c1 c2 (string< c1 c2))))
12962 (defun gnus-request-pseudo-article (props)
12963 (cond ((assq 'execute props)
12964 (gnus-execute-command (cdr (assq 'execute props)))))
12965 (let ((gnus-current-article (gnus-summary-article-number)))
12966 (run-hooks 'gnus-mark-article-hook)))
12968 (defun gnus-execute-command (command &optional automatic)
12970 (gnus-article-setup-buffer)
12971 (set-buffer gnus-article-buffer)
12972 (let ((command (if automatic command (read-string "Command: " command)))
12973 (buffer-read-only nil))
12975 (insert "$ " command "\n\n")
12976 (if gnus-view-pseudo-asynchronously
12977 (start-process "gnus-execute" nil "sh" "-c" command)
12978 (call-process "sh" nil t nil "-c" command)))))
12980 (defun gnus-copy-file (file &optional to)
12983 (list (read-file-name "Copy file: " default-directory)
12984 (read-file-name "Copy file to: " default-directory)))
12985 (gnus-set-global-variables)
12986 (or to (setq to (read-file-name "Copy file to: " default-directory)))
12987 (and (file-directory-p to)
12988 (setq to (concat (file-name-as-directory to)
12989 (file-name-nondirectory file))))
12990 (copy-file file to))
12992 ;; Summary kill commands.
12994 (defun gnus-summary-edit-global-kill (article)
12995 "Edit the \"global\" kill file."
12996 (interactive (list (gnus-summary-article-number)))
12997 (gnus-set-global-variables)
12998 (gnus-group-edit-global-kill article))
13000 (defun gnus-summary-edit-local-kill ()
13001 "Edit a local kill file applied to the current newsgroup."
13003 (gnus-set-global-variables)
13004 (setq gnus-current-headers (gnus-summary-article-header))
13005 (gnus-set-global-variables)
13006 (gnus-group-edit-local-kill
13007 (gnus-summary-article-number) gnus-newsgroup-name))
13011 ;;; Gnus article mode
13014 (put 'gnus-article-mode 'mode-class 'special)
13016 (if gnus-article-mode-map
13018 (setq gnus-article-mode-map (make-keymap))
13019 (suppress-keymap gnus-article-mode-map)
13021 (gnus-define-keys gnus-article-mode-map
13022 " " gnus-article-goto-next-page
13023 "\177" gnus-article-goto-prev-page
13024 [delete] gnus-article-goto-prev-page
13025 "\C-c^" gnus-article-refer-article
13026 "h" gnus-article-show-summary
13027 "s" gnus-article-show-summary
13028 "\C-c\C-m" gnus-article-mail
13029 "?" gnus-article-describe-briefly
13030 gnus-mouse-2 gnus-article-push-button
13031 "\r" gnus-article-press-button
13032 "\t" gnus-article-next-button
13033 "\M-\t" gnus-article-prev-button
13034 "\C-c\C-b" gnus-bug)
13036 (substitute-key-definition
13037 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13039 (defun gnus-article-mode ()
13040 "Major mode for displaying an article.
13042 All normal editing commands are switched off.
13044 The following commands are available:
13046 \\<gnus-article-mode-map>
13047 \\[gnus-article-next-page]\t Scroll the article one page forwards
13048 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13049 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13050 \\[gnus-article-show-summary]\t Display the summary buffer
13051 \\[gnus-article-mail]\t Send a reply to the address near point
13052 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13053 \\[gnus-info-find-node]\t Go to the Gnus info node"
13055 (when (and menu-bar-mode
13056 (gnus-visual-p 'article-menu 'menu))
13057 (gnus-article-make-menu-bar))
13058 (kill-all-local-variables)
13059 (gnus-simplify-mode-line)
13060 (setq mode-name "Article")
13061 (setq major-mode 'gnus-article-mode)
13062 (make-local-variable 'minor-mode-alist)
13063 (or (assq 'gnus-show-mime minor-mode-alist)
13064 (setq minor-mode-alist
13065 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13066 (use-local-map gnus-article-mode-map)
13067 (make-local-variable 'page-delimiter)
13068 (setq page-delimiter gnus-page-delimiter)
13069 (buffer-disable-undo (current-buffer))
13070 (setq buffer-read-only t) ;Disable modification
13071 (run-hooks 'gnus-article-mode-hook))
13073 (defun gnus-article-setup-buffer ()
13074 "Initialize the article buffer."
13075 (let* ((name (if gnus-single-article-buffer "*Article*"
13076 (concat "*Article " gnus-newsgroup-name "*")))
13078 (progn (string-match "\\*Article" name)
13079 (concat " *Original Article"
13080 (substring name (match-end 0))))))
13081 (setq gnus-article-buffer name)
13082 (setq gnus-original-article-buffer original)
13083 ;; This might be a variable local to the summary buffer.
13084 (unless gnus-single-article-buffer
13086 (set-buffer gnus-summary-buffer)
13087 (setq gnus-article-buffer name)
13088 (setq gnus-original-article-buffer original)
13089 (gnus-set-global-variables))
13090 (make-local-variable 'gnus-summary-buffer))
13091 (if (get-buffer name)
13094 (buffer-disable-undo (current-buffer))
13095 (setq buffer-read-only t)
13096 (gnus-add-current-to-buffer-list)
13097 (or (eq major-mode 'gnus-article-mode)
13098 (gnus-article-mode))
13101 (set-buffer (get-buffer-create name))
13102 (gnus-add-current-to-buffer-list)
13103 (gnus-article-mode)
13104 (current-buffer)))))
13106 ;; Set article window start at LINE, where LINE is the number of lines
13107 ;; from the head of the article.
13108 (defun gnus-article-set-window-start (&optional line)
13110 (get-buffer-window gnus-article-buffer)
13112 (set-buffer gnus-article-buffer)
13113 (goto-char (point-min))
13116 (gnus-message 6 "Moved to bookmark")
13117 (search-forward "\n\n" nil t)
13118 (forward-line line)
13121 (defun gnus-kill-all-overlays ()
13122 "Delete all overlays in the current buffer."
13123 (when (fboundp 'overlay-lists)
13124 (let* ((overlayss (overlay-lists))
13125 (buffer-read-only nil)
13126 (overlays (nconc (car overlayss) (cdr overlayss))))
13128 (delete-overlay (pop overlays))))))
13130 (defun gnus-request-article-this-buffer (article group)
13131 "Get an article and insert it into this buffer."
13135 (gnus-kill-all-overlays)
13136 (setq group (or group gnus-newsgroup-name))
13138 ;; Open server if it has closed.
13139 (gnus-check-server (gnus-find-method-for-group group))
13141 ;; Using `gnus-request-article' directly will insert the article into
13142 ;; `nntp-server-buffer' - so we'll save some time by not having to
13143 ;; copy it from the server buffer into the article buffer.
13145 ;; We only request an article by message-id when we do not have the
13146 ;; headers for it, so we'll have to get those.
13147 (when (stringp article)
13148 (let ((gnus-override-method gnus-refer-article-method))
13149 (gnus-read-header article)))
13151 ;; If the article number is negative, that means that this article
13152 ;; doesn't belong in this newsgroup (possibly), so we find its
13153 ;; message-id and request it by id instead of number.
13154 (when (and (numberp article)
13155 gnus-summary-buffer
13156 (buffer-name gnus-summary-buffer))
13158 (set-buffer gnus-summary-buffer)
13159 (let ((header (gnus-summary-article-header article)))
13162 ((memq article gnus-newsgroup-sparse)
13163 ;; This is a sparse gap article.
13164 (setq article (mail-header-id header)))
13166 ;; It's a real article.
13167 (setq article (mail-header-id header)))
13169 ;; It is an extracted pseudo-article.
13170 (setq article 'pseudo)
13171 (gnus-request-pseudo-article header))))
13173 (let ((method (gnus-find-method-for-group
13174 gnus-newsgroup-name)))
13175 (if (not (eq (car method) 'nneething))
13177 (let ((dir (concat (file-name-as-directory (nth 1 method))
13178 (mail-header-subject header))))
13179 (if (file-directory-p dir)
13181 (setq article 'nneething)
13182 (gnus-group-enter-directory dir)))))))))
13185 ;; We first check `gnus-original-article-buffer'.
13186 ((and (equal (car gnus-original-article) group)
13187 (eq (cdr gnus-original-article) article)
13188 (get-buffer gnus-original-article-buffer))
13189 (insert-buffer-substring gnus-original-article-buffer)
13191 ;; Check the backlog.
13192 ((and gnus-keep-backlog
13193 (gnus-backlog-request-article group article (current-buffer)))
13195 ;; Check the cache.
13196 ((and gnus-use-cache
13198 (gnus-cache-request-article article group))
13200 ;; Get the article and put into the article buffer.
13201 ((or (stringp article) (numberp article))
13202 (let ((gnus-override-method
13203 (and (stringp article) gnus-refer-article-method))
13204 (buffer-read-only nil))
13206 (gnus-kill-all-overlays)
13207 (if (gnus-request-article article group (current-buffer))
13209 (and gnus-keep-backlog
13210 (gnus-backlog-enter-article
13211 group article (current-buffer)))
13213 ;; It was a pseudo.
13216 ;; Take the article from the original article buffer
13217 ;; and place it in the buffer it's supposed to be in.
13218 (setq gnus-original-article (cons group article))
13219 (when (and (get-buffer gnus-article-buffer)
13220 (equal (buffer-name (current-buffer))
13221 (buffer-name (get-buffer gnus-article-buffer))))
13223 (if (get-buffer gnus-original-article-buffer)
13224 (set-buffer (get-buffer gnus-original-article-buffer))
13225 (set-buffer (get-buffer-create gnus-original-article-buffer))
13226 (buffer-disable-undo (current-buffer))
13227 (setq major-mode 'gnus-original-article-mode)
13228 (setq buffer-read-only t)
13229 (gnus-add-current-to-buffer-list))
13230 (let (buffer-read-only)
13232 (insert-buffer-substring gnus-article-buffer))))
13234 ;; Update sparse articles.
13235 (when (memq article gnus-newsgroup-sparse)
13236 (gnus-summary-update-article article))))
13238 (defun gnus-read-header (id)
13239 "Read the headers of article ID and enter them into the Gnus system."
13240 (let ((group gnus-newsgroup-name)
13241 (headers gnus-newsgroup-headers)
13243 ;; First we check to see whether the header in question is already
13246 ;; This is a Message-ID.
13247 (setq header (gnus-id-to-header id))
13248 ;; This is an article number.
13249 (setq header (gnus-summary-article-header id)))
13251 ;; We have found the header.
13253 ;; We have to really fetch the header to this article.
13255 (if (gnus-check-backend-function 'request-head group)
13256 (gnus-request-head id group)
13257 (gnus-request-article id group)))
13259 (set-buffer nntp-server-buffer)
13260 (and (search-forward "\n\n" nil t)
13261 (delete-region (1- (point)) (point-max)))
13262 (goto-char (point-max))
13264 (goto-char (point-min))
13273 gnus-reffed-article-number)))
13274 " Article retrieved.\n"))
13275 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13276 () ; Malformed head.
13277 (if (and (stringp id)
13278 (not (string= (gnus-group-real-name group)
13280 ;; If we fetched by Message-ID and the article came
13281 ;; from a different group, we fudge some bogus article
13282 ;; numbers for this article.
13283 (mail-header-set-number header gnus-reffed-article-number))
13284 (decf gnus-reffed-article-number)
13285 (push header gnus-newsgroup-headers)
13286 (setq gnus-current-headers header)
13287 (push (mail-header-number header) gnus-newsgroup-limit)
13290 (defun gnus-article-prepare (article &optional all-headers header)
13291 "Prepare ARTICLE in article mode buffer.
13292 ARTICLE should either be an article number or a Message-ID.
13293 If ARTICLE is an id, HEADER should be the article headers.
13294 If ALL-HEADERS is non-nil, no headers are hidden."
13296 ;; Make sure we start in a summary buffer.
13297 (unless (eq major-mode 'gnus-summary-mode)
13298 (set-buffer gnus-summary-buffer))
13299 (setq gnus-summary-buffer (current-buffer))
13300 ;; Make sure the connection to the server is alive.
13301 (unless (gnus-server-opened
13302 (gnus-find-method-for-group gnus-newsgroup-name))
13303 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13304 (gnus-request-group gnus-newsgroup-name t))
13305 (let* ((article (if header (mail-header-number header) article))
13306 (summary-buffer (current-buffer))
13307 (internal-hook gnus-article-internal-prepare-hook)
13308 (group gnus-newsgroup-name)
13311 (gnus-article-setup-buffer)
13312 (set-buffer gnus-article-buffer)
13313 ;; Deactivate active regions.
13314 (when (and (boundp 'transient-mark-mode)
13315 transient-mark-mode)
13316 (setq mark-active nil))
13317 (if (not (setq result (let ((buffer-read-only nil))
13318 (gnus-request-article-this-buffer
13320 ;; There is no such article.
13322 (when (and (numberp article)
13323 (not (memq article gnus-newsgroup-sparse)))
13324 (setq gnus-article-current
13325 (cons gnus-newsgroup-name article))
13326 (set-buffer gnus-summary-buffer)
13327 (setq gnus-current-article article)
13328 (gnus-summary-mark-article article gnus-canceled-mark))
13329 (unless (memq article gnus-newsgroup-sparse)
13331 1 "No such article (may have expired or been canceled)")
13334 (if (or (eq result 'pseudo) (eq result 'nneething))
13337 (set-buffer summary-buffer)
13338 (setq gnus-last-article gnus-current-article
13339 gnus-newsgroup-history (cons gnus-current-article
13340 gnus-newsgroup-history)
13341 gnus-current-article 0
13342 gnus-current-headers nil
13343 gnus-article-current nil)
13344 (if (eq result 'nneething)
13345 (gnus-configure-windows 'summary)
13346 (gnus-configure-windows 'article))
13347 (gnus-set-global-variables))
13348 (gnus-set-mode-line 'article))
13349 ;; The result from the `request' was an actual article -
13350 ;; or at least some text that is now displayed in the
13352 (if (and (numberp article)
13353 (not (eq article gnus-current-article)))
13354 ;; Seems like a new article has been selected.
13355 ;; `gnus-current-article' must be an article number.
13357 (set-buffer summary-buffer)
13358 (setq gnus-last-article gnus-current-article
13359 gnus-newsgroup-history (cons gnus-current-article
13360 gnus-newsgroup-history)
13361 gnus-current-article article
13362 gnus-current-headers
13363 (gnus-summary-article-header gnus-current-article)
13364 gnus-article-current
13365 (cons gnus-newsgroup-name gnus-current-article))
13366 (unless (vectorp gnus-current-headers)
13367 (setq gnus-current-headers nil))
13368 (gnus-summary-show-thread)
13369 (run-hooks 'gnus-mark-article-hook)
13370 (gnus-set-mode-line 'summary)
13371 (and (gnus-visual-p 'article-highlight 'highlight)
13372 (run-hooks 'gnus-visual-mark-article-hook))
13373 ;; Set the global newsgroup variables here.
13374 ;; Suggested by Jim Sisolak
13375 ;; <sisolak@trans4.neep.wisc.edu>.
13376 (gnus-set-global-variables)
13377 (setq gnus-have-all-headers
13378 (or all-headers gnus-show-all-headers))
13379 (and gnus-use-cache
13380 (vectorp (gnus-summary-article-header article))
13381 (gnus-cache-possibly-enter-article
13383 (gnus-summary-article-header article)
13384 (memq article gnus-newsgroup-marked)
13385 (memq article gnus-newsgroup-dormant)
13386 (memq article gnus-newsgroup-unreads)))))
13387 ;; Hooks for getting information from the article.
13388 ;; This hook must be called before being narrowed.
13389 (let (buffer-read-only)
13390 (run-hooks 'internal-hook)
13391 (run-hooks 'gnus-article-prepare-hook)
13392 ;; Decode MIME message.
13394 (if (or (not gnus-strict-mime)
13395 (gnus-fetch-field "Mime-Version"))
13396 (funcall gnus-show-mime-method)
13397 (funcall gnus-decode-encoded-word-method)))
13398 ;; Perform the article display hooks.
13399 (run-hooks 'gnus-article-display-hook))
13401 (goto-char (point-min))
13402 (and gnus-break-pages (gnus-narrow-to-page))
13403 (gnus-set-mode-line 'article)
13404 (gnus-configure-windows 'article)
13405 (goto-char (point-min))
13408 (defun gnus-article-show-all-headers ()
13409 "Show all article headers in article mode buffer."
13411 (gnus-article-setup-buffer)
13412 (set-buffer gnus-article-buffer)
13413 (let ((buffer-read-only nil))
13414 (remove-text-properties (point-min) (point-max)
13415 gnus-hidden-properties))))
13417 (defun gnus-article-hide-headers-if-wanted ()
13418 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13419 Provided for backwards compatibility."
13420 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13421 gnus-inhibit-hiding
13422 (gnus-article-hide-headers)))
13424 (defun gnus-article-hide-headers (&optional arg delete)
13425 "Toggle whether to hide unwanted headers and possibly sort them as well.
13426 If given a negative prefix, always show; if given a positive prefix,
13429 (unless (gnus-article-check-hidden-text 'headers arg)
13430 ;; This function might be inhibited.
13431 (unless gnus-inhibit-hiding
13433 (set-buffer gnus-article-buffer)
13435 (let ((buffer-read-only nil)
13436 (ignored (when (not (stringp gnus-visible-headers))
13437 (cond ((stringp gnus-ignored-headers)
13438 gnus-ignored-headers)
13439 ((listp gnus-ignored-headers)
13440 (mapconcat 'identity gnus-ignored-headers
13443 (cond ((stringp gnus-visible-headers)
13444 gnus-visible-headers)
13445 ((and gnus-visible-headers
13446 (listp gnus-visible-headers))
13447 (mapconcat 'identity gnus-visible-headers "\\|"))))
13448 want-list beg want-l)
13449 ;; First we narrow to just the headers.
13451 (goto-char (point-min))
13452 ;; Hide any "From " lines at the beginning of (mail) articles.
13453 (while (looking-at "From ")
13456 (add-text-properties
13457 (point-min) (point)
13458 (nconc (list 'gnus-type 'headers) gnus-hidden-properties)))
13459 ;; Then treat the rest of the header lines.
13462 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13463 ;; Then we use the two regular expressions
13464 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13465 ;; select which header lines is to remain visible in the
13467 (goto-char (point-min))
13468 (while (re-search-forward "^[^ \t]*:" nil t)
13469 (beginning-of-line)
13470 ;; We add the headers we want to keep to a list and delete
13471 ;; them from the buffer.
13472 (if (or (and visible (looking-at visible))
13473 (and ignored (not (looking-at ignored))))
13475 (push (buffer-substring
13479 ;; Be sure to get multi-line headers...
13480 (re-search-forward "^[^ \t]*:" nil t)
13481 (beginning-of-line)
13484 (delete-region beg (point)))
13486 ;; Sort the headers that we want to display.
13487 (setq want-list (sort want-list 'gnus-article-header-less))
13488 (goto-char (point-min))
13490 (insert (pop want-list)))
13491 ;; We make the unwanted headers invisible.
13493 (delete-region (point-min) (point-max))
13494 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13495 (add-text-properties
13496 (point) (point-max)
13497 (nconc (list 'gnus-type 'headers)
13498 gnus-hidden-properties)))))))))
13500 (defsubst gnus-article-header-rank (header)
13501 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13502 (let ((list gnus-sorted-header-list)
13505 (when (string-match (car list) header)
13507 (setq list (cdr list))
13511 (defun gnus-article-header-less (h1 h2)
13512 "Say whether string H1 is \"less\" than string H2."
13513 (< (gnus-article-header-rank h1)
13514 (gnus-article-header-rank h2)))
13516 (defun gnus-article-hide-boring-headers (&optional arg)
13517 "Toggle hiding of headers that aren't very interesting.
13518 If given a negative prefix, always show; if given a positive prefix,
13521 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13523 (set-buffer gnus-article-buffer)
13525 (let ((buffer-read-only nil)
13526 (list gnus-boring-article-headers)
13527 (inhibit-point-motion-hooks t)
13529 (nnheader-narrow-to-headers)
13531 (setq elem (pop list))
13532 (goto-char (point-min))
13534 ;; Hide empty headers.
13536 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13538 (add-text-properties
13539 (progn (beginning-of-line) (point))
13542 (if (re-search-forward "^[^ \t]" nil t)
13543 (match-beginning 0)
13545 (nconc (list 'gnus-type 'boring-headers)
13546 gnus-hidden-properties))))
13547 ;; Hide boring Newsgroups header.
13548 ((eq elem 'newsgroups)
13549 (when (equal (mail-fetch-field "newsgroups")
13550 (gnus-group-real-name gnus-newsgroup-name))
13551 (gnus-article-hide-header "newsgroups")))
13552 ((eq elem 'followup-to)
13553 (when (equal (mail-fetch-field "followup-to")
13554 (mail-fetch-field "newsgroups"))
13555 (gnus-article-hide-header "followup-to")))
13556 ((eq elem 'reply-to)
13557 (let ((from (mail-fetch-field "from"))
13558 (reply-to (mail-fetch-field "reply-to")))
13562 (nth 1 (mail-extract-address-components from))
13563 (nth 1 (mail-extract-address-components reply-to))))
13564 (gnus-article-hide-header "reply-to"))))
13566 (let ((date (mail-fetch-field "date")))
13568 (< (gnus-days-between date (current-time-string))
13570 (gnus-article-hide-header "date")))))))))))
13572 (defun gnus-article-hide-header (header)
13574 (goto-char (point-min))
13575 (when (re-search-forward (concat "^" header ":") nil t)
13576 (add-text-properties
13577 (progn (beginning-of-line) (point))
13580 (if (re-search-forward "^[^ \t]" nil t)
13581 (match-beginning 0)
13583 (nconc (list 'gnus-type 'boring-headers)
13584 gnus-hidden-properties)))))
13586 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13587 (defun gnus-article-treat-overstrike ()
13588 "Translate overstrikes into bold text."
13591 (set-buffer gnus-article-buffer)
13592 (let ((buffer-read-only nil))
13593 (while (search-forward "\b" nil t)
13594 (let ((next (following-char))
13595 (previous (char-after (- (point) 2))))
13596 (cond ((eq next previous)
13597 (put-text-property (- (point) 2) (point) 'invisible t)
13598 (put-text-property (point) (1+ (point)) 'face 'bold))
13600 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13602 (- (point) 2) (1- (point)) 'face 'underline))
13604 (put-text-property (- (point) 2) (point) 'invisible t)
13606 (point) (1+ (point)) 'face 'underline))))))))
13608 (defun gnus-article-word-wrap ()
13609 "Format too long lines."
13612 (set-buffer gnus-article-buffer)
13613 (let ((buffer-read-only nil)
13616 (goto-char (point-min))
13617 (search-forward "\n\n" nil t)
13619 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13620 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13621 (adaptive-fill-mode t))
13622 (while (not (eobp))
13623 (and (>= (current-column) (min fill-column (window-width)))
13624 (/= (preceding-char) ?:)
13625 (fill-paragraph nil))
13626 (end-of-line 2))))))
13628 (defun gnus-article-remove-cr ()
13629 "Remove carriage returns from an article."
13632 (set-buffer gnus-article-buffer)
13633 (let ((buffer-read-only nil))
13634 (goto-char (point-min))
13635 (while (search-forward "\r" nil t)
13636 (replace-match "" t t)))))
13638 (defun gnus-article-remove-trailing-blank-lines ()
13639 "Remove all trailing blank lines from the article."
13642 (set-buffer gnus-article-buffer)
13643 (let ((buffer-read-only nil))
13644 (goto-char (point-max))
13648 (while (looking-at "^[ \t]*$")
13653 (defun gnus-article-display-x-face (&optional force)
13654 "Look for an X-Face header and display it if present."
13655 (interactive (list 'force))
13657 (set-buffer gnus-article-buffer)
13658 ;; Delete the old process, if any.
13659 (when (process-status "gnus-x-face")
13660 (delete-process "gnus-x-face"))
13661 (let ((inhibit-point-motion-hooks t)
13662 (case-fold-search nil)
13665 (nnheader-narrow-to-headers)
13666 (setq from (mail-fetch-field "from"))
13667 (goto-char (point-min))
13668 (when (and gnus-article-x-face-command
13670 ;; Check whether this face is censored.
13671 (not gnus-article-x-face-too-ugly)
13672 (and gnus-article-x-face-too-ugly from
13673 (not (string-match gnus-article-x-face-too-ugly
13675 ;; Has to be present.
13676 (re-search-forward "^X-Face: " nil t))
13677 ;; We now have the area of the buffer where the X-Face is stored.
13678 (let ((beg (point))
13679 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13680 ;; We display the face.
13681 (if (symbolp gnus-article-x-face-command)
13682 ;; The command is a lisp function, so we call it.
13683 (if (gnus-functionp gnus-article-x-face-command)
13684 (funcall gnus-article-x-face-command beg end)
13685 (error "%s is not a function" gnus-article-x-face-command))
13686 ;; The command is a string, so we interpret the command
13687 ;; as a, well, command, and fork it off.
13688 (let ((process-connection-type nil))
13689 (process-kill-without-query
13691 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13692 (process-send-region "gnus-x-face" beg end)
13693 (process-send-eof "gnus-x-face")))))))))
13695 (defun gnus-headers-decode-quoted-printable ()
13696 "Hack to remove QP encoding from headers."
13697 (let ((case-fold-search t)
13698 (inhibit-point-motion-hooks t)
13700 (goto-char (point-min))
13701 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13702 (setq string (match-string 1))
13703 (narrow-to-region (match-beginning 0) (match-end 0))
13704 (delete-region (point-min) (point-max))
13706 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13707 (subst-char-in-region (point-min) (point-max) ?_ ? )
13709 (goto-char (point-min)))))
13711 (defun gnus-article-de-quoted-unreadable (&optional force)
13712 "Do a naive translation of a quoted-printable-encoded article.
13713 This is in no way, shape or form meant as a replacement for real MIME
13714 processing, but is simply a stop-gap measure until MIME support is
13716 If FORCE, decode the article whether it is marked as quoted-printable
13718 (interactive (list 'force))
13720 (set-buffer gnus-article-buffer)
13721 (let ((case-fold-search t)
13722 (buffer-read-only nil)
13723 (type (gnus-fetch-field "content-transfer-encoding")))
13725 (and type (string-match "quoted-printable" type)))
13726 (gnus-headers-decode-quoted-printable)
13727 (goto-char (point-min))
13728 (search-forward "\n\n" nil 'move)
13729 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13731 (defun gnus-mime-decode-quoted-printable (from to)
13732 "Decode Quoted-Printable in the region between FROM and TO."
13734 (while (search-forward "=" to t)
13735 (cond ((eq (following-char) ?\n)
13738 ((looking-at "[0-9A-F][0-9A-F]")
13740 (insert (hexl-hex-string-to-integer
13741 (buffer-substring (point) (+ 2 (point)))))
13745 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13747 (defun gnus-article-hide-pgp (&optional arg)
13748 "Toggle hiding of any PGP headers and signatures in the current article.
13749 If given a negative prefix, always show; if given a positive prefix,
13752 (unless (gnus-article-check-hidden-text 'pgp arg)
13754 (set-buffer gnus-article-buffer)
13755 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13756 buffer-read-only beg end)
13758 (goto-char (point-min))
13759 ;; Hide the "header".
13760 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13761 (add-text-properties (match-beginning 0) (match-end 0) props))
13763 ;; Hide the actual signature.
13764 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13765 (setq end (match-beginning 0))
13766 (add-text-properties
13767 (match-beginning 0)
13768 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13770 ;; Perhaps we shouldn't hide to the end of the buffer
13771 ;; if there is no end to the signature?
13774 ;; Hide "- " PGP quotation markers.
13775 (when (and beg end)
13776 (narrow-to-region beg end)
13777 (goto-char (point-min))
13778 (while (re-search-forward "^- " nil t)
13779 (add-text-properties (match-beginning 0) (match-end 0) props))
13782 (defun gnus-article-hide-signature (&optional arg)
13783 "Hide the signature in the current article.
13784 If given a negative prefix, always show; if given a positive prefix,
13787 (unless (gnus-article-check-hidden-text 'signature arg)
13789 (set-buffer gnus-article-buffer)
13791 (let ((buffer-read-only nil))
13792 (when (gnus-narrow-to-signature)
13793 (add-text-properties
13794 (point-min) (point-max)
13795 (nconc (list 'gnus-type 'signature)
13796 gnus-hidden-properties))))))))
13798 (defun gnus-narrow-to-signature ()
13799 "Narrow to the signature."
13801 (goto-char (point-max))
13802 (when (re-search-backward gnus-signature-separator nil t)
13804 (when (or (null gnus-signature-limit)
13805 (and (numberp gnus-signature-limit)
13806 (< (- (point-max) (point)) gnus-signature-limit))
13807 (and (gnus-functionp gnus-signature-limit)
13808 (funcall gnus-signature-limit))
13809 (and (stringp gnus-signature-limit)
13810 (not (re-search-forward gnus-signature-limit nil t))))
13811 (narrow-to-region (point) (point-max))
13814 (defun gnus-article-check-hidden-text (type arg)
13815 "Return nil if hiding is necessary."
13817 (set-buffer gnus-article-buffer)
13818 (let ((hide (gnus-article-hidden-text-p type)))
13819 (cond ((or (and (null arg) (eq hide 'hidden))
13820 (and arg (< 0 (prefix-numeric-value arg))))
13821 (gnus-article-show-hidden-text type))
13823 (gnus-article-show-hidden-text type t))
13826 (defun gnus-article-hidden-text-p (type)
13827 "Say whether the current buffer contains hidden text of type TYPE."
13828 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type))
13831 (if (get-text-property pos 'invisible)
13835 (defun gnus-article-hide (&optional arg force)
13836 "Hide all the gruft in the current article.
13837 This means that PGP stuff, signatures, cited text and (some)
13838 headers will be hidden.
13839 If given a prefix, show the hidden text instead."
13840 (interactive (list current-prefix-arg 'force))
13841 (gnus-article-hide-headers arg)
13842 (gnus-article-hide-pgp arg)
13843 (gnus-article-hide-citation-maybe arg force)
13844 (gnus-article-hide-signature arg))
13846 (defun gnus-article-show-hidden-text (type &optional hide)
13847 "Show all hidden text of type TYPE.
13848 If HIDE, hide the text instead."
13850 (set-buffer gnus-article-buffer)
13851 (let ((buffer-read-only nil)
13852 (inhibit-point-motion-hooks t)
13854 (while (gnus-goto-char (text-property-any
13855 beg (point-max) 'gnus-type type))
13859 (add-text-properties beg (point) gnus-hidden-properties)
13860 (remove-text-properties beg (point) gnus-hidden-properties))
13861 (setq beg (point)))
13864 (defvar gnus-article-time-units
13865 `((year . ,(* 365.25 24 60 60))
13866 (week . ,(* 7 24 60 60))
13867 (day . ,(* 24 60 60))
13868 (hour . ,(* 60 60))
13871 "Mapping from time units to seconds.")
13873 (defun gnus-article-date-ut (&optional type highlight)
13874 "Convert DATE date to universal time in the current article.
13875 If TYPE is `local', convert to local time; if it is `lapsed', output
13876 how much time has lapsed since DATE."
13877 (interactive (list 'ut t))
13878 (let* ((header (or gnus-current-headers
13879 (gnus-summary-article-header) ""))
13880 (date (and (vectorp header) (mail-header-date header)))
13881 (date-regexp "^Date: \\|^X-Sent: ")
13882 (now (current-time))
13883 (inhibit-point-motion-hooks t))
13884 (when (and date (not (string= date "")))
13886 (set-buffer gnus-article-buffer)
13888 (nnheader-narrow-to-headers)
13889 (let ((buffer-read-only nil))
13890 ;; Delete any old Date headers.
13891 (if (zerop (nnheader-remove-header date-regexp t))
13892 (beginning-of-line)
13893 (goto-char (point-max)))
13896 ;; Convert to the local timezone. We have to slap a
13897 ;; `condition-case' round the calls to the timezone
13898 ;; functions since they aren't particularly resistant to
13901 (concat "Date: " (condition-case ()
13902 (timezone-make-date-arpa-standard date)
13905 ;; Convert to Universal Time.
13909 (timezone-make-date-arpa-standard date nil "UT")
13912 ;; Get the original date from the article.
13913 ((eq type 'original)
13914 (concat "Date: " date "\n"))
13915 ;; Do an X-Sent lapsed format.
13917 ;; If the date is seriously mangled, the timezone
13918 ;; functions are liable to bug out, so we condition-case
13919 ;; the entire thing.
13924 (timezone-make-date-arpa-standard
13925 (current-time-string now)
13926 (current-time-zone now) "UT"))
13928 (timezone-make-date-arpa-standard
13931 (real-sec (+ (* (float (car real-time)) 65536)
13933 (sec (abs real-sec))
13939 ;; This is a bit convoluted, but basically we go
13940 ;; through the time units for years, weeks, etc,
13941 ;; and divide things to see whether that results
13942 ;; in positive answers.
13945 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
13946 ;; The (remaining) seconds are too few to
13947 ;; be divided into this time unit.
13949 ;; It's big enough, so we output it.
13950 (setq sec (- sec (* num (cdr unit))))
13952 (concat (if prev ", " "") (int-to-string
13954 " " (symbol-name (car unit))
13955 (if (> num 1) "s" ""))
13957 gnus-article-time-units "")
13958 ;; If dates are odd, then it might appear like the
13959 ;; article was sent in the future.
13962 " in the future\n")))))
13964 (error "Unknown conversion type: %s" type)))))
13965 ;; Do highlighting.
13966 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
13967 (gnus-article-highlight-headers)))))))
13969 (defun gnus-article-date-local (&optional highlight)
13970 "Convert the current article date to the local timezone."
13971 (interactive (list t))
13972 (gnus-article-date-ut 'local highlight))
13974 (defun gnus-article-date-original (&optional highlight)
13975 "Convert the current article date to what it was originally.
13976 This is only useful if you have used some other date conversion
13977 function and want to see what the date was before converting."
13978 (interactive (list t))
13979 (gnus-article-date-ut 'original highlight))
13981 (defun gnus-article-date-lapsed (&optional highlight)
13982 "Convert the current article date to time lapsed since it was sent."
13983 (interactive (list t))
13984 (gnus-article-date-ut 'lapsed highlight))
13986 (defun gnus-article-maybe-highlight ()
13987 "Do some article highlighting if `gnus-visual' is non-nil."
13988 (if (gnus-visual-p 'article-highlight 'highlight)
13989 (gnus-article-highlight-some)))
13993 (defun gnus-output-to-rmail (file-name)
13994 "Append the current article to an Rmail file named FILE-NAME."
13996 ;; Most of these codes are borrowed from rmailout.el.
13997 (setq file-name (expand-file-name file-name))
13998 (setq rmail-default-rmail-file file-name)
13999 (let ((artbuf (current-buffer))
14000 (tmpbuf (get-buffer-create " *Gnus-output*")))
14002 (or (get-file-buffer file-name)
14003 (file-exists-p file-name)
14004 (if (gnus-yes-or-no-p
14005 (concat "\"" file-name "\" does not exist, create it? "))
14006 (let ((file-buffer (create-file-buffer file-name)))
14008 (set-buffer file-buffer)
14009 (rmail-insert-rmail-file-header)
14010 (let ((require-final-newline nil))
14011 (write-region (point-min) (point-max) file-name t 1)))
14012 (kill-buffer file-buffer))
14013 (error "Output file does not exist")))
14014 (set-buffer tmpbuf)
14015 (buffer-disable-undo (current-buffer))
14017 (insert-buffer-substring artbuf)
14018 (gnus-convert-article-to-rmail)
14019 ;; Decide whether to append to a file or to an Emacs buffer.
14020 (let ((outbuf (get-file-buffer file-name)))
14022 (append-to-file (point-min) (point-max) file-name)
14023 ;; File has been visited, in buffer OUTBUF.
14024 (set-buffer outbuf)
14025 (let ((buffer-read-only nil)
14026 (msg (and (boundp 'rmail-current-message)
14027 (symbol-value 'rmail-current-message))))
14028 ;; If MSG is non-nil, buffer is in RMAIL mode.
14031 (narrow-to-region (point-max) (point-max))))
14032 (insert-buffer-substring tmpbuf)
14035 (goto-char (point-min))
14037 (search-backward "\^_")
14038 (narrow-to-region (point) (point-max))
14039 (goto-char (1+ (point-min)))
14040 (rmail-count-new-messages t)
14041 (rmail-show-message msg)))))))
14042 (kill-buffer tmpbuf)))
14044 (defun gnus-output-to-file (file-name)
14045 "Append the current article to a file named FILE-NAME."
14046 (setq file-name (expand-file-name file-name))
14047 (let ((artbuf (current-buffer))
14048 (tmpbuf (get-buffer-create " *Gnus-output*")))
14050 (set-buffer tmpbuf)
14051 (buffer-disable-undo (current-buffer))
14053 (insert-buffer-substring artbuf)
14054 ;; Append newline at end of the buffer as separator, and then
14055 ;; save it to file.
14056 (goto-char (point-max))
14058 (append-to-file (point-min) (point-max) file-name))
14059 (kill-buffer tmpbuf)))
14061 (defun gnus-convert-article-to-rmail ()
14062 "Convert article in current buffer to Rmail message format."
14063 (let ((buffer-read-only nil))
14064 ;; Convert article directly into Babyl format.
14065 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14066 (goto-char (point-min))
14067 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14068 (while (search-forward "\n\^_" nil t) ;single char
14069 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14070 (goto-char (point-max))
14073 (defun gnus-narrow-to-page (&optional arg)
14074 "Narrow the article buffer to a page.
14075 If given a numerical ARG, move forward ARG pages."
14077 (setq arg (if arg (prefix-numeric-value arg) 0))
14079 (set-buffer gnus-article-buffer)
14080 (goto-char (point-min))
14082 (when (gnus-visual-p 'page-marker)
14083 (let ((buffer-read-only nil))
14084 (gnus-remove-text-with-property 'gnus-prev)
14085 (gnus-remove-text-with-property 'gnus-next)))
14088 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14090 (re-search-forward page-delimiter nil 'move arg)))
14091 (goto-char (match-end 0)))
14094 (if (re-search-forward page-delimiter nil 'move)
14095 (match-beginning 0)
14097 (when (and (gnus-visual-p 'page-marker)
14098 (not (= (point-min) 1)))
14100 (goto-char (point-min))
14101 (gnus-insert-prev-page-button)))
14102 (when (and (gnus-visual-p 'page-marker)
14103 (not (= (1- (point-max)) (buffer-size))))
14105 (goto-char (point-max))
14106 (gnus-insert-next-page-button)))))
14108 ;; Article mode commands
14110 (defun gnus-article-goto-next-page ()
14111 "Show the next page of the article."
14113 (when (gnus-article-next-page)
14114 (gnus-article-read-summary-keys nil ?n)))
14116 (defun gnus-article-goto-prev-page ()
14117 "Show the next page of the article."
14119 (if (bobp) (gnus-article-read-summary-keys nil ?n)
14120 (gnus-article-prev-page nil)))
14122 (defun gnus-article-next-page (&optional lines)
14123 "Show the next page of the current article.
14124 If end of article, return non-nil. Otherwise return nil.
14125 Argument LINES specifies lines to be scrolled up."
14127 (move-to-window-line -1)
14128 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14129 (if (save-excursion
14131 (and (pos-visible-in-window-p) ;Not continuation line.
14133 ;; Nothing in this page.
14134 (if (or (not gnus-break-pages)
14137 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14139 (gnus-narrow-to-page 1) ;Go to next page.
14141 ;; More in this page.
14145 ;; Long lines may cause an end-of-buffer error.
14146 (goto-char (point-max))))
14147 (move-to-window-line 0)
14150 (defun gnus-article-prev-page (&optional lines)
14151 "Show previous page of current article.
14152 Argument LINES specifies lines to be scrolled down."
14154 (move-to-window-line 0)
14155 (if (and gnus-break-pages
14157 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14159 (gnus-narrow-to-page -1) ;Go to previous page.
14160 (goto-char (point-max))
14164 (scroll-down lines)
14166 (move-to-window-line 0))))
14168 (defun gnus-article-refer-article ()
14169 "Read article specified by message-id around point."
14171 (let ((point (point)))
14172 (search-forward ">" nil t) ;Move point to end of "<....>".
14173 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14174 (let ((message-id (match-string 1)))
14176 (set-buffer gnus-summary-buffer)
14177 (gnus-summary-refer-article message-id))
14178 (goto-char (point))
14179 (error "No references around point"))))
14181 (defun gnus-article-show-summary ()
14182 "Reconfigure windows to show summary buffer."
14184 (gnus-configure-windows 'article)
14185 (gnus-summary-goto-subject gnus-current-article))
14187 (defun gnus-article-describe-briefly ()
14188 "Describe article mode commands briefly."
14191 (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")))
14193 (defun gnus-article-summary-command ()
14194 "Execute the last keystroke in the summary buffer."
14196 (let ((obuf (current-buffer))
14197 (owin (current-window-configuration))
14199 (switch-to-buffer gnus-summary-buffer 'norecord)
14200 (setq func (lookup-key (current-local-map) (this-command-keys)))
14201 (call-interactively func)
14203 (set-window-configuration owin)
14204 (set-window-point (get-buffer-window (current-buffer)) (point))))
14206 (defun gnus-article-summary-command-nosave ()
14207 "Execute the last keystroke in the summary buffer."
14210 (pop-to-buffer gnus-summary-buffer 'norecord)
14211 (setq func (lookup-key (current-local-map) (this-command-keys)))
14212 (call-interactively func)))
14214 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14215 "Read a summary buffer key sequence and execute it from the article buffer."
14218 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14219 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14223 (set-buffer gnus-summary-buffer)
14224 (push (or key last-command-event) unread-command-events)
14225 (setq keys (read-key-sequence nil)))
14228 (if (member keys nosaves)
14230 (pop-to-buffer gnus-summary-buffer 'norecord)
14231 (if (setq func (lookup-key (current-local-map) keys))
14232 (call-interactively func)
14234 (let ((obuf (current-buffer))
14235 (owin (current-window-configuration))
14238 (if not-restore-window
14239 (pop-to-buffer gnus-summary-buffer 'norecord)
14240 (switch-to-buffer gnus-summary-buffer 'norecord))
14241 (setq in-buffer (current-buffer))
14242 (if (setq func (lookup-key (current-local-map) keys))
14243 (call-interactively func)
14245 (when (eq in-buffer (current-buffer))
14247 (unless not-restore-window
14248 (set-window-configuration owin))
14249 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14253 ;;; Kill file handling.
14257 (defalias 'gnus-batch-kill 'gnus-batch-score)
14259 (defun gnus-batch-score ()
14260 "Run batched scoring.
14261 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14262 Newsgroups is a list of strings in Bnews format. If you want to score
14263 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14264 score the alt hierarchy, you'd say \"!alt.all\"."
14267 (gnus-newsrc-parse-options
14268 (apply (function concat)
14269 (mapcar (lambda (g) (concat g " "))
14270 command-line-args-left))))
14271 (gnus-expert-user t)
14272 (nnmail-spool-file nil)
14273 (gnus-use-dribble-file nil)
14274 (yes (car yes-and-no))
14275 (no (cdr yes-and-no))
14277 ;; Disable verbose message.
14278 gnus-novice-user gnus-large-newsgroup)
14279 ;; Eat all arguments.
14280 (setq command-line-args-left nil)
14283 ;; Apply kills to specified newsgroups in command line arguments.
14284 (setq newsrc (cdr gnus-newsrc-alist))
14286 (setq group (caar newsrc))
14287 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14288 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14290 (or (eq (car entry) t)
14291 (not (zerop (car entry)))))
14292 (if yes (string-match yes group) t)
14293 (or (null no) (not (string-match no group))))
14295 (gnus-summary-read-group group nil t nil t)
14296 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14297 (gnus-summary-exit))))
14298 (setq newsrc (cdr newsrc)))
14300 (switch-to-buffer gnus-group-buffer)
14301 (gnus-group-save-newsrc)))
14303 (defun gnus-apply-kill-file ()
14304 "Apply a kill file to the current newsgroup.
14305 Returns the number of articles marked as read."
14306 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14307 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14308 (gnus-apply-kill-file-internal)
14311 (defun gnus-kill-save-kill-buffer ()
14312 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14313 (when (get-file-buffer file)
14315 (set-buffer (get-file-buffer file))
14316 (and (buffer-modified-p) (save-buffer))
14317 (kill-buffer (current-buffer))))))
14319 (defvar gnus-kill-file-name "KILL"
14320 "Suffix of the kill files.")
14322 (defun gnus-newsgroup-kill-file (newsgroup)
14323 "Return the name of a kill file name for NEWSGROUP.
14324 If NEWSGROUP is nil, return the global kill file name instead."
14326 ;; The global KILL file is placed at top of the directory.
14327 ((or (null newsgroup)
14328 (string-equal newsgroup ""))
14329 (expand-file-name gnus-kill-file-name
14330 (or gnus-kill-files-directory "~/News")))
14331 ;; Append ".KILL" to newsgroup name.
14332 ((gnus-use-long-file-name 'not-kill)
14333 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14334 "." gnus-kill-file-name)
14335 (or gnus-kill-files-directory "~/News")))
14336 ;; Place "KILL" under the hierarchical directory.
14338 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14339 "/" gnus-kill-file-name)
14340 (or gnus-kill-files-directory "~/News")))))
14347 (defvar gnus-dribble-ignore nil)
14348 (defvar gnus-dribble-eval-file nil)
14350 (defun gnus-dribble-file-name ()
14351 "Return the dribble file for the current .newsrc."
14353 (if gnus-dribble-directory
14354 (concat (file-name-as-directory gnus-dribble-directory)
14355 (file-name-nondirectory gnus-current-startup-file))
14356 gnus-current-startup-file)
14359 (defun gnus-dribble-enter (string)
14360 "Enter STRING into the dribble buffer."
14361 (if (and (not gnus-dribble-ignore)
14362 gnus-dribble-buffer
14363 (buffer-name gnus-dribble-buffer))
14364 (let ((obuf (current-buffer)))
14365 (set-buffer gnus-dribble-buffer)
14366 (insert string "\n")
14367 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14368 (set-buffer obuf))))
14370 (defun gnus-dribble-read-file ()
14371 "Read the dribble file from disk."
14372 (let ((dribble-file (gnus-dribble-file-name)))
14374 (set-buffer (setq gnus-dribble-buffer
14376 (file-name-nondirectory dribble-file))))
14377 (gnus-add-current-to-buffer-list)
14379 (setq buffer-file-name dribble-file)
14381 (buffer-disable-undo (current-buffer))
14382 (bury-buffer (current-buffer))
14383 (set-buffer-modified-p nil)
14384 (let ((auto (make-auto-save-file-name))
14385 (gnus-dribble-ignore t))
14386 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14387 ;; Load whichever file is newest -- the auto save file
14388 ;; or the "real" file.
14389 (if (file-newer-than-file-p auto dribble-file)
14390 (insert-file-contents auto)
14391 (insert-file-contents dribble-file))
14392 (unless (zerop (buffer-size))
14393 (set-buffer-modified-p t))
14394 ;; Set the file modes to reflect the .newsrc file modes.
14396 (when (file-exists-p gnus-current-startup-file)
14397 (set-file-modes dribble-file
14398 (file-modes gnus-current-startup-file)))
14399 ;; Possibly eval the file later.
14400 (when (gnus-y-or-n-p
14401 "Auto-save file exists. Do you want to read it? ")
14402 (setq gnus-dribble-eval-file t)))))))
14404 (defun gnus-dribble-eval-file ()
14405 (if (not gnus-dribble-eval-file)
14407 (setq gnus-dribble-eval-file nil)
14409 (let ((gnus-dribble-ignore t))
14410 (set-buffer gnus-dribble-buffer)
14411 (eval-buffer (current-buffer))))))
14413 (defun gnus-dribble-delete-file ()
14414 (if (file-exists-p (gnus-dribble-file-name))
14415 (delete-file (gnus-dribble-file-name)))
14416 (if gnus-dribble-buffer
14418 (set-buffer gnus-dribble-buffer)
14419 (let ((auto (make-auto-save-file-name)))
14420 (if (file-exists-p auto)
14421 (delete-file auto))
14423 (set-buffer-modified-p nil)))))
14425 (defun gnus-dribble-save ()
14426 (if (and gnus-dribble-buffer
14427 (buffer-name gnus-dribble-buffer))
14429 (set-buffer gnus-dribble-buffer)
14432 (defun gnus-dribble-clear ()
14434 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14436 (set-buffer gnus-dribble-buffer)
14438 (set-buffer-modified-p nil)
14439 (setq buffer-saved-size (buffer-size))))))
14443 ;;; Server Communication
14446 (defun gnus-start-news-server (&optional confirm)
14447 "Open a method for getting news.
14448 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14450 (if gnus-current-select-method
14451 ;; Stream is already opened.
14453 ;; Open NNTP server.
14454 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14457 ;; Read server name with completion.
14458 (setq gnus-nntp-server
14459 (completing-read "NNTP server: "
14460 (mapcar (lambda (server) (list server))
14461 (cons (list gnus-nntp-server)
14462 gnus-secondary-servers))
14463 nil nil gnus-nntp-server))))
14465 (if (and gnus-nntp-server
14466 (stringp gnus-nntp-server)
14467 (not (string= gnus-nntp-server "")))
14468 (setq gnus-select-method
14469 (cond ((or (string= gnus-nntp-server "")
14470 (string= gnus-nntp-server "::"))
14471 (list 'nnspool (system-name)))
14472 ((string-match "^:" gnus-nntp-server)
14473 (list 'nnmh gnus-nntp-server
14474 (list 'nnmh-directory
14475 (file-name-as-directory
14477 (concat "~/" (substring
14478 gnus-nntp-server 1)))))
14479 (list 'nnmh-get-new-mail nil)))
14481 (list 'nntp gnus-nntp-server)))))
14483 (setq how (car gnus-select-method))
14484 (cond ((eq how 'nnspool)
14486 (gnus-message 5 "Looking up local news spool..."))
14489 (gnus-message 5 "Looking up mh spool..."))
14492 (setq gnus-current-select-method gnus-select-method)
14493 (run-hooks 'gnus-open-server-hook)
14495 ;; gnus-open-server-hook might have opened it
14496 (gnus-server-opened gnus-select-method)
14497 (gnus-open-server gnus-select-method)
14500 "%s (%s) open error: '%s'. Continue? "
14501 (car gnus-select-method) (cadr gnus-select-method)
14502 (gnus-status-message gnus-select-method)))
14504 (gnus-message 1 "Couldn't open server on %s"
14505 (nth 1 gnus-select-method))
14509 (defun gnus-check-group (group)
14510 "Try to make sure that the server where GROUP exists is alive."
14511 (let ((method (gnus-find-method-for-group group)))
14512 (or (gnus-server-opened method)
14513 (gnus-open-server method))))
14515 (defun gnus-check-server (&optional method silent)
14516 "Check whether the connection to METHOD is down.
14517 If METHOD is nil, use `gnus-select-method'.
14518 If it is down, start it up (again)."
14519 (let ((method (or method gnus-select-method)))
14520 ;; Transform virtual server names into select methods.
14521 (when (stringp method)
14522 (setq method (gnus-server-to-method method)))
14523 (if (gnus-server-opened method)
14524 ;; The stream is already opened.
14526 ;; Open the server.
14528 (gnus-message 5 "Opening %s server%s..." (car method)
14529 (if (equal (nth 1 method) "") ""
14530 (format " on %s" (nth 1 method)))))
14531 (run-hooks 'gnus-open-server-hook)
14533 (gnus-open-server method)
14537 (defun gnus-get-function (method function)
14538 "Return a function symbol based on METHOD and FUNCTION."
14539 ;; Translate server names into methods.
14541 (error "Attempted use of a nil select method"))
14542 (when (stringp method)
14543 (setq method (gnus-server-to-method method)))
14544 (let ((func (intern (format "%s-%s" (car method) function))))
14545 ;; If the functions isn't bound, we require the backend in
14547 (unless (fboundp func)
14548 (require (car method))
14549 (unless (fboundp func)
14550 ;; This backend doesn't implement this function.
14551 (error "No such function: %s" func)))
14556 ;;; Interface functions to the backends.
14559 (defun gnus-open-server (method)
14560 "Open a connection to METHOD."
14561 (let ((elem (assoc method gnus-opened-servers)))
14562 ;; If this method was previously denied, we just return nil.
14563 (if (eq (nth 1 elem) 'denied)
14565 (gnus-message 1 "Denied server")
14567 ;; Open the server.
14569 (funcall (gnus-get-function method 'open-server)
14570 (nth 1 method) (nthcdr 2 method))))
14571 ;; If this hasn't been opened before, we add it to the list.
14573 (setq elem (list method nil)
14574 gnus-opened-servers (cons elem gnus-opened-servers)))
14575 ;; Set the status of this server.
14576 (setcar (cdr elem) (if result 'ok 'denied))
14577 ;; Return the result from the "open" call.
14580 (defun gnus-close-server (method)
14581 "Close the connection to METHOD."
14582 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14584 (defun gnus-request-list (method)
14585 "Request the active file from METHOD."
14586 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14588 (defun gnus-request-list-newsgroups (method)
14589 "Request the newsgroups file from METHOD."
14590 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14592 (defun gnus-request-newgroups (date method)
14593 "Request all new groups since DATE from METHOD."
14594 (funcall (gnus-get-function method 'request-newgroups)
14595 date (nth 1 method)))
14597 (defun gnus-server-opened (method)
14598 "Check whether a connection to METHOD has been opened."
14599 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14601 (defun gnus-status-message (method)
14602 "Return the status message from METHOD.
14603 If METHOD is a string, it is interpreted as a group name. The method
14604 this group uses will be queried."
14605 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14607 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14609 (defun gnus-request-group (group &optional dont-check method)
14610 "Request GROUP. If DONT-CHECK, no information is required."
14611 (let ((method (or method (gnus-find-method-for-group group))))
14612 (funcall (gnus-get-function method 'request-group)
14613 (gnus-group-real-name group) (nth 1 method) dont-check)))
14615 (defun gnus-request-asynchronous (group &optional articles)
14616 "Request that GROUP behave asynchronously.
14617 ARTICLES is the `data' of the group."
14618 (let ((method (gnus-find-method-for-group group)))
14619 (funcall (gnus-get-function method 'request-asynchronous)
14620 (gnus-group-real-name group) (nth 1 method) articles)))
14622 (defun gnus-list-active-group (group)
14623 "Request active information on GROUP."
14624 (let ((method (gnus-find-method-for-group group))
14625 (func 'list-active-group))
14626 (when (gnus-check-backend-function func group)
14627 (funcall (gnus-get-function method func)
14628 (gnus-group-real-name group) (nth 1 method)))))
14630 (defun gnus-request-group-description (group)
14631 "Request a description of GROUP."
14632 (let ((method (gnus-find-method-for-group group))
14633 (func 'request-group-description))
14634 (when (gnus-check-backend-function func group)
14635 (funcall (gnus-get-function method func)
14636 (gnus-group-real-name group) (nth 1 method)))))
14638 (defun gnus-close-group (group)
14639 "Request the GROUP be closed."
14640 (let ((method (gnus-find-method-for-group group)))
14641 (funcall (gnus-get-function method 'close-group)
14642 (gnus-group-real-name group) (nth 1 method))))
14644 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14645 "Request headers for ARTICLES in GROUP.
14646 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14647 (let ((method (gnus-find-method-for-group group)))
14648 (if (and gnus-use-cache (numberp (car articles)))
14649 (gnus-cache-retrieve-headers articles group fetch-old)
14650 (funcall (gnus-get-function method 'retrieve-headers)
14651 articles (gnus-group-real-name group) (nth 1 method)
14654 (defun gnus-retrieve-groups (groups method)
14655 "Request active information on GROUPS from METHOD."
14656 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14658 (defun gnus-request-type (group &optional article)
14659 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14660 (let ((method (gnus-find-method-for-group group)))
14661 (if (not (gnus-check-backend-function 'request-type (car method)))
14663 (funcall (gnus-get-function method 'request-type)
14664 (gnus-group-real-name group) article))))
14666 (defun gnus-request-update-mark (group article mark)
14667 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14668 (let ((method (gnus-find-method-for-group group)))
14669 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14671 (funcall (gnus-get-function method 'request-update-mark)
14672 (gnus-group-real-name group) article mark))))
14674 (defun gnus-request-article (article group &optional buffer)
14675 "Request the ARTICLE in GROUP.
14676 ARTICLE can either be an article number or an article Message-ID.
14677 If BUFFER, insert the article in that group."
14678 (let ((method (gnus-find-method-for-group group)))
14679 (funcall (gnus-get-function method 'request-article)
14680 article (gnus-group-real-name group) (nth 1 method) buffer)))
14682 (defun gnus-request-head (article group)
14683 "Request the head of ARTICLE in GROUP."
14684 (let ((method (gnus-find-method-for-group group)))
14685 (funcall (gnus-get-function method 'request-head)
14686 article (gnus-group-real-name group) (nth 1 method))))
14688 (defun gnus-request-body (article group)
14689 "Request the body of ARTICLE in GROUP."
14690 (let ((method (gnus-find-method-for-group group)))
14691 (funcall (gnus-get-function method 'request-body)
14692 article (gnus-group-real-name group) (nth 1 method))))
14694 (defun gnus-request-post (method)
14695 "Post the current buffer using METHOD."
14696 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14698 (defun gnus-request-scan (group method)
14699 "Request a SCAN being performed in GROUP from METHOD.
14700 If GROUP is nil, all groups on METHOD are scanned."
14701 (let ((method (if group (gnus-find-method-for-group group) method)))
14702 (funcall (gnus-get-function method 'request-scan)
14703 (and group (gnus-group-real-name group)) (nth 1 method))))
14705 (defsubst gnus-request-update-info (info method)
14706 "Request that METHOD update INFO."
14707 (when (gnus-check-backend-function 'request-update-info (car method))
14708 (funcall (gnus-get-function method 'request-update-info)
14709 (gnus-group-real-name (gnus-info-group info))
14710 info (nth 1 method))))
14712 (defun gnus-request-expire-articles (articles group &optional force)
14713 (let ((method (gnus-find-method-for-group group)))
14714 (funcall (gnus-get-function method 'request-expire-articles)
14715 articles (gnus-group-real-name group) (nth 1 method)
14718 (defun gnus-request-move-article
14719 (article group server accept-function &optional last)
14720 (let ((method (gnus-find-method-for-group group)))
14721 (funcall (gnus-get-function method 'request-move-article)
14722 article (gnus-group-real-name group)
14723 (nth 1 method) accept-function last)))
14725 (defun gnus-request-accept-article (group &optional last method)
14726 ;; Make sure there's a newline at the end of the article.
14727 (goto-char (point-max))
14730 (let ((func (if (symbolp group) group
14731 (car (or method (gnus-find-method-for-group group))))))
14732 (funcall (intern (format "%s-request-accept-article" func))
14733 (if (stringp group) (gnus-group-real-name group) group)
14736 (defun gnus-request-replace-article (article group buffer)
14737 (let ((func (car (gnus-find-method-for-group group))))
14738 (funcall (intern (format "%s-request-replace-article" func))
14739 article (gnus-group-real-name group) buffer)))
14741 (defun gnus-request-associate-buffer (group)
14742 (let ((method (gnus-find-method-for-group group)))
14743 (funcall (gnus-get-function method 'request-associate-buffer)
14744 (gnus-group-real-name group))))
14746 (defun gnus-request-restore-buffer (article group)
14747 "Request a new buffer restored to the state of ARTICLE."
14748 (let ((method (gnus-find-method-for-group group)))
14749 (funcall (gnus-get-function method 'request-restore-buffer)
14750 article (gnus-group-real-name group) (nth 1 method))))
14752 (defun gnus-request-create-group (group &optional method)
14753 (let ((method (or method (gnus-find-method-for-group group))))
14754 (funcall (gnus-get-function method 'request-create-group)
14755 (gnus-group-real-name group) (nth 1 method))))
14757 (defun gnus-request-delete-group (group &optional force)
14758 (let ((method (gnus-find-method-for-group group)))
14759 (funcall (gnus-get-function method 'request-delete-group)
14760 (gnus-group-real-name group) force (nth 1 method))))
14762 (defun gnus-request-rename-group (group new-name)
14763 (let ((method (gnus-find-method-for-group group)))
14764 (funcall (gnus-get-function method 'request-rename-group)
14765 (gnus-group-real-name group)
14766 (gnus-group-real-name new-name) (nth 1 method))))
14768 (defun gnus-member-of-valid (symbol group)
14769 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14770 (memq symbol (assoc
14771 (symbol-name (car (gnus-find-method-for-group group)))
14772 gnus-valid-select-methods)))
14774 (defun gnus-method-option-p (method option)
14775 "Return non-nil if select METHOD has OPTION as a parameter."
14776 (memq option (assoc (format "%s" (car method))
14777 gnus-valid-select-methods)))
14779 (defun gnus-server-extend-method (group method)
14780 ;; This function "extends" a virtual server. If the server is
14781 ;; "hello", and the select method is ("hello" (my-var "something"))
14782 ;; in the group "alt.alt", this will result in a new virtual server
14783 ;; called "hello+alt.alt".
14785 (gnus-copy-sequence
14786 (if (equal (car method) "native") gnus-select-method
14787 (cdr (assoc (car method) gnus-server-alist))))))
14788 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14789 (nconc entry (cdr method))))
14791 (defun gnus-find-method-for-group (group &optional info)
14792 "Find the select method that GROUP uses."
14793 (or gnus-override-method
14795 gnus-select-method)
14796 (let ((info (or info (gnus-get-info group)))
14799 (not (setq method (gnus-info-method info)))
14800 (equal method "native"))
14803 (cond ((stringp method)
14804 (gnus-server-to-method method))
14805 ((stringp (car method))
14806 (gnus-server-extend-method group method))
14809 (if (equal (cadr method) "")
14811 (gnus-server-add-address method))))))
14813 (defun gnus-check-backend-function (func group)
14814 "Check whether GROUP supports function FUNC."
14815 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14817 (fboundp (intern (format "%s-%s" method func)))))
14819 (defun gnus-methods-using (feature)
14820 "Find all methods that have FEATURE."
14821 (let ((valids gnus-valid-select-methods)
14824 (if (memq feature (car valids))
14825 (setq outs (cons (car valids) outs)))
14826 (setq valids (cdr valids)))
14831 ;;; Active & Newsrc File Handling
14834 (defun gnus-setup-news (&optional rawfile level)
14835 "Setup news information.
14836 If RAWFILE is non-nil, the .newsrc file will also be read.
14837 If LEVEL is non-nil, the news will be set up at level LEVEL."
14838 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
14839 ;; Clear some variables to re-initialize news information.
14840 (if init (setq gnus-newsrc-alist nil
14841 gnus-active-hashtb nil))
14843 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
14844 (if init (gnus-read-newsrc-file rawfile))
14846 (when (and (not (assoc "archive" gnus-server-alist))
14847 gnus-message-archive-method)
14848 (push (cons "archive" gnus-message-archive-method)
14849 gnus-server-alist))
14851 ;; If we don't read the complete active file, we fill in the
14853 (if (or (null gnus-read-active-file)
14854 (eq gnus-read-active-file 'some))
14855 (gnus-update-active-hashtb-from-killed))
14857 ;; Read the active file and create `gnus-active-hashtb'.
14858 ;; If `gnus-read-active-file' is nil, then we just create an empty
14859 ;; hash table. The partial filling out of the hash table will be
14860 ;; done in `gnus-get-unread-articles'.
14861 (and gnus-read-active-file
14863 (gnus-read-active-file))
14865 (or gnus-active-hashtb
14866 (setq gnus-active-hashtb (make-vector 4095 0)))
14868 ;; Initialize the cache.
14869 (when gnus-use-cache
14872 ;; Possibly eval the dribble file.
14873 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
14875 (gnus-update-format-specifications)
14877 ;; Find new newsgroups and treat them.
14878 (if (and init gnus-check-new-newsgroups (not level)
14879 (gnus-check-server gnus-select-method))
14880 (gnus-find-new-newsgroups))
14882 ;; Find the number of unread articles in each non-dead group.
14883 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
14884 (gnus-get-unread-articles level))
14886 (if (and init gnus-check-bogus-newsgroups
14887 gnus-read-active-file (not level)
14888 (gnus-server-opened gnus-select-method))
14889 (gnus-check-bogus-newsgroups))))
14891 (defun gnus-find-new-newsgroups (&optional arg)
14892 "Search for new newsgroups and add them.
14893 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
14894 The `-n' option line from .newsrc is respected.
14895 If ARG (the prefix), use the `ask-server' method to query
14896 the server for new groups."
14898 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
14899 (null gnus-read-active-file)
14900 (eq gnus-read-active-file 'some))
14901 'ask-server gnus-check-new-newsgroups)))
14902 (unless (gnus-check-first-time-used)
14903 (if (or (consp check)
14904 (eq check 'ask-server))
14905 ;; Ask the server for new groups.
14906 (gnus-ask-server-for-new-groups)
14907 ;; Go through the active hashtb and look for new groups.
14909 group new-newsgroups)
14910 (gnus-message 5 "Looking for new newsgroups...")
14911 (unless gnus-have-read-active-file
14912 (gnus-read-active-file))
14913 (setq gnus-newsrc-last-checked-date (current-time-string))
14914 (unless gnus-killed-hashtb
14915 (gnus-make-hashtable-from-killed))
14916 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
14917 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
14920 (if (or (null (setq group (symbol-name sym)))
14922 (null (symbol-value sym))
14923 (gnus-gethash group gnus-killed-hashtb)
14924 (gnus-gethash group gnus-newsrc-hashtb))
14926 (let ((do-sub (gnus-matches-options-n group)))
14928 ((eq do-sub 'subscribe)
14929 (setq groups (1+ groups))
14930 (gnus-sethash group group gnus-killed-hashtb)
14931 (funcall gnus-subscribe-options-newsgroup-method group))
14932 ((eq do-sub 'ignore)
14935 (setq groups (1+ groups))
14936 (gnus-sethash group group gnus-killed-hashtb)
14937 (if gnus-subscribe-hierarchical-interactive
14938 (setq new-newsgroups (cons group new-newsgroups))
14939 (funcall gnus-subscribe-newsgroup-method group)))))))
14940 gnus-active-hashtb)
14941 (when new-newsgroups
14942 (gnus-subscribe-hierarchical-interactive new-newsgroups))
14943 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14945 (gnus-message 6 "%d new newsgroup%s arrived."
14946 groups (if (> groups 1) "s have" " has"))
14947 (gnus-message 6 "No new newsgroups.")))))))
14949 (defun gnus-matches-options-n (group)
14950 ;; Returns `subscribe' if the group is to be unconditionally
14951 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
14952 ;; no match for the group.
14954 ;; First we check the two user variables.
14956 ((and gnus-options-subscribe
14957 (string-match gnus-options-subscribe group))
14959 ((and gnus-auto-subscribed-groups
14960 (string-match gnus-auto-subscribed-groups group))
14962 ((and gnus-options-not-subscribe
14963 (string-match gnus-options-not-subscribe group))
14965 ;; Then we go through the list that was retrieved from the .newsrc
14966 ;; file. This list has elements on the form
14967 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
14968 ;; is in the reverse order of the options line) is returned.
14970 (let ((regs gnus-newsrc-options-n))
14972 (not (string-match (caar regs) group)))
14973 (setq regs (cdr regs)))
14974 (and regs (cdar regs))))))
14976 (defun gnus-ask-server-for-new-groups ()
14977 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
14978 (methods (cons gnus-select-method
14980 (when gnus-message-archive-method
14983 (and (consp gnus-check-new-newsgroups)
14984 gnus-check-new-newsgroups)
14985 gnus-secondary-select-methods))))
14987 (new-date (current-time-string))
14988 group new-newsgroups got-new method hashtb
14989 gnus-override-subscribe-method)
14990 ;; Go through both primary and secondary select methods and
14991 ;; request new newsgroups.
14992 (while (setq method (gnus-server-get-method nil (pop methods)))
14993 (setq new-newsgroups nil)
14994 (setq gnus-override-subscribe-method method)
14995 (when (and (gnus-check-server method)
14996 (gnus-request-newgroups date method))
14999 (setq hashtb (gnus-make-hashtable 100))
15000 (set-buffer nntp-server-buffer)
15001 ;; Enter all the new groups into a hashtable.
15002 (gnus-active-to-gnus-format method hashtb 'ignore)))
15003 ;; Now all new groups from `method' are in `hashtb'.
15005 (lambda (group-sym)
15006 (if (or (null (setq group (symbol-name group-sym)))
15007 (null (symbol-value group-sym))
15008 (gnus-gethash group gnus-newsrc-hashtb)
15009 (member group gnus-zombie-list)
15010 (member group gnus-killed-list))
15011 ;; The group is already known.
15013 ;; Make this group active.
15014 (when (symbol-value group-sym)
15015 (gnus-set-active group (symbol-value group-sym)))
15016 ;; Check whether we want it or not.
15017 (let ((do-sub (gnus-matches-options-n group)))
15019 ((eq do-sub 'subscribe)
15021 (gnus-sethash group group gnus-killed-hashtb)
15022 (funcall gnus-subscribe-options-newsgroup-method group))
15023 ((eq do-sub 'ignore)
15027 (gnus-sethash group group gnus-killed-hashtb)
15028 (if gnus-subscribe-hierarchical-interactive
15029 (push group new-newsgroups)
15030 (funcall gnus-subscribe-newsgroup-method group)))))))
15032 (when new-newsgroups
15033 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15034 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15036 (gnus-message 6 "%d new newsgroup%s arrived."
15037 groups (if (> groups 1) "s have" " has")))
15038 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15041 (defun gnus-check-first-time-used ()
15042 (if (or (> (length gnus-newsrc-alist) 1)
15043 (file-exists-p gnus-startup-file)
15044 (file-exists-p (concat gnus-startup-file ".el"))
15045 (file-exists-p (concat gnus-startup-file ".eld")))
15047 (gnus-message 6 "First time user; subscribing you to default groups")
15048 (unless gnus-have-read-active-file
15049 (gnus-read-active-file))
15050 (setq gnus-newsrc-last-checked-date (current-time-string))
15051 (let ((groups gnus-default-subscribed-newsgroups)
15055 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15058 (if (null (setq group (symbol-name sym)))
15060 (let ((do-sub (gnus-matches-options-n group)))
15062 ((eq do-sub 'subscribe)
15063 (gnus-sethash group group gnus-killed-hashtb)
15064 (funcall gnus-subscribe-options-newsgroup-method group))
15065 ((eq do-sub 'ignore)
15068 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15069 gnus-active-hashtb)
15071 (if (gnus-active (car groups))
15072 (gnus-group-change-level
15073 (car groups) gnus-level-default-subscribed gnus-level-killed))
15074 (setq groups (cdr groups)))
15075 (gnus-group-make-help-group)
15076 (and gnus-novice-user
15077 (gnus-message 7 "`A k' to list killed groups"))))))
15079 (defun gnus-subscribe-group (group previous &optional method)
15080 (gnus-group-change-level
15082 (list t group gnus-level-default-subscribed nil nil method)
15084 gnus-level-default-subscribed gnus-level-killed previous t))
15086 ;; `gnus-group-change-level' is the fundamental function for changing
15087 ;; subscription levels of newsgroups. This might mean just changing
15088 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15089 ;; again, which subscribes/unsubscribes a group, which is equally
15090 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15091 ;; from 8-9 to 1-7 means that you remove the group from the list of
15092 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15093 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15094 ;; which is trivial.
15095 ;; ENTRY can either be a string (newsgroup name) or a list (if
15096 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15097 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15099 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15100 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15102 (defun gnus-group-change-level (entry level &optional oldlevel
15103 previous fromkilled)
15104 (let (group info active num)
15105 ;; Glean what info we can from the arguments
15107 (if fromkilled (setq group (nth 1 entry))
15108 (setq group (car (nth 2 entry))))
15109 (setq group entry))
15110 (if (and (stringp entry)
15112 (< oldlevel gnus-level-zombie))
15113 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15114 (if (and (not oldlevel)
15116 (setq oldlevel (gnus-info-level (nth 2 entry)))
15118 (if (stringp previous)
15119 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15121 (if (and (>= oldlevel gnus-level-zombie)
15122 (gnus-gethash group gnus-newsrc-hashtb))
15123 ;; We are trying to subscribe a group that is already
15127 (or (gnus-ephemeral-group-p group)
15128 (gnus-dribble-enter
15129 (format "(gnus-group-change-level %S %S %S %S %S)"
15130 group level oldlevel (car (nth 2 previous)) fromkilled)))
15132 ;; Then we remove the newgroup from any old structures, if needed.
15133 ;; If the group was killed, we remove it from the killed or zombie
15134 ;; list. If not, and it is in fact going to be killed, we remove
15135 ;; it from the newsrc hash table and assoc.
15137 ((>= oldlevel gnus-level-zombie)
15138 (if (= oldlevel gnus-level-zombie)
15139 (setq gnus-zombie-list (delete group gnus-zombie-list))
15140 (setq gnus-killed-list (delete group gnus-killed-list))))
15142 (if (and (>= level gnus-level-zombie)
15145 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15147 (setcdr (gnus-gethash (car (nth 3 entry))
15148 gnus-newsrc-hashtb)
15150 (setcdr (cdr entry) (cdddr entry))))))
15152 ;; Finally we enter (if needed) the list where it is supposed to
15153 ;; go, and change the subscription level. If it is to be killed,
15154 ;; we enter it into the killed or zombie list.
15156 ((>= level gnus-level-zombie)
15157 ;; Remove from the hash table.
15158 (gnus-sethash group nil gnus-newsrc-hashtb)
15159 ;; We do not enter foreign groups into the list of dead
15161 (unless (gnus-group-foreign-p group)
15162 (if (= level gnus-level-zombie)
15163 (setq gnus-zombie-list (cons group gnus-zombie-list))
15164 (setq gnus-killed-list (cons group gnus-killed-list)))))
15166 ;; If the list is to be entered into the newsrc assoc, and
15167 ;; it was killed, we have to create an entry in the newsrc
15168 ;; hashtb format and fix the pointers in the newsrc assoc.
15169 (if (< oldlevel gnus-level-zombie)
15170 ;; It was alive, and it is going to stay alive, so we
15171 ;; just change the level and don't change any pointers or
15172 ;; hash table entries.
15173 (setcar (cdaddr entry) level)
15175 (setq info (cdr entry)
15177 (setq active (gnus-active group))
15179 (if active (- (1+ (cdr active)) (car active)) t))
15180 ;; Check whether the group is foreign. If so, the
15181 ;; foreign select method has to be entered into the
15183 (let ((method (or gnus-override-subscribe-method
15184 (gnus-group-method group))))
15185 (if (eq method gnus-select-method)
15186 (setq info (list group level nil))
15187 (setq info (list group level nil nil method)))))
15190 (let ((p gnus-newsrc-alist))
15194 (setq entry (cons info (cddr previous)))
15197 (setcdr (cdr previous) entry)
15198 (gnus-sethash group (cons num (cdr previous))
15199 gnus-newsrc-hashtb))
15200 (setcdr previous entry)
15201 (gnus-sethash group (cons num previous)
15202 gnus-newsrc-hashtb))
15204 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15205 (when gnus-group-change-level-function
15206 (funcall gnus-group-change-level-function group level oldlevel)))))
15208 (defun gnus-kill-newsgroup (newsgroup)
15209 "Obsolete function. Kills a newsgroup."
15210 (gnus-group-change-level
15211 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15213 (defun gnus-check-bogus-newsgroups (&optional confirm)
15214 "Remove bogus newsgroups.
15215 If CONFIRM is non-nil, the user has to confirm the deletion of every
15217 (let ((newsrc (cdr gnus-newsrc-alist))
15218 bogus group entry info)
15219 (gnus-message 5 "Checking bogus newsgroups...")
15220 (unless gnus-have-read-active-file
15221 (gnus-read-active-file))
15222 (when (member gnus-select-method gnus-have-read-active-file)
15223 ;; Find all bogus newsgroup that are subscribed.
15225 (setq info (pop newsrc)
15226 group (gnus-info-group info))
15227 (unless (or (gnus-active group) ; Active
15228 (gnus-info-method info) ; Foreign
15230 (not (gnus-y-or-n-p
15231 (format "Remove bogus newsgroup: %s " group)))))
15232 ;; Found a bogus newsgroup.
15233 (push group bogus)))
15234 ;; Remove all bogus subscribed groups by first killing them, and
15235 ;; then removing them from the list of killed groups.
15237 (when (setq entry (gnus-gethash (setq group (pop bogus))
15238 gnus-newsrc-hashtb))
15239 (gnus-group-change-level entry gnus-level-killed)
15240 (setq gnus-killed-list (delete group gnus-killed-list))))
15241 ;; Then we remove all bogus groups from the list of killed and
15242 ;; zombie groups. They are are removed without confirmation.
15243 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15246 (setq killed (symbol-value (car dead-lists)))
15248 (unless (gnus-active (setq group (pop killed)))
15249 ;; The group is bogus.
15250 ;; !!!Slow as hell.
15251 (set (car dead-lists)
15252 (delete group (symbol-value (car dead-lists))))))
15253 (setq dead-lists (cdr dead-lists))))
15254 (gnus-message 5 "Checking bogus newsgroups...done"))))
15256 (defun gnus-check-duplicate-killed-groups ()
15257 "Remove duplicates from the list of killed groups."
15259 (let ((killed gnus-killed-list))
15261 (gnus-message 9 "%d" (length killed))
15262 (setcdr killed (delete (car killed) (cdr killed)))
15263 (setq killed (cdr killed)))))
15265 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15266 ;; and compute how many unread articles there are in each group.
15267 (defun gnus-get-unread-articles (&optional level)
15268 (let* ((newsrc (cdr gnus-newsrc-alist))
15269 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15272 (cond ((and gnus-activate-foreign-newsgroups
15273 (not (numberp gnus-activate-foreign-newsgroups)))
15274 (1+ gnus-level-subscribed))
15275 ((numberp gnus-activate-foreign-newsgroups)
15276 gnus-activate-foreign-newsgroups)
15279 info group active method)
15280 (gnus-message 5 "Checking new news...")
15283 (setq active (gnus-active (setq group (gnus-info-group
15284 (setq info (pop newsrc))))))
15286 ;; Check newsgroups. If the user doesn't want to check them, or
15287 ;; they can't be checked (for instance, if the news server can't
15288 ;; be reached) we just set the number of unread articles in this
15289 ;; newsgroup to t. This means that Gnus thinks that there are
15290 ;; unread articles, but it has no idea how many.
15291 (if (and (setq method (gnus-info-method info))
15292 (not (gnus-server-equal
15294 (gnus-server-get-method nil method)))
15295 (not (gnus-secondary-method-p method)))
15296 ;; These groups are foreign. Check the level.
15297 (when (<= (gnus-info-level info) foreign-level)
15298 (setq active (gnus-activate-group group 'scan))
15299 (gnus-close-group group))
15301 ;; These groups are native or secondary.
15302 (when (and (<= (gnus-info-level info) level)
15303 (not gnus-read-active-file))
15304 (setq active (gnus-activate-group group 'scan))
15305 (gnus-close-group group)))
15308 (gnus-get-unread-articles-in-group info active t)
15309 ;; The group couldn't be reached, so we nix out the number of
15310 ;; unread articles and stuff.
15311 (gnus-set-active group nil)
15312 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15314 (gnus-message 5 "Checking new news...done")))
15316 ;; Create a hash table out of the newsrc alist. The `car's of the
15317 ;; alist elements are used as keys.
15318 (defun gnus-make-hashtable-from-newsrc-alist ()
15319 (let ((alist gnus-newsrc-alist)
15320 (ohashtb gnus-newsrc-hashtb)
15322 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15324 (setq prev (setq gnus-newsrc-alist
15325 (if (equal (caar gnus-newsrc-alist)
15328 (cons (list "dummy.group" 0 nil) alist)))))
15332 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15334 gnus-newsrc-hashtb)
15336 alist (cdr alist)))))
15338 (defun gnus-make-hashtable-from-killed ()
15339 "Create a hash table from the killed and zombie lists."
15340 (let ((lists '(gnus-killed-list gnus-zombie-list))
15342 (setq gnus-killed-hashtb
15343 (gnus-make-hashtable
15344 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15346 (setq list (symbol-value (car lists)))
15347 (setq lists (cdr lists))
15349 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
15350 (setq list (cdr list))))))
15352 (defun gnus-get-unread-articles-in-group (info active &optional update)
15354 ;; Allow the backend to update the info in the group.
15356 (gnus-request-update-info
15357 info (gnus-find-method-for-group (gnus-info-group info))))
15358 (gnus-activate-group (gnus-info-group info)))
15359 (let* ((range (gnus-info-read info))
15361 (marked (gnus-info-marks info)))
15362 ;; If a cache is present, we may have to alter the active info.
15363 (when (and gnus-use-cache info)
15364 (gnus-cache-possibly-alter-active (gnus-info-group info) active))
15365 ;; Modify the list of read articles according to what articles
15366 ;; are available; then tally the unread articles and add the
15367 ;; number to the group hash table entry.
15369 ((zerop (cdr active))
15372 (setq num (- (1+ (cdr active)) (car active))))
15373 ((not (listp (cdr range)))
15374 ;; Fix a single (num . num) range according to the
15375 ;; active hash table.
15376 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15377 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15378 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15379 ;; Compute number of unread articles.
15380 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15382 ;; The read list is a list of ranges. Fix them according to
15383 ;; the active hash table.
15384 ;; First peel off any elements that are below the lower
15386 (while (and (cdr range)
15388 (or (and (atom (cadr range)) (cadr range))
15390 (if (numberp (car range))
15393 (or (and (numberp (cadr range))
15396 (setcdr (car range)
15397 (or (and (numberp (nth 1 range)) (nth 1 range))
15399 (setcdr range (cddr range)))
15400 ;; Adjust the first element to be the same as the lower limit.
15401 (if (and (not (atom (car range)))
15402 (< (cdar range) (car active)))
15403 (setcdr (car range) (1- (car active))))
15404 ;; Then we want to peel off any elements that are higher
15405 ;; than the upper active limit.
15406 (let ((srange range))
15407 ;; Go past all legal elements.
15408 (while (and (cdr srange)
15409 (<= (or (and (atom (cadr srange))
15411 (caadr srange)) (cdr active)))
15412 (setq srange (cdr srange)))
15414 ;; Nuke all remaining illegal elements.
15415 (setcdr srange nil))
15417 ;; Adjust the final element.
15418 (if (and (not (atom (car srange)))
15419 (> (cdar srange) (cdr active)))
15420 (setcdr (car srange) (cdr active))))
15421 ;; Compute the number of unread articles.
15423 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15425 (or (and (atom (car range)) (car range))
15427 (setq range (cdr range)))
15428 (setq num (max 0 (- (cdr active) num)))))
15429 ;; Set the number of unread articles.
15431 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15434 (defun gnus-activate-group (group &optional scan)
15435 ;; Check whether a group has been activated or not.
15436 ;; If SCAN, request a scan of that group as well.
15437 (let ((method (gnus-find-method-for-group group))
15439 (and (gnus-check-server method)
15440 ;; We escape all bugs and quit here to make it possible to
15441 ;; continue if a group is so out-there that it reports bugs
15445 (gnus-check-backend-function 'request-scan (car method))
15446 (gnus-request-scan group method))
15449 (gnus-request-group group)
15453 (set-buffer nntp-server-buffer)
15454 (goto-char (point-min))
15455 ;; Parse the result we got from `gnus-request-group'.
15456 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15458 (goto-char (match-beginning 1))
15460 group (setq active (cons (read (current-buffer))
15461 (read (current-buffer)))))
15462 ;; Return the new active info.
15465 (defun gnus-update-read-articles (group unread)
15466 "Update the list of read and ticked articles in GROUP using the
15467 UNREAD and TICKED lists.
15468 Note: UNSELECTED has to be sorted over `<'.
15469 Returns whether the updating was successful."
15470 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15471 (entry (gnus-gethash group gnus-newsrc-hashtb))
15472 (info (nth 2 entry))
15473 (marked (gnus-info-marks info))
15475 (unread (sort (copy-sequence unread) '<))
15477 (if (or (not info) (not active))
15478 ;; There is no info on this group if it was, in fact,
15479 ;; killed. Gnus stores no information on killed groups, so
15480 ;; there's nothing to be done.
15481 ;; One could store the information somewhere temporarily,
15482 ;; perhaps... Hmmm...
15484 ;; Remove any negative articles numbers.
15485 (while (and unread (< (car unread) 0))
15486 (setq unread (cdr unread)))
15487 ;; Remove any expired article numbers
15488 (while (and unread (< (car unread) (car active)))
15489 (setq unread (cdr unread)))
15490 ;; Compute the ranges of read articles by looking at the list of
15491 ;; unread articles.
15493 (if (/= (car unread) prev)
15494 (setq read (cons (if (= prev (1- (car unread))) prev
15495 (cons prev (1- (car unread)))) read)))
15496 (setq prev (1+ (car unread)))
15497 (setq unread (cdr unread)))
15498 (when (<= prev (cdr active))
15499 (setq read (cons (cons prev (cdr active)) read)))
15500 ;; Enter this list into the group info.
15501 (gnus-info-set-read
15502 info (if (> (length read) 1) (nreverse read) read))
15503 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15504 (gnus-get-unread-articles-in-group info (gnus-active group))
15507 (defun gnus-make-articles-unread (group articles)
15508 "Mark ARTICLES in GROUP as unread."
15509 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15510 (gnus-gethash (gnus-group-real-name group)
15511 gnus-newsrc-hashtb))))
15512 (ranges (gnus-info-read info))
15515 (when (gnus-member-of-range
15516 (setq article (pop articles)) ranges)
15517 (setq news (cons article news))))
15519 (gnus-info-set-read
15520 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15521 (gnus-group-update-group group t))))
15523 ;; Enter all dead groups into the hashtb.
15524 (defun gnus-update-active-hashtb-from-killed ()
15525 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15526 (lists (list gnus-killed-list gnus-zombie-list))
15529 (setq killed (car lists))
15531 (gnus-sethash (car killed) nil hashtb)
15532 (setq killed (cdr killed)))
15533 (setq lists (cdr lists)))))
15535 ;; Get the active file(s) from the backend(s).
15536 (defun gnus-read-active-file ()
15537 (gnus-group-set-mode-line)
15540 (if (gnus-check-server gnus-select-method)
15541 ;; The native server is available.
15542 (cons gnus-select-method gnus-secondary-select-methods)
15543 ;; The native server is down, so we just do the
15545 gnus-secondary-select-methods)
15546 ;; Also read from the archive server.
15547 (when gnus-message-archive-method
15548 (list "archive"))))
15550 (setq gnus-have-read-active-file nil)
15552 (set-buffer nntp-server-buffer)
15554 (let* ((method (if (stringp (car methods))
15555 (gnus-server-get-method nil (car methods))
15557 (where (nth 1 method))
15558 (mesg (format "Reading active file%s via %s..."
15559 (if (and where (not (zerop (length where))))
15560 (concat " from " where) "")
15562 (gnus-message 5 mesg)
15563 (when (gnus-check-server method)
15564 ;; Request that the backend scan its incoming messages.
15565 (and (gnus-check-backend-function 'request-scan (car method))
15566 (gnus-request-scan nil method))
15568 ((and (eq gnus-read-active-file 'some)
15569 (gnus-check-backend-function 'retrieve-groups (car method)))
15570 (let ((newsrc (cdr gnus-newsrc-alist))
15571 (gmethod (if (stringp method)
15572 (gnus-server-get-method nil method)
15575 (while (setq info (pop newsrc))
15576 (when (gnus-server-equal
15577 (gnus-find-method-for-group
15578 (gnus-info-group info) info)
15580 (push (gnus-group-real-name (gnus-info-group info))
15583 (gnus-check-server method)
15584 (setq list-type (gnus-retrieve-groups groups method))
15588 1 "Cannot read partial active file from %s server."
15592 ((eq list-type 'active)
15593 (gnus-active-to-gnus-format method gnus-active-hashtb))
15595 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15597 (if (not (gnus-request-list method))
15599 (unless (equal method gnus-message-archive-method)
15600 (gnus-message 1 "Cannot read active file from %s server."
15603 (gnus-active-to-gnus-format method)
15604 ;; We mark this active file as read.
15605 (push method gnus-have-read-active-file)
15606 (gnus-message 5 "%sdone" mesg))))))
15607 (setq methods (cdr methods))))))
15609 ;; Read an active file and place the results in `gnus-active-hashtb'.
15610 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15612 (setq method gnus-select-method))
15613 (let ((cur (current-buffer))
15615 (if (and gnus-active-hashtb
15616 (not (equal method gnus-select-method)))
15618 (setq gnus-active-hashtb
15619 (if (equal method gnus-select-method)
15620 (gnus-make-hashtable
15621 (count-lines (point-min) (point-max)))
15622 (gnus-make-hashtable 4096))))))
15623 (flag-hashtb (gnus-make-hashtable 60)))
15624 ;; Delete unnecessary lines.
15625 (goto-char (point-min))
15626 (while (search-forward "\nto." nil t)
15627 (delete-region (1+ (match-beginning 0))
15628 (progn (forward-line 1) (point))))
15629 (or (string= gnus-ignored-newsgroups "")
15631 (goto-char (point-min))
15632 (delete-matching-lines gnus-ignored-newsgroups)))
15633 ;; Make the group names readable as a lisp expression even if they
15634 ;; contain special characters.
15635 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15636 (goto-char (point-max))
15637 (while (re-search-backward "[][';?()#]" nil t)
15639 ;; If these are groups from a foreign select method, we insert the
15640 ;; group prefix in front of the group names.
15641 (and method (not (gnus-server-equal
15642 (gnus-server-get-method nil method)
15643 (gnus-server-get-method nil gnus-select-method)))
15644 (let ((prefix (gnus-group-prefixed-name "" method)))
15645 (goto-char (point-min))
15646 (while (and (not (eobp))
15647 (progn (insert prefix)
15648 (zerop (forward-line 1)))))))
15649 ;; Store the active file in a hash table.
15650 (goto-char (point-min))
15651 (if (string-match "%[oO]" gnus-group-line-format)
15652 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15653 ;; If we want information on moderated groups, we use this
15655 (let* ((mod-hashtb (make-vector 7 0))
15656 (m (intern "m" mod-hashtb))
15658 (while (not (eobp))
15659 (condition-case nil
15661 (narrow-to-region (point) (gnus-point-at-eol))
15662 (setq group (let ((obarray hashtb)) (read cur)))
15663 (if (and (numberp (setq max (read cur)))
15664 (numberp (setq min (read cur)))
15666 (skip-chars-forward " \t")
15668 (or (= (following-char) ?=)
15669 (= (following-char) ?x)
15670 (= (following-char) ?j)))))
15671 (set group (cons min max))
15673 ;; Enter moderated groups into a list.
15674 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15675 (setq gnus-moderated-list
15676 (cons (symbol-name group) gnus-moderated-list))))
15683 ;; And if we do not care about moderation, we use this loop,
15684 ;; which is faster.
15685 (let (group max min)
15686 (while (not (eobp))
15689 (narrow-to-region (point) (gnus-point-at-eol))
15690 ;; group gets set to a symbol interned in the hash table
15691 ;; (what a hack!!) - jwz
15692 (setq group (let ((obarray hashtb)) (read cur)))
15693 (if (and (numberp (setq max (read cur)))
15694 (numberp (setq min (read cur)))
15696 (skip-chars-forward " \t")
15698 (or (= (following-char) ?=)
15699 (= (following-char) ?x)
15700 (= (following-char) ?j)))))
15701 (set group (cons min max))
15709 (gnus-message 3 "Warning - illegal active: %s"
15711 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15713 (forward-line 1))))))
15715 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15716 ;; Parse a "groups" active file.
15717 (let ((cur (current-buffer))
15719 (if (and method gnus-active-hashtb)
15721 (setq gnus-active-hashtb
15722 (gnus-make-hashtable
15723 (count-lines (point-min) (point-max)))))))
15724 (prefix (and method
15725 (not (gnus-server-equal
15726 (gnus-server-get-method nil method)
15727 (gnus-server-get-method nil gnus-select-method)))
15728 (gnus-group-prefixed-name "" method))))
15730 (goto-char (point-min))
15731 ;; We split this into to separate loops, one with the prefix
15732 ;; and one without to speed the reading up somewhat.
15734 (let (min max opoint group)
15735 (while (not (eobp))
15738 (read cur) (read cur)
15739 (setq min (read cur)
15742 (skip-chars-forward " \t")
15745 (set (let ((obarray hashtb)) (read cur))
15747 (error (and group (symbolp group) (set group nil))))
15749 (let (min max group)
15750 (while (not (eobp))
15752 (if (= (following-char) ?2)
15754 (read cur) (read cur)
15755 (setq min (read cur)
15757 (set (setq group (let ((obarray hashtb)) (read cur)))
15759 (error (and group (symbolp group) (set group nil))))
15760 (forward-line 1))))))
15762 (defun gnus-read-newsrc-file (&optional force)
15763 "Read startup file.
15764 If FORCE is non-nil, the .newsrc file is read."
15765 ;; Reset variables that might be defined in the .newsrc.eld file.
15766 (let ((variables gnus-variable-list))
15768 (set (car variables) nil)
15769 (setq variables (cdr variables))))
15770 (let* ((newsrc-file gnus-current-startup-file)
15771 (quick-file (concat newsrc-file ".el")))
15773 ;; We always load the .newsrc.eld file. If always contains
15774 ;; much information that can not be gotten from the .newsrc
15775 ;; file (ticked articles, killed groups, foreign methods, etc.)
15776 (gnus-read-newsrc-el-file quick-file)
15778 (if (and (file-exists-p gnus-current-startup-file)
15780 (and (file-newer-than-file-p newsrc-file quick-file)
15781 (file-newer-than-file-p newsrc-file
15782 (concat quick-file "d")))
15783 (not gnus-newsrc-alist)))
15784 ;; We read the .newsrc file. Note that if there if a
15785 ;; .newsrc.eld file exists, it has already been read, and
15786 ;; the `gnus-newsrc-hashtb' has been created. While reading
15787 ;; the .newsrc file, Gnus will only use the information it
15788 ;; can find there for changing the data already read -
15789 ;; ie. reading the .newsrc file will not trash the data
15790 ;; already read (except for read articles).
15792 (gnus-message 5 "Reading %s..." newsrc-file)
15793 (set-buffer (find-file-noselect newsrc-file))
15794 (buffer-disable-undo (current-buffer))
15795 (gnus-newsrc-to-gnus-format)
15796 (kill-buffer (current-buffer))
15797 (gnus-message 5 "Reading %s...done" newsrc-file)))
15799 ;; Read any slave files.
15801 (gnus-master-read-slave-newsrc)))))
15803 (defun gnus-read-newsrc-el-file (file)
15804 (let ((ding-file (concat file "d")))
15805 ;; We always, always read the .eld file.
15806 (gnus-message 5 "Reading %s..." ding-file)
15807 (let (gnus-newsrc-assoc)
15808 (condition-case nil
15809 (load ding-file t t t)
15811 (gnus-message 1 "Error in %s" ding-file)
15813 (when gnus-newsrc-assoc
15814 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15815 (gnus-make-hashtable-from-newsrc-alist)
15816 (when (file-newer-than-file-p file ding-file)
15817 ;; Old format quick file
15818 (gnus-message 5 "Reading %s..." file)
15819 ;; The .el file is newer than the .eld file, so we read that one
15821 (gnus-read-old-newsrc-el-file file))))
15823 ;; Parse the old-style quick startup file
15824 (defun gnus-read-old-newsrc-el-file (file)
15825 (let (newsrc killed marked group m)
15827 (let ((gnus-killed-assoc nil)
15828 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
15830 (condition-case nil
15833 (setq newsrc gnus-newsrc-assoc
15834 killed gnus-killed-assoc
15835 marked gnus-marked-assoc)))
15836 (setq gnus-newsrc-alist nil)
15838 (setq group (car newsrc))
15839 (let ((info (gnus-get-info (car group))))
15842 (gnus-info-set-read info (cddr group))
15843 (gnus-info-set-level
15844 info (if (nth 1 group) gnus-level-default-subscribed
15845 gnus-level-default-unsubscribed))
15846 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
15847 (setq gnus-newsrc-alist
15851 (if (nth 1 group) gnus-level-default-subscribed
15852 gnus-level-default-unsubscribed)
15854 gnus-newsrc-alist)))
15855 (if (setq m (assoc (car group) marked))
15856 (gnus-info-set-marks
15857 info (cons (list (cons 'tick (gnus-compress-sequence
15858 (sort (cdr m) '<) t)))
15860 (setq newsrc (cdr newsrc)))
15861 (setq newsrc killed)
15863 (setcar newsrc (caar newsrc))
15864 (setq newsrc (cdr newsrc)))
15865 (setq gnus-killed-list killed))
15866 ;; The .el file version of this variable does not begin with
15867 ;; "options", while the .eld version does, so we just add it if it
15870 gnus-newsrc-options
15872 (and (not (string-match "^ *options" gnus-newsrc-options))
15873 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
15874 (and (not (string-match "\n$" gnus-newsrc-options))
15875 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
15876 ;; Finally, if we read some options lines, we parse them.
15877 (or (string= gnus-newsrc-options "")
15878 (gnus-newsrc-parse-options gnus-newsrc-options))))
15880 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
15881 (gnus-make-hashtable-from-newsrc-alist)))
15883 (defun gnus-make-newsrc-file (file)
15884 "Make server dependent file name by catenating FILE and server host name."
15885 (let* ((file (expand-file-name file nil))
15886 (real-file (concat file "-" (nth 1 gnus-select-method))))
15887 (if (or (file-exists-p real-file)
15888 (file-exists-p (concat real-file ".el"))
15889 (file-exists-p (concat real-file ".eld")))
15892 (defun gnus-newsrc-to-gnus-format ()
15893 (setq gnus-newsrc-options "")
15894 (setq gnus-newsrc-options-n nil)
15896 (or gnus-active-hashtb
15897 (setq gnus-active-hashtb (make-vector 4095 0)))
15898 (let ((buf (current-buffer))
15899 (already-read (> (length gnus-newsrc-alist) 1))
15900 group subscribed options-symbol newsrc Options-symbol
15902 (goto-char (point-min))
15903 ;; We intern the symbol `options' in the active hashtb so that we
15904 ;; can `eq' against it later.
15905 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
15906 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
15908 (while (not (eobp))
15909 ;; We first read the first word on the line by narrowing and
15910 ;; then reading into `gnus-active-hashtb'. Most groups will
15911 ;; already exist in that hashtb, so this will save some string
15915 (progn (skip-chars-forward "^ \t!:\n") (point)))
15916 (goto-char (point-min))
15918 (and (/= (point-min) (point-max))
15919 (let ((obarray gnus-active-hashtb)) (read buf))))
15921 ;; Now, the symbol we have read is either `options' or a group
15922 ;; name. If it is an options line, we just add it to a string.
15924 ((or (eq symbol options-symbol)
15925 (eq symbol Options-symbol))
15926 (setq gnus-newsrc-options
15927 ;; This concating is quite inefficient, but since our
15928 ;; thorough studies show that approx 99.37% of all
15929 ;; .newsrc files only contain a single options line, we
15930 ;; don't give a damn, frankly, my dear.
15931 (concat gnus-newsrc-options
15933 (gnus-point-at-bol)
15934 ;; Options may continue on the next line.
15935 (or (and (re-search-forward "^[^ \t]" nil 'move)
15936 (progn (beginning-of-line) (point)))
15940 ;; Group names can be just numbers.
15941 (when (numberp symbol)
15942 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
15943 (or (boundp symbol) (set symbol nil))
15944 ;; It was a group name.
15945 (setq subscribed (= (following-char) ?:)
15946 group (symbol-name symbol)
15949 ;; If the line ends here, this is clearly a buggy line, so
15950 ;; we put point a the beginning of line and let the cond
15951 ;; below do the error handling.
15952 (beginning-of-line)
15953 ;; We skip to the beginning of the ranges.
15954 (skip-chars-forward "!: \t"))
15955 ;; We are now at the beginning of the list of read articles.
15956 ;; We read them range by range.
15959 ((looking-at "[0-9]+")
15960 ;; We narrow and read a number instead of buffer-substring/
15961 ;; string-to-int because it's faster. narrow/widen is
15962 ;; faster than save-restriction/narrow, and save-restriction
15963 ;; produces a garbage object.
15965 (narrow-to-region (match-beginning 0) (match-end 0))
15968 ;; If the next character is a dash, then this is a range.
15969 (if (= (following-char) ?-)
15971 ;; We read the upper bound of the range.
15973 (if (not (looking-at "[0-9]+"))
15974 ;; This is a buggy line, by we pretend that
15975 ;; it's kinda OK. Perhaps the user should be
15977 (setq reads (cons num1 reads))
15982 (narrow-to-region (match-beginning 0)
15987 ;; It was just a simple number, so we add it to the
15989 (setq reads (cons num1 reads)))
15990 ;; If the next char in ?\n, then we have reached the end
15991 ;; of the line and return nil.
15992 (/= (following-char) ?\n))
15993 ((= (following-char) ?\n)
15994 ;; End of line, so we end.
15997 ;; Not numbers and not eol, so this might be a buggy
16000 ;; If it was eob instead of ?\n, we allow it.
16002 ;; The line was buggy.
16004 (gnus-message 3 "Mangled line: %s"
16005 (buffer-substring (gnus-point-at-bol)
16006 (gnus-point-at-eol)))
16010 ;; Skip past ", ". Spaces are illegal in these ranges, but
16011 ;; we allow them, because it's a common mistake to put a
16012 ;; space after the comma.
16013 (skip-chars-forward ", "))
16015 ;; We have already read .newsrc.eld, so we gently update the
16016 ;; data in the hash table with the information we have just
16019 (let ((info (gnus-get-info group))
16022 ;; There is an entry for this file in the alist.
16024 (gnus-info-set-read info (nreverse reads))
16025 ;; We update the level very gently. In fact, we
16026 ;; only change it if there's been a status change
16027 ;; from subscribed to unsubscribed, or vice versa.
16028 (setq level (gnus-info-level info))
16029 (cond ((and (<= level gnus-level-subscribed)
16031 (setq level (if reads
16032 gnus-level-default-unsubscribed
16033 (1+ gnus-level-default-unsubscribed))))
16034 ((and (> level gnus-level-subscribed) subscribed)
16035 (setq level gnus-level-default-subscribed)))
16036 (gnus-info-set-level info level))
16037 ;; This is a new group.
16038 (setq info (list group
16040 gnus-level-default-subscribed
16042 (1+ gnus-level-subscribed)
16043 gnus-level-default-unsubscribed))
16044 (nreverse reads))))
16045 (setq newsrc (cons info newsrc))))))
16048 (setq newsrc (nreverse newsrc))
16050 (if (not already-read)
16052 ;; We now have two newsrc lists - `newsrc', which is what we
16053 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16054 ;; what we've read from .newsrc.eld. We have to merge these
16055 ;; lists. We do this by "attaching" any (foreign) groups in the
16056 ;; gnus-newsrc-alist to the (native) group that precedes them.
16057 (let ((rc (cdr gnus-newsrc-alist))
16058 (prev gnus-newsrc-alist)
16061 (or (null (nth 4 (car rc))) ; It's a native group.
16062 (assoc (caar rc) newsrc) ; It's already in the alist.
16063 (if (setq entry (assoc (caar prev) newsrc))
16064 (setcdr (setq mentry (memq entry newsrc))
16065 (cons (car rc) (cdr mentry)))
16066 (setq newsrc (cons (car rc) newsrc))))
16070 (setq gnus-newsrc-alist newsrc)
16071 ;; We make the newsrc hashtb.
16072 (gnus-make-hashtable-from-newsrc-alist)
16074 ;; Finally, if we read some options lines, we parse them.
16075 (or (string= gnus-newsrc-options "")
16076 (gnus-newsrc-parse-options gnus-newsrc-options))))
16078 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16079 ;; The return value will be a list on the form
16080 ;; ((regexp1 . ignore)
16081 ;; (regexp2 . subscribe)...)
16082 ;; When handling new newsgroups, groups that match a `ignore' regexp
16083 ;; will be ignored, and groups that match a `subscribe' regexp will be
16084 ;; subscribed. A line like
16085 ;; options -n !all rec.all
16086 ;; will lead to a list that looks like
16087 ;; (("^rec\\..+" . subscribe)
16088 ;; ("^.+" . ignore))
16089 ;; So all "rec.*" groups will be subscribed, while all the other
16090 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16091 ;; different from "options -n rec.all !all".
16092 (defun gnus-newsrc-parse-options (options)
16095 (gnus-set-work-buffer)
16096 (insert (regexp-quote options))
16097 ;; First we treat all continuation lines.
16098 (goto-char (point-min))
16099 (while (re-search-forward "\n[ \t]+" nil t)
16100 (replace-match " " t t))
16101 ;; Then we transform all "all"s into ".+"s.
16102 (goto-char (point-min))
16103 (while (re-search-forward "\\ball\\b" nil t)
16104 (replace-match ".+" t t))
16105 (goto-char (point-min))
16106 ;; We remove all other options than the "-n" ones.
16107 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16108 (replace-match " ")
16110 (goto-char (point-min))
16112 ;; We are only interested in "options -n" lines - we
16113 ;; ignore the other option lines.
16114 (while (re-search-forward "[ \t]-n" nil t)
16116 (or (save-excursion
16117 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16119 (gnus-point-at-eol)))
16120 ;; Search for all "words"...
16121 (while (re-search-forward "[^ \t,\n]+" eol t)
16122 (if (= (char-after (match-beginning 0)) ?!)
16123 ;; If the word begins with a bang (!), this is a "not"
16124 ;; spec. We put this spec (minus the bang) and the
16125 ;; symbol `ignore' into the list.
16126 (setq out (cons (cons (concat
16127 "^" (buffer-substring
16128 (1+ (match-beginning 0))
16131 ;; There was no bang, so this is a "yes" spec.
16132 (setq out (cons (cons (concat "^" (match-string 0))
16133 'subscribe) out)))))
16135 (setq gnus-newsrc-options-n out))))
16137 (defun gnus-save-newsrc-file (&optional force)
16138 "Save .newsrc file."
16139 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16140 ;; from the variable gnus-newsrc-alist.
16141 (when (and (or gnus-newsrc-alist gnus-killed-list)
16142 gnus-current-startup-file)
16144 (if (and (or gnus-use-dribble-file gnus-slave)
16146 (or (not gnus-dribble-buffer)
16147 (not (buffer-name gnus-dribble-buffer))
16148 (zerop (save-excursion
16149 (set-buffer gnus-dribble-buffer)
16151 (gnus-message 4 "(No changes need to be saved)")
16152 (run-hooks 'gnus-save-newsrc-hook)
16154 (gnus-slave-save-newsrc)
16156 (when gnus-save-newsrc-file
16157 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16158 (gnus-gnus-to-newsrc-format)
16159 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16160 ;; Save .newsrc.eld.
16161 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16162 (make-local-variable 'version-control)
16163 (setq version-control 'never)
16164 (setq buffer-file-name
16165 (concat gnus-current-startup-file ".eld"))
16166 (gnus-add-current-to-buffer-list)
16167 (buffer-disable-undo (current-buffer))
16169 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16170 (gnus-gnus-to-quick-newsrc-format)
16171 (run-hooks 'gnus-save-quick-newsrc-hook)
16173 (kill-buffer (current-buffer))
16175 5 "Saving %s.eld...done" gnus-current-startup-file))
16176 (gnus-dribble-delete-file)))))
16178 (defun gnus-gnus-to-quick-newsrc-format ()
16179 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16180 (insert ";; Gnus startup file.\n")
16181 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16182 (insert ";; to read .newsrc.\n")
16183 (insert "(setq gnus-newsrc-file-version "
16184 (prin1-to-string gnus-version) ")\n")
16186 (if gnus-save-killed-list gnus-variable-list
16187 ;; Remove the `gnus-killed-list' from the list of variables
16188 ;; to be saved, if required.
16189 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16190 ;; Peel off the "dummy" group.
16191 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16193 ;; Insert the variables into the file.
16195 (when (and (boundp (setq variable (pop variables)))
16196 (symbol-value variable))
16197 (insert "(setq " (symbol-name variable) " '"
16198 (prin1-to-string (symbol-value variable)) ")\n")))))
16200 (defun gnus-gnus-to-newsrc-format ()
16201 ;; Generate and save the .newsrc file.
16202 (let ((newsrc (cdr gnus-newsrc-alist))
16205 (set-buffer (create-file-buffer gnus-current-startup-file))
16206 (setq buffer-file-name gnus-current-startup-file)
16207 (buffer-disable-undo (current-buffer))
16210 (if gnus-newsrc-options (insert gnus-newsrc-options))
16211 ;; Write subscribed and unsubscribed.
16213 (setq info (car newsrc))
16214 (if (not (gnus-info-method info))
16215 ;; Don't write foreign groups to .newsrc.
16217 (insert (gnus-info-group info)
16218 (if (> (gnus-info-level info) gnus-level-subscribed)
16220 (if (setq ranges (gnus-info-read info))
16223 (if (not (listp (cdr ranges)))
16224 (if (= (car ranges) (cdr ranges))
16225 (insert (int-to-string (car ranges)))
16226 (insert (int-to-string (car ranges)) "-"
16227 (int-to-string (cdr ranges))))
16229 (setq range (car ranges)
16230 ranges (cdr ranges))
16231 (if (or (atom range) (= (car range) (cdr range)))
16232 (insert (int-to-string
16233 (or (and (atom range) range)
16235 (insert (int-to-string (car range)) "-"
16236 (int-to-string (cdr range))))
16237 (if ranges (insert ","))))))
16239 (setq newsrc (cdr newsrc)))
16240 (make-local-variable 'version-control)
16241 (setq version-control 'never)
16242 ;; It has been reported that sometime the modtime on the .newsrc
16243 ;; file seems to be off. We really do want to overwrite it, so
16244 ;; we clear the modtime here before saving. It's a bit odd,
16246 ;; sometimes the modtime clear isn't sufficient. most brute force:
16247 ;; delete the silly thing entirely first. but this fails to provide
16248 ;; such niceties as .newsrc~ creation.
16249 (if gnus-modtime-botch
16250 (delete-file gnus-startup-file)
16251 (clear-visited-file-modtime))
16252 (run-hooks 'gnus-save-standard-newsrc-hook)
16254 (kill-buffer (current-buffer)))))
16258 ;;; Slave functions.
16261 (defun gnus-slave-save-newsrc ()
16263 (set-buffer gnus-dribble-buffer)
16265 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16266 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16268 (defun gnus-master-read-slave-newsrc ()
16271 (file-name-directory gnus-current-startup-file)
16275 (file-name-nondirectory gnus-current-startup-file)
16279 (if (not slave-files)
16280 () ; There are no slave files to read.
16281 (gnus-message 7 "Reading slave newsrcs...")
16283 (set-buffer (get-buffer-create " *gnus slave*"))
16284 (buffer-disable-undo (current-buffer))
16286 (sort (mapcar (lambda (file)
16287 (list (nth 5 (file-attributes file)) file))
16290 (or (< (caar f1) (caar f2))
16291 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16294 (setq file (nth 1 (car slave-files)))
16295 (insert-file-contents file)
16296 (if (condition-case ()
16298 (eval-buffer (current-buffer))
16301 (gnus-message 3 "Possible error in %s" file)
16305 (or gnus-slave ; Slaves shouldn't delete these files.
16309 (setq slave-files (cdr slave-files))))
16310 (gnus-message 7 "Reading slave newsrcs...done"))))
16314 ;;; Group description.
16317 (defun gnus-read-all-descriptions-files ()
16318 (let ((methods (cons gnus-select-method
16320 (when gnus-message-archive-method
16322 gnus-secondary-select-methods))))
16324 (gnus-read-descriptions-file (car methods))
16325 (setq methods (cdr methods)))
16328 (defun gnus-read-descriptions-file (&optional method)
16329 (let ((method (or method gnus-select-method)))
16330 (when (stringp method)
16331 (setq method (gnus-server-to-method method)))
16332 ;; We create the hashtable whether we manage to read the desc file
16333 ;; to avoid trying to re-read after a failed read.
16334 (or gnus-description-hashtb
16335 (setq gnus-description-hashtb
16336 (gnus-make-hashtable (length gnus-active-hashtb))))
16337 ;; Mark this method's desc file as read.
16338 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16339 gnus-description-hashtb)
16341 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16343 ((not (gnus-check-server method))
16344 (gnus-message 1 "Couldn't open server")
16346 ((not (gnus-request-list-newsgroups method))
16347 (gnus-message 1 "Couldn't read newsgroups descriptions")
16353 (set-buffer nntp-server-buffer)
16354 (goto-char (point-min))
16355 (if (or (search-forward "\n.\n" nil t)
16356 (goto-char (point-max)))
16358 (beginning-of-line)
16359 (narrow-to-region (point-min) (point))))
16360 (goto-char (point-min))
16361 (while (not (eobp))
16362 ;; If we get an error, we set group to 0, which is not a
16366 (let ((obarray gnus-description-hashtb))
16367 ;; Group is set to a symbol interned in this
16369 (read nntp-server-buffer))
16371 (skip-chars-forward " \t")
16372 ;; ... which leads to this line being effectively ignored.
16373 (and (symbolp group)
16374 (set group (buffer-substring
16375 (point) (progn (end-of-line) (point)))))
16376 (forward-line 1))))
16377 (gnus-message 5 "Reading descriptions file...done")
16380 (defun gnus-group-get-description (group)
16381 "Get the description of a group by sending XGTITLE to the server."
16382 (when (gnus-request-group-description group)
16384 (set-buffer nntp-server-buffer)
16385 (goto-char (point-min))
16386 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16387 (match-string 1)))))
16391 ;;; Buffering of read articles.
16394 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16395 (defvar gnus-backlog-articles nil)
16396 (defvar gnus-backlog-hashtb nil)
16398 (defun gnus-backlog-buffer ()
16399 "Return the backlog buffer."
16400 (or (get-buffer gnus-backlog-buffer)
16402 (set-buffer (get-buffer-create gnus-backlog-buffer))
16403 (buffer-disable-undo (current-buffer))
16404 (setq buffer-read-only t)
16405 (gnus-add-current-to-buffer-list)
16406 (get-buffer gnus-backlog-buffer))))
16408 (defun gnus-backlog-setup ()
16409 "Initialize backlog variables."
16410 (unless gnus-backlog-hashtb
16411 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16413 (defun gnus-backlog-shutdown ()
16414 "Clear all backlog variables and buffers."
16415 (when (get-buffer gnus-backlog-buffer)
16416 (kill-buffer gnus-backlog-buffer))
16417 (setq gnus-backlog-hashtb nil
16418 gnus-backlog-articles nil))
16420 (defun gnus-backlog-enter-article (group number buffer)
16421 (gnus-backlog-setup)
16422 (let ((ident (intern (concat group ":" (int-to-string number))
16423 gnus-backlog-hashtb))
16425 (if (memq ident gnus-backlog-articles)
16426 () ; It's already kept.
16427 ;; Remove the oldest article, if necessary.
16428 (and (numberp gnus-keep-backlog)
16429 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16430 (gnus-backlog-remove-oldest-article))
16431 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16432 ;; Insert the new article.
16434 (set-buffer (gnus-backlog-buffer))
16435 (let (buffer-read-only)
16436 (goto-char (point-max))
16437 (or (bolp) (insert "\n"))
16439 (insert-buffer-substring buffer)
16440 ;; Tag the beginning of the article with the ident.
16441 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16443 (defun gnus-backlog-remove-oldest-article ()
16445 (set-buffer (gnus-backlog-buffer))
16446 (goto-char (point-min))
16447 (if (zerop (buffer-size))
16448 () ; The buffer is empty.
16449 (let ((ident (get-text-property (point) 'gnus-backlog))
16451 ;; Remove the ident from the list of articles.
16453 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16454 ;; Delete the article itself.
16456 (point) (next-single-property-change
16457 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16459 (defun gnus-backlog-request-article (group number buffer)
16460 (when (numberp number)
16461 (gnus-backlog-setup)
16462 (let ((ident (intern (concat group ":" (int-to-string number))
16463 gnus-backlog-hashtb))
16465 (when (memq ident gnus-backlog-articles)
16466 ;; It was in the backlog.
16468 (set-buffer (gnus-backlog-buffer))
16469 (if (not (setq beg (text-property-any
16470 (point-min) (point-max) 'gnus-backlog
16472 ;; It wasn't in the backlog after all.
16474 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16475 ;; Find the end (i. e., the beginning of the next article).
16477 (next-single-property-change
16478 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16479 (let ((buffer-read-only nil))
16481 (insert-buffer-substring gnus-backlog-buffer beg end)
16484 ;; Allow redefinition of Gnus functions.
16486 (gnus-ems-redefine)
16490 ;;; gnus.el ends here