1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval '(run-hooks 'gnus-load-hook))
35 (eval-when-compile (require 'cl))
37 ;; Site dependent variables. These variables should be defined in
40 (defvar gnus-default-nntp-server nil
41 "Specify a default NNTP server.
42 This variable should be defined in paths.el, and should never be set
44 If you want to change servers, you should use `gnus-select-method'.
45 See the documentation to that variable.")
47 (defvar gnus-backup-default-subscribed-newsgroups
48 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
49 "Default default new newsgroups the first time Gnus is run.
50 Should be set in paths.el, and shouldn't be touched by the user.")
52 (defvar gnus-local-domain nil
53 "Local domain name without a host name.
54 The DOMAINNAME environment variable is used instead if it is defined.
55 If the `system-name' function returns the full Internet name, there is
56 no need to set this variable.")
58 (defvar gnus-local-organization nil
59 "String with a description of what organization (if any) the user belongs to.
60 The ORGANIZATION environment variable is used instead if it is defined.
61 If this variable contains a function, this function will be called
62 with the current newsgroup name as the argument. The function should
65 In any case, if the string (either in the variable, in the environment
66 variable, or returned by the function) is a file name, the contents of
67 this file will be used as the organization.")
69 (defvar gnus-use-generic-from nil
70 "If nil, the full host name will be the system name prepended to the domain name.
71 If this is a string, the full host name will be this string.
72 If this is non-nil, non-string, the domain name will be used as the
75 (defvar gnus-use-generic-path nil
76 "If nil, use the NNTP server name in the Path header.
77 If stringp, use this; if non-nil, use no host name (user name only).")
79 ;; Customization variables
81 ;; Don't touch this variable.
82 (defvar gnus-nntp-service "nntp"
83 "*NNTP service name (\"nntp\" or 119).
84 This is an obsolete variable, which is scarcely used. If you use an
85 nntp server for your newsgroup and want to change the port number
86 used to 899, you would say something along these lines:
88 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
90 (defvar gnus-nntpserver-file "/etc/nntpserver"
91 "*A file with only the name of the nntp server in it.")
93 ;; This function is used to check both the environment variable
94 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
95 ;; an nntp server name default.
96 (defun gnus-getenv-nntpserver ()
97 (or (getenv "NNTPSERVER")
98 (and (file-readable-p gnus-nntpserver-file)
100 (set-buffer (get-buffer-create " *gnus nntp*"))
101 (buffer-disable-undo (current-buffer))
102 (insert-file-contents gnus-nntpserver-file)
103 (let ((name (buffer-string)))
105 (if (string-match "^[ \t\n]*$" name)
108 (kill-buffer (current-buffer))))))))
110 (defvar gnus-select-method
112 (list 'nntp (or (condition-case ()
113 (gnus-getenv-nntpserver)
115 (if (and gnus-default-nntp-server
116 (not (string= gnus-default-nntp-server "")))
117 gnus-default-nntp-server)
119 (if (or (null gnus-nntp-service)
120 (equal gnus-nntp-service "nntp"))
122 (list gnus-nntp-service)))
123 "*Default method for selecting a newsgroup.
124 This variable should be a list, where the first element is how the
125 news is to be fetched, the second is the address.
127 For instance, if you want to get your news via NNTP from
128 \"flab.flab.edu\", you could say:
130 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
132 If you want to use your local spool, say:
134 (setq gnus-select-method (list 'nnspool (system-name)))
136 If you use this variable, you must set `gnus-nntp-server' to nil.
138 There is a lot more to know about select methods and virtual servers -
139 see the manual for details.")
141 (defvar gnus-message-archive-method
142 '(nnfolder "archive" (nnfolder-directory "~/Mail/archive/")
143 (nnfolder-active-file "~/Mail/archive/active")
144 (nnfolder-get-new-mail nil)
145 (nnfolder-inhibit-expiry t))
146 "*Method used for archiving messages you've sent.
147 This should be a mail method.")
149 (defvar gnus-refer-article-method nil
150 "*Preferred method for fetching an article by Message-ID.
151 If you are reading news from the local spool (with nnspool), fetching
152 articles by Message-ID is painfully slow. By setting this method to an
153 nntp method, you might get acceptable results.
155 The value of this variable must be a valid select method as discussed
156 in the documentation of `gnus-select-method'.")
158 (defvar gnus-secondary-select-methods nil
159 "*A list of secondary methods that will be used for reading news.
160 This is a list where each element is a complete select method (see
161 `gnus-select-method').
163 If, for instance, you want to read your mail with the nnml backend,
164 you could set this variable:
166 (setq gnus-secondary-select-methods '((nnml \"\")))")
168 (defvar gnus-secondary-servers nil
169 "*List of NNTP servers that the user can choose between interactively.
170 To make Gnus query you for a server, you have to give `gnus' a
171 non-numeric prefix - `C-u M-x gnus', in short.")
173 (defvar gnus-nntp-server nil
174 "*The name of the host running the NNTP server.
175 This variable is semi-obsolete. Use the `gnus-select-method'
178 (defvar gnus-startup-file "~/.newsrc"
179 "*Your `.newsrc' file.
180 `.newsrc-SERVER' will be used instead if that exists.")
182 (defvar gnus-init-file "~/.gnus"
183 "*Your Gnus elisp startup file.
184 If a file with the .el or .elc suffixes exist, it will be read
187 (defvar gnus-group-faq-directory
188 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
189 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
190 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
191 "/ftp@rtfm.mit.edu:/pub/usenet/news.answers/"
192 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
193 "/ftp@ftp.sunet.se:/pub/usenet/"
194 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
195 "/ftp@hwarang.postech.ac.kr:/pub/usenet/news.answers/"
196 "/ftp@ftp.hk.super.net:/mirror/faqs/")
197 "*Directory where the group FAQs are stored.
198 This will most commonly be on a remote machine, and the file will be
201 This variable can also be a list of directories. In that case, the
202 first element in the list will be used by default, and the others will
203 be used as backup sites.
205 Note that Gnus uses an aol machine as the default directory. If this
206 feels fundamentally unclean, just think of it as a way to finally get
207 something of value back from them.
209 If the default site is too slow, try one of these:
211 North America: mirrors.aol.com /pub/rtfm/usenet
212 ftp.seas.gwu.edu /pub/rtfm
213 rtfm.mit.edu /pub/usenet/news.answers
214 Europe: ftp.uni-paderborn.de /pub/FAQ
215 src.doc.ic.ac.uk /usenet/news-FAQS
216 ftp.sunet.se /pub/usenet
217 Asia: nctuccca.edu.tw /USENET/FAQ
218 hwarang.postech.ac.kr /pub/usenet/news.answers
219 ftp.hk.super.net /mirror/faqs")
221 (defvar gnus-group-archive-directory
222 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
223 "*The address of the (ding) archives.")
225 (defvar gnus-group-recent-archive-directory
226 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
227 "*The address of the most recent (ding) articles.")
229 (defvar gnus-default-subscribed-newsgroups nil
230 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
231 It should be a list of strings.
232 If it is `t', Gnus will not do anything special the first time it is
233 started; it'll just use the normal newsgroups subscription methods.")
235 (defvar gnus-use-cross-reference t
236 "*Non-nil means that cross referenced articles will be marked as read.
237 If nil, ignore cross references. If t, mark articles as read in
238 subscribed newsgroups. If neither t nor nil, mark as read in all
241 (defvar gnus-single-article-buffer t
242 "*If non-nil, display all articles in the same buffer.
243 If nil, each group will get its own article buffer.")
245 (defvar gnus-use-dribble-file t
246 "*Non-nil means that Gnus will use a dribble file to store user updates.
247 If Emacs should crash without saving the .newsrc files, complete
248 information can be restored from the dribble file.")
250 (defvar gnus-dribble-directory nil
251 "*The directory where dribble files will be saved.
252 If this variable is nil, the directory where the .newsrc files are
253 saved will be used.")
255 (defvar gnus-asynchronous nil
256 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
258 (defvar gnus-kill-summary-on-exit t
259 "*If non-nil, kill the summary buffer when you exit from it.
260 If nil, the summary will become a \"*Dead Summary*\" buffer, and
261 it will be killed sometime later.")
263 (defvar gnus-large-newsgroup 200
264 "*The number of articles which indicates a large newsgroup.
265 If the number of articles in a newsgroup is greater than this value,
266 confirmation is required for selecting the newsgroup.")
268 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
269 (defvar gnus-no-groups-message "No news is horrible news"
270 "*Message displayed by Gnus when no groups are available.")
272 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
273 "*Non-nil means that the default name of a file to save articles in is the group name.
274 If it's nil, the directory form of the group name is used instead.
276 If this variable is a list, and the list contains the element
277 `not-score', long file names will not be used for score files; if it
278 contains the element `not-save', long file names will not be used for
279 saving; and if it contains the element `not-kill', long file names
280 will not be used for kill files.")
282 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
283 "*Name of the directory articles will be saved in (default \"~/News\").
284 Initialized from the SAVEDIR environment variable.")
286 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
287 "*Name of the directory where kill files will be stored (default \"~/News\").
288 Initialized from the SAVEDIR environment variable.")
290 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
291 "*A function to save articles in your favorite format.
292 The function must be interactively callable (in other words, it must
293 be an Emacs command).
295 Gnus provides the following functions:
297 * gnus-summary-save-in-rmail (Rmail format)
298 * gnus-summary-save-in-mail (Unix mail format)
299 * gnus-summary-save-in-folder (MH folder)
300 * gnus-summary-save-in-file (article format).
301 * gnus-summary-save-in-vm (use VM's folder format).")
303 (defvar gnus-prompt-before-saving 'always
304 "*This variable says how much prompting is to be done when saving articles.
305 If it is nil, no prompting will be done, and the articles will be
306 saved to the default files. If this variable is `always', each and
307 every article that is saved will be preceded by a prompt, even when
308 saving large batches of articles. If this variable is neither nil not
309 `always', there the user will be prompted once for a file name for
310 each invocation of the saving commands.")
312 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
313 "*A function generating a file name to save articles in Rmail format.
314 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
316 (defvar gnus-mail-save-name (function gnus-plain-save-name)
317 "*A function generating a file name to save articles in Unix mail format.
318 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
320 (defvar gnus-folder-save-name (function gnus-folder-save-name)
321 "*A function generating a file name to save articles in MH folder.
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
324 (defvar gnus-file-save-name (function gnus-numeric-save-name)
325 "*A function generating a file name to save articles in article format.
326 The function is called with NEWSGROUP, HEADERS, and optional
329 (defvar gnus-split-methods
330 '((gnus-article-archive-name))
331 "*Variable used to suggest where articles are to be saved.
332 For instance, if you would like to save articles related to Gnus in
333 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
334 you could set this variable to something like:
336 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
337 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
339 This variable is an alist where the where the key is the match and the
340 value is a list of possible files to save in if the match is non-nil.
342 If the match is a string, it is used as a regexp match on the
343 article. If the match is a symbol, that symbol will be funcalled
344 from the buffer of the article to be saved with the newsgroup as the
345 parameter. If it is a list, it will be evaled in the same buffer.
347 If this form or function returns a string, this string will be used as
348 a possible file name; and if it returns a non-nil list, that list will
349 be used as possible file names.")
351 (defvar gnus-move-split-methods nil
352 "*Variable used to suggest where articles are to be moved to.
353 It uses the same syntax as the `gnus-split-methods' variable.")
355 (defvar gnus-save-score nil
356 "*If non-nil, save group scoring info.")
358 (defvar gnus-use-adaptive-scoring nil
359 "*If non-nil, use some adaptive scoring scheme.")
361 (defvar gnus-use-cache nil
362 "*If nil, Gnus will ignore the article cache.
363 If `passive', it will allow entering (and reading) articles
364 explicitly entered into the cache. If anything else, use the
365 cache to the full extent of the law.")
367 (defvar gnus-use-trees nil
368 "*If non-nil, display a thread tree buffer.")
370 (defvar gnus-use-grouplens nil
371 "*If non-nil, use GroupLens ratings.")
373 (defvar gnus-keep-backlog nil
374 "*If non-nil, Gnus will keep read articles for later re-retrieval.
375 If it is a number N, then Gnus will only keep the last N articles
376 read. If it is neither nil nor a number, Gnus will keep all read
377 articles. This is not a good idea.")
379 (defvar gnus-use-nocem nil
380 "*If non-nil, Gnus will read NoCeM cancel messages.")
382 (defvar gnus-use-demon nil
383 "If non-nil, Gnus might use some demons.")
385 (defvar gnus-use-scoring t
386 "*If non-nil, enable scoring.")
388 (defvar gnus-use-picons nil
389 "*If non-nil, display picons.")
391 (defvar gnus-fetch-old-headers nil
392 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
393 If an unread article in the group refers to an older, already read (or
394 just marked as read) article, the old article will not normally be
395 displayed in the Summary buffer. If this variable is non-nil, Gnus
396 will attempt to grab the headers to the old articles, and thereby
397 build complete threads. If it has the value `some', only enough
398 headers to connect otherwise loose threads will be displayed.
399 This variable can also be a number. In that case, no more than that
400 number of old headers will be fetched.
402 The server has to support NOV for any of this to work.")
405 ;(defvar gnus-visual t
406 ; "*If non-nil, will do various highlighting.
407 ;If nil, no mouse highlights (or any other highlights) will be
408 ;performed. This might speed up Gnus some when generating large group
409 ;and summary buffers.")
411 (defvar gnus-novice-user t
412 "*Non-nil means that you are a usenet novice.
413 If non-nil, verbose messages may be displayed and confirmations may be
416 (defvar gnus-expert-user nil
417 "*Non-nil means that you will never be asked for confirmation about anything.
418 And that means *anything*.")
420 (defvar gnus-verbose 7
421 "*Integer that says how verbose Gnus should be.
422 The higher the number, the more messages Gnus will flash to say what
423 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
424 display most important messages; and at ten, Gnus will keep on
425 jabbering all the time.")
427 (defvar gnus-keep-same-level nil
428 "*Non-nil means that the next newsgroup after the current will be on the same level.
429 When you type, for instance, `n' after reading the last article in the
430 current newsgroup, you will go to the next newsgroup. If this variable
431 is nil, the next newsgroup will be the next from the group
433 If this variable is non-nil, Gnus will either put you in the
434 next newsgroup with the same level, or, if no such newsgroup is
435 available, the next newsgroup with the lowest possible level higher
436 than the current level.
437 If this variable is `best', Gnus will make the next newsgroup the one
438 with the best level.")
440 (defvar gnus-summary-make-false-root 'adopt
441 "*nil means that Gnus won't gather loose threads.
442 If the root of a thread has expired or been read in a previous
443 session, the information necessary to build a complete thread has been
444 lost. Instead of having many small sub-threads from this original thread
445 scattered all over the summary buffer, Gnus can gather them.
447 If non-nil, Gnus will try to gather all loose sub-threads from an
448 original thread into one large thread.
450 If this variable is non-nil, it should be one of `none', `adopt',
453 If this variable is `none', Gnus will not make a false root, but just
454 present the sub-threads after another.
455 If this variable is `dummy', Gnus will create a dummy root that will
456 have all the sub-threads as children.
457 If this variable is `adopt', Gnus will make one of the \"children\"
458 the parent and mark all the step-children as such.
459 If this variable is `empty', the \"children\" are printed with empty
460 subject fields. (Or rather, they will be printed with a string
461 given by the `gnus-summary-same-subject' variable.)")
463 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
464 "*A regexp to match subjects to be excluded from loose thread gathering.
465 As loose thread gathering is done on subjects only, that means that
466 there can be many false gatherings performed. By rooting out certain
467 common subjects, gathering might become saner.")
469 (defvar gnus-summary-gather-subject-limit nil
470 "*Maximum length of subject comparisons when gathering loose threads.
471 Use nil to compare full subjects. Setting this variable to a low
472 number will help gather threads that have been corrupted by
473 newsreaders chopping off subject lines, but it might also mean that
474 unrelated articles that have subject that happen to begin with the
475 same few characters will be incorrectly gathered.
477 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
478 comparing subjects.")
480 (defvar gnus-simplify-ignored-prefixes nil
481 "*Regexp, matches for which are removed from subject lines when simplifying.")
483 (defvar gnus-build-sparse-threads nil
484 "*If non-nil, fill in the gaps in threads.
485 If `some', only fill in the gaps that are needed to tie loose threads
486 together. If `more', fill in all leaf nodes that Gnus can find. If
487 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
489 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
490 "Function used for gathering loose threads.
491 There are two pre-defined functions: `gnus-gather-threads-by-subject',
492 which only takes Subjects into consideration; and
493 `gnus-gather-threads-by-references', which compared the References
494 headers of the articles to find matches.")
496 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
497 (defvar gnus-summary-same-subject ""
498 "*String indicating that the current article has the same subject as the previous.
499 This variable will only be used if the value of
500 `gnus-summary-make-false-root' is `empty'.")
502 (defvar gnus-summary-goto-unread t
503 "*If non-nil, marking commands will go to the next unread article.
504 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
505 whether it is read or not.")
507 (defvar gnus-group-goto-unread t
508 "*If non-nil, movement commands will go to the next unread and subscribed group.")
510 (defvar gnus-goto-next-group-when-activating t
511 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
513 (defvar gnus-check-new-newsgroups t
514 "*Non-nil means that Gnus will add new newsgroups at startup.
515 If this variable is `ask-server', Gnus will ask the server for new
516 groups since the last time it checked. This means that the killed list
517 is no longer necessary, so you could set `gnus-save-killed-list' to
520 A variant is to have this variable be a list of select methods. Gnus
521 will then use the `ask-server' method on all these select methods to
522 query for new groups from all those servers.
525 (setq gnus-check-new-newsgroups
526 '((nntp \"some.server\") (nntp \"other.server\")))
528 If this variable is nil, then you have to tell Gnus explicitly to
529 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
531 (defvar gnus-check-bogus-newsgroups nil
532 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
533 If this variable is nil, then you have to tell Gnus explicitly to
534 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
536 (defvar gnus-read-active-file t
537 "*Non-nil means that Gnus will read the entire active file at startup.
538 If this variable is nil, Gnus will only know about the groups in your
541 If this variable is `some', Gnus will try to only read the relevant
542 parts of the active file from the server. Not all servers support
543 this, and it might be quite slow with other servers, but this should
544 generally be faster than both the t and nil value.
546 If you set this variable to nil or `some', you probably still want to
547 be told about new newsgroups that arrive. To do that, set
548 `gnus-check-new-newsgroups' to `ask-server'. This may not work
549 properly with all servers.")
551 (defvar gnus-level-subscribed 5
552 "*Groups with levels less than or equal to this variable are subscribed.")
554 (defvar gnus-level-unsubscribed 7
555 "*Groups with levels less than or equal to this variable are unsubscribed.
556 Groups with levels less than `gnus-level-subscribed', which should be
557 less than this variable, are subscribed.")
559 (defvar gnus-level-zombie 8
560 "*Groups with this level are zombie groups.")
562 (defvar gnus-level-killed 9
563 "*Groups with this level are killed.")
565 (defvar gnus-level-default-subscribed 3
566 "*New subscribed groups will be subscribed at this level.")
568 (defvar gnus-level-default-unsubscribed 6
569 "*New unsubscribed groups will be unsubscribed at this level.")
571 (defvar gnus-activate-level (1+ gnus-level-subscribed)
572 "*Groups higher than this level won't be activated on startup.
573 Setting this variable to something log might save lots of time when
574 you have many groups that you aren't interested in.")
576 (defvar gnus-activate-foreign-newsgroups 4
577 "*If nil, Gnus will not check foreign newsgroups at startup.
578 If it is non-nil, it should be a number between one and nine. Foreign
579 newsgroups that have a level lower or equal to this number will be
580 activated on startup. For instance, if you want to active all
581 subscribed newsgroups, but not the rest, you'd set this variable to
582 `gnus-level-subscribed'.
584 If you subscribe to lots of newsgroups from different servers, startup
585 might take a while. By setting this variable to nil, you'll save time,
586 but you won't be told how many unread articles there are in the
589 (defvar gnus-save-newsrc-file t
590 "*Non-nil means that Gnus will save the `.newsrc' file.
591 Gnus always saves its own startup file, which is called
592 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
593 be readily understood by other newsreaders. If you don't plan on
594 using other newsreaders, set this variable to nil to save some time on
597 (defvar gnus-save-killed-list t
598 "*If non-nil, save the list of killed groups to the startup file.
599 If you set this variable to nil, you'll save both time (when starting
600 and quitting) and space (both memory and disk), but it will also mean
601 that Gnus has no record of which groups are new and which are old, so
602 the automatic new newsgroups subscription methods become meaningless.
604 You should always set `gnus-check-new-newsgroups' to `ask-server' or
605 nil if you set this variable to nil.")
607 (defvar gnus-interactive-catchup t
608 "*If non-nil, require your confirmation when catching up a group.")
610 (defvar gnus-interactive-post t
611 "*If non-nil, group name will be asked for when posting.")
613 (defvar gnus-interactive-exit t
614 "*If non-nil, require your confirmation when exiting Gnus.")
616 (defvar gnus-kill-killed t
617 "*If non-nil, Gnus will apply kill files to already killed articles.
618 If it is nil, Gnus will never apply kill files to articles that have
619 already been through the scoring process, which might very well save lots
622 (defvar gnus-extract-address-components 'gnus-extract-address-components
623 "*Function for extracting address components from a From header.
624 Two pre-defined function exist: `gnus-extract-address-components',
625 which is the default, quite fast, and too simplistic solution, and
626 `mail-extract-address-components', which works much better, but is
629 (defvar gnus-summary-default-score 0
630 "*Default article score level.
631 If this variable is nil, scoring will be disabled.")
633 (defvar gnus-summary-zcore-fuzz 0
634 "*Fuzziness factor for the zcore in the summary buffer.
635 Articles with scores closer than this to `gnus-summary-default-score'
636 will not be marked.")
638 (defvar gnus-simplify-subject-fuzzy-regexp nil
639 "*Strings to be removed when doing fuzzy matches.
640 This can either be a regular expression or list of regular expressions
641 that will be removed from subject strings if fuzzy subject
642 simplification is selected.")
644 (defvar gnus-permanently-visible-groups nil
645 "*Regexp to match groups that should always be listed in the group buffer.
646 This means that they will still be listed when there are no unread
647 articles in the groups.")
649 (defvar gnus-list-groups-with-ticked-articles t
650 "*If non-nil, list groups that have only ticked articles.
651 If nil, only list groups that have unread articles.")
653 (defvar gnus-group-default-list-level gnus-level-subscribed
654 "*Default listing level.
655 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
657 (defvar gnus-group-use-permanent-levels nil
658 "*If non-nil, once you set a level, Gnus will use this level.")
660 (defvar gnus-group-list-inactive-groups t
661 "*If non-nil, inactive groups will be listed.")
663 (defvar gnus-show-mime nil
664 "*If non-nil, do mime processing of articles.
665 The articles will simply be fed to the function given by
666 `gnus-show-mime-method'.")
668 (defvar gnus-strict-mime t
669 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
671 (defvar gnus-show-mime-method 'metamail-buffer
672 "*Function to process a MIME message.
673 The function is called from the article buffer.")
675 (defvar gnus-decode-encoded-word-method (lambda ())
676 "*Function to decode a MIME encoded-words.
677 The function is called from the article buffer.")
679 (defvar gnus-show-threads t
680 "*If non-nil, display threads in summary mode.")
682 (defvar gnus-thread-hide-subtree nil
683 "*If non-nil, hide all threads initially.
684 If threads are hidden, you have to run the command
685 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
686 to expose hidden threads.")
688 (defvar gnus-thread-hide-killed t
689 "*If non-nil, hide killed threads automatically.")
691 (defvar gnus-thread-ignore-subject nil
692 "*If non-nil, ignore subjects and do all threading based on the Reference header.
693 If nil, which is the default, articles that have different subjects
694 from their parents will start separate threads.")
696 (defvar gnus-thread-operation-ignore-subject t
697 "*If non-nil, subjects will be ignored when doing thread commands.
698 This affects commands like `gnus-summary-kill-thread' and
699 `gnus-summary-lower-thread'.
701 If this variable is nil, articles in the same thread with different
702 subjects will not be included in the operation in question. If this
703 variable is `fuzzy', only articles that have subjects that are fuzzily
704 equal will be included.")
706 (defvar gnus-thread-indent-level 4
707 "*Number that says how much each sub-thread should be indented.")
709 (defvar gnus-ignored-newsgroups
710 (purecopy (mapconcat 'identity
711 '("^to\\." ; not "real" groups
712 "^[0-9. \t]+ " ; all digits in name
713 "[][\"#'()]" ; bogus characters
716 "*A regexp to match uninteresting newsgroups in the active file.
717 Any lines in the active file matching this regular expression are
718 removed from the newsgroup list before anything else is done to it,
719 thus making them effectively non-existent.")
721 (defvar gnus-ignored-headers
722 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
723 "*All headers that match this regexp will be hidden.
724 This variable can also be a list of regexps of headers to be ignored.
725 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
727 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-"
728 "*All headers that do not match this regexp will be hidden.
729 This variable can also be a list of regexp of headers to remain visible.
730 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
732 (defvar gnus-sorted-header-list
733 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
734 "^Cc:" "^Date:" "^Organization:")
735 "*This variable is a list of regular expressions.
736 If it is non-nil, headers that match the regular expressions will
737 be placed first in the article buffer in the sequence specified by
740 (defvar gnus-boring-article-headers
741 '(empty followup-to reply-to)
742 "*Headers that are only to be displayed if they have interesting data.
743 Possible values in this list are `empty', `newsgroups', `followup-to',
744 `reply-to', and `date'.")
746 (defvar gnus-show-all-headers nil
747 "*If non-nil, don't hide any headers.")
749 (defvar gnus-save-all-headers t
750 "*If non-nil, don't remove any headers before saving.")
752 (defvar gnus-saved-headers gnus-visible-headers
753 "*Headers to keep if `gnus-save-all-headers' is nil.
754 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
755 If that variable is nil, however, all headers that match this regexp
756 will be kept while the rest will be deleted before saving.")
758 (defvar gnus-inhibit-startup-message nil
759 "*If non-nil, the startup message will not be displayed.")
761 (defvar gnus-signature-separator "^-- *$"
762 "Regexp matching signature separator.")
764 (defvar gnus-signature-limit nil
765 "Provide a limit to what is considered a signature.
766 If it is a number, no signature may not be longer (in characters) than
767 that number. If it is a function, the function will be called without
768 any parameters, and if it returns nil, there is no signature in the
769 buffer. If it is a string, it will be used as a regexp. If it
770 matches, the text in question is not a signature.")
772 (defvar gnus-auto-extend-newsgroup t
773 "*If non-nil, extend newsgroup forward and backward when requested.")
775 (defvar gnus-auto-select-first t
776 "*If nil, don't select the first unread article when entering a group.
777 If this variable is `best', select the highest-scored unread article
778 in the group. If neither nil nor `best', select the first unread
781 If you want to prevent automatic selection of the first unread article
782 in some newsgroups, set the variable to nil in
783 `gnus-select-group-hook'.")
785 (defvar gnus-auto-select-next t
786 "*If non-nil, offer to go to the next group from the end of the previous.
787 If the value is t and the next newsgroup is empty, Gnus will exit
788 summary mode and go back to group mode. If the value is neither nil
789 nor t, Gnus will select the following unread newsgroup. In
790 particular, if the value is the symbol `quietly', the next unread
791 newsgroup will be selected without any confirmation, and if it is
792 `almost-quietly', the next group will be selected without any
793 confirmation if you are located on the last article in the group.
794 Finally, if this variable is `slightly-quietly', the `Z n' command
795 will go to the next group without confirmation.")
797 (defvar gnus-auto-select-same nil
798 "*If non-nil, select the next article with the same subject.")
800 (defvar gnus-summary-check-current nil
801 "*If non-nil, consider the current article when moving.
802 The \"unread\" movement commands will stay on the same line if the
803 current article is unread.")
805 (defvar gnus-auto-center-summary t
806 "*If non-nil, always center the current summary buffer.
807 In particular, if `vertical' do only vertical recentering. If non-nil
808 and non-`vertical', do both horizontal and vertical recentering.")
810 (defvar gnus-break-pages t
811 "*If non-nil, do page breaking on articles.
812 The page delimiter is specified by the `gnus-page-delimiter'
815 (defvar gnus-page-delimiter "^\^L"
816 "*Regexp describing what to use as article page delimiters.
817 The default value is \"^\^L\", which is a form linefeed at the
818 beginning of a line.")
820 (defvar gnus-use-full-window t
821 "*If non-nil, use the entire Emacs screen.")
823 (defvar gnus-window-configuration nil
824 "Obsolete variable. See `gnus-buffer-configuration'.")
826 (defvar gnus-window-min-width 2
827 "*Minimum width of Gnus buffers.")
829 (defvar gnus-window-min-height 1
830 "*Minimum height of Gnus buffers.")
832 (defvar gnus-buffer-configuration
836 (if gnus-carpal '(group-carpal 4))))
840 (if gnus-carpal '(summary-carpal 4))))
847 (if gnus-carpal '(summary-carpal 4))
849 (vertical ((height . 5) (width . 15)
851 (left . -1) (top . 1))
861 (if gnus-carpal '(summary-carpal 4))
862 (if gnus-use-trees '(tree 0.25))
867 (if gnus-carpal '(server-carpal 2))))
871 (if gnus-carpal '(browse-carpal 2))))
887 (article 1.0 point)))
898 (edit-group 1.0 point)))
902 (edit-server 1.0 point)))
906 (edit-score 1.0 point)))
933 (if gnus-carpal '(summary-carpal 4))
934 ("*Shell Command Output*" 1.0)))
942 "Window configuration for all possible Gnus buffers.
943 This variable is a list of lists. Each of these lists has a NAME and
944 a RULE. The NAMEs are commonsense names like `group', which names a
945 rule used when displaying the group buffer; `summary', which names a
946 rule for what happens when you enter a group and do not display an
947 article buffer; and so on. See the value of this variable for a
948 complete list of NAMEs.
950 Each RULE is a list of vectors. The first element in this vector is
951 the name of the buffer to be displayed; the second element is the
952 percentage of the screen this buffer is to occupy (a number in the
953 0.0-0.99 range); the optional third element is `point', which should
954 be present to denote which buffer point is to go to after making this
955 buffer configuration.")
957 (defvar gnus-window-to-buffer
958 '((group . gnus-group-buffer)
959 (summary . gnus-summary-buffer)
960 (article . gnus-article-buffer)
961 (server . gnus-server-buffer)
962 (browse . "*Gnus Browse Server*")
963 (edit-group . gnus-group-edit-buffer)
964 (edit-server . gnus-server-edit-buffer)
965 (group-carpal . gnus-carpal-group-buffer)
966 (summary-carpal . gnus-carpal-summary-buffer)
967 (server-carpal . gnus-carpal-server-buffer)
968 (browse-carpal . gnus-carpal-browse-buffer)
969 (edit-score . gnus-score-edit-buffer)
970 (mail . gnus-mail-buffer)
971 (post . gnus-post-news-buffer)
972 (faq . gnus-faq-buffer)
973 (picons . "*Picons*")
974 (tree . gnus-tree-buffer)
975 (info . gnus-info-buffer)
976 (article-copy . gnus-article-copy)
977 (draft . gnus-draft-buffer))
978 "Mapping from short symbols to buffer names or buffer variables.")
980 (defvar gnus-carpal nil
981 "*If non-nil, display clickable icons.")
983 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
984 "*Function called with a group name when new group is detected.
985 A few pre-made functions are supplied: `gnus-subscribe-randomly'
986 inserts new groups at the beginning of the list of groups;
987 `gnus-subscribe-alphabetically' inserts new groups in strict
988 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
989 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
990 for your decision; `gnus-subscribe-killed' kills all new groups.")
992 ;; Suggested by a bug report by Hallvard B Furuseth.
993 ;; <h.b.furuseth@usit.uio.no>.
994 (defvar gnus-subscribe-options-newsgroup-method
995 (function gnus-subscribe-alphabetically)
996 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
997 If, for instance, you want to subscribe to all newsgroups in the
998 \"no\" and \"alt\" hierarchies, you'd put the following in your
1001 options -n no.all alt.all
1003 Gnus will the subscribe all new newsgroups in these hierarchies with
1004 the subscription method in this variable.")
1006 (defvar gnus-subscribe-hierarchical-interactive nil
1007 "*If non-nil, Gnus will offer to subscribe hierarchically.
1008 When a new hierarchy appears, Gnus will ask the user:
1010 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1012 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1013 subscribe to all newsgroups in the hierarchy and `s' will skip this
1014 hierarchy in its entirety.")
1016 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1017 "*Function used for sorting the group buffer.
1018 This function will be called with group info entries as the arguments
1019 for the groups to be sorted. Pre-made functions include
1020 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1021 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1022 `gnus-group-sort-by-rank'.
1024 This variable can also be a list of sorting functions. In that case,
1025 the most significant sort function should be the last function in the
1028 ;; Mark variables suggested by Thomas Michanek
1029 ;; <Thomas.Michanek@telelogic.se>.
1030 (defvar gnus-unread-mark ?
1031 "*Mark used for unread articles.")
1032 (defvar gnus-ticked-mark ?!
1033 "*Mark used for ticked articles.")
1034 (defvar gnus-dormant-mark ??
1035 "*Mark used for dormant articles.")
1036 (defvar gnus-del-mark ?r
1037 "*Mark used for del'd articles.")
1038 (defvar gnus-read-mark ?R
1039 "*Mark used for read articles.")
1040 (defvar gnus-expirable-mark ?E
1041 "*Mark used for expirable articles.")
1042 (defvar gnus-killed-mark ?K
1043 "*Mark used for killed articles.")
1044 (defvar gnus-souped-mark ?F
1045 "*Mark used for killed articles.")
1046 (defvar gnus-kill-file-mark ?X
1047 "*Mark used for articles killed by kill files.")
1048 (defvar gnus-low-score-mark ?Y
1049 "*Mark used for articles with a low score.")
1050 (defvar gnus-catchup-mark ?C
1051 "*Mark used for articles that are caught up.")
1052 (defvar gnus-replied-mark ?A
1053 "*Mark used for articles that have been replied to.")
1054 (defvar gnus-cached-mark ?*
1055 "*Mark used for articles that are in the cache.")
1056 (defvar gnus-saved-mark ?S
1057 "*Mark used for articles that have been saved to.")
1058 (defvar gnus-process-mark ?#
1060 (defvar gnus-ancient-mark ?O
1061 "*Mark used for ancient articles.")
1062 (defvar gnus-sparse-mark ?Q
1063 "*Mark used for sparsely reffed articles.")
1064 (defvar gnus-canceled-mark ?G
1065 "*Mark used for canceled articles.")
1066 (defvar gnus-score-over-mark ?+
1067 "*Score mark used for articles with high scores.")
1068 (defvar gnus-score-below-mark ?-
1069 "*Score mark used for articles with low scores.")
1070 (defvar gnus-empty-thread-mark ?
1071 "*There is no thread under the article.")
1072 (defvar gnus-not-empty-thread-mark ?=
1073 "*There is a thread under the article.")
1075 (defvar gnus-view-pseudo-asynchronously nil
1076 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1078 (defvar gnus-view-pseudos nil
1079 "*If `automatic', pseudo-articles will be viewed automatically.
1080 If `not-confirm', pseudos will be viewed automatically, and the user
1081 will not be asked to confirm the command.")
1083 (defvar gnus-view-pseudos-separately t
1084 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1085 If nil, all files that use the same viewing command will be given as a
1086 list of parameters to that command.")
1088 (defvar gnus-insert-pseudo-articles t
1089 "*If non-nil, insert pseudo-articles when decoding articles.")
1091 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1092 "*Format of group lines.
1093 It works along the same lines as a normal formatting string,
1094 with some simple extensions.
1096 %M Only marked articles (character, \"*\" or \" \")
1097 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1098 %L Level of subscribedness (integer)
1099 %N Number of unread articles (integer)
1100 %I Number of dormant articles (integer)
1101 %i Number of ticked and dormant (integer)
1102 %T Number of ticked articles (integer)
1103 %R Number of read articles (integer)
1104 %t Total number of articles (integer)
1105 %y Number of unread, unticked articles (integer)
1106 %G Group name (string)
1107 %g Qualified group name (string)
1108 %D Group description (string)
1109 %s Select method (string)
1110 %o Moderated group (char, \"m\")
1111 %p Process mark (char)
1112 %O Moderated group (string, \"(m)\" or \"\")
1113 %P Topic indentation (string)
1114 %l Whether there are GroupLens predictions for this group (string)
1115 %n Select from where (string)
1116 %z A string that look like `<%s:%n>' if a foreign select method is used
1117 %u User defined specifier. The next character in the format string should
1118 be a letter. Gnus will call the function gnus-user-format-function-X,
1119 where X is the letter following %u. The function will be passed the
1120 current header as argument. The function should return a string, which
1121 will be inserted into the buffer just like information from any other
1124 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1125 the mouse point move inside the area. There can only be one such area.
1127 Note that this format specification is not always respected. For
1128 reasons of efficiency, when listing killed groups, this specification
1129 is ignored altogether. If the spec is changed considerably, your
1130 output may end up looking strange when listing both alive and killed
1133 If you use %o or %O, reading the active file will be slower and quite
1134 a bit of extra memory will be used. %D will also worsen performance.
1135 Also note that if you change the format specification to include any
1136 of these specs, you must probably re-start Gnus to see them go into
1139 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1140 "*The format specification of the lines in the summary buffer.
1142 It works along the same lines as a normal formatting string,
1143 with some simple extensions.
1145 %N Article number, left padded with spaces (string)
1147 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1148 %n Name of the poster (string)
1149 %a Extracted name of the poster (string)
1150 %A Extracted address of the poster (string)
1151 %F Contents of the From: header (string)
1152 %x Contents of the Xref: header (string)
1153 %D Date of the article (string)
1154 %d Date of the article (string) in DD-MMM format
1155 %M Message-id of the article (string)
1156 %r References of the article (string)
1157 %c Number of characters in the article (integer)
1158 %L Number of lines in the article (integer)
1159 %I Indentation based on thread level (a string of spaces)
1160 %T A string with two possible values: 80 spaces if the article
1161 is on thread level two or larger and 0 spaces on level one
1162 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1163 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1164 %[ Opening bracket (character, \"[\" or \"<\")
1165 %] Closing bracket (character, \"]\" or \">\")
1166 %> Spaces of length thread-level (string)
1167 %< Spaces of length (- 20 thread-level) (string)
1168 %i Article score (number)
1169 %z Article zcore (character)
1170 %t Number of articles under the current thread (number).
1171 %e Whether the thread is empty or not (character).
1172 %l GroupLens score (number)
1173 %u User defined specifier. The next character in the format string should
1174 be a letter. Gnus will call the function gnus-user-format-function-X,
1175 where X is the letter following %u. The function will be passed the
1176 current header as argument. The function should return a string, which
1177 will be inserted into the summary just like information from any other
1180 Text between %( and %) will be highlighted with `gnus-mouse-face'
1181 when the mouse point is placed inside the area. There can only be one
1184 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1185 with care. For reasons of efficiency, Gnus will compute what column
1186 these characters will end up in, and \"hard-code\" that. This means that
1187 it is illegal to have these specs after a variable-length spec. Well,
1188 you might not be arrested, but your summary buffer will look strange,
1189 which is bad enough.
1191 The smart choice is to have these specs as for to the left as
1194 This restriction may disappear in later versions of Gnus.")
1196 (defvar gnus-summary-dummy-line-format
1198 "*The format specification for the dummy roots in the summary buffer.
1199 It works along the same lines as a normal formatting string,
1200 with some simple extensions.
1204 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1205 "*The format specification for the summary mode line.
1206 It works along the same lines as a normal formatting string,
1207 with some simple extensions:
1210 %p Unprefixed group name
1211 %A Current article number
1213 %U Number of unread articles in the group
1214 %e Number of unselected articles in the group
1215 %Z A string with unread/unselected article counts
1216 %g Shortish group name
1217 %S Subject of the current article
1218 %u User-defined spec
1219 %s Current score file name
1220 %d Number of dormant articles
1221 %r Number of articles that have been marked as read in this session
1222 %E Number of articles expunged by the score files")
1224 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1225 "*The format specification for the article mode line.
1226 See `gnus-summary-mode-line-format' for a closer description.")
1228 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1229 "*The format specification for the group mode line.
1230 It works along the same lines as a normal formatting string,
1231 with some simple extensions:
1233 %S The native news server.
1234 %M The native select method.")
1236 (defvar gnus-valid-select-methods
1237 '(("nntp" post address prompt-address)
1238 ("nnspool" post address)
1239 ("nnvirtual" post-mail virtual prompt-address)
1240 ("nnmbox" mail respool address)
1241 ("nnml" mail respool address)
1242 ("nnmh" mail respool address)
1243 ("nndir" post-mail prompt-address address)
1244 ("nneething" none address prompt-address)
1245 ("nndoc" none address prompt-address)
1246 ("nnbabyl" mail address respool)
1247 ("nnkiboze" post address virtual)
1248 ("nnsoup" post-mail address)
1249 ("nndraft" post-mail)
1250 ("nnfolder" mail respool address))
1251 "An alist of valid select methods.
1252 The first element of each list lists should be a string with the name
1253 of the select method. The other elements may be be the category of
1254 this method (ie. `post', `mail', `none' or whatever) or other
1255 properties that this method has (like being respoolable).
1256 If you implement a new select method, all you should have to change is
1257 this variable. I think.")
1259 (defvar gnus-updated-mode-lines '(group article summary tree)
1260 "*List of buffers that should update their mode lines.
1261 The list may contain the symbols `group', `article' and `summary'. If
1262 the corresponding symbol is present, Gnus will keep that mode line
1263 updated with information that may be pertinent.
1264 If this variable is nil, screen refresh may be quicker.")
1266 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1267 (defvar gnus-mode-non-string-length nil
1268 "*Max length of mode-line non-string contents.
1269 If this is nil, Gnus will take space as is needed, leaving the rest
1270 of the modeline intact.")
1273 ;(defvar gnus-mouse-face 'highlight
1274 ; "*Face used for mouse highlighting in Gnus.
1275 ;No mouse highlights will be done if `gnus-visual' is nil.")
1277 (defvar gnus-summary-mark-below nil
1278 "*Mark all articles with a score below this variable as read.
1279 This variable is local to each summary buffer and usually set by the
1282 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1283 "*List of functions used for sorting articles in the summary buffer.
1284 This variable is only used when not using a threaded display.")
1286 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1287 "*List of functions used for sorting threads in the summary buffer.
1288 By default, threads are sorted by article number.
1290 Each function takes two threads and return non-nil if the first thread
1291 should be sorted before the other. If you use more than one function,
1292 the primary sort function should be the last. You should probably
1293 always include `gnus-thread-sort-by-number' in the list of sorting
1294 functions -- preferably first.
1296 Ready-mady functions include `gnus-thread-sort-by-number',
1297 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1298 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1299 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1301 (defvar gnus-thread-score-function '+
1302 "*Function used for calculating the total score of a thread.
1304 The function is called with the scores of the article and each
1305 subthread and should then return the score of the thread.
1307 Some functions you can use are `+', `max', or `min'.")
1309 (defvar gnus-summary-expunge-below nil
1310 "All articles that have a score less than this variable will be expunged.")
1312 (defvar gnus-thread-expunge-below nil
1313 "All threads that have a total score less than this variable will be expunged.
1314 See `gnus-thread-score-function' for en explanation of what a
1315 \"thread score\" is.")
1317 (defvar gnus-auto-subscribed-groups
1318 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1319 "*All new groups that match this regexp will be subscribed automatically.
1320 Note that this variable only deals with new groups. It has no effect
1321 whatsoever on old groups.")
1323 (defvar gnus-options-subscribe nil
1324 "*All new groups matching this regexp will be subscribed unconditionally.
1325 Note that this variable deals only with new newsgroups. This variable
1326 does not affect old newsgroups.")
1328 (defvar gnus-options-not-subscribe nil
1329 "*All new groups matching this regexp will be ignored.
1330 Note that this variable deals only with new newsgroups. This variable
1331 does not affect old (already subscribed) newsgroups.")
1333 (defvar gnus-auto-expirable-newsgroups nil
1334 "*Groups in which to automatically mark read articles as expirable.
1335 If non-nil, this should be a regexp that should match all groups in
1336 which to perform auto-expiry. This only makes sense for mail groups.")
1338 (defvar gnus-total-expirable-newsgroups nil
1339 "*Groups in which to perform expiry of all read articles.
1340 Use with extreme caution. All groups that match this regexp will be
1341 expiring - which means that all read articles will be deleted after
1342 (say) one week. (This only goes for mail groups and the like, of
1345 (defvar gnus-group-uncollapsed-levels 1
1346 "Number of group name elements to leave alone when making a short group name.")
1348 (defvar gnus-hidden-properties '(invisible t intangible t)
1349 "Property list to use for hiding text.")
1351 (defvar gnus-modtime-botch nil
1352 "*Non-nil means .newsrc should be deleted prior to save.
1353 Its use is due to the bogus appearance that .newsrc was modified on
1358 (defvar gnus-group-mode-hook nil
1359 "*A hook for Gnus group mode.")
1361 (defvar gnus-summary-mode-hook nil
1362 "*A hook for Gnus summary mode.
1363 This hook is run before any variables are set in the summary buffer.")
1365 (defvar gnus-article-mode-hook nil
1366 "*A hook for Gnus article mode.")
1368 (defvar gnus-summary-prepare-exit-hook nil
1369 "*A hook called when preparing to exit from the summary buffer.
1370 It calls `gnus-summary-expire-articles' by default.")
1371 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1373 (defvar gnus-summary-exit-hook nil
1374 "*A hook called on exit from the summary buffer.")
1376 (defvar gnus-group-catchup-group-hook nil
1377 "*A hook run when catching up a group from the group buffer.")
1379 (defvar gnus-open-server-hook nil
1380 "*A hook called just before opening connection to the news server.")
1382 (defvar gnus-load-hook nil
1383 "*A hook run while Gnus is loaded.")
1385 (defvar gnus-startup-hook nil
1386 "*A hook called at startup.
1387 This hook is called after Gnus is connected to the NNTP server.")
1389 (defvar gnus-get-new-news-hook nil
1390 "*A hook run just before Gnus checks for new news.")
1392 (defvar gnus-after-getting-new-news-hook nil
1393 "*A hook run after Gnus checks for new news.")
1395 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1396 "*A function that is called to generate the group buffer.
1397 The function is called with three arguments: The first is a number;
1398 all group with a level less or equal to that number should be listed,
1399 if the second is non-nil, empty groups should also be displayed. If
1400 the third is non-nil, it is a number. No groups with a level lower
1401 than this number should be displayed.
1403 The only current function implemented is `gnus-group-prepare-flat'.")
1405 (defvar gnus-group-prepare-hook nil
1406 "*A hook called after the group buffer has been generated.
1407 If you want to modify the group buffer, you can use this hook.")
1409 (defvar gnus-summary-prepare-hook nil
1410 "*A hook called after the summary buffer has been generated.
1411 If you want to modify the summary buffer, you can use this hook.")
1413 (defvar gnus-summary-generate-hook nil
1414 "*A hook run just before generating the summary buffer.
1415 This hook is commonly used to customize threading variables and the
1418 (defvar gnus-article-prepare-hook nil
1419 "*A hook called after an article has been prepared in the article buffer.
1420 If you want to run a special decoding program like nkf, use this hook.")
1422 ;(defvar gnus-article-display-hook nil
1423 ; "*A hook called after the article is displayed in the article buffer.
1424 ;The hook is designed to change the contents of the article
1425 ;buffer. Typical functions that this hook may contain are
1426 ;`gnus-article-hide-headers' (hide selected headers),
1427 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1428 ;`gnus-article-hide-signature' (hide signature) and
1429 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1430 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1431 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1432 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1434 (defvar gnus-article-x-face-command
1435 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1436 "String or function to be executed to display an X-Face header.
1437 If it is a string, the command will be executed in a sub-shell
1438 asynchronously. The compressed face will be piped to this command.")
1440 (defvar gnus-article-x-face-too-ugly nil
1441 "Regexp matching posters whose face shouldn't be shown automatically.")
1443 (defvar gnus-select-group-hook nil
1444 "*A hook called when a newsgroup is selected.
1446 If you'd like to simplify subjects like the
1447 `gnus-summary-next-same-subject' command does, you can use the
1450 (setq gnus-select-group-hook
1453 (mapcar (lambda (header)
1454 (mail-header-set-subject
1456 (gnus-simplify-subject
1457 (mail-header-subject header) 're-only)))
1458 gnus-newsgroup-headers))))")
1460 (defvar gnus-select-article-hook nil
1461 "*A hook called when an article is selected.")
1463 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1464 "*A hook called to apply kill files to a group.
1465 This hook is intended to apply a kill file to the selected newsgroup.
1466 The function `gnus-apply-kill-file' is called by default.
1468 Since a general kill file is too heavy to use only for a few
1469 newsgroups, I recommend you to use a lighter hook function. For
1470 example, if you'd like to apply a kill file to articles which contains
1471 a string `rmgroup' in subject in newsgroup `control', you can use the
1474 (setq gnus-apply-kill-hook
1477 (cond ((string-match \"control\" gnus-newsgroup-name)
1478 (gnus-kill \"Subject\" \"rmgroup\")
1479 (gnus-expunge \"X\"))))))")
1481 (defvar gnus-visual-mark-article-hook
1482 (list 'gnus-highlight-selected-summary)
1483 "*Hook run after selecting an article in the summary buffer.
1484 It is meant to be used for highlighting the article in some way. It
1485 is not run if `gnus-visual' is nil.")
1487 (defvar gnus-parse-headers-hook nil
1488 "*A hook called before parsing the headers.")
1490 (defvar gnus-exit-group-hook nil
1491 "*A hook called when exiting (not quitting) summary mode.")
1493 (defvar gnus-suspend-gnus-hook nil
1494 "*A hook called when suspending (not exiting) Gnus.")
1496 (defvar gnus-exit-gnus-hook nil
1497 "*A hook called when exiting Gnus.")
1499 (defvar gnus-after-exiting-gnus-hook nil
1500 "*A hook called after exiting Gnus.")
1502 (defvar gnus-save-newsrc-hook nil
1503 "*A hook called before saving any of the newsrc files.")
1505 (defvar gnus-save-quick-newsrc-hook nil
1506 "*A hook called just before saving the quick newsrc file.
1507 Can be used to turn version control on or off.")
1509 (defvar gnus-save-standard-newsrc-hook nil
1510 "*A hook called just before saving the standard newsrc file.
1511 Can be used to turn version control on or off.")
1513 (defvar gnus-summary-update-hook
1514 (list 'gnus-summary-highlight-line)
1515 "*A hook called when a summary line is changed.
1516 The hook will not be called if `gnus-visual' is nil.
1518 The default function `gnus-summary-highlight-line' will
1519 highlight the line according to the `gnus-summary-highlight'
1522 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1523 "*A hook called when a group line is changed.
1524 The hook will not be called if `gnus-visual' is nil.
1526 The default function `gnus-group-highlight-line' will
1527 highlight the line according to the `gnus-group-highlight'
1530 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1531 "*A hook called when an article is selected for the first time.
1532 The hook is intended to mark an article as read (or unread)
1533 automatically when it is selected.")
1535 (defvar gnus-group-change-level-function nil
1536 "Function run when a group level is changed.
1537 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1539 ;; Remove any hilit infestation.
1540 (add-hook 'gnus-startup-hook
1542 (remove-hook 'gnus-summary-prepare-hook
1543 'hilit-rehighlight-buffer-quietly)
1544 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1545 (setq gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read))
1546 (remove-hook 'gnus-article-prepare-hook
1547 'hilit-rehighlight-buffer-quietly)))
1550 ;; Internal variables
1552 (defvar gnus-server-alist nil
1553 "List of available servers.")
1555 (defvar gnus-group-indentation-function nil)
1557 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1559 (defvar gnus-goto-missing-group-function nil)
1561 (defvar gnus-override-subscribe-method nil)
1563 (defvar gnus-group-goto-next-group-function nil
1564 "Function to override finding the next group after listing groups.")
1566 (defconst gnus-article-mark-lists
1567 '((marked . tick) (replied . reply)
1568 (expirable . expire) (killed . killed)
1569 (bookmarks . bookmark) (dormant . dormant)
1570 (scored . score) (saved . save)
1574 ;; Avoid highlighting in kill files.
1575 (defvar gnus-summary-inhibit-highlight nil)
1576 (defvar gnus-newsgroup-selected-overlay nil)
1578 (defvar gnus-inhibit-hiding nil)
1579 (defvar gnus-group-indentation "")
1580 (defvar gnus-inhibit-limiting nil)
1581 (defvar gnus-created-frames nil)
1583 (defvar gnus-article-mode-map nil)
1584 (defvar gnus-dribble-buffer nil)
1585 (defvar gnus-headers-retrieved-by nil)
1586 (defvar gnus-article-reply nil)
1587 (defvar gnus-override-method nil)
1588 (defvar gnus-article-check-size nil)
1590 (defvar gnus-current-score-file nil)
1591 (defvar gnus-newsgroup-adaptive-score-file nil)
1592 (defvar gnus-scores-exclude-files nil)
1594 (defvar gnus-opened-servers nil)
1596 (defvar gnus-current-move-group nil)
1598 (defvar gnus-newsgroup-dependencies nil)
1599 (defvar gnus-newsgroup-async nil)
1600 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1602 (defvar gnus-newsgroup-adaptive nil)
1604 (defvar gnus-summary-display-table nil)
1605 (defvar gnus-summary-display-article-function nil)
1607 (defvar gnus-summary-highlight-line-function nil
1608 "Function called after highlighting a summary line.")
1610 (defvar gnus-group-line-format-alist
1611 `((?M gnus-tmp-marked-mark ?c)
1612 (?S gnus-tmp-subscribed ?c)
1613 (?L gnus-tmp-level ?d)
1614 (?N (cond ((eq number t) "*" )
1618 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1619 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1621 (?R gnus-tmp-number-of-read ?s)
1622 (?t gnus-tmp-number-total ?d)
1623 (?y gnus-tmp-number-of-unread ?s)
1624 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1625 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1626 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1627 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1628 (?g gnus-tmp-group ?s)
1629 (?G gnus-tmp-qualified-group ?s)
1630 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1631 (?D gnus-tmp-newsgroup-description ?s)
1632 (?o gnus-tmp-moderated ?c)
1633 (?O gnus-tmp-moderated-string ?s)
1634 (?p gnus-tmp-process-marked ?c)
1635 (?s gnus-tmp-news-server ?s)
1636 (?n gnus-tmp-news-method ?s)
1637 (?P gnus-group-indentation ?s)
1638 (?l gnus-tmp-grouplens ?s)
1639 (?z gnus-tmp-news-method-string ?s)
1640 (?u gnus-tmp-user-defined ?s)))
1642 (defvar gnus-summary-line-format-alist
1643 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1644 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1645 (?s gnus-tmp-subject-or-nil ?s)
1646 (?n gnus-tmp-name ?s)
1647 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1649 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1651 (?F gnus-tmp-from ?s)
1652 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1653 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1654 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1655 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1656 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1657 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1658 (?L gnus-tmp-lines ?d)
1659 (?I gnus-tmp-indentation ?s)
1660 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1661 (?R gnus-tmp-replied ?c)
1662 (?\[ gnus-tmp-opening-bracket ?c)
1663 (?\] gnus-tmp-closing-bracket ?c)
1664 (?\> (make-string gnus-tmp-level ? ) ?s)
1665 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1666 (?i gnus-tmp-score ?d)
1667 (?z gnus-tmp-score-char ?c)
1668 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1669 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1670 (?U gnus-tmp-unread ?c)
1671 (?t (gnus-summary-number-of-articles-in-thread
1672 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1674 (?e (gnus-summary-number-of-articles-in-thread
1675 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1677 (?u gnus-tmp-user-defined ?s))
1678 "An alist of format specifications that can appear in summary lines,
1679 and what variables they correspond with, along with the type of the
1680 variable (string, integer, character, etc).")
1682 (defvar gnus-summary-dummy-line-format-alist
1683 `((?S gnus-tmp-subject ?s)
1684 (?N gnus-tmp-number ?d)
1685 (?u gnus-tmp-user-defined ?s)))
1687 (defvar gnus-summary-mode-line-format-alist
1688 `((?G gnus-tmp-group-name ?s)
1689 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1690 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1691 (?A gnus-tmp-article-number ?d)
1692 (?Z gnus-tmp-unread-and-unselected ?s)
1693 (?V gnus-version ?s)
1694 (?U gnus-tmp-unread ?d)
1695 (?S gnus-tmp-subject ?s)
1696 (?e gnus-tmp-unselected ?d)
1697 (?u gnus-tmp-user-defined ?s)
1698 (?d (length gnus-newsgroup-dormant) ?d)
1699 (?t (length gnus-newsgroup-marked) ?d)
1700 (?r (length gnus-newsgroup-reads) ?d)
1701 (?E gnus-newsgroup-expunged-tally ?d)
1702 (?s (gnus-current-score-file-nondirectory) ?s)))
1704 (defvar gnus-article-mode-line-format-alist
1705 gnus-summary-mode-line-format-alist)
1707 (defvar gnus-group-mode-line-format-alist
1708 `((?S gnus-tmp-news-server ?s)
1709 (?M gnus-tmp-news-method ?s)
1710 (?u gnus-tmp-user-defined ?s)))
1712 (defvar gnus-have-read-active-file nil)
1714 (defconst gnus-maintainer
1715 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1716 "The mail address of the Gnus maintainers.")
1718 (defconst gnus-version "September Gnus v0.53"
1719 "Version number for this version of Gnus.")
1721 (defvar gnus-info-nodes
1722 '((gnus-group-mode "(gnus)The Group Buffer")
1723 (gnus-summary-mode "(gnus)The Summary Buffer")
1724 (gnus-article-mode "(gnus)The Article Buffer"))
1725 "Assoc list of major modes and related Info nodes.")
1727 (defvar gnus-group-buffer "*Group*")
1728 (defvar gnus-summary-buffer "*Summary*")
1729 (defvar gnus-article-buffer "*Article*")
1730 (defvar gnus-server-buffer "*Server*")
1732 (defvar gnus-work-buffer " *gnus work*")
1734 (defvar gnus-original-article-buffer " *Original Article*")
1735 (defvar gnus-original-article nil)
1737 (defvar gnus-buffer-list nil
1738 "Gnus buffers that should be killed on exit.")
1740 (defvar gnus-slave nil
1741 "Whether this Gnus is a slave or not.")
1743 (defvar gnus-variable-list
1744 '(gnus-newsrc-options gnus-newsrc-options-n
1745 gnus-newsrc-last-checked-date
1746 gnus-newsrc-alist gnus-server-alist
1747 gnus-killed-list gnus-zombie-list
1748 gnus-topic-topology gnus-topic-alist
1750 "Gnus variables saved in the quick startup file.")
1752 (defvar gnus-newsrc-options nil
1753 "Options line in the .newsrc file.")
1755 (defvar gnus-newsrc-options-n nil
1756 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1758 (defvar gnus-newsrc-last-checked-date nil
1759 "Date Gnus last asked server for new newsgroups.")
1761 (defvar gnus-topic-topology nil
1762 "The complete topic hierarchy.")
1764 (defvar gnus-topic-alist nil
1765 "The complete topic-group alist.")
1767 (defvar gnus-newsrc-alist nil
1768 "Assoc list of read articles.
1769 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1771 (defvar gnus-newsrc-hashtb nil
1772 "Hashtable of gnus-newsrc-alist.")
1774 (defvar gnus-killed-list nil
1775 "List of killed newsgroups.")
1777 (defvar gnus-killed-hashtb nil
1778 "Hash table equivalent of gnus-killed-list.")
1780 (defvar gnus-zombie-list nil
1781 "List of almost dead newsgroups.")
1783 (defvar gnus-description-hashtb nil
1784 "Descriptions of newsgroups.")
1786 (defvar gnus-list-of-killed-groups nil
1787 "List of newsgroups that have recently been killed by the user.")
1789 (defvar gnus-active-hashtb nil
1790 "Hashtable of active articles.")
1792 (defvar gnus-moderated-list nil
1793 "List of moderated newsgroups.")
1795 (defvar gnus-group-marked nil)
1797 (defvar gnus-current-startup-file nil
1798 "Startup file for the current host.")
1800 (defvar gnus-last-search-regexp nil
1801 "Default regexp for article search command.")
1803 (defvar gnus-last-shell-command nil
1804 "Default shell command on article.")
1806 (defvar gnus-current-select-method nil
1807 "The current method for selecting a newsgroup.")
1809 (defvar gnus-group-list-mode nil)
1811 (defvar gnus-article-internal-prepare-hook nil)
1813 (defvar gnus-newsgroup-name nil)
1814 (defvar gnus-newsgroup-begin nil)
1815 (defvar gnus-newsgroup-end nil)
1816 (defvar gnus-newsgroup-last-rmail nil)
1817 (defvar gnus-newsgroup-last-mail nil)
1818 (defvar gnus-newsgroup-last-folder nil)
1819 (defvar gnus-newsgroup-last-file nil)
1820 (defvar gnus-newsgroup-auto-expire nil)
1821 (defvar gnus-newsgroup-active nil)
1823 (defvar gnus-newsgroup-data nil)
1824 (defvar gnus-newsgroup-data-reverse nil)
1825 (defvar gnus-newsgroup-limit nil)
1826 (defvar gnus-newsgroup-limits nil)
1828 (defvar gnus-newsgroup-unreads nil
1829 "List of unread articles in the current newsgroup.")
1831 (defvar gnus-newsgroup-unselected nil
1832 "List of unselected unread articles in the current newsgroup.")
1834 (defvar gnus-newsgroup-reads nil
1835 "Alist of read articles and article marks in the current newsgroup.")
1837 (defvar gnus-newsgroup-expunged-tally nil)
1839 (defvar gnus-newsgroup-marked nil
1840 "List of ticked articles in the current newsgroup (a subset of unread art).")
1842 (defvar gnus-newsgroup-killed nil
1843 "List of ranges of articles that have been through the scoring process.")
1845 (defvar gnus-newsgroup-cached nil
1846 "List of articles that come from the article cache.")
1848 (defvar gnus-newsgroup-saved nil
1849 "List of articles that have been saved.")
1851 (defvar gnus-newsgroup-kill-headers nil)
1853 (defvar gnus-newsgroup-replied nil
1854 "List of articles that have been replied to in the current newsgroup.")
1856 (defvar gnus-newsgroup-expirable nil
1857 "List of articles in the current newsgroup that can be expired.")
1859 (defvar gnus-newsgroup-processable nil
1860 "List of articles in the current newsgroup that can be processed.")
1862 (defvar gnus-newsgroup-bookmarks nil
1863 "List of articles in the current newsgroup that have bookmarks.")
1865 (defvar gnus-newsgroup-dormant nil
1866 "List of dormant articles in the current newsgroup.")
1868 (defvar gnus-newsgroup-scored nil
1869 "List of scored articles in the current newsgroup.")
1871 (defvar gnus-newsgroup-headers nil
1872 "List of article headers in the current newsgroup.")
1874 (defvar gnus-newsgroup-threads nil)
1876 (defvar gnus-newsgroup-prepared nil
1877 "Whether the current group has been prepared properly.")
1879 (defvar gnus-newsgroup-ancient nil
1880 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1882 (defvar gnus-newsgroup-sparse nil)
1884 (defvar gnus-current-article nil)
1885 (defvar gnus-article-current nil)
1886 (defvar gnus-current-headers nil)
1887 (defvar gnus-have-all-headers nil)
1888 (defvar gnus-last-article nil)
1889 (defvar gnus-newsgroup-history nil)
1890 (defvar gnus-current-kill-article nil)
1892 ;; Save window configuration.
1893 (defvar gnus-prev-winconf nil)
1895 (defvar gnus-summary-mark-positions nil)
1896 (defvar gnus-group-mark-positions nil)
1898 (defvar gnus-reffed-article-number nil)
1900 ;;; Let the byte-compiler know that we know about this variable.
1901 (defvar rmail-default-rmail-file)
1903 (defvar gnus-cache-removable-articles nil)
1905 (defvar gnus-dead-summary nil)
1907 (defconst gnus-summary-local-variables
1908 '(gnus-newsgroup-name
1909 gnus-newsgroup-begin gnus-newsgroup-end
1910 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1911 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1912 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1913 gnus-newsgroup-unselected gnus-newsgroup-marked
1914 gnus-newsgroup-reads gnus-newsgroup-saved
1915 gnus-newsgroup-replied gnus-newsgroup-expirable
1916 gnus-newsgroup-processable gnus-newsgroup-killed
1917 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1918 gnus-newsgroup-headers gnus-newsgroup-threads
1919 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1920 gnus-current-article gnus-current-headers gnus-have-all-headers
1921 gnus-last-article gnus-article-internal-prepare-hook
1922 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1923 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1924 gnus-newsgroup-async
1925 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1926 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1927 gnus-newsgroup-history gnus-newsgroup-ancient
1928 gnus-newsgroup-sparse
1929 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1930 gnus-newsgroup-adaptive-score-file
1931 (gnus-newsgroup-expunged-tally . 0)
1932 gnus-cache-removable-articles gnus-newsgroup-cached
1933 gnus-newsgroup-data gnus-newsgroup-data-reverse
1934 gnus-newsgroup-limit gnus-newsgroup-limits)
1935 "Variables that are buffer-local to the summary buffers.")
1937 (defconst gnus-bug-message
1938 "Sending a bug report to the Gnus Towers.
1939 ========================================
1941 The buffer below is a mail buffer. When you press `C-c C-c', it will
1942 be sent to the Gnus Bug Exterminators.
1944 At the bottom of the buffer you'll see lots of variable settings.
1945 Please do not delete those. They will tell the Bug People what your
1946 environment is, so that it will be easier to locate the bugs.
1948 If you have found a bug that makes Emacs go \"beep\", set
1949 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1950 and include the backtrace in your bug report.
1952 Please describe the bug in annoying, painstaking detail.
1954 Thank you for your help in stamping out bugs.
1957 ;;; End of variables.
1959 ;; Define some autoload functions Gnus might use.
1962 ;; This little mapcar goes through the list below and marks the
1963 ;; symbols in question as autoloaded functions.
1966 (let ((interactive (nth 1 (memq ':interactive package))))
1970 (when (consp function)
1971 (setq keymap (car (memq 'keymap function)))
1972 (setq function (car function)))
1973 (autoload function (car package) nil interactive keymap)))
1974 (if (eq (nth 1 package) ':interactive)
1977 '(("metamail" metamail-buffer)
1978 ("info" Info-goto-node)
1979 ("hexl" hexl-hex-string-to-integer)
1980 ("pp" pp pp-to-string pp-eval-expression)
1981 ("mail-extr" mail-extract-address-components)
1982 ("nnmail" nnmail-split-fancy nnmail-article-group)
1983 ("nnvirtual" nnvirtual-catchup-group)
1984 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1985 timezone-make-sortable-date timezone-make-time-string)
1986 ("sendmail" mail-position-on-field mail-setup)
1987 ("rmailout" rmail-output)
1988 ("rnewspost" news-mail-other-window news-reply-yank-original
1989 news-caesar-buffer-body)
1990 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1992 ("gnus-soup" :interactive t
1993 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1994 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1995 ("nnsoup" nnsoup-pack-replies)
1996 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1997 gnus-Folder-save-name gnus-folder-save-name)
1998 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1999 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2000 gnus-server-make-menu-bar gnus-article-make-menu-bar
2001 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2002 gnus-summary-highlight-line gnus-carpal-setup-buffer
2003 gnus-group-highlight-line
2004 gnus-article-add-button gnus-insert-next-page-button
2005 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2006 ("gnus-vis" :interactive t
2007 gnus-article-push-button gnus-article-press-button
2008 gnus-article-highlight gnus-article-highlight-some
2009 gnus-article-highlight-headers gnus-article-highlight-signature
2010 gnus-article-add-buttons gnus-article-add-buttons-to-head
2011 gnus-article-next-button gnus-article-prev-button)
2012 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2013 gnus-demon-add-disconnection gnus-demon-add-handler
2014 gnus-demon-remove-handler)
2015 ("gnus-demon" :interactive t
2016 gnus-demon-init gnus-demon-cancel)
2017 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2018 gnus-tree-open gnus-tree-close)
2019 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2020 gnus-nocem-unwanted-article-p)
2021 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2022 ("gnus-srvr" gnus-browse-foreign-server)
2023 ("gnus-cite" :interactive t
2024 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2025 gnus-article-hide-citation gnus-article-fill-cited-article)
2026 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2027 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2028 gnus-execute gnus-expunge)
2029 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2030 gnus-cache-possibly-remove-articles gnus-cache-request-article
2031 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2032 gnus-cache-enter-remove-article gnus-cached-article-p
2033 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2034 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2035 gnus-cache-remove-article)
2036 ("gnus-score" :interactive t
2037 gnus-summary-increase-score gnus-summary-lower-score
2038 gnus-score-flush-cache gnus-score-close
2039 gnus-score-raise-same-subject-and-select
2040 gnus-score-raise-same-subject gnus-score-default
2041 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2042 gnus-score-lower-same-subject gnus-score-lower-thread
2043 gnus-possibly-score-headers)
2045 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2046 gnus-current-score-file-nondirectory gnus-score-adaptive
2047 gnus-score-find-trace gnus-score-file-name)
2048 ("gnus-edit" :interactive t gnus-score-customize)
2049 ("gnus-topic" :interactive t gnus-topic-mode)
2050 ("gnus-topic" gnus-topic-remove-group)
2051 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2052 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2053 ("gnus-uu" :interactive t
2054 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2055 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2056 gnus-uu-mark-by-regexp gnus-uu-mark-all
2057 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2058 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2059 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2060 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2061 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2062 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2063 gnus-uu-decode-binhex-view)
2064 ("gnus-msg" (gnus-summary-send-map keymap)
2065 gnus-mail-yank-original gnus-mail-send-and-exit
2066 gnus-sendmail-setup-mail gnus-article-mail
2067 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2068 ("gnus-msg" :interactive t
2069 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2070 gnus-summary-followup gnus-summary-followup-with-original
2071 gnus-summary-followup-and-reply
2072 gnus-summary-followup-and-reply-with-original
2073 gnus-summary-cancel-article gnus-summary-supersede-article
2074 gnus-post-news gnus-inews-news gnus-cancel-news
2075 gnus-summary-reply gnus-summary-reply-with-original
2076 gnus-summary-mail-forward gnus-summary-mail-other-window
2078 ("gnus-picon" :interactive t gnus-article-display-picons
2079 gnus-group-display-picons gnus-picons-article-display-x-face)
2080 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2081 gnus-grouplens-mode)
2082 ("gnus-vm" gnus-vm-mail-setup)
2083 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2084 gnus-summary-save-article-vm gnus-yank-article))))
2088 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2089 ;; If you want the cursor to go somewhere else, set these two
2090 ;; functions in some startup hook to whatever you want.
2091 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2092 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2094 ;;; Various macros and substs.
2096 (defun gnus-header-from (header)
2097 (mail-header-from header))
2099 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2100 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2101 (let ((tempvar (make-symbol "GnusStartBufferWindow")))
2102 `(let ((,tempvar (selected-window)))
2105 (pop-to-buffer ,buffer)
2107 (select-window ,tempvar)))))
2109 (defmacro gnus-gethash (string hashtable)
2110 "Get hash value of STRING in HASHTABLE."
2111 `(symbol-value (intern-soft ,string ,hashtable)))
2113 (defmacro gnus-sethash (string value hashtable)
2114 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2115 `(set (intern ,string ,hashtable) ,value))
2117 (defmacro gnus-intern-safe (string hashtable)
2118 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2119 `(let ((symbol (intern ,string ,hashtable)))
2124 (defmacro gnus-group-unread (group)
2125 "Get the currently computed number of unread articles in GROUP."
2126 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2128 (defmacro gnus-group-entry (group)
2129 "Get the newsrc entry for GROUP."
2130 `(gnus-gethash ,group gnus-newsrc-hashtb))
2132 (defmacro gnus-active (group)
2133 "Get active info on GROUP."
2134 `(gnus-gethash ,group gnus-active-hashtb))
2136 (defmacro gnus-set-active (group active)
2137 "Set GROUP's active info."
2138 `(gnus-sethash ,group ,active gnus-active-hashtb))
2140 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2141 ;; function `substring' might cut on a middle of multi-octet
2143 (defun gnus-truncate-string (str width)
2144 (substring str 0 width))
2146 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2147 ;; to limit the length of a string. This function is necessary since
2148 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2149 (defsubst gnus-limit-string (str width)
2150 (if (> (length str) width)
2151 (substring str 0 width)
2154 (defsubst gnus-simplify-subject-re (subject)
2155 "Remove \"Re:\" from subject lines."
2156 (if (string-match "^[Rr][Ee]: *" subject)
2157 (substring subject (match-end 0))
2160 (defsubst gnus-functionp (form)
2161 "Return non-nil if FORM is funcallable."
2162 (or (and (symbolp form) (fboundp form))
2163 (and (listp form) (eq (car form) 'lambda))))
2165 (defsubst gnus-goto-char (point)
2166 (and point (goto-char point)))
2168 (defmacro gnus-buffer-exists-p (buffer)
2169 `(let ((buffer ,buffer))
2171 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2174 (defmacro gnus-kill-buffer (buffer)
2175 `(let ((buf ,buffer))
2176 (if (gnus-buffer-exists-p buf)
2177 (kill-buffer buf))))
2179 (defsubst gnus-point-at-bol ()
2180 "Return point at the beginning of the line."
2187 (defsubst gnus-point-at-eol ()
2188 "Return point at the end of the line."
2195 (defun gnus-alive-p ()
2196 "Say whether Gnus is running or not."
2197 (and gnus-group-buffer
2198 (get-buffer gnus-group-buffer)))
2200 ;; Delete the current line (and the next N lines.);
2201 (defmacro gnus-delete-line (&optional n)
2202 `(delete-region (progn (beginning-of-line) (point))
2203 (progn (forward-line ,(or n 1)) (point))))
2205 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2206 (defvar gnus-init-inhibit nil)
2207 (defun gnus-read-init-file (&optional inhibit-next)
2208 (if gnus-init-inhibit
2209 (setq gnus-init-inhibit nil)
2210 (setq gnus-init-inhibit inhibit-next)
2212 (or (and (file-exists-p gnus-init-file)
2213 ;; Don't try to load a directory.
2214 (not (file-directory-p gnus-init-file)))
2215 (file-exists-p (concat gnus-init-file ".el"))
2216 (file-exists-p (concat gnus-init-file ".elc")))
2218 (load gnus-init-file nil t)
2220 (error "Error in %s: %s" gnus-init-file var))))))
2222 ;; Info access macros.
2224 (defmacro gnus-info-group (info)
2226 (defmacro gnus-info-rank (info)
2228 (defmacro gnus-info-read (info)
2230 (defmacro gnus-info-marks (info)
2232 (defmacro gnus-info-method (info)
2234 (defmacro gnus-info-params (info)
2237 (defmacro gnus-info-level (info)
2238 `(let ((rank (gnus-info-rank ,info)))
2242 (defmacro gnus-info-score (info)
2243 `(let ((rank (gnus-info-rank ,info)))
2244 (or (and (consp rank) (cdr rank)) 0)))
2246 (defmacro gnus-info-set-group (info group)
2247 `(setcar ,info ,group))
2248 (defmacro gnus-info-set-rank (info rank)
2249 `(setcar (nthcdr 1 ,info) ,rank))
2250 (defmacro gnus-info-set-read (info read)
2251 `(setcar (nthcdr 2 ,info) ,read))
2252 (defmacro gnus-info-set-marks (info marks)
2253 `(setcar (nthcdr 3 ,info) ,marks))
2254 (defmacro gnus-info-set-method (info method)
2255 `(setcar (nthcdr 4 ,info) ,method))
2256 (defmacro gnus-info-set-params (info params)
2257 `(setcar (nthcdr 5 ,info) ,params))
2259 (defmacro gnus-info-set-level (info level)
2260 `(let ((rank (cdr ,info)))
2261 (if (consp (car rank))
2262 (setcar (car rank) ,level)
2263 (setcar rank ,level))))
2264 (defmacro gnus-info-set-score (info score)
2265 `(let ((rank (cdr ,info)))
2266 (if (consp (car rank))
2267 (setcdr (car rank) ,score)
2268 (setcar rank (cons (car rank) ,score)))))
2270 (defmacro gnus-get-info (group)
2271 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2273 (defun gnus-byte-code (func)
2274 "Return a form that can be `eval'ed based on FUNC."
2275 (let ((fval (symbol-function func)))
2276 (if (byte-code-function-p fval)
2277 (let ((flist (append fval nil)))
2278 (setcar flist 'byte-code)
2280 (cons 'progn (cddr fval)))))
2282 ;;; Load the compatability functions.
2289 ;; Format specs. The chunks below are the machine-generated forms
2290 ;; that are to be evaled as the result of the default format strings.
2291 ;; We write them in here to get them byte-compiled. That way the
2292 ;; default actions will be quite fast, while still retaining the full
2293 ;; flexibility of the user-defined format specs.
2295 ;; First we have lots of dummy defvars to let the compiler know these
2296 ;; are really dynamic variables.
2298 (defvar gnus-tmp-unread)
2299 (defvar gnus-tmp-replied)
2300 (defvar gnus-tmp-score-char)
2301 (defvar gnus-tmp-indentation)
2302 (defvar gnus-tmp-opening-bracket)
2303 (defvar gnus-tmp-lines)
2304 (defvar gnus-tmp-name)
2305 (defvar gnus-tmp-closing-bracket)
2306 (defvar gnus-tmp-subject-or-nil)
2307 (defvar gnus-tmp-subject)
2308 (defvar gnus-tmp-marked)
2309 (defvar gnus-tmp-marked-mark)
2310 (defvar gnus-tmp-subscribed)
2311 (defvar gnus-tmp-process-marked)
2312 (defvar gnus-tmp-number-of-unread)
2313 (defvar gnus-tmp-group-name)
2314 (defvar gnus-tmp-group)
2315 (defvar gnus-tmp-article-number)
2316 (defvar gnus-tmp-unread-and-unselected)
2317 (defvar gnus-tmp-news-method)
2318 (defvar gnus-tmp-news-server)
2319 (defvar gnus-tmp-article-number)
2320 (defvar gnus-mouse-face)
2321 (defvar gnus-mouse-face-prop)
2323 (defun gnus-summary-line-format-spec ()
2324 (insert gnus-tmp-unread gnus-tmp-replied
2325 gnus-tmp-score-char gnus-tmp-indentation)
2330 gnus-tmp-opening-bracket
2331 (format "%4d: %-20s"
2333 (if (> (length gnus-tmp-name) 20)
2334 (substring gnus-tmp-name 0 20)
2336 gnus-tmp-closing-bracket)
2338 gnus-mouse-face-prop gnus-mouse-face)
2339 (insert " " gnus-tmp-subject-or-nil "\n"))
2341 (defvar gnus-summary-line-format-spec
2342 (gnus-byte-code 'gnus-summary-line-format-spec))
2344 (defun gnus-summary-dummy-line-format-spec ()
2351 gnus-mouse-face-prop gnus-mouse-face)
2352 (insert " " gnus-tmp-subject "\n"))
2354 (defvar gnus-summary-dummy-line-format-spec
2355 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2357 (defun gnus-group-line-format-spec ()
2358 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2359 gnus-tmp-process-marked
2360 gnus-group-indentation
2361 (format "%5s: " gnus-tmp-number-of-unread))
2365 (insert gnus-tmp-group "\n")
2367 gnus-mouse-face-prop gnus-mouse-face))
2368 (defvar gnus-group-line-format-spec
2369 (gnus-byte-code 'gnus-group-line-format-spec))
2371 (defvar gnus-format-specs
2372 `((version . ,emacs-version)
2373 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2374 (summary-dummy ,gnus-summary-dummy-line-format
2375 ,gnus-summary-dummy-line-format-spec)
2376 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2378 (defvar gnus-article-mode-line-format-spec nil)
2379 (defvar gnus-summary-mode-line-format-spec nil)
2380 (defvar gnus-group-mode-line-format-spec nil)
2382 ;;; Phew. All that gruft is over, fortunately.
2386 ;;; Gnus Utility Functions
2389 (defun gnus-extract-address-components (from)
2391 ;; First find the address - the thing with the @ in it. This may
2392 ;; not be accurate in mail addresses, but does the trick most of
2393 ;; the time in news messages.
2394 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2395 (setq address (substring from (match-beginning 0) (match-end 0))))
2396 ;; Then we check whether the "name <address>" format is used.
2398 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2399 ;; Linear white space is not required.
2400 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2401 (and (setq name (substring from 0 (match-beginning 0)))
2402 ;; Strip any quotes from the name.
2403 (string-match "\".*\"" name)
2404 (setq name (substring name 1 (1- (match-end 0))))))
2405 ;; If not, then "address (name)" is used.
2407 (and (string-match "(.+)" from)
2408 (setq name (substring from (1+ (match-beginning 0))
2409 (1- (match-end 0)))))
2410 (and (string-match "()" from)
2411 (setq name address))
2412 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2413 ;; XOVER might not support folded From headers.
2414 (and (string-match "(.*" from)
2415 (setq name (substring from (1+ (match-beginning 0))
2417 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2418 (list (or name from) (or address from))))
2420 (defun gnus-fetch-field (field)
2421 "Return the value of the header FIELD of current article."
2424 (let ((case-fold-search t))
2425 (nnheader-narrow-to-headers)
2426 (mail-fetch-field field)))))
2428 (defun gnus-goto-colon ()
2430 (search-forward ":" (gnus-point-at-eol) t))
2433 (defun gnus-update-format (var)
2434 "Update the format specification near point."
2439 ;; Find the end of the current word.
2440 (re-search-forward "[ \t\n]" nil t)
2442 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2443 (match-string 1)))))
2444 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2445 (match-string 1 var))))
2446 (entry (assq type gnus-format-specs))
2449 (setq gnus-format-specs (delq entry gnus-format-specs)))
2451 (intern (format "%s-spec" var))
2452 (gnus-parse-format (setq value (symbol-value (intern var)))
2453 (symbol-value (intern (format "%s-alist" var)))
2454 (not (string-match "mode" var))))
2455 (setq spec (symbol-value (intern (format "%s-spec" var))))
2456 (push (list type value spec) gnus-format-specs)
2458 (pop-to-buffer "*Gnus Format*")
2460 (lisp-interaction-mode)
2461 (insert (pp-to-string spec))))
2463 (defun gnus-update-format-specifications (&optional force)
2464 "Update all (necessary) format specifications."
2465 ;; Make the indentation array.
2466 (gnus-make-thread-indent-array)
2468 ;; See whether all the stored info needs to be flushed.
2470 (not (equal emacs-version
2471 (cdr (assq 'version gnus-format-specs)))))
2472 (setq gnus-format-specs nil))
2474 ;; Go through all the formats and see whether they need updating.
2475 (let ((types '(summary summary-dummy group
2476 summary-mode group-mode article-mode))
2477 new-format entry type val)
2478 (while (setq type (pop types))
2479 ;; Jump to the proper buffer to find out the value of
2480 ;; the variable, if possible. (It may be buffer-local.)
2482 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2484 (when (and (boundp buffer)
2485 (setq val (symbol-value buffer))
2487 (buffer-name (get-buffer val)))
2488 (set-buffer (get-buffer val)))
2489 (setq new-format (symbol-value
2490 (intern (format "gnus-%s-line-format" type))))))
2491 (setq entry (cdr (assq type gnus-format-specs)))
2493 (equal (car entry) new-format))
2494 ;; Use the old format.
2495 (set (intern (format "gnus-%s-line-format-spec" type))
2497 ;; This is a new format.
2499 (if (not (stringp new-format))
2500 ;; This is a function call or something.
2502 ;; This is a "real" format.
2506 (intern (format "gnus-%s-line-format-alist"
2507 (if (eq type 'article-mode)
2508 'summary-mode type))))
2509 (not (string-match "mode$" (symbol-name type))))))
2510 ;; Enter the new format spec into the list.
2513 (setcar (cdr entry) val)
2514 (setcar entry new-format))
2515 (push (list type new-format val) gnus-format-specs))
2516 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2518 (push (cons 'version emacs-version) gnus-format-specs)
2520 (gnus-update-group-mark-positions)
2521 (gnus-update-summary-mark-positions))
2523 (defun gnus-update-summary-mark-positions ()
2524 "Compute where the summary marks are to go."
2526 (let ((gnus-replied-mark 129)
2527 (gnus-score-below-mark 130)
2528 (gnus-score-over-mark 130)
2532 (gnus-set-work-buffer)
2533 (gnus-summary-insert-line
2534 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2535 (goto-char (point-min))
2536 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2538 (goto-char (point-min))
2539 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2541 (goto-char (point-min))
2542 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2544 (setq gnus-summary-mark-positions pos))))
2546 (defun gnus-update-group-mark-positions ()
2548 (let ((gnus-process-mark 128)
2549 (gnus-group-marked '("dummy.group")))
2550 (gnus-set-active "dummy.group" '(0 . 0))
2551 (gnus-set-work-buffer)
2552 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2553 (goto-char (point-min))
2554 (setq gnus-group-mark-positions
2555 (list (cons 'process (and (search-forward "\200" nil t)
2556 (- (point) 2))))))))
2558 (defvar gnus-mouse-face-0 'highlight)
2559 (defvar gnus-mouse-face-1 'highlight)
2560 (defvar gnus-mouse-face-2 'highlight)
2561 (defvar gnus-mouse-face-3 'highlight)
2562 (defvar gnus-mouse-face-4 'highlight)
2564 (defun gnus-mouse-face-function (form type)
2566 (point) (progn ,@form (point))
2567 gnus-mouse-face-prop
2570 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2572 (defvar gnus-face-0 'bold)
2573 (defvar gnus-face-1 'italic)
2574 (defvar gnus-face-2 'bold-italic)
2575 (defvar gnus-face-3 'bold)
2576 (defvar gnus-face-4 'bold)
2578 (defun gnus-face-face-function (form type)
2580 (point) (progn ,@form (point))
2581 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2583 (defun gnus-max-width-function (el max-width)
2584 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2586 `(if (> (length ,el) ,max-width)
2587 (substring ,el 0 ,max-width)
2589 `(let ((val (eval ,el)))
2591 (setq val (int-to-string val)))
2592 (if (> (length val) ,max-width)
2593 (substring val 0 ,max-width)
2596 (defun gnus-parse-format (format spec-alist &optional insert)
2597 ;; This function parses the FORMAT string with the help of the
2598 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2599 ;; string. If the FORMAT string contains the specifiers %( and %)
2600 ;; the text between them will have the mouse-face text property.
2602 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2604 (gnus-parse-complex-format format spec-alist)
2605 ;; This is a simple format.
2606 (gnus-parse-simple-format format spec-alist insert)))
2608 (defun gnus-parse-complex-format (format spec-alist)
2610 (gnus-set-work-buffer)
2612 (goto-char (point-min))
2613 (while (re-search-forward "\"" nil t)
2614 (replace-match "\\\"" nil t))
2615 (goto-char (point-min))
2617 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2618 (let ((number (if (match-beginning 1)
2619 (match-string 1) "0"))
2620 (delim (aref (match-string 2) 0)))
2621 (if (or (= delim ?\() (= delim ?\{))
2622 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2624 (replace-match "\")\""))))
2625 (goto-char (point-max))
2627 (goto-char (point-min))
2628 (let ((form (read (current-buffer))))
2629 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2631 (defun gnus-complex-form-to-spec (form spec-alist)
2636 (gnus-parse-simple-format sform spec-alist t)
2637 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2638 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2642 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2643 ;; This function parses the FORMAT string with the help of the
2644 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2647 spec flist fstring newspec elem beg result dontinsert)
2649 (gnus-set-work-buffer)
2651 (goto-char (point-min))
2652 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2654 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2656 beg (1+ (match-beginning 0)))
2657 ;; First check if there are any specs that look anything like
2658 ;; "%12,12A", ie. with a "max width specification". These have
2659 ;; to be treated specially.
2660 (if (setq beg (match-beginning 1))
2664 (1+ (match-beginning 1)) (match-end 1))))
2666 (setq beg (match-beginning 2)))
2667 ;; Find the specification from `spec-alist'.
2668 (unless (setq elem (cdr (assq spec spec-alist)))
2669 (setq elem '("*" ?s)))
2670 ;; Treat user defined format specifiers specially.
2671 (when (eq (car elem) 'gnus-tmp-user-defined)
2674 (list (intern (concat "gnus-user-format-function-"
2676 'gnus-tmp-header) ?s))
2677 (delete-region (match-beginning 3) (match-end 3)))
2678 (if (not (zerop max-width))
2679 (let ((el (car elem)))
2680 (cond ((= (cadr elem) ?c)
2681 (setq el (list 'char-to-string el)))
2683 (setq el (list 'int-to-string el))))
2684 (setq flist (cons (gnus-max-width-function el max-width)
2688 (setq flist (cons (car elem) flist))
2689 (setq newspec (cadr elem)))))
2690 ;; Remove the old specification (and possibly a ",12" string).
2691 (delete-region beg (match-end 2))
2692 ;; Insert the new specification.
2695 (setq fstring (buffer-substring 1 (point-max))))
2696 ;; Do some postprocessing to increase efficiency.
2701 ((string= fstring "")
2703 ;; Not a format string.
2704 ((not (string-match "%" fstring))
2706 ;; A format string with just a single string spec.
2707 ((string= fstring "%s")
2709 ;; A single character.
2710 ((string= fstring "%c")
2713 ((string= fstring "%d")
2716 (list `(princ ,(car flist)))
2717 (list `(int-to-string ,(car flist)))))
2718 ;; Just lots of chars and strings.
2719 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2721 ;; A single string spec at the beginning of the spec.
2722 ((string-match "\\`%[sc][^%]+\\'" fstring)
2723 (list (car flist) (substring fstring 2)))
2724 ;; A single string spec in the middle of the spec.
2725 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2726 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2727 ;; A single string spec in the end of the spec.
2728 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2729 (list (match-string 1 fstring) (car flist)))
2730 ;; A more complex spec.
2732 (list (cons 'format (cons fstring (nreverse flist)))))))
2738 (cons 'insert result)))
2739 (cond ((stringp result)
2742 (cons 'concat result))
2745 (defun gnus-eval-format (format &optional alist props)
2746 "Eval the format variable FORMAT, using ALIST.
2747 If PROPS, insert the result."
2748 (let ((form (gnus-parse-format format alist props)))
2750 (add-text-properties (point) (progn (eval form) (point)) props)
2753 (defun gnus-remove-text-with-property (prop)
2754 "Delete all text in the current buffer with text property PROP."
2756 (goto-char (point-min))
2758 (while (get-text-property (point) prop)
2760 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2762 (defun gnus-set-work-buffer ()
2763 (if (get-buffer gnus-work-buffer)
2765 (set-buffer gnus-work-buffer)
2767 (set-buffer (get-buffer-create gnus-work-buffer))
2768 (kill-all-local-variables)
2769 (buffer-disable-undo (current-buffer))
2770 (gnus-add-current-to-buffer-list)))
2772 ;; Article file names when saving.
2774 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2775 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2776 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2777 Otherwise, it is like ~/News/news/group/num."
2780 (concat (if (gnus-use-long-file-name 'not-save)
2781 (gnus-capitalize-newsgroup newsgroup)
2782 (gnus-newsgroup-directory-form newsgroup))
2783 "/" (int-to-string (mail-header-number headers)))
2784 (or gnus-article-save-directory "~/News"))))
2786 (string-equal (file-name-directory default)
2787 (file-name-directory last-file))
2788 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2790 (or last-file default))))
2792 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2793 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2794 If variable `gnus-use-long-file-name' is non-nil, it is
2795 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2798 (concat (if (gnus-use-long-file-name 'not-save)
2800 (gnus-newsgroup-directory-form newsgroup))
2801 "/" (int-to-string (mail-header-number headers)))
2802 (or gnus-article-save-directory "~/News"))))
2804 (string-equal (file-name-directory default)
2805 (file-name-directory last-file))
2806 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2808 (or last-file default))))
2810 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2811 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2812 If variable `gnus-use-long-file-name' is non-nil, it is
2813 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2816 (if (gnus-use-long-file-name 'not-save)
2817 (gnus-capitalize-newsgroup newsgroup)
2818 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2819 (or gnus-article-save-directory "~/News"))))
2821 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2822 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2823 If variable `gnus-use-long-file-name' is non-nil, it is
2824 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2827 (if (gnus-use-long-file-name 'not-save)
2829 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2830 (or gnus-article-save-directory "~/News"))))
2832 ;; For subscribing new newsgroup
2834 (defun gnus-subscribe-hierarchical-interactive (groups)
2835 (let ((groups (sort groups 'string<))
2836 prefixes prefix start ans group starts)
2838 (setq prefixes (list "^"))
2839 (while (and groups prefixes)
2840 (while (not (string-match (car prefixes) (car groups)))
2841 (setq prefixes (cdr prefixes)))
2842 (setq prefix (car prefixes))
2843 (setq start (1- (length prefix)))
2844 (if (and (string-match "[^\\.]\\." (car groups) start)
2847 (concat "^" (substring (car groups) 0 (match-end 0))))
2848 (string-match prefix (cadr groups)))
2850 (setq prefixes (cons prefix prefixes))
2851 (message "Descend hierarchy %s? ([y]nsq): "
2852 (substring prefix 1 (1- (length prefix))))
2853 (setq ans (read-char))
2856 (string-match prefix
2857 (setq group (car groups))))
2858 (setq gnus-killed-list
2859 (cons group gnus-killed-list))
2860 (gnus-sethash group group gnus-killed-hashtb)
2861 (setq groups (cdr groups)))
2862 (setq starts (cdr starts)))
2865 (string-match prefix
2866 (setq group (car groups))))
2867 (gnus-sethash group group gnus-killed-hashtb)
2868 (gnus-subscribe-alphabetically (car groups))
2869 (setq groups (cdr groups)))
2870 (setq starts (cdr starts)))
2873 (setq group (car groups))
2874 (setq gnus-killed-list (cons group gnus-killed-list))
2875 (gnus-sethash group group gnus-killed-hashtb)
2876 (setq groups (cdr groups))))
2878 (message "Subscribe %s? ([n]yq)" (car groups))
2879 (setq ans (read-char))
2880 (setq group (car groups))
2882 (gnus-subscribe-alphabetically (car groups))
2883 (gnus-sethash group group gnus-killed-hashtb))
2886 (setq group (car groups))
2887 (setq gnus-killed-list (cons group gnus-killed-list))
2888 (gnus-sethash group group gnus-killed-hashtb)
2889 (setq groups (cdr groups))))
2891 (setq gnus-killed-list (cons group gnus-killed-list))
2892 (gnus-sethash group group gnus-killed-hashtb)))
2893 (setq groups (cdr groups)))))))
2895 (defun gnus-subscribe-randomly (newsgroup)
2896 "Subscribe new NEWSGROUP by making it the first newsgroup."
2897 (gnus-subscribe-newsgroup newsgroup))
2899 (defun gnus-subscribe-alphabetically (newgroup)
2900 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2901 (let ((groups (cdr gnus-newsrc-alist))
2903 (while (and (not before) groups)
2904 (if (string< newgroup (caar groups))
2905 (setq before (caar groups))
2906 (setq groups (cdr groups))))
2907 (gnus-subscribe-newsgroup newgroup before)))
2909 (defun gnus-subscribe-hierarchically (newgroup)
2910 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2911 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2913 (set-buffer (find-file-noselect gnus-current-startup-file))
2914 (let ((groupkey newgroup)
2916 (while (and (not before) groupkey)
2917 (goto-char (point-min))
2919 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2920 (while (and (re-search-forward groupkey-re nil t)
2922 (setq before (match-string 1))
2923 (string< before newgroup)))))
2924 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2926 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2927 (substring groupkey (match-beginning 1) (match-end 1)))))
2928 (gnus-subscribe-newsgroup newgroup before))))
2930 (defun gnus-subscribe-interactively (group)
2931 "Subscribe the new GROUP interactively.
2932 It is inserted in hierarchical newsgroup order if subscribed. If not,
2934 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2935 (gnus-subscribe-hierarchically group)
2936 (push group gnus-killed-list)))
2938 (defun gnus-subscribe-zombies (group)
2939 "Make the new GROUP into a zombie group."
2940 (push group gnus-zombie-list))
2942 (defun gnus-subscribe-killed (group)
2943 "Make the new GROUP a killed group."
2944 (push group gnus-killed-list))
2946 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2947 "Subscribe new NEWSGROUP.
2948 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2949 the first newsgroup."
2950 ;; We subscribe the group by changing its level to `subscribed'.
2951 (gnus-group-change-level
2952 newsgroup gnus-level-default-subscribed
2953 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2954 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2958 (defun gnus-newsgroup-directory-form (newsgroup)
2959 "Make hierarchical directory name from NEWSGROUP name."
2960 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2961 (len (length newsgroup))
2963 ;; If this is a foreign group, we don't want to translate the
2965 (if (setq idx (string-match ":" newsgroup))
2966 (aset newsgroup idx ?/)
2968 ;; Replace all occurrences of `.' with `/'.
2970 (if (= (aref newsgroup idx) ?.)
2971 (aset newsgroup idx ?/))
2972 (setq idx (1+ idx)))
2975 (defun gnus-newsgroup-savable-name (group)
2976 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2978 (nnheader-replace-chars-in-string group ?/ ?.))
2980 (defun gnus-make-directory (dir)
2981 "Make DIRECTORY recursively."
2982 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2983 ;; of the many mysteries of the universe.
2984 (let* ((dir (expand-file-name dir default-directory))
2986 (if (string-match "/$" dir)
2987 (setq dir (substring dir 0 (match-beginning 0))))
2988 ;; First go down the path until we find a directory that exists.
2989 (while (not (file-exists-p dir))
2990 (setq dirs (cons dir dirs))
2991 (string-match "/[^/]+$" dir)
2992 (setq dir (substring dir 0 (match-beginning 0))))
2993 ;; Then create all the subdirs.
2994 (while (and dirs (not err))
2996 (make-directory (car dirs))
2997 (error (setq err t)))
2998 (setq dirs (cdr dirs)))
2999 ;; We return whether we were successful or not.
3002 (defun gnus-capitalize-newsgroup (newsgroup)
3003 "Capitalize NEWSGROUP name."
3004 (and (not (zerop (length newsgroup)))
3005 (concat (char-to-string (upcase (aref newsgroup 0)))
3006 (substring newsgroup 1))))
3008 ;; Various... things.
3010 (defun gnus-simplify-subject (subject &optional re-only)
3011 "Remove `Re:' and words in parentheses.
3012 If RE-ONLY is non-nil, strip leading `Re:'s only."
3013 (let ((case-fold-search t)) ;Ignore case.
3014 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3015 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3016 (setq subject (substring subject (match-end 0))))
3017 ;; Remove uninteresting prefixes.
3018 (if (and (not re-only)
3019 gnus-simplify-ignored-prefixes
3020 (string-match gnus-simplify-ignored-prefixes subject))
3021 (setq subject (substring subject (match-end 0))))
3022 ;; Remove words in parentheses from end.
3024 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3025 (setq subject (substring subject 0 (match-beginning 0)))))
3026 ;; Return subject string.
3029 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3031 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3032 (defun gnus-simplify-buffer-fuzzy ()
3033 (goto-char (point-min))
3034 (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*" nil t)
3035 (goto-char (match-beginning 0))
3037 (looking-at "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*")
3038 (looking-at "^[[].*:[ \t].*[]]$"))
3039 (goto-char (point-min))
3040 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
3042 (replace-match "" t t))
3043 (goto-char (point-min))
3044 (while (re-search-forward "^[[].*:[ \t].*[]]$" nil t)
3045 (goto-char (match-end 0))
3048 (progn (goto-char (match-beginning 0)))
3049 (re-search-forward ":"))))
3050 (goto-char (point-min))
3051 (while (re-search-forward "[ \t\n]*[[{(][^()\n]*[]})][ \t]*$" nil t)
3052 (replace-match "" t t))
3053 (goto-char (point-min))
3054 (while (re-search-forward "[ \t]+" nil t)
3055 (replace-match " " t t))
3056 (goto-char (point-min))
3057 (while (re-search-forward "[ \t]+$" nil t)
3058 (replace-match "" t t))
3059 (goto-char (point-min))
3060 (while (re-search-forward "^[ \t]+" nil t)
3061 (replace-match "" t t))
3062 (goto-char (point-min))
3063 (if gnus-simplify-subject-fuzzy-regexp
3064 (if (listp gnus-simplify-subject-fuzzy-regexp)
3065 (let ((list gnus-simplify-subject-fuzzy-regexp))
3067 (goto-char (point-min))
3068 (while (re-search-forward (car list) nil t)
3069 (replace-match "" t t))
3070 (setq list (cdr list))))
3071 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3072 (replace-match "" t t)))))
3074 (defun gnus-simplify-subject-fuzzy (subject)
3075 "Siplify a subject string fuzzily."
3077 (gnus-set-work-buffer)
3078 (let ((case-fold-search t))
3080 (inline (gnus-simplify-buffer-fuzzy))
3083 ;; Add the current buffer to the list of buffers to be killed on exit.
3084 (defun gnus-add-current-to-buffer-list ()
3085 (or (memq (current-buffer) gnus-buffer-list)
3086 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3088 (defun gnus-string> (s1 s2)
3089 (not (or (string< s1 s2)
3092 ;;; General various misc type functions.
3094 (defun gnus-clear-system ()
3095 "Clear all variables and buffers."
3096 ;; Clear Gnus variables.
3097 (let ((variables gnus-variable-list))
3099 (set (car variables) nil)
3100 (setq variables (cdr variables))))
3101 ;; Clear other internal variables.
3102 (setq gnus-list-of-killed-groups nil
3103 gnus-have-read-active-file nil
3104 gnus-newsrc-alist nil
3105 gnus-newsrc-hashtb nil
3106 gnus-killed-list nil
3107 gnus-zombie-list nil
3108 gnus-killed-hashtb nil
3109 gnus-active-hashtb nil
3110 gnus-moderated-list nil
3111 gnus-description-hashtb nil
3112 gnus-current-headers nil
3113 gnus-thread-indent-array nil
3114 gnus-newsgroup-headers nil
3115 gnus-newsgroup-name nil
3116 gnus-server-alist nil
3117 gnus-group-list-mode nil
3118 gnus-opened-servers nil
3119 gnus-current-select-method nil)
3120 (gnus-shutdown 'gnus)
3121 ;; Kill the startup file.
3122 (and gnus-current-startup-file
3123 (get-file-buffer gnus-current-startup-file)
3124 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3125 ;; Clear the dribble buffer.
3126 (gnus-dribble-clear)
3127 ;; Kill global KILL file buffer.
3128 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3129 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3130 (gnus-kill-buffer nntp-server-buffer)
3131 ;; Kill Gnus buffers.
3132 (while gnus-buffer-list
3133 (gnus-kill-buffer (pop gnus-buffer-list)))
3134 ;; Remove Gnus frames.
3135 (while gnus-created-frames
3136 (when (frame-live-p (car gnus-created-frames))
3137 ;; We slap a condition-case around this `delete-frame' to ensure
3138 ;; agains errors if we try do delete the single frame that's left.
3140 (delete-frame (car gnus-created-frames))
3142 (pop gnus-created-frames)))
3144 (defun gnus-windows-old-to-new (setting)
3145 ;; First we take care of the really, really old Gnus 3 actions.
3146 (when (symbolp setting)
3148 ;; Take care of ooold GNUS 3.x values.
3149 (cond ((eq setting 'SelectArticle) 'article)
3150 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3151 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3153 (if (or (listp setting)
3154 (not (and gnus-window-configuration
3155 (memq setting '(group summary article)))))
3157 (let* ((setting (if (eq setting 'group)
3158 (if (assq 'newsgroup gnus-window-configuration)
3160 'newsgroups) setting))
3161 (elem (cadr (assq setting gnus-window-configuration)))
3162 (total (apply '+ elem))
3163 (types '(group summary article))
3164 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3169 (or (not (numberp (nth i elem)))
3170 (zerop (nth i elem))
3172 (setq perc (/ (float (nth 0 elem)) total))
3173 (setq out (cons (if (eq pbuf (nth i types))
3174 (vector (nth i types) perc 'point)
3175 (vector (nth i types) perc))
3178 (list (nreverse out)))))
3181 (defun gnus-add-configuration (conf)
3182 "Add the window configuration CONF to `gnus-buffer-configuration'."
3183 (setq gnus-buffer-configuration
3184 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3185 gnus-buffer-configuration))))
3187 (defvar gnus-frame-list nil)
3189 (defun gnus-configure-frame (split &optional window)
3190 "Split WINDOW according to SPLIT."
3192 (setq window (get-buffer-window (current-buffer))))
3193 (select-window window)
3194 ;; This might be an old-stylee buffer config.
3195 (when (vectorp split)
3196 (setq split (append split nil)))
3197 (when (or (consp (car split))
3198 (vectorp (car split)))
3200 (push 'vertical split))
3201 ;; The SPLIT might be something that is to be evaled to
3202 ;; return a new SPLIT.
3203 (while (and (not (assq (car split) gnus-window-to-buffer))
3204 (gnus-functionp (car split)))
3205 (setq split (eval split)))
3206 (let* ((type (car split))
3208 (len (if (eq type 'horizontal) (window-width) (window-height)))
3210 (window-min-width (or gnus-window-min-width window-min-width))
3211 (window-min-height (or gnus-window-min-height window-min-height))
3212 s result new-win rest comp-subs size sub)
3214 ;; Nothing to do here.
3216 ;; Don't switch buffers.
3218 (and (memq 'point split) window))
3219 ;; This is a buffer to be selected.
3220 ((not (memq type '(frame horizontal vertical)))
3221 (let ((buffer (cond ((stringp type) type)
3222 (t (cdr (assq type gnus-window-to-buffer)))))
3225 (error "Illegal buffer type: %s" type))
3226 (unless (setq buf (get-buffer (if (symbolp buffer)
3227 (symbol-value buffer) buffer)))
3228 (setq buf (get-buffer-create (if (symbolp buffer)
3229 (symbol-value buffer) buffer))))
3230 (switch-to-buffer buf)
3231 ;; We return the window if it has the `point' spec.
3232 (and (memq 'point split) window)))
3233 ;; This is a frame split.
3235 (unless gnus-frame-list
3236 (setq gnus-frame-list (list (window-frame
3237 (get-buffer-window (current-buffer))))))
3239 params frame fresult)
3240 (while (< i (length subs))
3241 ;; Frame parameter is gotten from the sub-split.
3242 (setq params (cadr (elt subs i)))
3243 ;; It should be a list.
3244 (unless (listp params)
3246 ;; Create a new frame?
3247 (unless (setq frame (elt gnus-frame-list i))
3248 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3249 (push frame gnus-created-frames))
3250 ;; Is the old frame still alive?
3251 (unless (frame-live-p frame)
3252 (setcar (nthcdr i gnus-frame-list)
3253 (setq frame (make-frame params))))
3254 ;; Select the frame in question and do more splits there.
3255 (select-frame frame)
3256 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3258 ;; Select the frame that has the selected buffer.
3260 (select-frame (window-frame fresult)))))
3261 ;; This is a normal split.
3263 (when (> (length subs) 0)
3264 ;; First we have to compute the sizes of all new windows.
3266 (setq sub (append (pop subs) nil))
3267 (while (and (not (assq (car sub) gnus-window-to-buffer))
3268 (gnus-functionp (car sub)))
3269 (setq sub (eval sub)))
3271 (push sub comp-subs)
3272 (setq size (cadar comp-subs))
3273 (cond ((equal size 1.0)
3274 (setq rest (car comp-subs))
3277 (setq s (floor (* size len))))
3281 (error "Illegal size: %s" size)))
3282 ;; Try to make sure that we are inside the safe limits.
3284 ((eq type 'horizontal)
3285 (setq s (max s window-min-width)))
3286 ((eq type 'vertical)
3287 (setq s (max s window-min-height))))
3288 (setcar (cdar comp-subs) s)
3290 ;; Take care of the "1.0" spec.
3292 (setcar (cdr rest) (- len total))
3293 (error "No 1.0 specs in %s" split))
3294 ;; The we do the actual splitting in a nice recursive
3296 (setq comp-subs (nreverse comp-subs))
3298 (if (null (cdr comp-subs))
3299 (setq new-win window)
3301 (split-window window (cadar comp-subs)
3302 (eq type 'horizontal))))
3303 (setq result (or (gnus-configure-frame
3304 (car comp-subs) window) result))
3305 (select-window new-win)
3306 (setq window new-win)
3307 (setq comp-subs (cdr comp-subs))))
3308 ;; Return the proper window, if any.
3310 (select-window result))))))
3312 (defvar gnus-frame-split-p nil)
3314 (defun gnus-configure-windows (setting &optional force)
3315 (setq setting (gnus-windows-old-to-new setting))
3316 (let ((split (if (symbolp setting)
3317 (cadr (assq setting gnus-buffer-configuration))
3321 (setq gnus-frame-split-p nil)
3324 (error "No such setting: %s" setting))
3326 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3328 ;; All the windows mentioned are already visible, so we just
3329 ;; put point in the assigned buffer, and do not touch the
3331 (select-window all-visible)
3333 ;; Either remove all windows or just remove all Gnus windows.
3334 (let ((frame (selected-frame)))
3336 (if gnus-use-full-window
3337 ;; We want to remove all other windows.
3338 (if (not gnus-frame-split-p)
3339 ;; This is not a `frame' split, so we ignore the
3341 (delete-other-windows)
3342 ;; This is a `frame' split, so we delete all windows
3346 (unless (eq (cdr (assq 'minibuffer
3347 (frame-parameters frame)))
3349 (select-frame frame)
3350 (delete-other-windows)))
3352 ;; Just remove some windows.
3353 (gnus-remove-some-windows)
3354 (switch-to-buffer nntp-server-buffer))
3355 (select-frame frame)))
3357 (switch-to-buffer nntp-server-buffer)
3358 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3360 (defun gnus-all-windows-visible-p (split)
3361 "Say whether all buffers in SPLIT are currently visible.
3362 In particular, the value returned will be the window that
3364 (let ((stack (list split))
3366 type buffer win buf)
3367 (while (and (setq split (pop stack))
3369 ;; Be backwards compatible.
3370 (when (vectorp split)
3371 (setq split (append split nil)))
3372 (when (or (consp (car split))
3373 (vectorp (car split)))
3375 (push 'vertical split))
3376 ;; The SPLIT might be something that is to be evaled to
3377 ;; return a new SPLIT.
3378 (while (and (not (assq (car split) gnus-window-to-buffer))
3379 (gnus-functionp (car split)))
3380 (setq split (eval split)))
3382 (setq type (elt split 0))
3387 ((not (memq type '(horizontal vertical frame)))
3388 (setq buffer (cond ((stringp type) type)
3389 (t (cdr (assq type gnus-window-to-buffer)))))
3391 (error "Illegal buffer type: %s" type))
3392 (when (setq buf (get-buffer (if (symbolp buffer)
3393 (symbol-value buffer)
3395 (setq win (get-buffer-window buf t)))
3397 (when (memq 'point split)
3398 (setq all-visible win))
3399 (setq all-visible nil)))
3401 (when (eq type 'frame)
3402 (setq gnus-frame-split-p t))
3403 (setq stack (append (cddr split) stack)))))
3404 (unless (eq all-visible t)
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.
3433 (let ((buf (window-buffer win)))
3434 (if (string-match "^\\*Summary" (buffer-name buf))
3436 (setq bufs (cons buf bufs))
3438 (if (or (not lowest)
3439 (< (gnus-window-top-edge) lowest))
3441 (setq lowest-buf buf)
3442 (setq lowest (gnus-window-top-edge)))))))))
3445 (pop-to-buffer lowest-buf)
3446 (switch-to-buffer nntp-server-buffer)))
3448 (and (not (eq (car bufs) lowest-buf))
3449 (delete-windows-on (car bufs)))
3450 (setq bufs (cdr bufs))))))
3452 (defun gnus-version ()
3453 "Version numbers of this version of Gnus."
3455 (let ((methods gnus-valid-select-methods)
3458 ;; Go through all the legal select methods and add their version
3459 ;; numbers to the total version string. Only the backends that are
3460 ;; currently in use will have their message numbers taken into
3463 (setq meth (intern (concat (caar methods) "-version")))
3465 (stringp (symbol-value meth))
3466 (setq mess (concat mess "; " (symbol-value meth))))
3467 (setq methods (cdr methods)))
3468 (gnus-message 2 mess)))
3470 (defun gnus-info-find-node ()
3471 "Find Info documentation of Gnus."
3473 ;; Enlarge info window if needed.
3474 (let ((mode major-mode)
3476 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3477 (setq gnus-info-buffer (current-buffer))
3478 (gnus-configure-windows 'info)))
3480 (defun gnus-days-between (date1 date2)
3481 ;; Return the number of days between date1 and date2.
3482 (- (gnus-day-number date1) (gnus-day-number date2)))
3484 (defun gnus-day-number (date)
3485 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3486 (timezone-parse-date date))))
3487 (timezone-absolute-from-gregorian
3488 (nth 1 dat) (nth 2 dat) (car dat))))
3490 (defun gnus-encode-date (date)
3491 "Convert DATE to internal time."
3492 (let* ((parse (timezone-parse-date date))
3493 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3494 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3495 (encode-time (caddr time) (cadr time) (car time)
3496 (caddr date) (cadr date) (car date) (nth 4 date))))
3498 (defun gnus-time-minus (t1 t2)
3499 "Subtract two internal times."
3500 (let ((borrow (< (cadr t1) (cadr t2))))
3501 (list (- (car t1) (car t2) (if borrow 1 0))
3502 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3504 (defun gnus-file-newer-than (file date)
3505 (let ((fdate (nth 5 (file-attributes file))))
3506 (or (> (car fdate) (car date))
3507 (and (= (car fdate) (car date))
3508 (> (nth 1 fdate) (nth 1 date))))))
3510 (defmacro gnus-local-set-keys (&rest plist)
3511 "Set the keys in PLIST in the current keymap."
3512 `(gnus-define-keys-1 (current-local-map) ',plist))
3514 (defmacro gnus-define-keys (keymap &rest plist)
3515 "Define all keys in PLIST in KEYMAP."
3516 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3518 (put 'gnus-define-keys 'lisp-indent-function 1)
3519 (put 'gnus-define-keys 'lisp-indent-hook 1)
3520 (put 'gnus-define-keymap 'lisp-indent-function 1)
3521 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3523 (defmacro gnus-define-keymap (keymap &rest plist)
3524 "Define all keys in PLIST in KEYMAP."
3525 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3527 (defun gnus-define-keys-1 (keymap plist)
3529 (error "Can't set keys in a null keymap"))
3530 (cond ((symbolp keymap)
3531 (setq keymap (symbol-value keymap)))
3534 (set (car keymap) nil)
3535 (define-prefix-command (car keymap))
3536 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3537 (setq keymap (symbol-value (car keymap)))))
3540 (when (symbolp (setq key (pop plist)))
3541 (setq key (symbol-value key)))
3542 (define-key keymap key (pop plist)))))
3544 (defun gnus-group-read-only-p (&optional group)
3545 "Check whether GROUP supports editing or not.
3546 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3547 that that variable is buffer-local to the summary buffers."
3548 (let ((group (or group gnus-newsgroup-name)))
3549 (not (gnus-check-backend-function 'request-replace-article group))))
3551 (defun gnus-group-total-expirable-p (group)
3552 "Check whether GROUP is total-expirable or not."
3553 (let ((params (gnus-info-params (gnus-get-info group))))
3554 (or (memq 'total-expire params)
3555 (cdr (assq 'total-expire params)) ; (total-expire . t)
3556 (and gnus-total-expirable-newsgroups ; Check var.
3557 (string-match gnus-total-expirable-newsgroups group)))))
3559 (defun gnus-group-auto-expirable-p (group)
3560 "Check whether GROUP is total-expirable or not."
3561 (let ((params (gnus-info-params (gnus-get-info group))))
3562 (or (memq 'auto-expire params)
3563 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3564 (and gnus-auto-expirable-newsgroups ; Check var.
3565 (string-match gnus-auto-expirable-newsgroups group)))))
3567 (defun gnus-virtual-group-p (group)
3568 "Say whether GROUP is virtual or not."
3569 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3570 gnus-valid-select-methods)))
3572 (defsubst gnus-simplify-subject-fully (subject)
3573 "Simplify a subject string according to the user's wishes."
3575 ((null gnus-summary-gather-subject-limit)
3576 (gnus-simplify-subject-re subject))
3577 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3578 (gnus-simplify-subject-fuzzy subject))
3579 ((numberp gnus-summary-gather-subject-limit)
3580 (gnus-limit-string (gnus-simplify-subject-re subject)
3581 gnus-summary-gather-subject-limit))
3585 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3586 "Check whether two subjects are equal. If optional argument
3587 simple-first is t, first argument is already simplified."
3589 ((null simple-first)
3590 (equal (gnus-simplify-subject-fully s1)
3591 (gnus-simplify-subject-fully s2)))
3594 (gnus-simplify-subject-fully s2)))))
3596 ;; Returns a list of writable groups.
3597 (defun gnus-writable-groups ()
3598 (let ((alist gnus-newsrc-alist)
3600 (while (setq group (car (pop alist)))
3601 (unless (gnus-group-read-only-p group)
3602 (push group groups)))
3605 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3607 (defun gnus-y-or-n-p (prompt)
3612 (defun gnus-yes-or-no-p (prompt)
3614 (yes-or-no-p prompt)
3617 ;; Check whether to use long file names.
3618 (defun gnus-use-long-file-name (symbol)
3619 ;; The variable has to be set...
3620 (and gnus-use-long-file-name
3621 ;; If it isn't a list, then we return t.
3622 (or (not (listp gnus-use-long-file-name))
3623 ;; If it is a list, and the list contains `symbol', we
3625 (not (memq symbol gnus-use-long-file-name)))))
3627 ;; I suspect there's a better way, but I haven't taken the time to do
3628 ;; it yet. -erik selberg@cs.washington.edu
3629 (defun gnus-dd-mmm (messy-date)
3630 "Return a string like DD-MMM from a big messy string"
3631 (let ((datevec (timezone-parse-date messy-date)))
3634 ;; Make sure leading zeroes are stripped.
3635 (number-to-string (string-to-number (aref datevec 2)))
3639 (nth (1- (string-to-number (aref datevec 1)))
3640 timezone-months-assoc))
3643 ;; Make a hash table (default and minimum size is 255).
3644 ;; Optional argument HASHSIZE specifies the table size.
3645 (defun gnus-make-hashtable (&optional hashsize)
3646 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3648 ;; Make a number that is suitable for hashing; bigger than MIN and one
3650 (defun gnus-create-hash-size (min)
3656 ;; Show message if message has a lower level than `gnus-verbose'.
3657 ;; Guideline for numbers:
3658 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3659 ;; for things that take a long time, 7 - not very important messages
3660 ;; on stuff, 9 - messages inside loops.
3661 (defun gnus-message (level &rest args)
3662 (if (<= level gnus-verbose)
3663 (apply 'message args)
3664 ;; We have to do this format thingy here even if the result isn't
3665 ;; shown - the return value has to be the same as the return value
3667 (apply 'format args)))
3669 ;; Generate a unique new group name.
3670 (defun gnus-generate-new-group-name (leaf)
3673 (while (gnus-gethash name gnus-newsrc-hashtb)
3674 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3677 (defsubst gnus-hide-text (b e props)
3678 "Set text PROPS on the B to E region, extending `intangble' 1 past B."
3679 (add-text-properties b e props)
3680 (when (memq 'intangible props)
3681 (put-text-property (1- b) b 'intangible (cddr (memq 'intangible props)))))
3683 (defsubst gnus-unhide-text (b e)
3684 "Remove hidden text properties from region between B and E."
3685 (remove-text-properties b e gnus-hidden-properties)
3686 (when (memq 'intangible gnus-hidden-properties)
3687 (put-text-property (1- b) b 'intangible nil)))
3689 (defun gnus-hide-text-type (b e type)
3690 "Hide text of TYPE between B and E."
3691 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3693 ;; Find out whether the gnus-visual TYPE is wanted.
3694 (defun gnus-visual-p (&optional type class)
3695 (and gnus-visual ; Has to be non-nil, at least.
3696 (if (not type) ; We don't care about type.
3698 (if (listp gnus-visual) ; It's a list, so we check it.
3699 (or (memq type gnus-visual)
3700 (memq class gnus-visual))
3703 (defun gnus-parent-id (references)
3704 "Return the last Message-ID in REFERENCES."
3705 (when (and references
3706 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3707 (substring references (match-beginning 1) (match-end 1))))
3709 (defun gnus-split-references (references)
3710 "Return a list of Message-IDs in REFERENCES."
3713 (while (string-match "<[^>]+>" references beg)
3714 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3718 (defun gnus-ephemeral-group-p (group)
3719 "Say whether GROUP is ephemeral or not."
3720 (gnus-group-get-parameter group 'quit-config))
3722 (defun gnus-group-quit-config (group)
3723 "Return the quit-config of GROUP."
3724 (gnus-group-get-parameter group 'quit-config))
3726 (defun gnus-simplify-mode-line ()
3727 "Make mode lines a bit simpler."
3728 (setq mode-line-modified "-- ")
3729 (when (listp mode-line-format)
3730 (make-local-variable 'mode-line-format)
3731 (setq mode-line-format (copy-sequence mode-line-format))
3732 (when (equal (nth 3 mode-line-format) " ")
3733 (setcar (nthcdr 3 mode-line-format) " "))))
3735 ;;; List and range functions
3737 (defun gnus-last-element (list)
3738 "Return last element of LIST."
3740 (setq list (cdr list)))
3743 (defun gnus-copy-sequence (list)
3744 "Do a complete, total copy of a list."
3745 (if (and (consp list) (not (consp (cdr list))))
3746 (cons (car list) (cdr list))
3747 (mapcar (lambda (elem) (if (consp elem)
3748 (if (consp (cdr elem))
3749 (gnus-copy-sequence elem)
3750 (cons (car elem) (cdr elem)))
3754 (defun gnus-set-difference (list1 list2)
3755 "Return a list of elements of LIST1 that do not appear in LIST2."
3756 (let ((list1 (copy-sequence list1)))
3758 (setq list1 (delq (car list2) list1))
3759 (setq list2 (cdr list2)))
3762 (defun gnus-sorted-complement (list1 list2)
3763 "Return a list of elements of LIST1 that do not appear in LIST2.
3764 Both lists have to be sorted over <."
3766 (if (or (null list1) (null list2))
3768 (while (and list1 list2)
3769 (cond ((= (car list1) (car list2))
3770 (setq list1 (cdr list1)
3772 ((< (car list1) (car list2))
3773 (setq out (cons (car list1) out))
3774 (setq list1 (cdr list1)))
3776 (setq out (cons (car list2) out))
3777 (setq list2 (cdr list2)))))
3778 (nconc (nreverse out) (or list1 list2)))))
3780 (defun gnus-intersection (list1 list2)
3783 (if (memq (car list2) list1)
3784 (setq result (cons (car list2) result)))
3785 (setq list2 (cdr list2)))
3788 (defun gnus-sorted-intersection (list1 list2)
3789 ;; LIST1 and LIST2 have to be sorted over <.
3791 (while (and list1 list2)
3792 (cond ((= (car list1) (car list2))
3793 (setq out (cons (car list1) out)
3796 ((< (car list1) (car list2))
3797 (setq list1 (cdr list1)))
3799 (setq list2 (cdr list2)))))
3802 (defun gnus-set-sorted-intersection (list1 list2)
3803 ;; LIST1 and LIST2 have to be sorted over <.
3804 ;; This function modifies LIST1.
3805 (let* ((top (cons nil list1))
3807 (while (and list1 list2)
3808 (cond ((= (car list1) (car list2))
3812 ((< (car list1) (car list2))
3813 (setcdr prev (cdr list1))
3814 (setq list1 (cdr list1)))
3816 (setq list2 (cdr list2)))))
3820 (defun gnus-compress-sequence (numbers &optional always-list)
3821 "Convert list of numbers to a list of ranges or a single range.
3822 If ALWAYS-LIST is non-nil, this function will always release a list of
3824 (let* ((first (car numbers))
3825 (last (car numbers))
3829 (if (not (listp (cdr numbers)))
3832 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3833 ((= (1+ last) (car numbers)) ;Still in sequence
3834 (setq last (car numbers)))
3835 (t ;End of one sequence
3837 (cons (if (= first last) first
3838 (cons first last)) result))
3839 (setq first (car numbers))
3840 (setq last (car numbers))))
3841 (setq numbers (cdr numbers)))
3842 (if (and (not always-list) (null result))
3843 (if (= first last) (list first) (cons first last))
3844 (nreverse (cons (if (= first last) first (cons first last))
3847 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3848 (defun gnus-uncompress-range (ranges)
3849 "Expand a list of ranges into a list of numbers.
3850 RANGES is either a single range on the form `(num . num)' or a list of
3852 (let (first last result)
3856 ((not (listp (cdr ranges)))
3857 (setq first (car ranges))
3858 (setq last (cdr ranges))
3859 (while (<= first last)
3860 (setq result (cons first result))
3861 (setq first (1+ first)))
3865 (if (atom (car ranges))
3866 (if (numberp (car ranges))
3867 (setq result (cons (car ranges) result)))
3868 (setq first (caar ranges))
3869 (setq last (cdar ranges))
3870 (while (<= first last)
3871 (setq result (cons first result))
3872 (setq first (1+ first))))
3873 (setq ranges (cdr ranges)))
3874 (nreverse result)))))
3876 (defun gnus-add-to-range (ranges list)
3877 "Return a list of ranges that has all articles from both RANGES and LIST.
3878 Note: LIST has to be sorted over `<'."
3880 (gnus-compress-sequence list t)
3881 (setq list (copy-sequence list))
3882 (or (listp (cdr ranges))
3883 (setq ranges (list ranges)))
3885 ilist lowest highest temp)
3886 (while (and ranges list)
3888 (setq lowest (or (and (atom (car ranges)) (car ranges))
3890 (while (and list (cdr list) (< (cadr list) lowest))
3891 (setq list (cdr list)))
3892 (if (< (car ilist) lowest)
3895 (setq list (cdr list))
3897 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3898 (setq highest (or (and (atom (car ranges)) (car ranges))
3900 (while (and list (<= (car list) highest))
3901 (setq list (cdr list)))
3902 (setq ranges (cdr ranges)))
3904 (setq out (nconc (gnus-compress-sequence list t) out)))
3905 (setq out (sort out (lambda (r1 r2)
3906 (< (or (and (atom r1) r1) (car r1))
3907 (or (and (atom r2) r2) (car r2))))))
3910 (if (atom (car ranges))
3912 (if (atom (cadr ranges))
3913 (if (= (1+ (car ranges)) (cadr ranges))
3915 (setcar ranges (cons (car ranges)
3917 (setcdr ranges (cddr ranges))))
3918 (if (= (1+ (car ranges)) (caadr ranges))
3920 (setcar (cadr ranges) (car ranges))
3921 (setcar ranges (cadr ranges))
3922 (setcdr ranges (cddr ranges))))))
3924 (if (atom (cadr ranges))
3925 (if (= (1+ (cdar ranges)) (cadr ranges))
3927 (setcdr (car ranges) (cadr ranges))
3928 (setcdr ranges (cddr ranges))))
3929 (if (= (1+ (cdar ranges)) (caadr ranges))
3931 (setcdr (car ranges) (cdadr ranges))
3932 (setcdr ranges (cddr ranges)))))))
3933 (setq ranges (cdr ranges)))
3936 (defun gnus-remove-from-range (ranges list)
3937 "Return a list of ranges that has all articles from LIST removed from RANGES.
3938 Note: LIST has to be sorted over `<'."
3939 ;; !!! This function shouldn't look like this, but I've got a headache.
3940 (gnus-compress-sequence
3941 (gnus-sorted-complement
3942 (gnus-uncompress-range ranges) list)))
3944 (defun gnus-member-of-range (number ranges)
3945 (if (not (listp (cdr ranges)))
3946 (and (>= number (car ranges))
3947 (<= number (cdr ranges)))
3950 (if (numberp (car ranges))
3951 (>= number (car ranges))
3952 (>= number (caar ranges)))
3954 (if (if (numberp (car ranges))
3955 (= number (car ranges))
3956 (and (>= number (caar ranges))
3957 (<= number (cdar ranges))))
3958 (setq not-stop nil))
3959 (setq ranges (cdr ranges)))
3962 (defun gnus-range-length (range)
3963 "Return the length RANGE would have if uncompressed."
3964 (length (gnus-uncompress-range range)))
3966 (defun gnus-sublist-p (list sublist)
3967 "Test whether all elements in SUBLIST are members of LIST."
3970 (unless (memq (pop sublist) list)
3980 (defvar gnus-group-mode-map nil)
3981 (put 'gnus-group-mode 'mode-class 'special)
3983 (unless gnus-group-mode-map
3984 (setq gnus-group-mode-map (make-keymap))
3985 (suppress-keymap gnus-group-mode-map)
3987 (gnus-define-keys gnus-group-mode-map
3988 " " gnus-group-read-group
3989 "=" gnus-group-select-group
3990 "\r" gnus-group-select-group
3991 "\M-\r" gnus-group-quick-select-group
3992 "j" gnus-group-jump-to-group
3993 "n" gnus-group-next-unread-group
3994 "p" gnus-group-prev-unread-group
3995 "\177" gnus-group-prev-unread-group
3996 [delete] gnus-group-prev-unread-group
3997 "N" gnus-group-next-group
3998 "P" gnus-group-prev-group
3999 "\M-n" gnus-group-next-unread-group-same-level
4000 "\M-p" gnus-group-prev-unread-group-same-level
4001 "," gnus-group-best-unread-group
4002 "." gnus-group-first-unread-group
4003 "u" gnus-group-unsubscribe-current-group
4004 "U" gnus-group-unsubscribe-group
4005 "c" gnus-group-catchup-current
4006 "C" gnus-group-catchup-current-all
4007 "l" gnus-group-list-groups
4008 "L" gnus-group-list-all-groups
4010 "g" gnus-group-get-new-news
4011 "\M-g" gnus-group-get-new-news-this-group
4012 "R" gnus-group-restart
4013 "r" gnus-group-read-init-file
4014 "B" gnus-group-browse-foreign-server
4015 "b" gnus-group-check-bogus-groups
4016 "F" gnus-find-new-newsgroups
4017 "\C-c\C-d" gnus-group-describe-group
4018 "\M-d" gnus-group-describe-all-groups
4019 "\C-c\C-a" gnus-group-apropos
4020 "\C-c\M-\C-a" gnus-group-description-apropos
4021 "a" gnus-group-post-news
4022 "\ek" gnus-group-edit-local-kill
4023 "\eK" gnus-group-edit-global-kill
4024 "\C-k" gnus-group-kill-group
4025 "\C-y" gnus-group-yank-group
4026 "\C-w" gnus-group-kill-region
4027 "\C-x\C-t" gnus-group-transpose-groups
4028 "\C-c\C-l" gnus-group-list-killed
4029 "\C-c\C-x" gnus-group-expire-articles
4030 "\C-c\M-\C-x" gnus-group-expire-all-groups
4032 "s" gnus-group-save-newsrc
4033 "z" gnus-group-suspend
4034 "Z" gnus-group-clear-dribble
4037 "?" gnus-group-describe-briefly
4038 "\C-c\C-i" gnus-info-find-node
4039 "\M-e" gnus-group-edit-group-method
4040 "^" gnus-group-enter-server-mode
4041 gnus-mouse-2 gnus-mouse-pick-group
4042 "<" beginning-of-buffer
4045 "\C-c\C-s" gnus-group-sort-groups
4047 "\C-c\M-g" gnus-activate-all-groups
4048 "\M-&" gnus-group-universal-argument
4049 "#" gnus-group-mark-group
4050 "\M-#" gnus-group-unmark-group)
4052 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4053 "m" gnus-group-mark-group
4054 "u" gnus-group-unmark-group
4055 "w" gnus-group-mark-region
4056 "m" gnus-group-mark-buffer
4057 "r" gnus-group-mark-regexp
4058 "U" gnus-group-unmark-all-groups)
4060 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4061 "d" gnus-group-make-directory-group
4062 "h" gnus-group-make-help-group
4063 "a" gnus-group-make-archive-group
4064 "k" gnus-group-make-kiboze-group
4065 "m" gnus-group-make-group
4066 "E" gnus-group-edit-group
4067 "e" gnus-group-edit-group-method
4068 "p" gnus-group-edit-group-parameters
4069 "v" gnus-group-add-to-virtual
4070 "V" gnus-group-make-empty-virtual
4071 "D" gnus-group-enter-directory
4072 "f" gnus-group-make-doc-group
4073 "r" gnus-group-rename-group
4074 "\177" gnus-group-delete-group
4075 [delete] gnus-group-delete-group)
4077 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4078 "b" gnus-group-brew-soup
4079 "w" gnus-soup-save-areas
4080 "s" gnus-soup-send-replies
4081 "p" gnus-soup-pack-packet
4082 "r" nnsoup-pack-replies)
4084 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4085 "s" gnus-group-sort-groups
4086 "a" gnus-group-sort-groups-by-alphabet
4087 "u" gnus-group-sort-groups-by-unread
4088 "l" gnus-group-sort-groups-by-level
4089 "v" gnus-group-sort-groups-by-score
4090 "r" gnus-group-sort-groups-by-rank
4091 "m" gnus-group-sort-groups-by-method)
4093 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4094 "k" gnus-group-list-killed
4095 "z" gnus-group-list-zombies
4096 "s" gnus-group-list-groups
4097 "u" gnus-group-list-all-groups
4098 "A" gnus-group-list-active
4099 "a" gnus-group-apropos
4100 "d" gnus-group-description-apropos
4101 "m" gnus-group-list-matching
4102 "M" gnus-group-list-all-matching
4103 "l" gnus-group-list-level)
4105 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4106 "f" gnus-score-flush-cache)
4108 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4109 "f" gnus-group-fetch-faq)
4111 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4112 "l" gnus-group-set-current-level
4113 "t" gnus-group-unsubscribe-current-group
4114 "s" gnus-group-unsubscribe-group
4115 "k" gnus-group-kill-group
4116 "y" gnus-group-yank-group
4117 "w" gnus-group-kill-region
4118 "\C-k" gnus-group-kill-level
4119 "z" gnus-group-kill-all-zombies))
4121 (defun gnus-group-mode ()
4122 "Major mode for reading news.
4124 All normal editing commands are switched off.
4125 \\<gnus-group-mode-map>
4126 The group buffer lists (some of) the groups available. For instance,
4127 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4128 lists all zombie groups.
4130 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4131 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4133 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4135 The following commands are available:
4137 \\{gnus-group-mode-map}"
4139 (when (and menu-bar-mode
4140 (gnus-visual-p 'group-menu 'menu))
4141 (gnus-group-make-menu-bar))
4142 (kill-all-local-variables)
4143 (gnus-simplify-mode-line)
4144 (setq major-mode 'gnus-group-mode)
4145 (setq mode-name "Group")
4146 (gnus-group-set-mode-line)
4147 (setq mode-line-process nil)
4148 (use-local-map gnus-group-mode-map)
4149 (buffer-disable-undo (current-buffer))
4150 (setq truncate-lines t)
4151 (setq buffer-read-only t)
4152 (run-hooks 'gnus-group-mode-hook))
4154 (defun gnus-mouse-pick-group (e)
4155 "Enter the group under the mouse pointer."
4158 (gnus-group-read-group nil))
4160 ;; Look at LEVEL and find out what the level is really supposed to be.
4161 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4162 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4163 (defun gnus-group-default-level (&optional level number-or-nil)
4165 (gnus-group-use-permanent-levels
4166 (setq gnus-group-default-list-level
4167 (or level gnus-group-default-list-level))
4168 (or gnus-group-default-list-level gnus-level-subscribed))
4172 (or level gnus-group-default-list-level gnus-level-subscribed))))
4175 (defun gnus-slave-no-server (&optional arg)
4176 "Read network news as a slave, without connecting to local server"
4178 (gnus-no-server arg t))
4181 (defun gnus-no-server (&optional arg slave)
4183 If ARG is a positive number, Gnus will use that as the
4184 startup level. If ARG is nil, Gnus will be started at level 2.
4185 If ARG is non-nil and not a positive number, Gnus will
4186 prompt the user for the name of an NNTP server to use.
4187 As opposed to `gnus', this command will not connect to the local server."
4189 (let ((gnus-group-use-permanent-levels t))
4190 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4191 (make-local-variable 'gnus-group-use-permanent-levels)
4192 (setq gnus-group-use-permanent-levels t))
4195 (defun gnus-slave (&optional arg)
4196 "Read news as a slave."
4198 (gnus arg nil 'slave))
4201 (defun gnus-other-frame (&optional arg)
4202 "Pop up a frame to read news."
4204 (if (get-buffer gnus-group-buffer)
4205 (let ((pop-up-frames t))
4207 (select-frame (make-frame))
4211 (defun gnus (&optional arg dont-connect slave)
4213 If ARG is non-nil and a positive number, Gnus will use that as the
4214 startup level. If ARG is non-nil and not a positive number, Gnus will
4215 prompt the user for the name of an NNTP server to use."
4218 (if (get-buffer gnus-group-buffer)
4220 (switch-to-buffer gnus-group-buffer)
4221 (gnus-group-get-new-news))
4224 (nnheader-init-server-buffer)
4225 (gnus-read-init-file)
4226 (setq gnus-slave slave)
4228 (gnus-group-setup-buffer)
4229 (let ((buffer-read-only nil))
4231 (if (not gnus-inhibit-startup-message)
4233 (gnus-group-startup-message)
4236 (let ((level (and (numberp arg) (> arg 0) arg))
4242 (gnus-start-news-server (and arg (not level))))))
4243 (if (and (not dont-connect)
4246 (run-hooks 'gnus-startup-hook)
4247 ;; NNTP server is successfully open.
4249 ;; Find the current startup file name.
4250 (setq gnus-current-startup-file
4251 (gnus-make-newsrc-file gnus-startup-file))
4253 ;; Read the dribble file.
4254 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4256 ;; Allow using GroupLens predictions.
4257 (when gnus-use-grouplens
4259 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4261 (gnus-summary-make-display-table)
4262 ;; Do the actual startup.
4263 (gnus-setup-news nil level dont-connect)
4264 ;; Generate the group buffer.
4265 (gnus-group-list-groups level)
4266 (gnus-group-first-unread-group)
4267 (gnus-configure-windows 'group)
4268 (gnus-group-set-mode-line))))))
4270 (defun gnus-unload ()
4271 "Unload all Gnus features."
4273 (or (boundp 'load-history)
4274 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4275 (let ((history load-history)
4278 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4279 (setq feature (cdr (assq 'provide (car history))))
4280 (unload-feature feature 'force))
4281 (setq history (cdr history)))))
4283 (defun gnus-compile ()
4284 "Byte-compile the user-defined format specs."
4286 (let ((entries gnus-format-specs)
4287 entry gnus-tmp-func)
4289 (gnus-message 7 "Compiling format specs...")
4292 (setq entry (pop entries))
4293 (if (eq (car entry) 'version)
4294 (setq gnus-format-specs (delq entry gnus-format-specs))
4295 (when (and (listp (caddr entry))
4296 (not (eq 'byte-code (caaddr entry))))
4297 (fset 'gnus-tmp-func
4298 `(lambda () ,(caddr entry)))
4299 (byte-compile 'gnus-tmp-func)
4300 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4302 (push (cons 'version emacs-version) gnus-format-specs)
4304 (gnus-message 7 "Compiling user specs...done"))))
4306 (defun gnus-indent-rigidly (start end arg)
4307 "Indent rigidly using only spaces and no tabs."
4310 (narrow-to-region start end)
4311 (indent-rigidly start end arg)
4312 (goto-char (point-min))
4313 (while (search-forward "\t" nil t)
4314 (replace-match " " t t)))))
4316 (defun gnus-group-startup-message (&optional x y)
4317 "Insert startup message in current buffer."
4318 ;; Insert the message.
4323 _ ___ __ ___ __ _ ___
4342 ;; And then hack it.
4343 (gnus-indent-rigidly (point-min) (point-max)
4344 (/ (max (- (window-width) (or x 46)) 0) 2))
4345 (goto-char (point-min))
4347 (let* ((pheight (count-lines (point-min) (point-max)))
4348 (wheight (window-height))
4349 (rest (- wheight pheight)))
4350 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4352 (goto-char (point-min))
4353 (and (search-forward "Praxis" nil t)
4354 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4355 (goto-char (point-min))
4356 (let* ((mode-string (gnus-group-set-mode-line)))
4357 (setq mode-line-buffer-identification
4358 (list (concat gnus-version (substring (car mode-string) 4))))
4359 (set-buffer-modified-p t)))
4361 (defun gnus-group-setup-buffer ()
4362 (or (get-buffer gnus-group-buffer)
4364 (switch-to-buffer gnus-group-buffer)
4365 (gnus-add-current-to-buffer-list)
4367 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4369 (defun gnus-group-list-groups (&optional level unread lowest)
4370 "List newsgroups with level LEVEL or lower that have unread articles.
4371 Default is all subscribed groups.
4372 If argument UNREAD is non-nil, groups with no unread articles are also
4374 (interactive (list (if current-prefix-arg
4375 (prefix-numeric-value current-prefix-arg)
4377 (gnus-group-default-level nil t)
4378 gnus-group-default-list-level
4379 gnus-level-subscribed))))
4381 (setq level (car gnus-group-list-mode)
4382 unread (cdr gnus-group-list-mode)))
4383 (setq level (gnus-group-default-level level))
4384 (gnus-group-setup-buffer) ;May call from out of group buffer
4385 (gnus-update-format-specifications)
4386 (let ((case-fold-search nil)
4387 (props (text-properties-at (gnus-point-at-bol)))
4388 (group (gnus-group-group-name)))
4389 (set-buffer gnus-group-buffer)
4390 (funcall gnus-group-prepare-function level unread lowest)
4391 (if (zerop (buffer-size))
4392 (gnus-message 5 gnus-no-groups-message)
4393 (goto-char (point-max))
4394 (when (or (not gnus-group-goto-next-group-function)
4395 (not (funcall gnus-group-goto-next-group-function
4398 ;; Go to the first group with unread articles.
4399 (gnus-group-search-forward t)
4400 ;; Find the right group to put point on. If the current group
4401 ;; has disappeared in the new listing, try to find the next
4402 ;; one. If no next one can be found, just leave point at the
4403 ;; first newsgroup in the buffer.
4404 (if (not (gnus-goto-char
4406 (point-min) (point-max)
4407 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4408 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4410 (not (gnus-goto-char
4412 (point-min) (point-max) 'gnus-group
4414 (caar newsrc) gnus-active-hashtb)))))
4415 (setq newsrc (cdr newsrc)))
4416 (or newsrc (progn (goto-char (point-max))
4417 (forward-line -1)))))))
4418 ;; Adjust cursor point.
4419 (gnus-group-position-point))))
4421 (defun gnus-group-list-level (level &optional all)
4422 "List groups on LEVEL.
4423 If ALL (the prefix), also list groups that have no unread articles."
4424 (interactive "nList groups on level: \nP")
4425 (gnus-group-list-groups level all level))
4427 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4428 "List all newsgroups with unread articles of level LEVEL or lower.
4429 If ALL is non-nil, list groups that have no unread articles.
4430 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4431 If REGEXP, only list groups matching REGEXP."
4432 (set-buffer gnus-group-buffer)
4433 (let ((buffer-read-only nil)
4434 (newsrc (cdr gnus-newsrc-alist))
4435 (lowest (or lowest 1))
4436 info clevel unread group params)
4438 (if (< lowest gnus-level-zombie)
4439 ;; List living groups.
4441 (setq info (car newsrc)
4442 group (gnus-info-group info)
4443 params (gnus-info-params info)
4445 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4446 (and unread ; This group might be bogus
4448 (string-match regexp group))
4449 (<= (setq clevel (gnus-info-level info)) level)
4451 (or all ; We list all groups?
4452 (if (eq unread t) ; Unactivated?
4453 gnus-group-list-inactive-groups ; We list unactivated
4454 (> unread 0)) ; We list groups with unread articles
4455 (and gnus-list-groups-with-ticked-articles
4456 (cdr (assq 'tick (gnus-info-marks info))))
4457 ; And groups with tickeds
4458 ;; Check for permanent visibility.
4459 (and gnus-permanently-visible-groups
4460 (string-match gnus-permanently-visible-groups
4462 (memq 'visible params)
4463 (cdr (assq 'visible params)))
4464 (gnus-group-insert-group-line
4465 group (gnus-info-level info)
4466 (gnus-info-marks info) unread (gnus-info-method info)))))
4468 ;; List dead groups.
4469 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4470 (gnus-group-prepare-flat-list-dead
4471 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4472 gnus-level-zombie ?Z
4474 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4475 (gnus-group-prepare-flat-list-dead
4476 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4477 gnus-level-killed ?K regexp))
4479 (gnus-group-set-mode-line)
4480 (setq gnus-group-list-mode (cons level all))
4481 (run-hooks 'gnus-group-prepare-hook)))
4483 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4484 ;; List zombies and killed lists somewhat faster, which was
4485 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4486 ;; this by ignoring the group format specification altogether.
4489 ;; This loop is used when listing groups that match some
4492 (setq group (pop groups))
4493 (when (string-match regexp group)
4494 (add-text-properties
4495 (point) (prog1 (1+ (point))
4496 (insert " " mark " *: " group "\n"))
4497 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4499 'gnus-level level))))
4500 ;; This loop is used when listing all groups.
4502 (add-text-properties
4503 (point) (prog1 (1+ (point))
4504 (insert " " mark " *: "
4505 (setq group (pop groups)) "\n"))
4506 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4508 'gnus-level level))))))
4510 (defmacro gnus-group-real-name (group)
4511 "Find the real name of a foreign newsgroup."
4512 `(let ((gname ,group))
4513 (if (string-match ":[^:]+$" gname)
4514 (substring gname (1+ (match-beginning 0)))
4517 (defsubst gnus-server-add-address (method)
4518 (let ((method-name (symbol-name (car method))))
4519 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4520 (not (assq (intern (concat method-name "-address")) method)))
4521 (append method (list (list (intern (concat method-name "-address"))
4525 (defsubst gnus-server-get-method (group method)
4526 ;; Input either a server name, and extended server name, or a
4527 ;; select method, and return a select method.
4528 (cond ((stringp method)
4529 (gnus-server-to-method method))
4530 ((and (stringp (car method)) group)
4531 (gnus-server-extend-method group method))
4533 (gnus-server-add-address method))))
4535 (defun gnus-server-to-method (server)
4536 "Map virtual server names to select methods."
4538 ;; Perhaps this is the native server?
4539 (and (equal server "native") gnus-select-method)
4540 ;; It should be in the server alist.
4541 (cdr (assoc server gnus-server-alist))
4542 ;; If not, we look through all the opened server
4543 ;; to see whether we can find it there.
4544 (let ((opened gnus-opened-servers))
4546 (not (equal server (format "%s:%s" (caaar opened)
4551 (defmacro gnus-method-equal (ss1 ss2)
4552 "Say whether two servers are equal."
4556 (and (= (length s1) (length s2))
4558 (while (and s1 (member (car s1) s2))
4562 (defun gnus-server-equal (m1 m2)
4563 "Say whether two methods are equal."
4564 (let ((m1 (cond ((null m1) gnus-select-method)
4565 ((stringp m1) (gnus-server-to-method m1))
4567 (m2 (cond ((null m2) gnus-select-method)
4568 ((stringp m2) (gnus-server-to-method m2))
4570 (gnus-method-equal m1 m2)))
4572 (defun gnus-group-prefixed-name (group method)
4573 "Return the whole name from GROUP and METHOD."
4574 (and (stringp method) (setq method (gnus-server-to-method method)))
4575 (concat (format "%s" (car method))
4577 (or (assoc (format "%s" (car method))
4578 (gnus-methods-using 'address))
4579 (gnus-server-equal method gnus-message-archive-method))
4581 (not (string= (nth 1 method) "")))
4582 (concat "+" (nth 1 method)))
4585 (defun gnus-group-real-prefix (group)
4586 "Return the prefix of the current group name."
4587 (if (string-match "^[^:]+:" group)
4588 (substring group 0 (match-end 0))
4591 (defun gnus-group-method (group)
4592 "Return the server or method used for selecting GROUP."
4593 (let ((prefix (gnus-group-real-prefix group)))
4594 (if (equal prefix "")
4596 (let ((servers gnus-opened-servers)
4598 backend possible found)
4599 (if (string-match "^[^\\+]+\\+" prefix)
4600 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4601 server (substring prefix (match-end 0) (1- (length prefix))))
4602 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4604 (when (eq (caaar servers) backend)
4605 (setq possible (caar servers))
4606 (when (equal (cadaar servers) server)
4607 (setq found (caar servers))))
4609 (or (car (rassoc found gnus-server-alist))
4611 (car (rassoc possible gnus-server-alist))
4613 (list backend server))))))
4615 (defsubst gnus-secondary-method-p (method)
4616 "Return whether METHOD is a secondary select method."
4617 (let ((methods gnus-secondary-select-methods)
4618 (gmethod (gnus-server-get-method nil method)))
4620 (not (equal (gnus-server-get-method nil (car methods))
4622 (setq methods (cdr methods)))
4625 (defun gnus-group-foreign-p (group)
4626 "Say whether a group is foreign or not."
4627 (and (not (gnus-group-native-p group))
4628 (not (gnus-group-secondary-p group))))
4630 (defun gnus-group-native-p (group)
4631 "Say whether the group is native or not."
4632 (not (string-match ":" group)))
4634 (defun gnus-group-secondary-p (group)
4635 "Say whether the group is secondary or not."
4636 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4638 (defun gnus-group-get-parameter (group &optional symbol)
4639 "Returns the group parameters for GROUP.
4640 If SYMBOL, return the value of that symbol in the group parameters."
4641 (let ((params (gnus-info-params (gnus-get-info group))))
4643 (gnus-group-parameter-value params symbol)
4646 (defun gnus-group-parameter-value (params symbol)
4647 "Return the value of SYMBOL in group PARAMS."
4648 (or (car (memq symbol params)) ; It's either a simple symbol
4649 (cdr (assq symbol params)))) ; or a cons.
4651 (defun gnus-group-add-parameter (group param)
4652 "Add parameter PARAM to GROUP."
4653 (let ((info (gnus-get-info group)))
4655 () ; This is a dead group. We just ignore it.
4656 ;; Cons the new param to the old one and update.
4657 (gnus-group-set-info (cons param (gnus-info-params info))
4660 (defun gnus-group-set-parameter (group name value)
4661 "Set parameter NAME to VALUE in GROUP."
4662 (let ((info (gnus-get-info group)))
4664 () ; This is a dead group. We just ignore it.
4665 (let ((old-params (gnus-info-params info))
4666 (new-params (list (cons name value))))
4668 (if (or (not (listp (car old-params)))
4669 (not (eq (caar old-params) name)))
4670 (setq new-params (append new-params (list (car old-params)))))
4671 (setq old-params (cdr old-params)))
4672 (gnus-group-set-info new-params group 'params)))))
4674 (defun gnus-group-add-score (group &optional score)
4675 "Add SCORE to the GROUP score.
4676 If SCORE is nil, add 1 to the score of GROUP."
4677 (let ((info (gnus-get-info group)))
4678 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))
4680 (defun gnus-summary-bubble-group ()
4681 "Increase the score of the current group.
4682 This is a handy function to add to `gnus-summary-exit-hook' to
4683 increase the score of each group you read."
4684 (gnus-group-add-score gnus-newsgroup-name))
4686 (defun gnus-group-set-info (info &optional method-only-group part)
4687 (let* ((entry (gnus-gethash
4688 (or method-only-group (gnus-info-group info))
4689 gnus-newsrc-hashtb))
4691 (info (if method-only-group (nth 2 entry) info))
4693 (when method-only-group
4695 (error "Trying to change non-existent group %s" method-only-group))
4696 ;; We have received parts of the actual group info - either the
4697 ;; select method or the group parameters. We first check
4698 ;; whether we have to extend the info, and if so, do that.
4699 (let ((len (length info))
4700 (total (if (eq part 'method) 5 6)))
4702 (setcdr (nthcdr (1- len) info)
4703 (make-list (- total len) nil)))
4704 ;; Then we enter the new info.
4705 (setcar (nthcdr (1- total) info) part-info)))
4707 ;; This is a new group, so we just create it.
4709 (set-buffer gnus-group-buffer)
4710 (setq method (gnus-info-method info))
4711 (when (gnus-server-equal method "native")
4714 ;; It's a foreign group...
4715 (gnus-group-make-group
4716 (gnus-group-real-name (gnus-info-group info))
4717 (if (stringp method) method
4718 (prin1-to-string (car method)))
4720 (nth 1 (gnus-info-method info))))
4721 ;; It's a native group.
4722 (gnus-group-make-group (gnus-info-group info)))
4723 (gnus-message 6 "Note: New group created")
4725 (gnus-gethash (gnus-group-prefixed-name
4726 (gnus-group-real-name (gnus-info-group info))
4727 (or (gnus-info-method info) gnus-select-method))
4728 gnus-newsrc-hashtb))))
4729 ;; Whether it was a new group or not, we now have the entry, so we
4730 ;; can do the update.
4733 (setcar (nthcdr 2 entry) info)
4734 (when (and (not (eq (car entry) t))
4735 (gnus-active (gnus-info-group info)))
4736 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4737 (error "No such group: %s" (gnus-info-group info)))))
4739 (defun gnus-group-set-method-info (group select-method)
4740 (gnus-group-set-info select-method group 'method))
4742 (defun gnus-group-set-params-info (group params)
4743 (gnus-group-set-info params group 'params))
4745 (defun gnus-group-update-group-line ()
4746 "Update the current line in the group buffer."
4747 (let* ((buffer-read-only nil)
4748 (group (gnus-group-group-name))
4749 (gnus-group-indentation (gnus-group-group-indentation))
4750 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4752 (not (gnus-ephemeral-group-p group))
4754 (concat "(gnus-group-set-info '"
4755 (prin1-to-string (nth 2 entry)) ")")))
4757 (gnus-group-insert-group-line-info group)
4759 (gnus-group-position-point)))
4761 (defun gnus-group-insert-group-line-info (group)
4762 "Insert GROUP on the current line."
4763 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4767 ;; (Un)subscribed group.
4768 (setq info (nth 2 entry))
4769 (gnus-group-insert-group-line
4770 group (gnus-info-level info) (gnus-info-marks info)
4771 (or (car entry) t) (gnus-info-method info)))
4772 ;; This group is dead.
4773 (gnus-group-insert-group-line
4775 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4777 (if (setq active (gnus-active group))
4778 (- (1+ (cdr active)) (car active)) 0)
4781 (defun gnus-group-insert-group-line
4782 (gnus-tmp-group gnus-tmp-level gnus-tmp-marked number
4784 "Insert a group line in the group buffer."
4785 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4786 (gnus-tmp-number-total
4788 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4790 (gnus-tmp-number-of-unread
4791 (if (numberp number) (int-to-string (max 0 number))
4793 (gnus-tmp-number-of-read
4794 (if (numberp number)
4795 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4797 (gnus-tmp-subscribed
4798 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4799 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4800 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4802 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4803 (gnus-tmp-newsgroup-description
4804 (if gnus-description-hashtb
4805 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4808 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4809 (gnus-tmp-moderated-string
4810 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4812 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4813 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4814 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4815 (gnus-tmp-news-method-string
4817 (format "(%s:%s)" (car gnus-tmp-method)
4818 (cadr gnus-tmp-method)) ""))
4819 (gnus-tmp-marked-mark
4820 (if (and (numberp number)
4822 (cdr (assq 'tick gnus-tmp-marked)))
4824 (gnus-tmp-process-marked
4825 (if (member gnus-tmp-group gnus-group-marked)
4826 gnus-process-mark ? ))
4828 (or (and gnus-use-grouplens
4829 (bbb-grouplens-group-p gnus-tmp-group))
4831 (buffer-read-only nil)
4832 header gnus-tmp-header) ; passed as parameter to user-funcs.
4834 (add-text-properties
4838 (eval gnus-group-line-format-spec))
4839 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4840 gnus-unread ,(if (numberp number)
4841 (string-to-int gnus-tmp-number-of-unread)
4843 gnus-marked ,gnus-tmp-marked-mark
4844 gnus-indentation ,gnus-group-indentation
4845 gnus-level ,gnus-tmp-level))
4846 (when (gnus-visual-p 'group-highlight 'highlight)
4848 (run-hooks 'gnus-group-update-hook)
4850 ;; Allow XEmacs to remove front-sticky text properties.
4851 (gnus-group-remove-excess-properties)))
4853 (defun gnus-group-update-group (group &optional visible-only)
4854 "Update all lines where GROUP appear.
4855 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4858 (set-buffer gnus-group-buffer)
4859 ;; The buffer may be narrowed.
4862 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4864 found buffer-read-only)
4865 ;; Enter the current status into the dribble buffer.
4866 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4867 (if (and entry (not (gnus-ephemeral-group-p group)))
4869 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4871 ;; Find all group instances. If topics are in use, each group
4872 ;; may be listed in more than once.
4873 (while (setq loc (text-property-any
4874 loc (point-max) 'gnus-group ident))
4877 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4879 (gnus-group-insert-group-line-info group))
4880 (setq loc (1+ loc)))
4881 (unless (or found visible-only)
4882 ;; No such line in the buffer, find out where it's supposed to
4883 ;; go, and insert it there (or at the end of the buffer).
4884 (if gnus-goto-missing-group-function
4885 (funcall gnus-goto-missing-group-function group)
4886 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4887 (while (and entry (car entry)
4891 (point-min) (point-max)
4892 'gnus-group (gnus-intern-safe
4893 (caar entry) gnus-active-hashtb)))))
4894 (setq entry (cdr entry)))
4895 (or entry (goto-char (point-max)))))
4896 ;; Finally insert the line.
4897 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4898 (gnus-group-insert-group-line-info group)))
4899 (gnus-group-set-mode-line)))))
4901 (defun gnus-group-set-mode-line ()
4902 (when (memq 'group gnus-updated-mode-lines)
4903 (let* ((gformat (or gnus-group-mode-line-format-spec
4904 (setq gnus-group-mode-line-format-spec
4906 gnus-group-mode-line-format
4907 gnus-group-mode-line-format-alist))))
4908 (gnus-tmp-news-server (cadr gnus-select-method))
4909 (gnus-tmp-news-method (car gnus-select-method))
4911 gnus-tmp-header ;Dummy binding for user-defined formats
4912 ;; Get the resulting string.
4913 (mode-string (eval gformat)))
4914 ;; If the line is too long, we chop it off.
4915 (when (> (length mode-string) max-len)
4916 (setq mode-string (substring mode-string 0 (- max-len 4))))
4918 (setq mode-line-buffer-identification (list mode-string))
4919 (set-buffer-modified-p t)))))
4921 (defun gnus-group-group-name ()
4922 "Get the name of the newsgroup on the current line."
4923 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4924 (and group (symbol-name group))))
4926 (defun gnus-group-group-level ()
4927 "Get the level of the newsgroup on the current line."
4928 (get-text-property (gnus-point-at-bol) 'gnus-level))
4930 (defun gnus-group-group-indentation ()
4931 "Get the indentation of the newsgroup on the current line."
4932 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
4933 (and gnus-group-indentation-function
4934 (funcall gnus-group-indentation-function))
4937 (defun gnus-group-group-unread ()
4938 "Get the number of unread articles of the newsgroup on the current line."
4939 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4941 (defun gnus-group-search-forward (&optional backward all level first-too)
4942 "Find the next newsgroup with unread articles.
4943 If BACKWARD is non-nil, find the previous newsgroup instead.
4944 If ALL is non-nil, just find any newsgroup.
4945 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4947 If FIRST-TOO, the current line is also eligible as a target."
4948 (let ((way (if backward -1 1))
4949 (low gnus-level-killed)
4952 (if (and backward (progn (beginning-of-line)) (bobp))
4954 (or first-too (forward-line way))
4962 (get-text-property (point) 'gnus-unread)))
4963 (and (numberp unread) (> unread 0)))
4964 (setq lev (get-text-property (point)
4966 (<= lev gnus-level-subscribed)))
4968 (and (setq lev (get-text-property (point)
4977 (zerop (forward-line way)))))
4979 (progn (gnus-group-position-point) t)
4980 (goto-char (or pos beg))
4983 ;;; Gnus group mode commands
4987 (defun gnus-group-mark-group (n &optional unmark no-advance)
4988 "Mark the current group."
4990 (let ((buffer-read-only nil)
4994 (setq group (gnus-group-group-name))
4998 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5003 (setq gnus-group-marked (delete group gnus-group-marked)))
5005 (setq gnus-group-marked
5006 (cons group (delete group gnus-group-marked))))
5008 (or no-advance (zerop (gnus-group-next-group 1))))
5010 (gnus-summary-position-point)
5013 (defun gnus-group-unmark-group (n)
5014 "Remove the mark from the current group."
5016 (gnus-group-mark-group n 'unmark)
5017 (gnus-group-position-point))
5019 (defun gnus-group-unmark-all-groups ()
5020 "Unmark all groups."
5022 (let ((groups gnus-group-marked))
5025 (gnus-group-remove-mark (pop groups)))))
5026 (gnus-group-position-point))
5028 (defun gnus-group-mark-region (unmark beg end)
5029 "Mark all groups between point and mark.
5030 If UNMARK, remove the mark instead."
5031 (interactive "P\nr")
5032 (let ((num (count-lines beg end)))
5035 (- num (gnus-group-mark-group num unmark)))))
5037 (defun gnus-group-mark-buffer (&optional unmark)
5038 "Mark all groups in the buffer.
5039 If UNMARK, remove the mark instead."
5041 (gnus-group-mark-region unmark (point-min) (point-max)))
5043 (defun gnus-group-mark-regexp (regexp)
5044 "Mark all groups that match some regexp."
5045 (interactive "sMark (regexp): ")
5046 (let ((alist (cdr gnus-newsrc-alist))
5049 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5050 (gnus-group-set-mark group))))
5051 (gnus-group-position-point))
5053 (defun gnus-group-remove-mark (group)
5054 "Remove the process mark from GROUP and move point there.
5055 Return nil if the group isn't displayed."
5056 (if (gnus-group-goto-group group)
5058 (gnus-group-mark-group 1 'unmark t)
5060 (setq gnus-group-marked
5061 (delete group gnus-group-marked))
5064 (defun gnus-group-set-mark (group)
5065 "Set the process mark on GROUP."
5066 (if (gnus-group-goto-group group)
5068 (gnus-group-mark-group 1 nil t))
5069 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5071 (defun gnus-group-universal-argument (arg &optional groups func)
5072 "Perform any command on all groups accoring to the process/prefix convention."
5074 (let ((groups (or groups (gnus-group-process-prefix arg)))
5076 (if (eq (setq func (or func
5079 (substitute-command-keys
5080 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5083 (message "Undefined key")
5086 (gnus-group-remove-mark (setq group (pop groups)))
5087 (command-execute func))))
5088 (gnus-group-position-point))
5090 (defun gnus-group-process-prefix (n)
5091 "Return a list of groups to work on.
5092 Take into consideration N (the prefix) and the list of marked groups."
5095 (setq n (prefix-numeric-value n))
5096 ;; There is a prefix, so we return a list of the N next
5098 (let ((way (if (< n 0) -1 1))
5103 (setq group (gnus-group-group-name)))
5104 (setq groups (cons group groups))
5106 (gnus-group-next-group way)))
5108 ((and (boundp 'transient-mark-mode)
5111 ;; Work on the region between point and mark.
5112 (let ((max (max (point) (mark)))
5115 (goto-char (min (point) (mark)))
5118 (push (gnus-group-group-name) groups)
5119 (zerop (gnus-group-next-group 1))
5121 (nreverse groups))))
5123 ;; No prefix, but a list of marked articles.
5124 (reverse gnus-group-marked))
5126 ;; Neither marked articles or a prefix, so we return the
5128 (let ((group (gnus-group-group-name)))
5129 (and group (list group))))))
5131 ;; Selecting groups.
5133 (defun gnus-group-read-group (&optional all no-article group)
5134 "Read news in this newsgroup.
5135 If the prefix argument ALL is non-nil, already read articles become
5136 readable. IF ALL is a number, fetch this number of articles. If the
5137 optional argument NO-ARTICLE is non-nil, no article will be
5138 auto-selected upon group entry. If GROUP is non-nil, fetch that
5141 (let ((group (or group (gnus-group-group-name)))
5142 number active marked entry)
5143 (or group (error "No group on current line"))
5144 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5145 group gnus-newsrc-hashtb)))))
5146 ;; This group might be a dead group. In that case we have to get
5147 ;; the number of unread articles from `gnus-active-hashtb'.
5149 (cond ((numberp all) all)
5151 ((setq active (gnus-active group))
5152 (- (1+ (cdr active)) (car active)))))
5153 (gnus-summary-read-group
5154 group (or all (and (numberp number)
5155 (zerop (+ number (length (cdr (assq 'tick marked)))
5156 (length (cdr (assq 'dormant marked)))))))
5159 (defun gnus-group-select-group (&optional all)
5160 "Select this newsgroup.
5161 No article is selected automatically.
5162 If ALL is non-nil, already read articles become readable.
5163 If ALL is a number, fetch this number of articles."
5165 (gnus-group-read-group all t))
5167 (defun gnus-group-quick-select-group (&optional all)
5168 "Select the current group \"quickly\".
5169 This means that no highlighting or scoring will be performed."
5172 gnus-score-find-score-files-function
5173 gnus-apply-kill-hook
5174 gnus-summary-expunge-below)
5175 (gnus-group-read-group all t)))
5177 (defun gnus-group-visible-select-group (&optional all)
5178 "Select the current group without hiding any articles."
5180 (let ((gnus-inhibit-limiting t))
5181 (gnus-group-read-group all t)))
5184 (defun gnus-fetch-group (group)
5185 "Start Gnus if necessary and enter GROUP.
5186 Returns whether the fetching was successful or not."
5187 (interactive "sGroup name: ")
5188 (or (get-buffer gnus-group-buffer)
5190 (gnus-group-read-group nil nil group))
5192 ;; Enter a group that is not in the group buffer. Non-nil is returned
5193 ;; if selection was successful.
5194 (defun gnus-group-read-ephemeral-group
5195 (group method &optional activate quit-config)
5196 (let ((group (if (gnus-group-foreign-p group) group
5197 (gnus-group-prefixed-name group method))))
5200 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5201 ((quit-config . ,(if quit-config quit-config
5202 (cons (current-buffer) 'summary))))))
5204 (set-buffer gnus-group-buffer)
5205 (or (gnus-check-server method)
5206 (error "Unable to contact server: %s" (gnus-status-message method)))
5207 (if activate (or (gnus-request-group group)
5208 (error "Couldn't request group")))
5210 (gnus-group-read-group t t group)
5214 (defun gnus-group-jump-to-group (group)
5215 "Jump to newsgroup GROUP."
5217 (list (completing-read
5218 "Group: " gnus-active-hashtb nil
5219 (memq gnus-select-method gnus-have-read-active-file))))
5221 (if (equal group "")
5222 (error "Empty group name"))
5224 (let ((b (text-property-any
5225 (point-min) (point-max)
5226 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5227 (unless (gnus-ephemeral-group-p group)
5229 ;; Either go to the line in the group buffer...
5231 ;; ... or insert the line.
5234 (gnus-activate-group group)
5235 (error "%s error: %s" group (gnus-status-message group)))
5237 (gnus-group-update-group group)
5238 (goto-char (text-property-any
5239 (point-min) (point-max)
5240 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5241 ;; Adjust cursor point.
5242 (gnus-group-position-point)))
5244 (defun gnus-group-goto-group (group)
5245 "Goto to newsgroup GROUP."
5247 (let ((b (text-property-any (point-min) (point-max)
5248 'gnus-group (gnus-intern-safe
5249 group gnus-active-hashtb))))
5250 (and b (goto-char b)))))
5252 (defun gnus-group-next-group (n)
5253 "Go to next N'th newsgroup.
5254 If N is negative, search backward instead.
5255 Returns the difference between N and the number of skips actually
5258 (gnus-group-next-unread-group n t))
5260 (defun gnus-group-next-unread-group (n &optional all level)
5261 "Go to next N'th unread newsgroup.
5262 If N is negative, search backward instead.
5263 If ALL is non-nil, choose any newsgroup, unread or not.
5264 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5265 such group can be found, the next group with a level higher than
5267 Returns the difference between N and the number of skips actually
5270 (let ((backward (< n 0))
5273 (gnus-group-search-forward
5274 backward (or (not gnus-group-goto-unread) all) level))
5276 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5277 (if level " on this level or higher" "")))
5280 (defun gnus-group-prev-group (n)
5281 "Go to previous N'th newsgroup.
5282 Returns the difference between N and the number of skips actually
5285 (gnus-group-next-unread-group (- n) t))
5287 (defun gnus-group-prev-unread-group (n)
5288 "Go to previous N'th unread newsgroup.
5289 Returns the difference between N and the number of skips actually
5292 (gnus-group-next-unread-group (- n)))
5294 (defun gnus-group-next-unread-group-same-level (n)
5295 "Go to next N'th unread newsgroup on the same level.
5296 If N is negative, search backward instead.
5297 Returns the difference between N and the number of skips actually
5300 (gnus-group-next-unread-group n t (gnus-group-group-level))
5301 (gnus-group-position-point))
5303 (defun gnus-group-prev-unread-group-same-level (n)
5304 "Go to next N'th unread newsgroup on the same level.
5305 Returns the difference between N and the number of skips actually
5308 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5309 (gnus-group-position-point))
5311 (defun gnus-group-best-unread-group (&optional exclude-group)
5312 "Go to the group with the highest level.
5313 If EXCLUDE-GROUP, do not go to that group."
5315 (goto-char (point-min))
5318 (while (setq unread (get-text-property (point) 'gnus-unread))
5319 (if (and (numberp unread) (> unread 0))
5321 (if (and (< (get-text-property (point) 'gnus-level) best)
5322 (or (not exclude-group)
5323 (not (equal exclude-group (gnus-group-group-name)))))
5325 (setq best (get-text-property (point) 'gnus-level))
5326 (setq best-point (point))))))
5328 (if best-point (goto-char best-point))
5329 (gnus-summary-position-point)
5330 (and best-point (gnus-group-group-name))))
5332 (defun gnus-group-first-unread-group ()
5333 "Go to the first group with unread articles."
5336 (let ((opoint (point))
5338 (goto-char (point-min))
5339 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5340 (and (numberp unread) ; Not a topic.
5341 (not (zerop unread))) ; Has unread articles.
5342 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5345 nil)) ; Not success.
5346 (gnus-group-position-point)))
5348 (defun gnus-group-enter-server-mode ()
5349 "Jump to the server buffer."
5351 (gnus-enter-server-buffer))
5353 (defun gnus-group-make-group (name &optional method address)
5354 "Add a new newsgroup.
5355 The user will be prompted for a NAME, for a select METHOD, and an
5359 (read-string "Group name: ")
5362 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5364 (if (assoc method gnus-valid-select-methods)
5366 (if (memq 'prompt-address
5367 (assoc method gnus-valid-select-methods))
5368 (read-string "Address: ")
5370 (list method "")))))
5373 (set-buffer gnus-group-buffer)
5374 (let* ((meth (and method (if address (list (intern method) address)
5376 (nname (if method (gnus-group-prefixed-name name meth) name))
5378 (and (gnus-gethash nname gnus-newsrc-hashtb)
5379 (error "Group %s already exists" nname))
5380 (gnus-group-change-level
5381 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5382 gnus-level-default-subscribed gnus-level-killed
5383 (and (gnus-group-group-name)
5384 (gnus-gethash (gnus-group-group-name)
5385 gnus-newsrc-hashtb))
5387 (gnus-set-active nname (cons 1 0))
5388 (or (gnus-ephemeral-group-p name)
5390 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5391 (gnus-group-insert-group-line-info nname)
5393 (when (assoc (symbol-name (car meth)) gnus-valid-select-methods)
5394 (require (car meth)))
5395 (gnus-check-server meth)
5396 (and (gnus-check-backend-function 'request-create-group nname)
5397 (gnus-request-create-group nname))
5400 (defun gnus-group-delete-group (group &optional force)
5401 "Delete the current group.
5402 If FORCE (the prefix) is non-nil, all the articles in the group will
5403 be deleted. This is \"deleted\" as in \"removed forever from the face
5404 of the Earth\". There is no undo."
5406 (list (gnus-group-group-name)
5407 current-prefix-arg))
5408 (or group (error "No group to rename"))
5409 (or (gnus-check-backend-function 'request-delete-group group)
5410 (error "This backend does not support group deletion"))
5412 (if (not (gnus-yes-or-no-p
5414 "Do you really want to delete %s%s? "
5415 group (if force " and all its contents" ""))))
5417 (gnus-message 6 "Deleting group %s..." group)
5418 (if (not (gnus-request-delete-group group force))
5420 (gnus-message 3 "Couldn't delete group %s" group)
5422 (gnus-message 6 "Deleting group %s...done" group)
5423 (gnus-group-goto-group group)
5424 (gnus-group-kill-group 1 t)
5425 (gnus-sethash group nil gnus-active-hashtb)
5427 (gnus-group-position-point)))
5429 (defun gnus-group-rename-group (group new-name)
5432 (gnus-group-group-name)
5434 (or (gnus-check-backend-function
5435 'request-rename-group (gnus-group-group-name))
5436 (error "This backend does not support renaming groups"))
5437 (read-string "New group name: "))))
5439 (or (gnus-check-backend-function 'request-rename-group group)
5440 (error "This backend does not support renaming groups"))
5442 (or group (error "No group to rename"))
5443 (and (string-match "^[ \t]*$" new-name)
5444 (error "Not a valid group name"))
5446 ;; We find the proper prefixed name.
5448 (gnus-group-prefixed-name
5449 (gnus-group-real-name new-name)
5450 (gnus-info-method (gnus-get-info group))))
5452 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5454 (if (not (gnus-request-rename-group group new-name))
5456 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5458 ;; We rename the group internally by killing it...
5459 (gnus-group-goto-group group)
5460 (gnus-group-kill-group)
5461 ;; ... changing its name ...
5462 (setcar (cdar gnus-list-of-killed-groups) new-name)
5463 ;; ... and then yanking it. Magic!
5464 (gnus-group-yank-group)
5465 (gnus-set-active new-name (gnus-active group))
5466 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5468 (gnus-group-position-point)))
5470 (defun gnus-group-edit-group (group &optional part)
5471 "Edit the group on the current line."
5472 (interactive (list (gnus-group-group-name)))
5473 (let* ((part (or part 'info))
5474 (done-func `(lambda ()
5475 "Exit editing mode and update the information."
5477 (gnus-group-edit-group-done ',part ,group)))
5478 (winconf (current-window-configuration))
5480 (or group (error "No group on current line"))
5481 (or (setq info (gnus-get-info group))
5482 (error "Killed group; can't be edited"))
5483 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5484 (gnus-configure-windows 'edit-group)
5485 (gnus-add-current-to-buffer-list)
5487 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5488 (use-local-map (copy-keymap emacs-lisp-mode-map))
5489 (local-set-key "\C-c\C-c" done-func)
5490 (make-local-variable 'gnus-prev-winconf)
5491 (setq gnus-prev-winconf winconf)
5496 ";; Type `C-c C-c' after editing the select method.\n\n")
5498 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5500 ";; Type `C-c C-c' after editing the group info.\n\n")))
5503 (cond ((eq part 'method)
5504 (or (gnus-info-method info) "native"))
5506 (gnus-info-params info))
5510 (defun gnus-group-edit-group-method (group)
5511 "Edit the select method of GROUP."
5512 (interactive (list (gnus-group-group-name)))
5513 (gnus-group-edit-group group 'method))
5515 (defun gnus-group-edit-group-parameters (group)
5516 "Edit the group parameters of GROUP."
5517 (interactive (list (gnus-group-group-name)))
5518 (gnus-group-edit-group group 'params))
5520 (defun gnus-group-edit-group-done (part group)
5521 "Get info from buffer, update variables and jump to the group buffer."
5522 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5523 (goto-char (point-min))
5524 (let* ((form (read (current-buffer)))
5525 (winconf gnus-prev-winconf)
5526 (method (cond ((eq part 'info) (nth 4 form))
5527 ((eq part 'method) form)
5529 (info (cond ((eq part 'info) form)
5530 ((eq part 'method) (gnus-get-info group))
5533 (if (or (not method)
5535 gnus-select-method method))
5536 (gnus-group-real-name (car info))
5537 (gnus-group-prefixed-name
5538 (gnus-group-real-name (car info)) method))
5540 (when (and new-group
5541 (not (equal new-group group)))
5542 (when (gnus-group-goto-group group)
5543 (gnus-group-kill-group 1))
5544 (gnus-activate-group new-group))
5546 (if (and info new-group)
5548 (setq info (gnus-copy-sequence info))
5549 (setcar info new-group)
5550 (unless (gnus-server-equal method "native")
5551 (unless (nthcdr 3 info)
5552 (nconc info (list nil nil)))
5553 (unless (nthcdr 4 info)
5554 (nconc info (list nil)))
5555 (gnus-info-set-method info method))
5556 (gnus-group-set-info info))
5557 (gnus-group-set-info form (or new-group group) part))
5558 (kill-buffer (current-buffer))
5559 (and winconf (set-window-configuration winconf))
5560 (set-buffer gnus-group-buffer)
5561 (gnus-group-update-group (or new-group group))
5562 (gnus-group-position-point)))
5564 (defun gnus-group-make-help-group ()
5565 "Create the Gnus documentation group."
5567 (let ((path load-path)
5568 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5570 (and (gnus-gethash name gnus-newsrc-hashtb)
5571 (error "Documentation group already exists"))
5573 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5575 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5577 (setq file (concat (file-name-directory
5578 (directory-file-name dir))
5579 "etc/gnus-tut.txt"))))
5582 (message "Couldn't find doc group")
5583 (gnus-group-make-group
5584 (gnus-group-real-name name)
5586 (list 'nndoc-address file)
5587 (list 'nndoc-article-type 'mbox)))))
5588 (gnus-group-position-point))
5590 (defun gnus-group-make-doc-group (file type)
5591 "Create a group that uses a single file as the source."
5593 (list (read-file-name "File name: ")
5594 (and current-prefix-arg 'ask)))
5595 (when (eq type 'ask)
5600 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5602 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5603 ((= char ?b) 'babyl)
5604 ((= char ?d) 'digest)
5605 ((= char ?f) 'forward)
5607 (t (setq err (format "%c unknown. " char))
5610 (let* ((file (expand-file-name file))
5611 (name (gnus-generate-new-group-name
5612 (gnus-group-prefixed-name
5613 (file-name-nondirectory file) '(nndoc "")))))
5614 (gnus-group-make-group
5615 (gnus-group-real-name name)
5617 (list 'nndoc-address file)
5618 (list 'nndoc-article-type (or type 'guess))))
5620 (gnus-group-position-point)))
5622 (defun gnus-group-make-archive-group (&optional all)
5623 "Create the (ding) Gnus archive group of the most recent articles.
5624 Given a prefix, create a full group."
5626 (let ((group (gnus-group-prefixed-name
5627 (if all "ding.archives" "ding.recent") '(nndir ""))))
5628 (and (gnus-gethash group gnus-newsrc-hashtb)
5629 (error "Archive group already exists"))
5630 (gnus-group-make-group
5631 (gnus-group-real-name group)
5632 (list 'nndir (if all "hpc" "edu")
5633 (list 'nndir-directory
5634 (if all gnus-group-archive-directory
5635 gnus-group-recent-archive-directory)))))
5637 (gnus-group-position-point))
5639 (defun gnus-group-make-directory-group (dir)
5640 "Create an nndir group.
5641 The user will be prompted for a directory. The contents of this
5642 directory will be used as a newsgroup. The directory should contain
5643 mail messages or news articles in files that have numeric names."
5645 (list (read-file-name "Create group from directory: ")))
5646 (or (file-exists-p dir) (error "No such directory"))
5647 (or (file-directory-p dir) (error "Not a directory"))
5651 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5653 (gnus-group-prefixed-name
5654 (concat (file-name-as-directory (directory-file-name dir))
5657 (setq ext (format "<%d>" (setq i (1+ i)))))
5658 (gnus-group-make-group
5659 (gnus-group-real-name group)
5660 (list 'nndir group (list 'nndir-directory dir))))
5662 (gnus-group-position-point))
5664 (defun gnus-group-make-kiboze-group (group address scores)
5665 "Create an nnkiboze group.
5666 The user will be prompted for a name, a regexp to match groups, and
5667 score file entries for articles to include in the group."
5670 (read-string "nnkiboze group name: ")
5671 (read-string "Source groups (regexp): ")
5672 (let ((headers (mapcar (lambda (group) (list group))
5673 '("subject" "from" "number" "date" "message-id"
5674 "references" "chars" "lines" "xref"
5675 "followup" "all" "body" "head")))
5676 scores header regexp regexps)
5677 (while (not (equal "" (setq header (completing-read
5678 "Match on header: " headers nil t))))
5680 (while (not (equal "" (setq regexp (read-string
5681 (format "Match on %s (string): "
5683 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5684 (setq scores (cons (cons header regexps) scores)))
5686 (gnus-group-make-group group "nnkiboze" address)
5688 (gnus-set-work-buffer)
5689 (let (emacs-lisp-mode-hook)
5690 (pp scores (current-buffer)))
5691 (write-region (point-min) (point-max)
5692 (gnus-score-file-name (concat "nnkiboze:" group))))
5694 (gnus-group-position-point))
5696 (defun gnus-group-add-to-virtual (n vgroup)
5697 "Add the current group to a virtual group."
5699 (list current-prefix-arg
5700 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5702 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5703 (error "%s is not an nnvirtual group" vgroup))
5704 (let* ((groups (gnus-group-process-prefix n))
5705 (method (gnus-info-method (gnus-get-info vgroup))))
5706 (setcar (cdr method)
5708 (nth 1 method) "\\|"
5711 (gnus-group-remove-mark s)
5712 (concat "\\(^" (regexp-quote s) "$\\)"))
5714 (gnus-group-position-point))
5716 (defun gnus-group-make-empty-virtual (group)
5717 "Create a new, fresh, empty virtual group."
5718 (interactive "sCreate new, empty virtual group: ")
5719 (let* ((method (list 'nnvirtual "^$"))
5720 (pgroup (gnus-group-prefixed-name group method)))
5721 ;; Check whether it exists already.
5722 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5723 (error "Group %s already exists." pgroup))
5724 ;; Subscribe the new group after the group on the current line.
5725 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5726 (gnus-group-update-group pgroup)
5728 (gnus-group-position-point)))
5730 (defun gnus-group-enter-directory (dir)
5731 "Enter an ephemeral nneething group."
5732 (interactive "DDirectory to read: ")
5733 (let* ((method (list 'nneething dir))
5734 (leaf (gnus-group-prefixed-name
5735 (file-name-nondirectory (directory-file-name dir))
5737 (name (gnus-generate-new-group-name leaf)))
5738 (let ((nneething-read-only t))
5739 (or (gnus-group-read-ephemeral-group
5741 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5743 (error "Couldn't enter %s" dir)))))
5745 ;; Group sorting commands
5746 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5748 (defun gnus-group-sort-groups (func &optional reverse)
5749 "Sort the group buffer according to FUNC.
5750 If REVERSE, reverse the sorting order."
5751 (interactive (list gnus-group-sort-function
5752 current-prefix-arg))
5754 ((not (listp func)) func)
5756 ((= 1 (length func)) (car func))
5758 ,(gnus-make-sort-function
5759 (reverse func)))))))
5760 ;; We peel off the dummy group from the alist.
5762 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5763 (pop gnus-newsrc-alist))
5765 (setq gnus-newsrc-alist
5766 (sort gnus-newsrc-alist func))
5768 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5769 ;; Regenerate the hash table.
5770 (gnus-make-hashtable-from-newsrc-alist)
5771 (gnus-group-list-groups))))
5773 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5774 "Sort the group buffer alphabetically by group name.
5775 If REVERSE, sort in reverse order."
5777 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5779 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5780 "Sort the group buffer by number of unread articles.
5781 If REVERSE, sort in reverse order."
5783 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5785 (defun gnus-group-sort-groups-by-level (&optional reverse)
5786 "Sort the group buffer by group level.
5787 If REVERSE, sort in reverse order."
5789 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5791 (defun gnus-group-sort-groups-by-score (&optional reverse)
5792 "Sort the group buffer by group score.
5793 If REVERSE, sort in reverse order."
5795 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5797 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5798 "Sort the group buffer by group rank.
5799 If REVERSE, sort in reverse order."
5801 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5803 (defun gnus-group-sort-groups-by-method (&optional reverse)
5804 "Sort the group buffer alphabetically by backend name.
5805 If REVERSE, sort in reverse order."
5807 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5809 (defun gnus-group-sort-by-alphabet (info1 info2)
5810 "Sort alphabetically."
5811 (string< (gnus-info-group info1) (gnus-info-group info2)))
5813 (defun gnus-group-sort-by-unread (info1 info2)
5814 "Sort by number of unread articles."
5815 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5816 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5817 (< (or (and (numberp n1) n1) 0)
5818 (or (and (numberp n2) n2) 0))))
5820 (defun gnus-group-sort-by-level (info1 info2)
5822 (< (gnus-info-level info1) (gnus-info-level info2)))
5824 (defun gnus-group-sort-by-method (info1 info2)
5825 "Sort alphabetically by backend name."
5826 (string< (symbol-name (car (gnus-find-method-for-group
5827 (gnus-info-group info1) info1)))
5828 (symbol-name (car (gnus-find-method-for-group
5829 (gnus-info-group info2) info2)))))
5831 (defun gnus-group-sort-by-score (info1 info2)
5832 "Sort by group score."
5833 (< (gnus-info-score info1) (gnus-info-score info2)))
5835 (defun gnus-group-sort-by-rank (info1 info2)
5836 "Sort by level and score."
5837 (let ((level1 (gnus-info-level info1))
5838 (level2 (gnus-info-level info2)))
5839 (or (< level1 level2)
5840 (and (= level1 level2)
5841 (< (gnus-info-score info1) (gnus-info-score info2))))))
5843 ;; Group catching up.
5845 (defun gnus-group-catchup-current (&optional n all)
5846 "Mark all articles not marked as unread in current newsgroup as read.
5847 If prefix argument N is numeric, the ARG next newsgroups will be
5848 caught up. If ALL is non-nil, marked articles will also be marked as
5849 read. Cross references (Xref: header) of articles are ignored.
5850 The difference between N and actual number of newsgroups that were
5851 caught up is returned."
5853 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5857 "Do you really want to mark all articles as read? "
5858 "Mark all unread articles as read? "))))
5860 (let ((groups (gnus-group-process-prefix n))
5863 ;; Virtual groups have to be given special treatment.
5864 (let ((method (gnus-find-method-for-group (car groups))))
5865 (if (eq 'nnvirtual (car method))
5866 (nnvirtual-catchup-group
5867 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5868 (gnus-group-remove-mark (car groups))
5870 (gnus-group-goto-group (car groups))
5871 (gnus-group-catchup (car groups) all))
5872 (gnus-group-update-group-line)
5873 (setq ret (1+ ret)))
5874 (setq groups (cdr groups)))
5875 (gnus-group-next-unread-group 1)
5878 (defun gnus-group-catchup-current-all (&optional n)
5879 "Mark all articles in current newsgroup as read.
5880 Cross references (Xref: header) of articles are ignored."
5882 (gnus-group-catchup-current n 'all))
5884 (defun gnus-group-catchup (group &optional all)
5885 "Mark all articles in GROUP as read.
5886 If ALL is non-nil, all articles are marked as read.
5887 The return value is the number of articles that were marked as read,
5888 or nil if no action could be taken."
5889 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5891 ;; Do the updating only if the newsgroup isn't killed.
5892 (if (not (numberp (car entry)))
5893 (gnus-message 1 "Can't catch up; non-active group")
5894 ;; Do auto-expirable marks if that's required.
5895 (when (gnus-group-auto-expirable-p group)
5896 (gnus-add-marked-articles
5897 group 'expire (gnus-list-of-unread-articles group))
5899 (let ((marks (nth 3 (nth 2 entry))))
5900 (gnus-add-marked-articles
5901 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5902 (gnus-add-marked-articles
5903 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5905 (gnus-update-read-articles group nil)
5906 ;; Also nix out the lists of marks and dormants.
5908 (gnus-add-marked-articles group 'tick nil nil 'force)
5909 (gnus-add-marked-articles group 'dormant nil nil 'force))
5910 (run-hooks 'gnus-group-catchup-group-hook)
5913 (defun gnus-group-expire-articles (&optional n)
5914 "Expire all expirable articles in the current newsgroup."
5916 (let ((groups (gnus-group-process-prefix n))
5919 (error "No groups to expire"))
5920 (while (setq group (pop groups))
5921 (gnus-group-remove-mark group)
5922 (when (gnus-check-backend-function 'request-expire-articles group)
5923 (gnus-message 6 "Expiring articles in %s..." group)
5924 (let* ((info (gnus-get-info group))
5925 (expirable (if (gnus-group-total-expirable-p group)
5926 (cons nil (gnus-list-of-read-articles group))
5927 (assq 'expire (gnus-info-marks info))))
5928 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5932 (gnus-compress-sequence
5934 ;; We set the expiry variables to the groupp
5936 (let ((nnmail-expiry-wait-function nil)
5937 (nnmail-expiry-wait expiry-wait))
5938 (gnus-request-expire-articles
5939 (gnus-uncompress-sequence (cdr expirable)) group))
5940 ;; Just expire using the normal expiry values.
5941 (gnus-request-expire-articles
5942 (gnus-uncompress-sequence (cdr expirable)) group)))))
5943 (gnus-message 6 "Expiring articles in %s...done" group)))
5944 (gnus-group-position-point))))
5946 (defun gnus-group-expire-all-groups ()
5947 "Expire all expirable articles in all newsgroups."
5950 (gnus-message 5 "Expiring...")
5951 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5952 (cdr gnus-newsrc-alist))))
5953 (gnus-group-expire-articles nil)))
5954 (gnus-group-position-point)
5955 (gnus-message 5 "Expiring...done"))
5957 (defun gnus-group-set-current-level (n level)
5958 "Set the level of the next N groups to LEVEL."
5963 (let ((s (read-string
5964 (format "Level (default %s): "
5965 (or (gnus-group-group-level)
5966 gnus-level-default-subscribed)))))
5967 (if (string-match "^\\s-*$" s)
5968 (int-to-string (or (gnus-group-group-level)
5969 gnus-level-default-subscribed))
5971 (or (and (>= level 1) (<= level gnus-level-killed))
5972 (error "Illegal level: %d" level))
5973 (let ((groups (gnus-group-process-prefix n))
5975 (while (setq group (pop groups))
5976 (gnus-group-remove-mark group)
5977 (gnus-message 6 "Changed level of %s from %d to %d"
5978 group (or (gnus-group-group-level) gnus-level-killed)
5980 (gnus-group-change-level
5981 group level (or (gnus-group-group-level) gnus-level-killed))
5982 (gnus-group-update-group-line)))
5983 (gnus-group-position-point))
5985 (defun gnus-group-unsubscribe-current-group (&optional n)
5986 "Toggle subscription of the current group.
5987 If given numerical prefix, toggle the N next groups."
5989 (let ((groups (gnus-group-process-prefix n))
5992 (setq group (car groups)
5993 groups (cdr groups))
5994 (gnus-group-remove-mark group)
5995 (gnus-group-unsubscribe-group
5996 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
5997 gnus-level-default-unsubscribed
5998 gnus-level-default-subscribed) t)
5999 (gnus-group-update-group-line))
6000 (gnus-group-next-group 1)))
6002 (defun gnus-group-unsubscribe-group (group &optional level silent)
6003 "Toggle subscription to GROUP.
6004 Killed newsgroups are subscribed. If SILENT, don't try to update the
6007 (list (completing-read
6008 "Group: " gnus-active-hashtb nil
6009 (memq gnus-select-method gnus-have-read-active-file))))
6010 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6012 ((string-match "^[ \t]$" group)
6013 (error "Empty group name"))
6015 ;; Toggle subscription flag.
6016 (gnus-group-change-level
6017 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6018 gnus-level-subscribed)
6019 (1+ gnus-level-subscribed)
6020 gnus-level-default-subscribed)))
6022 (gnus-group-update-group group)))
6023 ((and (stringp group)
6024 (or (not (memq gnus-select-method gnus-have-read-active-file))
6025 (gnus-active group)))
6026 ;; Add new newsgroup.
6027 (gnus-group-change-level
6029 (if level level gnus-level-default-subscribed)
6030 (or (and (member group gnus-zombie-list)
6033 (and (gnus-group-group-name)
6034 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6036 (gnus-group-update-group group)))
6037 (t (error "No such newsgroup: %s" group)))
6038 (gnus-group-position-point)))
6040 (defun gnus-group-transpose-groups (n)
6041 "Move the current newsgroup up N places.
6042 If given a negative prefix, move down instead. The difference between
6043 N and the number of steps taken is returned."
6045 (or (gnus-group-group-name)
6046 (error "No group on current line"))
6047 (gnus-group-kill-group 1)
6049 (forward-line (- n))
6050 (gnus-group-yank-group)
6051 (gnus-group-position-point)))
6053 (defun gnus-group-kill-all-zombies ()
6054 "Kill all zombie newsgroups."
6056 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6057 (setq gnus-zombie-list nil)
6058 (gnus-group-list-groups))
6060 (defun gnus-group-kill-region (begin end)
6061 "Kill newsgroups in current region (excluding current point).
6062 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6077 (beginning-of-line) ;Important when LINES < 1
6078 (gnus-group-kill-group lines)))
6080 (defun gnus-group-kill-group (&optional n discard)
6081 "Kill the next N groups.
6082 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6083 However, only groups that were alive can be yanked; already killed
6084 groups or zombie groups can't be yanked.
6085 The return value is the name of the group that was killed, or a list
6088 (let ((buffer-read-only nil)
6089 (groups (gnus-group-process-prefix n))
6090 group entry level out)
6091 (if (< (length groups) 10)
6092 ;; This is faster when there are few groups.
6094 (push (setq group (pop groups)) out)
6095 (gnus-group-remove-mark group)
6096 (setq level (gnus-group-group-level))
6098 (when (and (not discard)
6099 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6100 (push (cons (car entry) (nth 2 entry))
6101 gnus-list-of-killed-groups))
6102 (gnus-group-change-level
6103 (if entry entry group) gnus-level-killed (if entry nil level)))
6104 ;; If there are lots and lots of groups to be killed, we use
6105 ;; this thing instead.
6107 (setq groups (nreverse groups))
6109 (gnus-group-remove-mark (setq group (pop groups)))
6112 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6113 (push (cons (car entry) (nth 2 entry))
6114 gnus-list-of-killed-groups)
6115 (setcdr (cdr entry) (cdddr entry)))
6116 ((member group gnus-zombie-list)
6117 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6118 (gnus-make-hashtable-from-newsrc-alist)))
6120 (gnus-group-position-point)
6121 (if (< (length out) 2) (car out) (nreverse out))))
6123 (defun gnus-group-yank-group (&optional arg)
6124 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6125 inserting it before the current newsgroup. The numeric ARG specifies
6126 how many newsgroups are to be yanked. The name of the newsgroup yanked
6127 is returned, or (if several groups are yanked) a list of yanked groups
6130 (setq arg (or arg 1))
6131 (let (info group prev out)
6132 (while (>= (decf arg) 0)
6133 (if (not (setq info (pop gnus-list-of-killed-groups)))
6134 (error "No more newsgroups to yank"))
6135 (push (setq group (nth 1 info)) out)
6136 ;; Find which newsgroup to insert this one before - search
6137 ;; backward until something suitable is found. If there are no
6138 ;; other newsgroups in this buffer, just make this newsgroup the
6140 (setq prev (gnus-group-group-name))
6141 (gnus-group-change-level
6142 info (gnus-info-level (cdr info)) gnus-level-killed
6143 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6145 (gnus-group-insert-group-line-info group))
6147 (gnus-group-position-point)
6148 (if (< (length out) 2) (car out) (nreverse out))))
6150 (defun gnus-group-kill-level (level)
6151 "Kill all groups that is on a certain LEVEL."
6152 (interactive "nKill all groups on level: ")
6154 ((= level gnus-level-zombie)
6155 (setq gnus-killed-list
6156 (nconc gnus-zombie-list gnus-killed-list))
6157 (setq gnus-zombie-list nil))
6158 ((and (< level gnus-level-zombie)
6160 (or gnus-expert-user
6163 "Do you really want to kill all groups on level %d? "
6165 (let* ((prev gnus-newsrc-alist)
6168 (if (= (gnus-info-level level) level)
6169 (setcdr prev (cdr alist))
6171 (setq alist (cdr alist)))
6172 (gnus-make-hashtable-from-newsrc-alist)
6173 (gnus-group-list-groups)))
6175 (error "Can't kill; illegal level: %d" level))))
6177 (defun gnus-group-list-all-groups (&optional arg)
6178 "List all newsgroups with level ARG or lower.
6179 Default is gnus-level-unsubscribed, which lists all subscribed and most
6180 unsubscribed groups."
6182 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6184 ;; Redefine this to list ALL killed groups if prefix arg used.
6185 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6186 (defun gnus-group-list-killed (&optional arg)
6187 "List all killed newsgroups in the group buffer.
6188 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6189 entail asking the server for the groups."
6191 ;; Find all possible killed newsgroups if arg.
6193 ;; First make sure active file has been read.
6194 (unless gnus-have-read-active-file
6195 (let ((gnus-read-active-file t))
6196 (gnus-read-active-file)))
6197 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6198 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6202 (group (symbol-name sym)))
6203 (if (or (null group)
6204 (gnus-gethash group gnus-killed-hashtb)
6205 (gnus-gethash group gnus-newsrc-hashtb))
6207 (let ((do-sub (gnus-matches-options-n group)))
6208 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6210 (setq groups (1+ groups))
6211 (setq gnus-killed-list
6212 (cons group gnus-killed-list))
6213 (gnus-sethash group group gnus-killed-hashtb))))))
6214 gnus-active-hashtb))
6215 (if (not gnus-killed-list)
6216 (gnus-message 6 "No killed groups")
6217 (let (gnus-group-list-mode)
6218 (funcall gnus-group-prepare-function
6219 gnus-level-killed t gnus-level-killed))
6220 (goto-char (point-min)))
6221 (gnus-group-position-point))
6223 (defun gnus-group-list-zombies ()
6224 "List all zombie newsgroups in the group buffer."
6226 (if (not gnus-zombie-list)
6227 (gnus-message 6 "No zombie groups")
6228 (let (gnus-group-list-mode)
6229 (funcall gnus-group-prepare-function
6230 gnus-level-zombie t gnus-level-zombie))
6231 (goto-char (point-min)))
6232 (gnus-group-position-point))
6234 (defun gnus-group-list-active ()
6235 "List all groups that are available from the server(s)."
6237 ;; First we make sure that we have really read the active file.
6238 (unless gnus-have-read-active-file
6239 (let ((gnus-read-active-file t))
6240 (gnus-read-active-file)))
6241 ;; Find all groups and sort them.
6247 (and (symbol-value sym)
6248 (setq list (cons (symbol-name sym) list))))
6252 (buffer-read-only nil))
6255 (gnus-group-insert-group-line-info (car groups))
6256 (setq groups (cdr groups)))
6257 (goto-char (point-min))))
6259 (defun gnus-activate-all-groups (level)
6260 "Activate absolutely all groups."
6261 (interactive (list 7))
6262 (let ((gnus-activate-level level)
6263 (gnus-activate-foreign-newsgroups level))
6264 (gnus-group-get-new-news)))
6266 (defun gnus-group-get-new-news (&optional arg)
6267 "Get newly arrived articles.
6268 If ARG is a number, it specifies which levels you are interested in
6269 re-scanning. If ARG is non-nil and not a number, this will force
6270 \"hard\" re-reading of the active files from all servers."
6272 (run-hooks 'gnus-get-new-news-hook)
6273 ;; We might read in new NoCeM messages here.
6274 (when (and gnus-use-nocem
6276 (gnus-nocem-scan-groups))
6277 ;; If ARG is not a number, then we read the active file.
6278 (when (and arg (not (numberp arg)))
6279 (let ((gnus-read-active-file t))
6280 (gnus-read-active-file))
6283 (setq arg (gnus-group-default-level arg t))
6284 (if (and gnus-read-active-file (not arg))
6286 (gnus-read-active-file)
6287 (gnus-get-unread-articles arg))
6288 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6289 (gnus-get-unread-articles arg)))
6290 (run-hooks 'gnus-after-getting-new-news-hook)
6291 (gnus-group-list-groups))
6293 (defun gnus-group-get-new-news-this-group (&optional n)
6294 "Check for newly arrived news in the current group (and the N-1 next groups).
6295 The difference between N and the number of newsgroup checked is returned.
6296 If N is negative, this group and the N-1 previous groups will be checked."
6298 (let* ((groups (gnus-group-process-prefix n))
6299 (ret (if (numberp n) (- n (length groups)) 0))
6302 (setq group (car groups)
6303 groups (cdr groups))
6304 (gnus-group-remove-mark group)
6305 (unless (gnus-get-new-news-in-group group)
6307 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6308 (when gnus-goto-next-group-when-activating
6309 (gnus-group-next-unread-group 1 t))
6310 (gnus-summary-position-point)
6313 (defun gnus-get-new-news-in-group (group)
6314 (when (and group (gnus-activate-group group 'scan))
6315 (gnus-get-unread-articles-in-group
6316 (gnus-get-info group) (gnus-active group) t)
6317 (gnus-close-group group)
6318 (when (gnus-group-goto-group group)
6319 (gnus-group-update-group-line))
6322 (defun gnus-group-fetch-faq (group &optional faq-dir)
6323 "Fetch the FAQ for the current group."
6326 (gnus-group-real-name (gnus-group-group-name))
6327 (cond (current-prefix-arg
6329 "Faq dir: " (and (listp gnus-group-faq-directory)
6330 gnus-group-faq-directory))))))
6332 (setq faq-dir (if (listp gnus-group-faq-directory)
6333 (car gnus-group-faq-directory)
6334 gnus-group-faq-directory)))
6335 (or group (error "No group name given"))
6336 (let ((file (concat (file-name-as-directory faq-dir)
6337 (gnus-group-real-name group))))
6338 (if (not (file-exists-p file))
6339 (error "No such file: %s" file)
6342 (defun gnus-group-describe-group (force &optional group)
6343 "Display a description of the current newsgroup."
6344 (interactive (list current-prefix-arg (gnus-group-group-name)))
6345 (and force (setq gnus-description-hashtb nil))
6346 (let ((method (gnus-find-method-for-group group))
6348 (or group (error "No group name given"))
6349 (and (or (and gnus-description-hashtb
6350 ;; We check whether this group's method has been
6351 ;; queried for a description file.
6353 (gnus-group-prefixed-name "" method)
6354 gnus-description-hashtb))
6355 (setq desc (gnus-group-get-description group))
6356 (gnus-read-descriptions-file method))
6358 (or desc (gnus-gethash group gnus-description-hashtb)
6359 "No description available")))))
6361 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6362 (defun gnus-group-describe-all-groups (&optional force)
6363 "Pop up a buffer with descriptions of all newsgroups."
6365 (and force (setq gnus-description-hashtb nil))
6366 (if (not (or gnus-description-hashtb
6367 (gnus-read-all-descriptions-files)))
6368 (error "Couldn't request descriptions file"))
6369 (let ((buffer-read-only nil)
6375 (insert (format " *: %-20s %s\n" (symbol-name group)
6376 (symbol-value group)))
6377 (add-text-properties
6378 b (1+ b) (list 'gnus-group group
6379 'gnus-unread t 'gnus-marked nil
6380 'gnus-level (1+ gnus-level-subscribed))))
6381 gnus-description-hashtb)
6382 (goto-char (point-min))
6383 (gnus-group-position-point)))
6385 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6386 (defun gnus-group-apropos (regexp &optional search-description)
6387 "List all newsgroups that have names that match a regexp."
6388 (interactive "sGnus apropos (regexp): ")
6390 (obuf (current-buffer))
6392 ;; Go through all newsgroups that are known to Gnus.
6395 (and (symbol-name group)
6396 (string-match regexp (symbol-name group))
6397 (setq groups (cons (symbol-name group) groups))))
6399 ;; Also go through all descriptions that are known to Gnus.
6400 (when search-description
6403 (and (string-match regexp (symbol-value group))
6404 (gnus-active (symbol-name group))
6405 (setq groups (cons (symbol-name group) groups))))
6406 gnus-description-hashtb))
6408 (gnus-message 3 "No groups matched \"%s\"." regexp)
6409 ;; Print out all the groups.
6411 (pop-to-buffer "*Gnus Help*")
6412 (buffer-disable-undo (current-buffer))
6414 (setq groups (sort groups 'string<))
6416 ;; Groups may be entered twice into the list of groups.
6417 (if (not (string= (car groups) prev))
6419 (insert (setq prev (car groups)) "\n")
6420 (if (and gnus-description-hashtb
6421 (setq des (gnus-gethash (car groups)
6422 gnus-description-hashtb)))
6423 (insert " " des "\n"))))
6424 (setq groups (cdr groups)))
6425 (goto-char (point-min))))
6426 (pop-to-buffer obuf)))
6428 (defun gnus-group-description-apropos (regexp)
6429 "List all newsgroups that have names or descriptions that match a regexp."
6430 (interactive "sGnus description apropos (regexp): ")
6431 (if (not (or gnus-description-hashtb
6432 (gnus-read-all-descriptions-files)))
6433 (error "Couldn't request descriptions file"))
6434 (gnus-group-apropos regexp t))
6436 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6437 (defun gnus-group-list-matching (level regexp &optional all lowest)
6438 "List all groups with unread articles that match REGEXP.
6439 If the prefix LEVEL is non-nil, it should be a number that says which
6440 level to cut off listing groups.
6441 If ALL, also list groups with no unread articles.
6442 If LOWEST, don't list groups with level lower than LOWEST."
6443 (interactive "P\nsList newsgroups matching: ")
6444 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6445 all (or lowest 1) regexp)
6446 (goto-char (point-min))
6447 (gnus-group-position-point))
6449 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6450 "List all groups that match REGEXP.
6451 If the prefix LEVEL is non-nil, it should be a number that says which
6452 level to cut off listing groups.
6453 If LOWEST, don't list groups with level lower than LOWEST."
6454 (interactive "P\nsList newsgroups matching: ")
6455 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6457 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6458 (defun gnus-group-save-newsrc (&optional force)
6459 "Save the Gnus startup files.
6460 If FORCE, force saving whether it is necessary or not."
6462 (gnus-save-newsrc-file force))
6464 (defun gnus-group-restart (&optional arg)
6465 "Force Gnus to read the .newsrc file."
6467 (when (gnus-yes-or-no-p
6468 (format "Are you sure you want to read %s? "
6469 gnus-current-startup-file))
6470 (gnus-save-newsrc-file)
6471 (gnus-setup-news 'force)
6472 (gnus-group-list-groups arg)))
6474 (defun gnus-group-read-init-file ()
6475 "Read the Gnus elisp init file."
6477 (gnus-read-init-file))
6479 (defun gnus-group-check-bogus-groups (&optional silent)
6480 "Check bogus newsgroups.
6481 If given a prefix, don't ask for confirmation before removing a bogus
6484 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6485 (gnus-group-list-groups))
6487 (defun gnus-group-edit-global-kill (&optional article group)
6488 "Edit the global kill file.
6489 If GROUP, edit that local kill file instead."
6491 (setq gnus-current-kill-article article)
6492 (gnus-kill-file-edit-file group)
6495 (substitute-command-keys
6496 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6497 (if group "local" "global")))))
6499 (defun gnus-group-edit-local-kill (article group)
6500 "Edit a local kill file."
6501 (interactive (list nil (gnus-group-group-name)))
6502 (gnus-group-edit-global-kill article group))
6504 (defun gnus-group-force-update ()
6505 "Update `.newsrc' file."
6507 (gnus-save-newsrc-file))
6509 (defun gnus-group-suspend ()
6510 "Suspend the current Gnus session.
6511 In fact, cleanup buffers except for group mode buffer.
6512 The hook gnus-suspend-gnus-hook is called before actually suspending."
6514 (run-hooks 'gnus-suspend-gnus-hook)
6515 ;; Kill Gnus buffers except for group mode buffer.
6516 (let ((group-buf (get-buffer gnus-group-buffer)))
6517 ;; Do this on a separate list in case the user does a ^G before we finish
6518 (let ((gnus-buffer-list
6519 (delq group-buf (delq gnus-dribble-buffer
6520 (append gnus-buffer-list nil)))))
6521 (while gnus-buffer-list
6522 (gnus-kill-buffer (car gnus-buffer-list))
6523 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6526 (setq gnus-buffer-list (list group-buf))
6527 (bury-buffer group-buf)
6528 (delete-windows-on group-buf t)))))
6530 (defun gnus-group-clear-dribble ()
6531 "Clear all information from the dribble buffer."
6533 (gnus-dribble-clear)
6534 (gnus-message 7 "Cleared dribble buffer"))
6536 (defun gnus-group-exit ()
6537 "Quit reading news after updating .newsrc.eld and .newsrc.
6538 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6541 (or noninteractive ;For gnus-batch-kill
6542 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6543 (not gnus-interactive-exit) ;Without confirmation
6545 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6546 (run-hooks 'gnus-exit-gnus-hook)
6547 ;; Offer to save data from non-quitted summary buffers.
6548 (gnus-offer-save-summaries)
6549 ;; Save the newsrc file(s).
6550 (gnus-save-newsrc-file)
6552 (gnus-close-backends)
6553 ;; Reset everything.
6555 ;; Allow the user to do things after cleaning up.
6556 (run-hooks 'gnus-after-exiting-gnus-hook)))
6558 (defun gnus-close-backends ()
6559 ;; Send a close request to all backends that support such a request.
6560 (let ((methods gnus-valid-select-methods)
6563 (if (fboundp (setq func (intern (concat (caar methods)
6564 "-request-close"))))
6566 (setq methods (cdr methods)))))
6568 (defun gnus-group-quit ()
6569 "Quit reading news without updating .newsrc.eld or .newsrc.
6570 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6572 (when (or noninteractive ;For gnus-batch-kill
6573 (zerop (buffer-size))
6574 (not (gnus-server-opened gnus-select-method))
6576 (not gnus-current-startup-file)
6578 (format "Quit reading news without saving %s? "
6579 (file-name-nondirectory gnus-current-startup-file))))
6580 (run-hooks 'gnus-exit-gnus-hook)
6581 (if gnus-use-full-window
6582 (delete-other-windows)
6583 (gnus-remove-some-windows))
6585 (gnus-close-backends)
6587 ;; Allow the user to do things after cleaning up.
6588 (run-hooks 'gnus-after-exiting-gnus-hook)))
6590 (defun gnus-offer-save-summaries ()
6591 "Offer to save all active summary buffers."
6593 (let ((buflist (buffer-list))
6595 ;; Go through all buffers and find all summaries.
6597 (and (setq bufname (buffer-name (car buflist)))
6598 (string-match "Summary" bufname)
6600 (set-buffer bufname)
6601 ;; We check that this is, indeed, a summary buffer.
6602 (and (eq major-mode 'gnus-summary-mode)
6603 ;; Also make sure this isn't bogus.
6604 gnus-newsgroup-prepared))
6605 (push bufname buffers))
6606 (setq buflist (cdr buflist)))
6607 ;; Go through all these summary buffers and offer to save them.
6610 "Update summary buffer %s? "
6611 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6614 (defun gnus-group-describe-briefly ()
6615 "Give a one line description of the group mode commands."
6617 (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")))
6619 (defun gnus-group-browse-foreign-server (method)
6620 "Browse a foreign news server.
6621 If called interactively, this function will ask for a select method
6622 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6623 If not, METHOD should be a list where the first element is the method
6624 and the second element is the address."
6626 (list (let ((how (completing-read
6628 (append gnus-valid-select-methods gnus-server-alist)
6629 nil t (cons "nntp" 0))))
6630 ;; We either got a backend name or a virtual server name.
6631 ;; If the first, we also need an address.
6632 (if (assoc how gnus-valid-select-methods)
6634 ;; Suggested by mapjph@bath.ac.uk.
6637 (mapcar (lambda (server) (list server))
6638 gnus-secondary-servers)))
6639 ;; We got a server name, so we find the method.
6640 (gnus-server-to-method how)))))
6641 (gnus-browse-foreign-server method))
6645 ;;; Gnus summary mode
6648 (defvar gnus-summary-mode-map nil)
6650 (put 'gnus-summary-mode 'mode-class 'special)
6652 (unless gnus-summary-mode-map
6653 (setq gnus-summary-mode-map (make-keymap))
6654 (suppress-keymap gnus-summary-mode-map)
6656 ;; Non-orthogonal keys
6658 (gnus-define-keys gnus-summary-mode-map
6659 " " gnus-summary-next-page
6660 "\177" gnus-summary-prev-page
6661 [delete] gnus-summary-prev-page
6662 "\r" gnus-summary-scroll-up
6663 "n" gnus-summary-next-unread-article
6664 "p" gnus-summary-prev-unread-article
6665 "N" gnus-summary-next-article
6666 "P" gnus-summary-prev-article
6667 "\M-\C-n" gnus-summary-next-same-subject
6668 "\M-\C-p" gnus-summary-prev-same-subject
6669 "\M-n" gnus-summary-next-unread-subject
6670 "\M-p" gnus-summary-prev-unread-subject
6671 "." gnus-summary-first-unread-article
6672 "," gnus-summary-best-unread-article
6673 "\M-s" gnus-summary-search-article-forward
6674 "\M-r" gnus-summary-search-article-backward
6675 "<" gnus-summary-beginning-of-article
6676 ">" gnus-summary-end-of-article
6677 "j" gnus-summary-goto-article
6678 "^" gnus-summary-refer-parent-article
6679 "\M-^" gnus-summary-refer-article
6680 "u" gnus-summary-tick-article-forward
6681 "!" gnus-summary-tick-article-forward
6682 "U" gnus-summary-tick-article-backward
6683 "d" gnus-summary-mark-as-read-forward
6684 "D" gnus-summary-mark-as-read-backward
6685 "E" gnus-summary-mark-as-expirable
6686 "\M-u" gnus-summary-clear-mark-forward
6687 "\M-U" gnus-summary-clear-mark-backward
6688 "k" gnus-summary-kill-same-subject-and-select
6689 "\C-k" gnus-summary-kill-same-subject
6690 "\M-\C-k" gnus-summary-kill-thread
6691 "\M-\C-l" gnus-summary-lower-thread
6692 "e" gnus-summary-edit-article
6693 "#" gnus-summary-mark-as-processable
6694 "\M-#" gnus-summary-unmark-as-processable
6695 "\M-\C-t" gnus-summary-toggle-threads
6696 "\M-\C-s" gnus-summary-show-thread
6697 "\M-\C-h" gnus-summary-hide-thread
6698 "\M-\C-f" gnus-summary-next-thread
6699 "\M-\C-b" gnus-summary-prev-thread
6700 "\M-\C-u" gnus-summary-up-thread
6701 "\M-\C-d" gnus-summary-down-thread
6702 "&" gnus-summary-execute-command
6703 "c" gnus-summary-catchup-and-exit
6704 "\C-w" gnus-summary-mark-region-as-read
6705 "\C-t" gnus-summary-toggle-truncation
6706 "?" gnus-summary-mark-as-dormant
6707 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6708 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6709 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6710 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6711 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6712 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6713 "=" gnus-summary-expand-window
6714 "\C-x\C-s" gnus-summary-reselect-current-group
6715 "\M-g" gnus-summary-rescan-group
6716 "w" gnus-summary-stop-page-breaking
6717 "\C-c\C-r" gnus-summary-caesar-message
6718 "\M-t" gnus-summary-toggle-mime
6719 "f" gnus-summary-followup
6720 "F" gnus-summary-followup-with-original
6721 "C" gnus-summary-cancel-article
6722 "r" gnus-summary-reply
6723 "R" gnus-summary-reply-with-original
6724 "\C-c\C-f" gnus-summary-mail-forward
6725 "o" gnus-summary-save-article
6726 "\C-o" gnus-summary-save-article-mail
6727 "|" gnus-summary-pipe-output
6728 "\M-k" gnus-summary-edit-local-kill
6729 "\M-K" gnus-summary-edit-global-kill
6731 "\C-c\C-d" gnus-summary-describe-group
6732 "q" gnus-summary-exit
6733 "Q" gnus-summary-exit-no-update
6734 "\C-c\C-i" gnus-info-find-node
6735 gnus-mouse-2 gnus-mouse-pick-article
6736 "m" gnus-summary-mail-other-window
6737 "a" gnus-summary-post-news
6738 "x" gnus-summary-limit-to-unread
6739 "s" gnus-summary-isearch-article
6740 "t" gnus-article-hide-headers
6741 "g" gnus-summary-show-article
6742 "l" gnus-summary-goto-last-article
6743 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6744 "\C-d" gnus-summary-enter-digest-group
6746 "*" gnus-cache-enter-article
6747 "\M-*" gnus-cache-remove-article
6748 "\M-&" gnus-summary-universal-argument
6749 "\C-l" gnus-recenter
6750 "I" gnus-summary-increase-score
6751 "L" gnus-summary-lower-score
6753 "V" gnus-summary-score-map
6754 "X" gnus-uu-extract-map
6755 "S" gnus-summary-send-map)
6757 ;; Sort of orthogonal keymap
6758 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6759 "t" gnus-summary-tick-article-forward
6760 "!" gnus-summary-tick-article-forward
6761 "d" gnus-summary-mark-as-read-forward
6762 "r" gnus-summary-mark-as-read-forward
6763 "c" gnus-summary-clear-mark-forward
6764 " " gnus-summary-clear-mark-forward
6765 "e" gnus-summary-mark-as-expirable
6766 "x" gnus-summary-mark-as-expirable
6767 "?" gnus-summary-mark-as-dormant
6768 "b" gnus-summary-set-bookmark
6769 "B" gnus-summary-remove-bookmark
6770 "#" gnus-summary-mark-as-processable
6771 "\M-#" gnus-summary-unmark-as-processable
6772 "S" gnus-summary-limit-include-expunged
6773 "C" gnus-summary-catchup
6774 "H" gnus-summary-catchup-to-here
6775 "\C-c" gnus-summary-catchup-all
6776 "k" gnus-summary-kill-same-subject-and-select
6777 "K" gnus-summary-kill-same-subject
6778 "P" gnus-uu-mark-map)
6780 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6781 "c" gnus-summary-clear-above
6782 "u" gnus-summary-tick-above
6783 "m" gnus-summary-mark-above
6784 "k" gnus-summary-kill-below)
6786 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6787 "/" gnus-summary-limit-to-subject
6788 "n" gnus-summary-limit-to-articles
6789 "w" gnus-summary-pop-limit
6790 "s" gnus-summary-limit-to-subject
6791 "a" gnus-summary-limit-to-author
6792 "u" gnus-summary-limit-to-unread
6793 "m" gnus-summary-limit-to-marks
6794 "v" gnus-summary-limit-to-score
6795 "D" gnus-summary-limit-include-dormant
6796 "d" gnus-summary-limit-exclude-dormant
6797 ;; "t" gnus-summary-limit-exclude-thread
6798 "E" gnus-summary-limit-include-expunged
6799 "c" gnus-summary-limit-exclude-childless-dormant
6800 "C" gnus-summary-limit-mark-excluded-as-read)
6802 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6803 "n" gnus-summary-next-unread-article
6804 "p" gnus-summary-prev-unread-article
6805 "N" gnus-summary-next-article
6806 "P" gnus-summary-prev-article
6807 "\C-n" gnus-summary-next-same-subject
6808 "\C-p" gnus-summary-prev-same-subject
6809 "\M-n" gnus-summary-next-unread-subject
6810 "\M-p" gnus-summary-prev-unread-subject
6811 "f" gnus-summary-first-unread-article
6812 "b" gnus-summary-best-unread-article
6813 "j" gnus-summary-goto-article
6814 "g" gnus-summary-goto-subject
6815 "l" gnus-summary-goto-last-article
6816 "p" gnus-summary-pop-article)
6818 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6819 "k" gnus-summary-kill-thread
6820 "l" gnus-summary-lower-thread
6821 "i" gnus-summary-raise-thread
6822 "T" gnus-summary-toggle-threads
6823 "t" gnus-summary-rethread-current
6824 "^" gnus-summary-reparent-thread
6825 "s" gnus-summary-show-thread
6826 "S" gnus-summary-show-all-threads
6827 "h" gnus-summary-hide-thread
6828 "H" gnus-summary-hide-all-threads
6829 "n" gnus-summary-next-thread
6830 "p" gnus-summary-prev-thread
6831 "u" gnus-summary-up-thread
6832 "o" gnus-summary-top-thread
6833 "d" gnus-summary-down-thread
6834 "#" gnus-uu-mark-thread
6835 "\M-#" gnus-uu-unmark-thread)
6837 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6838 "c" gnus-summary-catchup-and-exit
6839 "C" gnus-summary-catchup-all-and-exit
6840 "E" gnus-summary-exit-no-update
6841 "Q" gnus-summary-exit
6842 "Z" gnus-summary-exit
6843 "n" gnus-summary-catchup-and-goto-next-group
6844 "R" gnus-summary-reselect-current-group
6845 "G" gnus-summary-rescan-group
6846 "N" gnus-summary-next-group
6847 "P" gnus-summary-prev-group)
6849 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6850 " " gnus-summary-next-page
6851 "n" gnus-summary-next-page
6852 "\177" gnus-summary-prev-page
6853 [delete] gnus-summary-prev-page
6854 "p" gnus-summary-prev-page
6855 "\r" gnus-summary-scroll-up
6856 "<" gnus-summary-beginning-of-article
6857 ">" gnus-summary-end-of-article
6858 "b" gnus-summary-beginning-of-article
6859 "e" gnus-summary-end-of-article
6860 "^" gnus-summary-refer-parent-article
6861 "r" gnus-summary-refer-parent-article
6862 "R" gnus-summary-refer-references
6863 "g" gnus-summary-show-article
6864 "s" gnus-summary-isearch-article)
6866 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6867 "b" gnus-article-add-buttons
6868 "B" gnus-article-add-buttons-to-head
6869 "o" gnus-article-treat-overstrike
6870 ;; "w" gnus-article-word-wrap
6871 "w" gnus-article-fill-cited-article
6872 "c" gnus-article-remove-cr
6873 "L" gnus-article-remove-trailing-blank-lines
6874 "q" gnus-article-de-quoted-unreadable
6875 "f" gnus-article-display-x-face
6876 "l" gnus-summary-stop-page-breaking
6877 "r" gnus-summary-caesar-message
6878 "t" gnus-article-hide-headers
6879 "v" gnus-summary-verbose-headers
6880 "m" gnus-summary-toggle-mime)
6882 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6883 "a" gnus-article-hide
6884 "h" gnus-article-hide-headers
6885 "b" gnus-article-hide-boring-headers
6886 "s" gnus-article-hide-signature
6887 "c" gnus-article-hide-citation
6888 "p" gnus-article-hide-pgp
6889 "\C-c" gnus-article-hide-citation-maybe)
6891 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6892 "a" gnus-article-highlight
6893 "h" gnus-article-highlight-headers
6894 "c" gnus-article-highlight-citation
6895 "s" gnus-article-highlight-signature)
6897 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6898 "z" gnus-article-date-ut
6899 "u" gnus-article-date-ut
6900 "l" gnus-article-date-local
6901 "e" gnus-article-date-lapsed
6902 "o" gnus-article-date-original)
6904 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
6906 "f" gnus-summary-fetch-faq
6907 "d" gnus-summary-describe-group
6908 "h" gnus-summary-describe-briefly
6909 "i" gnus-info-find-node)
6911 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
6912 "e" gnus-summary-expire-articles
6913 "\M-\C-e" gnus-summary-expire-articles-now
6914 "\177" gnus-summary-delete-article
6915 [delete] gnus-summary-delete-article
6916 "m" gnus-summary-move-article
6917 "r" gnus-summary-respool-article
6918 "w" gnus-summary-edit-article
6919 "c" gnus-summary-copy-article
6920 "B" gnus-summary-crosspost-article
6921 "q" gnus-summary-respool-query
6922 "i" gnus-summary-import-article)
6924 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
6925 "o" gnus-summary-save-article
6926 "m" gnus-summary-save-article-mail
6927 "r" gnus-summary-save-article-rmail
6928 "f" gnus-summary-save-article-file
6929 "b" gnus-summary-save-article-body-file
6930 "h" gnus-summary-save-article-folder
6931 "v" gnus-summary-save-article-vm
6932 "p" gnus-summary-pipe-output
6933 "s" gnus-soup-add-article)
6938 (defun gnus-summary-mode (&optional group)
6939 "Major mode for reading articles.
6941 All normal editing commands are switched off.
6942 \\<gnus-summary-mode-map>
6943 Each line in this buffer represents one article. To read an
6944 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6945 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6948 You can also post articles and send mail from this buffer. To
6949 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6950 of an article, type `\\[gnus-summary-reply]'.
6952 There are approx. one gazillion commands you can execute in this
6953 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6955 The following commands are available:
6957 \\{gnus-summary-mode-map}"
6959 (when (and menu-bar-mode
6960 (gnus-visual-p 'summary-menu 'menu))
6961 (gnus-summary-make-menu-bar))
6962 (kill-all-local-variables)
6963 (let ((locals gnus-summary-local-variables))
6965 (if (consp (car locals))
6967 (make-local-variable (caar locals))
6968 (set (caar locals) (eval (cdar locals))))
6969 (make-local-variable (car locals))
6970 (set (car locals) nil))
6971 (setq locals (cdr locals))))
6972 (gnus-make-thread-indent-array)
6973 (gnus-simplify-mode-line)
6974 (setq major-mode 'gnus-summary-mode)
6975 (setq mode-name "Summary")
6976 (make-local-variable 'minor-mode-alist)
6977 (use-local-map gnus-summary-mode-map)
6978 (buffer-disable-undo (current-buffer))
6979 (setq buffer-read-only t) ;Disable modification
6980 (setq truncate-lines t)
6981 (setq selective-display t)
6982 (setq selective-display-ellipses t) ;Display `...'
6983 (setq buffer-display-table gnus-summary-display-table)
6984 (setq gnus-newsgroup-name group)
6985 (run-hooks 'gnus-summary-mode-hook))
6987 (defun gnus-summary-make-display-table ()
6988 ;; Change the display table. Odd characters have a tendency to mess
6989 ;; up nicely formatted displays - we make all possible glyphs
6990 ;; display only a single character.
6992 ;; We start from the standard display table, if any.
6993 (setq gnus-summary-display-table
6994 (or (copy-sequence standard-display-table)
6995 (make-display-table)))
6996 ;; Nix out all the control chars...
6998 (while (>= (setq i (1- i)) 0)
6999 (aset gnus-summary-display-table i [??])))
7000 ;; ... but not newline and cr, of course. (cr is necessary for the
7001 ;; selective display).
7002 (aset gnus-summary-display-table ?\n nil)
7003 (aset gnus-summary-display-table ?\r nil)
7004 ;; We nix out any glyphs over 126 that are not set already.
7006 (while (>= (setq i (1- i)) 127)
7007 ;; Only modify if the entry is nil.
7008 (or (aref gnus-summary-display-table i)
7009 (aset gnus-summary-display-table i [??])))))
7011 (defun gnus-summary-clear-local-variables ()
7012 (let ((locals gnus-summary-local-variables))
7014 (if (consp (car locals))
7015 (and (vectorp (caar locals))
7016 (set (caar locals) nil))
7017 (and (vectorp (car locals))
7018 (set (car locals) nil)))
7019 (setq locals (cdr locals)))))
7021 ;; Summary data functions.
7023 (defmacro gnus-data-number (data)
7026 (defmacro gnus-data-set-number (data number)
7027 `(setcar ,data ,number))
7029 (defmacro gnus-data-mark (data)
7032 (defmacro gnus-data-set-mark (data mark)
7033 `(setcar (nthcdr 1 ,data) ,mark))
7035 (defmacro gnus-data-pos (data)
7038 (defmacro gnus-data-set-pos (data pos)
7039 `(setcar (nthcdr 2 ,data) ,pos))
7041 (defmacro gnus-data-header (data)
7044 (defmacro gnus-data-level (data)
7047 (defmacro gnus-data-unread-p (data)
7048 `(= (nth 1 ,data) gnus-unread-mark))
7050 (defmacro gnus-data-pseudo-p (data)
7051 `(consp (nth 3 ,data)))
7053 (defmacro gnus-data-find (number)
7054 `(assq ,number gnus-newsgroup-data))
7056 (defmacro gnus-data-find-list (number &optional data)
7057 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7058 (memq (assq ,number bdata)
7061 (defmacro gnus-data-make (number mark pos header level)
7062 `(list ,number ,mark ,pos ,header ,level))
7064 (defun gnus-data-enter (after-article number mark pos header level offset)
7065 (let ((data (gnus-data-find-list after-article)))
7066 (or data (error "No such article: %d" after-article))
7067 (setcdr data (cons (gnus-data-make number mark pos header level)
7069 (setq gnus-newsgroup-data-reverse nil)
7070 (gnus-data-update-list (cddr data) offset)))
7072 (defun gnus-data-enter-list (after-article list &optional offset)
7074 (let ((data (and after-article (gnus-data-find-list after-article)))
7076 (or data (not after-article) (error "No such article: %d" after-article))
7077 ;; Find the last element in the list to be spliced into the main
7080 (setq list (cdr list)))
7083 (setcdr list gnus-newsgroup-data)
7084 (setq gnus-newsgroup-data ilist)
7085 (and offset (gnus-data-update-list (cdr list) offset)))
7086 (setcdr list (cdr data))
7088 (and offset (gnus-data-update-list (cdr data) offset)))
7089 (setq gnus-newsgroup-data-reverse nil))))
7091 (defun gnus-data-remove (article &optional offset)
7092 (let ((data gnus-newsgroup-data))
7093 (if (= (gnus-data-number (car data)) article)
7094 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7095 gnus-newsgroup-data-reverse nil)
7097 (and (= (gnus-data-number (cadr data)) article)
7099 (setcdr data (cddr data))
7100 (and offset (gnus-data-update-list (cdr data) offset))
7102 gnus-newsgroup-data-reverse nil)))
7103 (setq data (cdr data))))))
7105 (defmacro gnus-data-list (backward)
7107 (or gnus-newsgroup-data-reverse
7108 (setq gnus-newsgroup-data-reverse
7109 (reverse gnus-newsgroup-data)))
7110 gnus-newsgroup-data))
7112 (defun gnus-data-update-list (data offset)
7113 "Add OFFSET to the POS of all data entries in DATA."
7115 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7116 (setq data (cdr data))))
7118 (defun gnus-data-compute-positions ()
7119 "Compute the positions of all articles."
7120 (let ((data gnus-newsgroup-data)
7123 (when (setq pos (text-property-any
7124 (point-min) (point-max)
7125 'gnus-number (gnus-data-number (car data))))
7126 (gnus-data-set-pos (car data) (+ pos 3)))
7127 (setq data (cdr data)))))
7129 (defun gnus-summary-article-pseudo-p (article)
7130 "Say whether this article is a pseudo article or not."
7131 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7133 (defun gnus-article-parent-p (number)
7134 "Say whether this article is a parent or not."
7135 (let ((data (gnus-data-find-list number)))
7136 (and (cdr data) ; There has to be an article after...
7137 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7138 (gnus-data-level (nth 1 data))))))
7140 (defun gnus-article-children (number)
7141 "Return a list of all children to NUMBER."
7142 (let* ((data (gnus-data-find-list number))
7143 (level (gnus-data-level (car data)))
7145 (setq data (cdr data))
7147 (= (gnus-data-level (car data)) (1+ level)))
7148 (push (gnus-data-number (car data)) children)
7149 (setq data (cdr data)))
7152 (defmacro gnus-summary-skip-intangible ()
7153 "If the current article is intangible, then jump to a different article."
7154 '(let ((to (get-text-property (point) 'gnus-intangible)))
7155 (and to (gnus-summary-goto-subject to))))
7157 (defmacro gnus-summary-article-intangible-p ()
7158 "Say whether this article is intangible or not."
7159 '(get-text-property (point) 'gnus-intangible))
7161 ;; Some summary mode macros.
7163 (defmacro gnus-summary-article-number ()
7164 "The article number of the article on the current line.
7165 If there isn's an article number here, then we return the current
7168 (gnus-summary-skip-intangible)
7169 (or (get-text-property (point) 'gnus-number)
7170 (gnus-summary-last-subject))))
7172 (defmacro gnus-summary-article-header (&optional number)
7173 `(gnus-data-header (gnus-data-find
7174 ,(or number '(gnus-summary-article-number)))))
7176 (defmacro gnus-summary-thread-level (&optional number)
7177 `(if (and (eq gnus-summary-make-false-root 'dummy)
7178 (get-text-property (point) 'gnus-intangible))
7180 (gnus-data-level (gnus-data-find
7181 ,(or number '(gnus-summary-article-number))))))
7183 (defmacro gnus-summary-article-mark (&optional number)
7184 `(gnus-data-mark (gnus-data-find
7185 ,(or number '(gnus-summary-article-number)))))
7187 (defmacro gnus-summary-article-pos (&optional number)
7188 `(gnus-data-pos (gnus-data-find
7189 ,(or number '(gnus-summary-article-number)))))
7191 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7192 (defmacro gnus-summary-article-subject (&optional number)
7193 "Return current subject string or nil if nothing."
7196 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7197 '(gnus-data-header (assq (gnus-summary-article-number)
7198 gnus-newsgroup-data)))))
7201 (mail-header-subject headers))))
7203 (defmacro gnus-summary-article-score (&optional number)
7204 "Return current article score."
7205 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7206 gnus-newsgroup-scored))
7207 gnus-summary-default-score 0))
7209 (defun gnus-summary-article-children (&optional number)
7210 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7211 (level (gnus-data-level (car data)))
7213 (while (and (setq data (cdr data))
7214 (> (setq l (gnus-data-level (car data))) level))
7215 (and (= (1+ level) l)
7216 (setq children (cons (gnus-data-number (car data))
7218 (nreverse children)))
7220 (defun gnus-summary-article-parent (&optional number)
7221 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7222 (gnus-data-list t)))
7223 (level (gnus-data-level (car data))))
7225 () ; This is a root.
7226 ;; We search until we find an article with a level less than
7227 ;; this one. That function has to be the parent.
7228 (while (and (setq data (cdr data))
7229 (not (< (gnus-data-level (car data)) level))))
7230 (and data (gnus-data-number (car data))))))
7232 (defun gnus-unread-mark-p (mark)
7233 "Say whether MARK is the unread mark."
7234 (= mark gnus-unread-mark))
7236 (defun gnus-read-mark-p (mark)
7237 "Say whether MARK is one of the marks that mark as read.
7238 This is all marks except unread, ticked, dormant, and expirable."
7239 (not (or (= mark gnus-unread-mark)
7240 (= mark gnus-ticked-mark)
7241 (= mark gnus-dormant-mark)
7242 (= mark gnus-expirable-mark))))
7244 ;; Various summary mode internalish functions.
7246 (defun gnus-mouse-pick-article (e)
7249 (gnus-summary-next-page nil t))
7251 (defun gnus-summary-setup-buffer (group)
7252 "Initialize summary buffer."
7253 (let ((buffer (concat "*Summary " group "*")))
7254 (if (get-buffer buffer)
7257 (setq gnus-summary-buffer (current-buffer))
7258 (not gnus-newsgroup-prepared))
7259 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7260 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7261 (gnus-add-current-to-buffer-list)
7262 (gnus-summary-mode group)
7264 (gnus-carpal-setup-buffer 'summary))
7265 (unless gnus-single-article-buffer
7266 (make-local-variable 'gnus-article-buffer)
7267 (make-local-variable 'gnus-article-current)
7268 (make-local-variable 'gnus-original-article-buffer))
7269 (setq gnus-newsgroup-name group)
7272 (defun gnus-set-global-variables ()
7273 ;; Set the global equivalents of the summary buffer-local variables
7274 ;; to the latest values they had. These reflect the summary buffer
7275 ;; that was in action when the last article was fetched.
7276 (when (eq major-mode 'gnus-summary-mode)
7277 (setq gnus-summary-buffer (current-buffer))
7278 (let ((name gnus-newsgroup-name)
7279 (marked gnus-newsgroup-marked)
7280 (unread gnus-newsgroup-unreads)
7281 (headers gnus-current-headers)
7282 (data gnus-newsgroup-data)
7283 (summary gnus-summary-buffer)
7284 (article-buffer gnus-article-buffer)
7285 (original gnus-original-article-buffer)
7286 (gac gnus-article-current)
7287 (score-file gnus-current-score-file))
7289 (set-buffer gnus-group-buffer)
7290 (setq gnus-newsgroup-name name)
7291 (setq gnus-newsgroup-marked marked)
7292 (setq gnus-newsgroup-unreads unread)
7293 (setq gnus-current-headers headers)
7294 (setq gnus-newsgroup-data data)
7295 (setq gnus-article-current gac)
7296 (setq gnus-summary-buffer summary)
7297 (setq gnus-article-buffer article-buffer)
7298 (setq gnus-original-article-buffer original)
7299 (setq gnus-current-score-file score-file)))))
7301 (defun gnus-summary-last-article-p (&optional article)
7302 "Return whether ARTICLE is the last article in the buffer."
7303 (if (not (setq article (or article (gnus-summary-article-number))))
7304 t ; All non-existant numbers are the last article. :-)
7305 (cdr (gnus-data-find-list article))))
7307 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7308 "Insert a dummy root in the summary buffer."
7310 (add-text-properties
7311 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7312 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7314 (defvar gnus-thread-indent-array nil)
7315 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7316 (defun gnus-make-thread-indent-array ()
7318 (unless (and gnus-thread-indent-array
7319 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7320 (setq gnus-thread-indent-array (make-vector 201 "")
7321 gnus-thread-indent-array-level gnus-thread-indent-level)
7323 (aset gnus-thread-indent-array n
7324 (make-string (* n gnus-thread-indent-level) ? ))
7327 (defun gnus-summary-insert-line
7328 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7329 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7330 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7331 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7332 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7333 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7334 (gnus-tmp-score-char
7335 (if (or (null gnus-summary-default-score)
7336 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7337 gnus-summary-zcore-fuzz)) ?
7338 (if (< gnus-tmp-score gnus-summary-default-score)
7339 gnus-score-below-mark gnus-score-over-mark)))
7340 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7341 ((memq gnus-tmp-current gnus-newsgroup-cached)
7343 (gnus-tmp-replied gnus-replied-mark)
7344 ((memq gnus-tmp-current gnus-newsgroup-saved)
7346 (t gnus-unread-mark)))
7347 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7350 ((string-match "(.+)" gnus-tmp-from)
7351 (substring gnus-tmp-from
7352 (1+ (match-beginning 0)) (1- (match-end 0))))
7353 ((string-match "<[^>]+> *$" gnus-tmp-from)
7354 (let ((beg (match-beginning 0)))
7355 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7356 (substring gnus-tmp-from (1+ (match-beginning 0))
7357 (1- (match-end 0))))
7358 (substring gnus-tmp-from 0 beg))))
7360 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7361 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7362 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7363 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7364 (buffer-read-only nil))
7365 (when (string= gnus-tmp-name "")
7366 (setq gnus-tmp-name gnus-tmp-from))
7367 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7370 (progn (eval gnus-summary-line-format-spec) (point))
7371 'gnus-number gnus-tmp-number)
7372 (when (gnus-visual-p 'summary-highlight 'highlight)
7374 (run-hooks 'gnus-summary-update-hook)
7377 (defun gnus-summary-update-line (&optional dont-update)
7378 ;; Update summary line after change.
7379 (when (and gnus-summary-default-score
7380 (not gnus-summary-inhibit-highlight))
7381 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7382 (article (gnus-summary-article-number))
7383 (score (gnus-summary-article-score article)))
7385 (if (and gnus-summary-mark-below
7386 (< (gnus-summary-article-score)
7387 gnus-summary-mark-below))
7388 ;; This article has a low score, so we mark it as read.
7389 (when (memq article gnus-newsgroup-unreads)
7390 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7391 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7392 ;; This article was previously marked as read on account
7393 ;; of a low score, but now it has risen, so we mark it as
7395 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7396 (gnus-summary-update-mark
7397 (if (or (null gnus-summary-default-score)
7398 (<= (abs (- score gnus-summary-default-score))
7399 gnus-summary-zcore-fuzz)) ?
7400 (if (< score gnus-summary-default-score)
7401 gnus-score-below-mark gnus-score-over-mark)) 'score))
7402 ;; Do visual highlighting.
7403 (when (gnus-visual-p 'summary-highlight 'highlight)
7404 (run-hooks 'gnus-summary-update-hook)))))
7406 (defvar gnus-tmp-new-adopts nil)
7408 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7409 ;; Sum up all elements (and sub-elements) in a list.
7411 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7413 ((and (consp thread) (cdr thread))
7416 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7419 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7422 (when (and level (zerop level) gnus-tmp-new-adopts)
7425 'gnus-summary-number-of-articles-in-thread
7426 gnus-tmp-new-adopts))))
7428 (if (> number 1) gnus-not-empty-thread-mark
7429 gnus-empty-thread-mark)
7432 (defun gnus-summary-set-local-parameters (group)
7433 "Go through the local params of GROUP and set all variable specs in that list."
7434 (let ((params (gnus-info-params (gnus-get-info group)))
7437 (setq elem (car params)
7438 params (cdr params))
7439 (and (consp elem) ; Has to be a cons.
7440 (consp (cdr elem)) ; The cdr has to be a list.
7441 (symbolp (car elem)) ; Has to be a symbol in there.
7442 (not (memq (car elem)
7443 '(quit-config to-address to-list to-group)))
7444 (progn ; So we set it.
7445 (make-local-variable (car elem))
7446 (set (car elem) (eval (nth 1 elem))))))))
7448 (defun gnus-summary-read-group (group &optional show-all no-article
7449 kill-buffer no-display)
7450 "Start reading news in newsgroup GROUP.
7451 If SHOW-ALL is non-nil, already read articles are also listed.
7452 If NO-ARTICLE is non-nil, no article is selected initially.
7453 If NO-DISPLAY, don't generate a summary buffer."
7454 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7455 (let* ((new-group (gnus-summary-setup-buffer group))
7456 (quit-config (gnus-group-quit-config group))
7457 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7459 ;; This summary buffer exists already, so we just select it.
7461 (gnus-set-global-variables)
7463 (gnus-kill-or-deaden-summary kill-buffer))
7464 (gnus-configure-windows 'summary 'force)
7465 (gnus-set-mode-line 'summary)
7466 (gnus-summary-position-point)
7469 ;; We couldn't select this group.
7471 (when (and (eq major-mode 'gnus-summary-mode)
7472 (not (equal (current-buffer) kill-buffer)))
7473 (kill-buffer (current-buffer))
7474 (if (not quit-config)
7476 (set-buffer gnus-group-buffer)
7477 (gnus-group-jump-to-group group)
7478 (gnus-group-next-unread-group 1))
7479 (if (not (buffer-name (car quit-config)))
7480 (gnus-configure-windows 'group 'force)
7481 (set-buffer (car quit-config))
7482 (and (eq major-mode 'gnus-summary-mode)
7483 (gnus-set-global-variables))
7484 (gnus-configure-windows (cdr quit-config)))))
7485 (gnus-message 3 "Can't select group")
7487 ;; The user did a `C-g' while prompting for number of articles,
7488 ;; so we exit this group.
7489 ((eq did-select 'quit)
7490 (and (eq major-mode 'gnus-summary-mode)
7491 (not (equal (current-buffer) kill-buffer))
7492 (kill-buffer (current-buffer)))
7494 (gnus-kill-or-deaden-summary kill-buffer))
7495 (if (not quit-config)
7497 (set-buffer gnus-group-buffer)
7498 (gnus-group-jump-to-group group)
7499 (gnus-group-next-unread-group 1)
7500 (gnus-configure-windows 'group 'force))
7501 (if (not (buffer-name (car quit-config)))
7502 (gnus-configure-windows 'group 'force)
7503 (set-buffer (car quit-config))
7504 (and (eq major-mode 'gnus-summary-mode)
7505 (gnus-set-global-variables))
7506 (gnus-configure-windows (cdr quit-config))))
7507 ;; Finally signal the quit.
7509 ;; The group was successfully selected.
7511 (gnus-set-global-variables)
7512 ;; Save the active value in effect when the group was entered.
7513 (setq gnus-newsgroup-active
7515 (gnus-active gnus-newsgroup-name)))
7516 ;; You can change the summary buffer in some way with this hook.
7517 (run-hooks 'gnus-select-group-hook)
7518 ;; Set any local variables in the group parameters.
7519 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7520 (gnus-update-format-specifications)
7521 ;; Do score processing.
7522 (when gnus-use-scoring
7523 (gnus-possibly-score-headers))
7524 ;; Check whether to fill in the gaps in the threads.
7525 (when gnus-build-sparse-threads
7526 (gnus-build-sparse-threads))
7527 ;; Find the initial limit.
7529 (let ((gnus-newsgroup-dormant nil))
7530 (gnus-summary-initial-limit show-all))
7531 (gnus-summary-initial-limit show-all))
7532 ;; Generate the summary buffer.
7534 (gnus-summary-prepare))
7535 (when gnus-use-trees
7536 (gnus-tree-open group)
7537 (setq gnus-summary-highlight-line-function
7538 'gnus-tree-highlight-article))
7539 ;; If the summary buffer is empty, but there are some low-scored
7540 ;; articles or some excluded dormants, we include these in the
7542 (when (and (zerop (buffer-size))
7544 (cond (gnus-newsgroup-dormant
7545 (gnus-summary-limit-include-dormant))
7546 ((and gnus-newsgroup-scored show-all)
7547 (gnus-summary-limit-include-expunged))))
7548 ;; Function `gnus-apply-kill-file' must be called in this hook.
7549 (run-hooks 'gnus-apply-kill-hook)
7550 (if (and (zerop (buffer-size))
7553 ;; This newsgroup is empty.
7554 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7555 (gnus-message 6 "No unread news")
7557 (gnus-kill-or-deaden-summary kill-buffer))
7558 ;; Return nil from this function.
7560 ;; Hide conversation thread subtrees. We cannot do this in
7561 ;; gnus-summary-prepare-hook since kill processing may not
7562 ;; work with hidden articles.
7563 (and gnus-show-threads
7564 gnus-thread-hide-subtree
7565 (gnus-summary-hide-all-threads))
7566 ;; Show first unread article if requested.
7567 (if (and (not no-article)
7569 gnus-newsgroup-unreads
7570 gnus-auto-select-first)
7571 (if (eq gnus-auto-select-first 'best)
7572 (gnus-summary-best-unread-article)
7573 (gnus-summary-first-unread-article))
7574 ;; Don't select any articles, just move point to the first
7575 ;; article in the group.
7576 (goto-char (point-min))
7577 (gnus-summary-position-point)
7578 (gnus-set-mode-line 'summary)
7579 (gnus-configure-windows 'summary 'force))
7580 ;; If we are in async mode, we send some info to the backend.
7581 (when gnus-newsgroup-async
7582 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7584 (gnus-kill-or-deaden-summary kill-buffer))
7585 (when (get-buffer-window gnus-group-buffer t)
7586 ;; Gotta use windows, because recenter does wierd stuff if
7587 ;; the current buffer ain't the displayed window.
7588 (let ((owin (selected-window)))
7589 (select-window (get-buffer-window gnus-group-buffer t))
7590 (when (gnus-group-goto-group group)
7592 (select-window owin))))
7593 ;; Mark this buffer as "prepared".
7594 (setq gnus-newsgroup-prepared t)
7597 (defun gnus-summary-prepare ()
7598 "Generate the summary buffer."
7599 (let ((buffer-read-only nil))
7601 (setq gnus-newsgroup-data nil
7602 gnus-newsgroup-data-reverse nil)
7603 (run-hooks 'gnus-summary-generate-hook)
7604 ;; Generate the buffer, either with threads or without.
7605 (when gnus-newsgroup-headers
7606 (gnus-summary-prepare-threads
7607 (if gnus-show-threads
7608 (gnus-sort-gathered-threads
7609 (funcall gnus-summary-thread-gathering-function
7611 (gnus-cut-threads (gnus-make-threads)))))
7612 ;; Unthreaded display.
7613 (gnus-sort-articles gnus-newsgroup-headers))))
7614 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7615 ;; Call hooks for modifying summary buffer.
7616 (goto-char (point-min))
7617 (run-hooks 'gnus-summary-prepare-hook)))
7619 (defun gnus-gather-threads-by-subject (threads)
7620 "Gather threads by looking at Subject headers."
7621 (if (not gnus-summary-make-false-root)
7623 (let ((hashtb (gnus-make-hashtable 1023))
7626 subject hthread whole-subject)
7628 (setq whole-subject (mail-header-subject (caar threads)))
7629 (if (and gnus-summary-gather-exclude-subject
7630 (string-match gnus-summary-gather-exclude-subject
7632 () ; We don't want to do anything with this article.
7633 ;; We simplify the subject before looking it up in the
7637 ;; Truncate the subject.
7638 ((numberp gnus-summary-gather-subject-limit)
7639 (setq subject (gnus-simplify-subject-re whole-subject))
7640 (if (> (length subject) gnus-summary-gather-subject-limit)
7641 (substring subject 0 gnus-summary-gather-subject-limit)
7643 ;; Fuzzily simplify it.
7644 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7645 (gnus-simplify-subject-fuzzy whole-subject))
7646 ;; Just remove the leading "Re:".
7648 (gnus-simplify-subject-re whole-subject))))
7650 (if (setq hthread (gnus-gethash subject hashtb))
7652 ;; We enter a dummy root into the thread, if we
7653 ;; haven't done that already.
7654 (unless (stringp (caar hthread))
7655 (setcar hthread (list whole-subject (car hthread))))
7656 ;; We add this new gathered thread to this gathered
7658 (setcdr (car hthread)
7659 (nconc (cdar hthread) (list (car threads))))
7660 ;; Remove it from the list of threads.
7661 (setcdr prev (cdr threads))
7662 (setq threads prev))
7663 ;; Enter this thread into the hash table.
7664 (gnus-sethash subject threads hashtb)))
7666 (setq threads (cdr threads)))
7669 (defun gnus-gather-threads-by-references (threads)
7670 "Gather threads by looking at References headers."
7671 (let ((idhashtb (gnus-make-hashtable 1023))
7672 (thhashtb (gnus-make-hashtable 1023))
7675 ids references id gthread gid entered)
7677 (when (setq references (mail-header-references (caar threads)))
7678 (setq id (mail-header-id (caar threads)))
7679 (setq ids (gnus-split-references references))
7682 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7684 (gnus-sethash (car ids) id idhashtb)
7685 (gnus-sethash id threads thhashtb))
7686 (setq gthread (gnus-gethash gid thhashtb))
7688 ;; We enter a dummy root into the thread, if we
7689 ;; haven't done that already.
7690 (unless (stringp (caar gthread))
7691 (setcar gthread (list (mail-header-subject (caar gthread))
7693 ;; We add this new gathered thread to this gathered
7695 (setcdr (car gthread)
7696 (nconc (cdar gthread) (list (car threads)))))
7697 ;; Add it into the thread hash table.
7698 (gnus-sethash id gthread thhashtb)
7700 ;; Remove it from the list of threads.
7701 (setcdr prev (cdr threads))
7702 (setq threads prev))
7703 (setq ids (cdr ids))))
7705 (setq threads (cdr threads)))
7708 (defun gnus-sort-gathered-threads (threads)
7709 "Sort subtreads inside each gathered thread by article number."
7710 (let ((result threads))
7712 (when (stringp (caar threads))
7713 (setcdr (car threads)
7714 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7715 (setq threads (cdr threads)))
7718 (defun gnus-make-threads ()
7719 "Go through the dependency hashtb and find the roots. Return all threads."
7723 (unless (car (symbol-value refs))
7724 ;; These threads do not refer back to any other articles,
7725 ;; so they're roots.
7726 (setq threads (append (cdr (symbol-value refs)) threads))))
7727 gnus-newsgroup-dependencies)
7730 (defun gnus-build-sparse-threads ()
7731 (let ((headers gnus-newsgroup-headers)
7732 (deps gnus-newsgroup-dependencies)
7733 header references generation relations
7734 cthread subject child end pthread relation)
7735 ;; First we create an alist of generations/relations, where
7736 ;; generations is how much we trust the ralation, and the relation
7738 (gnus-message 7 "Making sparse threads...")
7740 (nnheader-set-temp-buffer " *gnus sparse threads*")
7741 (while (setq header (pop headers))
7742 (when (and (setq references (mail-header-references header))
7743 (not (string= references "")))
7745 (setq child (mail-header-id header)
7746 subject (mail-header-subject header))
7748 (while (search-backward ">" nil t)
7749 (setq end (1+ (point)))
7750 (when (search-backward "<" nil t)
7751 (push (list (incf generation)
7752 child (setq child (buffer-substring (point) end))
7755 (push (list (1+ generation) child nil subject) relations)
7757 (kill-buffer (current-buffer)))
7758 ;; Sort over trustworthiness.
7759 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7760 (while (setq relation (pop relations))
7761 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7762 (unless (car (symbol-value cthread))
7763 ;; Make this article the parent of these threads.
7764 (setcar (symbol-value cthread)
7765 (vector gnus-reffed-article-number
7769 (or (caddr relation) "") 0 0 "")))
7770 (set cthread (list (vector gnus-reffed-article-number
7772 "" "" (cadr relation)
7773 (or (caddr relation) "") 0 0 ""))))
7774 (push gnus-reffed-article-number gnus-newsgroup-limit)
7775 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7776 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7777 gnus-newsgroup-reads)
7778 (decf gnus-reffed-article-number)
7779 ;; Make this new thread the child of its parent.
7780 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7781 (setcdr (symbol-value pthread)
7782 (nconc (cdr (symbol-value pthread))
7783 (list (symbol-value cthread))))
7784 (set pthread (list nil (symbol-value cthread))))))
7785 (gnus-message 7 "Making sparse threads...done")))
7787 (defun gnus-build-old-threads ()
7788 ;; Look at all the articles that refer back to old articles, and
7789 ;; fetch the headers for the articles that aren't there. This will
7790 ;; build complete threads - if the roots haven't been expired by the
7795 (when (not (car (symbol-value refs)))
7796 (setq heads (cdr (symbol-value refs)))
7798 (if (memq (mail-header-number (caar heads))
7799 gnus-newsgroup-dormant)
7800 (setq heads (cdr heads))
7801 (setq id (symbol-name refs))
7802 (while (and (setq id (gnus-build-get-header id))
7803 (not (car (gnus-gethash
7804 id gnus-newsgroup-dependencies)))))
7805 (setq heads nil)))))
7806 gnus-newsgroup-dependencies)))
7808 (defun gnus-build-get-header (id)
7809 ;; Look through the buffer of NOV lines and find the header to
7810 ;; ID. Enter this line into the dependencies hash table, and return
7811 ;; the id of the parent article (if any).
7812 (let ((deps gnus-newsgroup-dependencies)
7816 (set-buffer nntp-server-buffer)
7817 (goto-char (point-min))
7818 (while (and (not found) (search-forward id nil t))
7820 (setq found (looking-at
7821 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7822 (regexp-quote id))))
7823 (or found (beginning-of-line 2)))
7827 (setq header (gnus-nov-parse-line
7828 (read (current-buffer)) deps))
7829 (gnus-parent-id (mail-header-references header)))))
7831 (let ((number (mail-header-number header)))
7832 (push number gnus-newsgroup-limit)
7833 (push header gnus-newsgroup-headers)
7834 (if (memq number gnus-newsgroup-unselected)
7836 (push number gnus-newsgroup-unreads)
7837 (setq gnus-newsgroup-unselected
7838 (delq number gnus-newsgroup-unselected)))
7839 (push number gnus-newsgroup-ancient)))))))
7841 (defun gnus-summary-update-article (article &optional header)
7842 "Update ARTICLE in the summary buffer."
7843 (let ((id (mail-header-id (gnus-summary-article-header article)))
7844 (data (gnus-data-find article)))
7845 (setcar (gnus-id-to-thread id) nil)
7846 (gnus-summary-insert-subject id)
7847 ;; Set the (possibly) new article number in the data structure.
7848 (gnus-data-set-number data (gnus-id-to-article id))))
7850 (defun gnus-rebuild-thread (id)
7851 "Rebuild the thread containing ID."
7852 (let ((buffer-read-only nil)
7853 current thread data)
7854 (if (not gnus-show-threads)
7855 (setq thread (list (car (gnus-id-to-thread id))))
7856 ;; Get the thread this article is part of.
7857 (setq thread (gnus-remove-thread id)))
7858 (setq current (save-excursion
7859 (and (zerop (forward-line -1))
7860 (gnus-summary-article-number))))
7861 ;; If this is a gathered thread, we have to go some re-gathering.
7862 (when (stringp (car thread))
7863 (let ((subject (car thread))
7865 (setq thread (cdr thread))
7867 (unless (memq (setq thr (gnus-id-to-thread
7869 (mail-header-id (caar thread)))))
7872 (setq thread (cdr thread)))
7873 ;; We now have all (unique) roots.
7874 (if (= (length roots) 1)
7875 ;; All the loose roots are now one solid root.
7876 (setq thread (car roots))
7877 (setq thread (cons subject (gnus-sort-threads roots))))))
7879 ;; We then insert this thread into the summary buffer.
7880 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7881 (gnus-summary-prepare-threads (list thread))
7882 (setq data (nreverse gnus-newsgroup-data))
7883 (setq threads gnus-newsgroup-threads))
7884 ;; We splice the new data into the data structure.
7885 (gnus-data-enter-list current data)
7886 (gnus-data-compute-positions)
7887 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7889 (defun gnus-id-to-thread (id)
7890 "Return the (sub-)thread where ID appears."
7891 (gnus-gethash id gnus-newsgroup-dependencies))
7893 (defun gnus-id-to-article (id)
7894 "Return the article number of ID."
7895 (let ((thread (gnus-id-to-thread id)))
7897 (mail-header-number (car thread)))))
7899 (defun gnus-id-to-header (id)
7900 "Return the article headers of ID."
7901 (car (gnus-id-to-thread id)))
7903 (defun gnus-article-displayed-root-p (article)
7904 "Say whether ARTICLE is a root(ish) article."
7905 (let ((level (gnus-summary-thread-level article))
7911 (null (setq particle (gnus-id-to-article
7913 (mail-header-references
7914 (gnus-summary-article-header article))))))
7915 (null (gnus-summary-thread-level particle)))))))
7917 (defun gnus-root-id (id)
7918 "Return the id of the root of the thread where ID appears."
7920 (while (and id (setq prev (car (gnus-gethash
7921 id gnus-newsgroup-dependencies))))
7923 id (gnus-parent-id (mail-header-references prev))))
7926 (defun gnus-remove-thread (id &optional dont-remove)
7927 "Remove the thread that has ID in it."
7928 (let ((dep gnus-newsgroup-dependencies)
7929 headers thread last-id)
7930 ;; First go up in this thread until we find the root.
7931 (setq last-id (gnus-root-id id))
7932 (setq headers (list (car (gnus-id-to-thread last-id))
7933 (caadr (gnus-id-to-thread last-id))))
7934 ;; We have now found the real root of this thread. It might have
7935 ;; been gathered into some loose thread, so we have to search
7936 ;; through the threads to find the thread we wanted.
7937 (let ((threads gnus-newsgroup-threads)
7940 (setq sub (car threads))
7941 (if (stringp (car sub))
7942 ;; This is a gathered threads, so we look at the roots
7943 ;; below it to find whether this article in in this
7946 (setq sub (cdr sub))
7948 (when (member (caar sub) headers)
7949 (setq thread (car threads)
7952 (setq sub (cdr sub))))
7953 ;; It's an ordinary thread, so we check it.
7954 (when (eq (car sub) (car headers))
7957 (setq threads (cdr threads)))
7958 ;; If this article is in no thread, then it's a root.
7961 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
7962 (setq thread (gnus-gethash last-id dep)))
7965 thread ; We return this thread.
7967 (if (stringp (car thread))
7969 ;; If we use dummy roots, then we have to remove the
7970 ;; dummy root as well.
7971 (when (eq gnus-summary-make-false-root 'dummy)
7974 (setq thread (cdr thread))
7976 (gnus-remove-thread-1 (car thread))
7977 (setq thread (cdr thread))))
7978 (gnus-remove-thread-1 thread))))))))
7980 (defun gnus-remove-thread-1 (thread)
7981 "Remove the thread THREAD recursively."
7982 (let ((number (mail-header-number (car thread)))
7984 (when (setq pos (text-property-any
7985 (point-min) (point-max) 'gnus-number number))
7988 (gnus-data-remove number))
7989 (setq thread (cdr thread))
7991 (gnus-remove-thread-1 (car thread))
7992 (setq thread (cdr thread)))))
7994 (defun gnus-sort-threads (threads)
7996 (if (not gnus-thread-sort-functions)
7998 (let ((func (if (= 1 (length gnus-thread-sort-functions))
7999 (car gnus-thread-sort-functions)
8001 ,(gnus-make-sort-function
8002 (reverse gnus-thread-sort-functions))))))
8003 (gnus-message 7 "Sorting threads...")
8006 (gnus-message 7 "Sorting threads...done")))))
8008 (defun gnus-sort-articles (articles)
8010 (when gnus-article-sort-functions
8011 (let ((func (if (= 1 (length gnus-article-sort-functions))
8012 (car gnus-article-sort-functions)
8014 ,(gnus-make-sort-function
8015 (reverse gnus-article-sort-functions))))))
8016 (gnus-message 7 "Sorting articles...")
8018 (setq gnus-newsgroup-headers (sort articles func))
8019 (gnus-message 7 "Sorting articles...done")))))
8021 (defun gnus-make-sort-function (funs)
8022 "Return a composite sort condition based on the functions in FUNC."
8024 `(or (,(car funs) t1 t2)
8025 (and (not (,(car funs) t2 t1))
8026 ,(gnus-make-sort-function (cdr funs))))
8027 `(,(car funs) t1 t2)))
8029 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8030 (defmacro gnus-thread-header (thread)
8031 ;; Return header of first article in THREAD.
8032 ;; Note that THREAD must never, ever be anything else than a variable -
8033 ;; using some other form will lead to serious barfage.
8034 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8035 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8036 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8039 (defsubst gnus-article-sort-by-number (h1 h2)
8040 "Sort articles by article number."
8041 (< (mail-header-number h1)
8042 (mail-header-number h2)))
8044 (defun gnus-thread-sort-by-number (h1 h2)
8045 "Sort threads by root article number."
8046 (gnus-article-sort-by-number
8047 (gnus-thread-header h1) (gnus-thread-header h2)))
8049 (defsubst gnus-article-sort-by-author (h1 h2)
8050 "Sort articles by root author."
8052 (let ((extract (funcall
8053 gnus-extract-address-components
8054 (mail-header-from h1))))
8055 (or (car extract) (cdr extract)))
8056 (let ((extract (funcall
8057 gnus-extract-address-components
8058 (mail-header-from h2))))
8059 (or (car extract) (cdr extract)))))
8061 (defun gnus-thread-sort-by-author (h1 h2)
8062 "Sort threads by root author."
8063 (gnus-article-sort-by-author
8064 (gnus-thread-header h1) (gnus-thread-header h2)))
8066 (defsubst gnus-article-sort-by-subject (h1 h2)
8067 "Sort articles by root subject."
8069 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8070 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8072 (defun gnus-thread-sort-by-subject (h1 h2)
8073 "Sort threads by root subject."
8074 (gnus-article-sort-by-subject
8075 (gnus-thread-header h1) (gnus-thread-header h2)))
8077 (defsubst gnus-article-sort-by-date (h1 h2)
8078 "Sort articles by root article date."
8080 (gnus-sortable-date (mail-header-date h1))
8081 (gnus-sortable-date (mail-header-date h2))))
8083 (defun gnus-thread-sort-by-date (h1 h2)
8084 "Sort threads by root article date."
8085 (gnus-article-sort-by-date
8086 (gnus-thread-header h1) (gnus-thread-header h2)))
8088 (defsubst gnus-article-sort-by-score (h1 h2)
8089 "Sort articles by root article score.
8090 Unscored articles will be counted as having a score of zero."
8091 (> (or (cdr (assq (mail-header-number h1)
8092 gnus-newsgroup-scored))
8093 gnus-summary-default-score 0)
8094 (or (cdr (assq (mail-header-number h2)
8095 gnus-newsgroup-scored))
8096 gnus-summary-default-score 0)))
8098 (defun gnus-thread-sort-by-score (h1 h2)
8099 "Sort threads by root article score."
8100 (gnus-article-sort-by-score
8101 (gnus-thread-header h1) (gnus-thread-header h2)))
8103 (defun gnus-thread-sort-by-total-score (h1 h2)
8104 "Sort threads by the sum of all scores in the thread.
8105 Unscored articles will be counted as having a score of zero."
8106 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8108 (defun gnus-thread-total-score (thread)
8109 ;; This function find the total score of THREAD.
8111 (if (stringp (car thread))
8112 (apply gnus-thread-score-function 0
8113 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8114 (gnus-thread-total-score-1 thread))
8115 (gnus-thread-total-score-1 (list thread))))
8117 (defun gnus-thread-total-score-1 (root)
8118 ;; This function find the total score of the thread below ROOT.
8119 (setq root (car root))
8120 (apply gnus-thread-score-function
8121 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8122 gnus-summary-default-score 0)
8123 (mapcar 'gnus-thread-total-score
8124 (cdr (gnus-gethash (mail-header-id root)
8125 gnus-newsgroup-dependencies)))))
8127 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8128 (defvar gnus-tmp-prev-subject nil)
8129 (defvar gnus-tmp-false-parent nil)
8130 (defvar gnus-tmp-root-expunged nil)
8131 (defvar gnus-tmp-dummy-line nil)
8133 (defun gnus-summary-prepare-threads (threads)
8134 "Prepare summary buffer from THREADS and indentation LEVEL.
8135 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8136 or a straight list of headers."
8137 (gnus-message 7 "Generating summary...")
8139 (setq gnus-newsgroup-threads threads)
8142 (let ((gnus-tmp-level 0)
8143 (default-score (or gnus-summary-default-score 0))
8144 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8145 thread number subject stack state gnus-tmp-gathered beg-match
8146 new-roots gnus-tmp-new-adopts thread-end
8147 gnus-tmp-header gnus-tmp-unread
8148 gnus-tmp-replied gnus-tmp-subject-or-nil
8149 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8150 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8151 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8153 (setq gnus-tmp-prev-subject nil)
8155 (if (vectorp (car threads))
8156 ;; If this is a straight (sic) list of headers, then a
8157 ;; threaded summary display isn't required, so we just create
8158 ;; an unthreaded one.
8159 (gnus-summary-prepare-unthreaded threads)
8161 ;; Do the threaded display.
8163 (while (or threads stack gnus-tmp-new-adopts new-roots)
8165 (if (and (= gnus-tmp-level 0)
8166 (not (setq gnus-tmp-dummy-line nil))
8169 (not gnus-tmp-false-parent)
8170 (or gnus-tmp-new-adopts new-roots))
8171 (if gnus-tmp-new-adopts
8172 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8173 thread (list (car gnus-tmp-new-adopts))
8174 gnus-tmp-header (caar thread)
8175 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8177 (setq thread (list (car new-roots))
8178 gnus-tmp-header (caar thread)
8179 new-roots (cdr new-roots))))
8182 ;; If there are some threads, we do them before the
8183 ;; threads on the stack.
8184 (setq thread threads
8185 gnus-tmp-header (caar thread))
8186 ;; There were no current threads, so we pop something off
8188 (setq state (car stack)
8189 gnus-tmp-level (car state)
8192 gnus-tmp-header (caar thread))))
8194 (setq gnus-tmp-false-parent nil)
8195 (setq gnus-tmp-root-expunged nil)
8196 (setq thread-end nil)
8198 (if (stringp gnus-tmp-header)
8199 ;; The header is a dummy root.
8201 ((eq gnus-summary-make-false-root 'adopt)
8202 ;; We let the first article adopt the rest.
8203 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8205 (setq gnus-tmp-gathered
8207 (lambda (h) (mail-header-number (car h)))
8210 (setq thread (cons (list (caar thread)
8213 (setq gnus-tmp-level -1
8214 gnus-tmp-false-parent t))
8215 ((eq gnus-summary-make-false-root 'empty)
8216 ;; We print adopted articles with empty subject fields.
8217 (setq gnus-tmp-gathered
8219 (lambda (h) (mail-header-number (car h)))
8222 (setq gnus-tmp-level -1))
8223 ((eq gnus-summary-make-false-root 'dummy)
8224 ;; We remember that we probably want to output a dummy
8226 (setq gnus-tmp-dummy-line gnus-tmp-header)
8227 (setq gnus-tmp-prev-subject gnus-tmp-header))
8229 ;; We do not make a root for the gathered
8230 ;; sub-threads at all.
8231 (setq gnus-tmp-level -1)))
8233 (setq number (mail-header-number gnus-tmp-header)
8234 subject (mail-header-subject gnus-tmp-header))
8237 ;; If the thread has changed subject, we might want to make
8238 ;; this subthread into a root.
8239 ((and (null gnus-thread-ignore-subject)
8240 (not (zerop gnus-tmp-level))
8241 gnus-tmp-prev-subject
8243 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8244 (setq new-roots (nconc new-roots (list (car thread)))
8246 gnus-tmp-header nil))
8247 ;; If the article lies outside the current limit,
8248 ;; then we do not display it.
8249 ((and (not (memq number gnus-newsgroup-limit))
8250 (not gnus-tmp-dummy-line))
8251 (setq gnus-tmp-gathered
8253 (lambda (h) (mail-header-number (car h)))
8256 (setq gnus-tmp-new-adopts (if (cdar thread)
8257 (append gnus-tmp-new-adopts
8259 gnus-tmp-new-adopts)
8261 gnus-tmp-header nil)
8262 (when (zerop gnus-tmp-level)
8263 (setq gnus-tmp-root-expunged t)))
8264 ;; Perhaps this article is to be marked as read?
8265 ((and gnus-summary-mark-below
8266 (< (or (cdr (assq number gnus-newsgroup-scored))
8268 gnus-summary-mark-below)
8269 ;; Don't touch sparse articles.
8270 (not (memq number gnus-newsgroup-sparse)))
8271 (setq gnus-newsgroup-unreads
8272 (delq number gnus-newsgroup-unreads))
8273 (if gnus-newsgroup-auto-expire
8274 (push number gnus-newsgroup-expirable)
8275 (push (cons number gnus-low-score-mark)
8276 gnus-newsgroup-reads))))
8278 (when gnus-tmp-header
8279 ;; We may have an old dummy line to output before this
8281 (when gnus-tmp-dummy-line
8282 (gnus-summary-insert-dummy-line
8283 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8284 (setq gnus-tmp-dummy-line nil))
8286 ;; Compute the mark.
8290 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8291 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8292 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8293 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8294 (t (or (cdr (assq number gnus-newsgroup-reads))
8295 gnus-ancient-mark))))
8297 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8298 gnus-tmp-header gnus-tmp-level)
8299 gnus-newsgroup-data)
8301 ;; Actually insert the line.
8303 gnus-tmp-subject-or-nil
8305 ((and gnus-thread-ignore-subject
8306 gnus-tmp-prev-subject
8307 (not (inline (gnus-subject-equal
8308 gnus-tmp-prev-subject subject))))
8310 ((zerop gnus-tmp-level)
8311 (if (and (eq gnus-summary-make-false-root 'empty)
8312 (memq number gnus-tmp-gathered)
8313 gnus-tmp-prev-subject
8314 (inline (gnus-subject-equal
8315 gnus-tmp-prev-subject subject)))
8316 gnus-summary-same-subject
8318 (t gnus-summary-same-subject)))
8319 (if (and (eq gnus-summary-make-false-root 'adopt)
8320 (= gnus-tmp-level 1)
8321 (memq number gnus-tmp-gathered))
8322 (setq gnus-tmp-opening-bracket ?\<
8323 gnus-tmp-closing-bracket ?\>)
8324 (setq gnus-tmp-opening-bracket ?\[
8325 gnus-tmp-closing-bracket ?\]))
8327 gnus-tmp-indentation
8328 (aref gnus-thread-indent-array gnus-tmp-level)
8329 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8330 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8331 gnus-summary-default-score 0)
8333 (if (or (null gnus-summary-default-score)
8334 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8335 gnus-summary-zcore-fuzz)) ?
8336 (if (< gnus-tmp-score gnus-summary-default-score)
8337 gnus-score-below-mark gnus-score-over-mark))
8339 (cond ((memq number gnus-newsgroup-processable)
8341 ((memq number gnus-newsgroup-cached)
8343 ((memq number gnus-newsgroup-replied)
8345 (t gnus-unread-mark))
8346 gnus-tmp-from (mail-header-from gnus-tmp-header)
8349 ((string-match "(.+)" gnus-tmp-from)
8350 (substring gnus-tmp-from
8351 (1+ (match-beginning 0)) (1- (match-end 0))))
8352 ((string-match "<[^>]+> *$" gnus-tmp-from)
8353 (setq beg-match (match-beginning 0))
8354 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8355 (substring gnus-tmp-from (1+ (match-beginning 0))
8356 (1- (match-end 0))))
8357 (substring gnus-tmp-from 0 beg-match)))
8359 (when (string= gnus-tmp-name "")
8360 (setq gnus-tmp-name gnus-tmp-from))
8361 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8364 (progn (eval gnus-summary-line-format-spec) (point))
8365 'gnus-number number)
8368 (run-hooks 'gnus-summary-update-hook)
8371 (setq gnus-tmp-prev-subject subject)))
8373 (when (nth 1 thread)
8374 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8375 (incf gnus-tmp-level)
8376 (setq threads (if thread-end nil (cdar thread)))
8378 (setq gnus-tmp-level 0)))))
8379 (gnus-message 7 "Generating summary...done"))
8381 (defun gnus-summary-prepare-unthreaded (headers)
8382 "Generate an unthreaded summary buffer based on HEADERS."
8383 (let (header number mark)
8386 (setq header (car headers)
8387 headers (cdr headers)
8388 number (mail-header-number header))
8390 ;; We may have to root out some bad articles...
8391 (when (memq number gnus-newsgroup-limit)
8392 (when (and gnus-summary-mark-below
8393 (< (or (cdr (assq number gnus-newsgroup-scored))
8394 gnus-summary-default-score 0)
8395 gnus-summary-mark-below))
8396 (setq gnus-newsgroup-unreads
8397 (delq number gnus-newsgroup-unreads))
8398 (if gnus-newsgroup-auto-expire
8399 (push number gnus-newsgroup-expirable)
8400 (push (cons number gnus-low-score-mark)
8401 gnus-newsgroup-reads)))
8405 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8406 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8407 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8408 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8409 (t (or (cdr (assq number gnus-newsgroup-reads))
8410 gnus-ancient-mark))))
8411 (setq gnus-newsgroup-data
8412 (cons (gnus-data-make number mark (1+ (point)) header 0)
8413 gnus-newsgroup-data))
8414 (gnus-summary-insert-line
8415 header 0 nil mark (memq number gnus-newsgroup-replied)
8416 (memq number gnus-newsgroup-expirable)
8417 (mail-header-subject header) nil
8418 (cdr (assq number gnus-newsgroup-scored))
8419 (memq number gnus-newsgroup-processable))))))
8421 (defun gnus-select-newsgroup (group &optional read-all)
8422 "Select newsgroup GROUP.
8423 If READ-ALL is non-nil, all articles in the group are selected."
8424 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8425 (info (nth 2 entry))
8426 articles fetched-articles cached)
8428 (or (gnus-check-server
8429 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8430 (error "Couldn't open server"))
8432 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8433 (gnus-activate-group group) ; Or we can activate it...
8434 (progn ; Or we bug out.
8435 (when (equal major-mode 'gnus-summary-mode)
8436 (kill-buffer (current-buffer)))
8437 (error "Couldn't request group %s: %s"
8438 group (gnus-status-message group))))
8440 (setq gnus-newsgroup-name group)
8441 (setq gnus-newsgroup-unselected nil)
8442 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8444 (and gnus-asynchronous
8445 (gnus-check-backend-function
8446 'request-asynchronous gnus-newsgroup-name)
8447 (setq gnus-newsgroup-async
8448 (gnus-request-asynchronous gnus-newsgroup-name)))
8450 ;; Adjust and set lists of article marks.
8452 (gnus-adjust-marked-articles info))
8454 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8455 (when (gnus-virtual-group-p group)
8456 (setq cached gnus-newsgroup-cached))
8458 (setq gnus-newsgroup-unreads
8459 (gnus-set-difference
8460 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8461 gnus-newsgroup-dormant))
8463 (setq gnus-newsgroup-processable nil)
8465 (setq articles (gnus-articles-to-read group read-all))
8469 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8471 ((eq articles 0) nil)
8473 ;; Init the dependencies hash table.
8474 (setq gnus-newsgroup-dependencies
8475 (gnus-make-hashtable (length articles)))
8476 ;; Retrieve the headers and read them in.
8477 (gnus-message 5 "Fetching headers...")
8478 (setq gnus-newsgroup-headers
8480 (setq gnus-headers-retrieved-by
8481 (gnus-retrieve-headers
8482 articles gnus-newsgroup-name
8483 ;; We might want to fetch old headers, but
8484 ;; not if there is only 1 article.
8485 (and gnus-fetch-old-headers
8487 (not (eq gnus-fetch-old-headers 'some))
8488 (not (numberp gnus-fetch-old-headers)))
8489 (> (length articles) 1))))))
8490 (gnus-get-newsgroup-headers-xover articles)
8491 (gnus-get-newsgroup-headers)))
8492 (gnus-message 5 "Fetching headers...done")
8494 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8496 (setq gnus-newsgroup-cached cached))
8498 ;; Set the initial limit.
8499 (setq gnus-newsgroup-limit (copy-sequence articles))
8500 ;; Remove canceled articles from the list of unread articles.
8501 (setq gnus-newsgroup-unreads
8502 (gnus-set-sorted-intersection
8503 gnus-newsgroup-unreads
8504 (setq fetched-articles
8505 (mapcar (lambda (headers) (mail-header-number headers))
8506 gnus-newsgroup-headers))))
8507 ;; Removed marked articles that do not exist.
8508 (gnus-update-missing-marks
8509 (gnus-sorted-complement fetched-articles articles))
8510 ;; We might want to build some more threads first.
8511 (and gnus-fetch-old-headers
8512 (eq gnus-headers-retrieved-by 'nov)
8513 (gnus-build-old-threads))
8514 ;; Check whether auto-expire is to be done in this group.
8515 (setq gnus-newsgroup-auto-expire
8516 (gnus-group-auto-expirable-p group))
8517 ;; Set up the article buffer now, if necessary.
8518 (unless gnus-single-article-buffer
8519 (gnus-article-setup-buffer))
8520 ;; First and last article in this newsgroup.
8521 (and gnus-newsgroup-headers
8522 (setq gnus-newsgroup-begin
8523 (mail-header-number (car gnus-newsgroup-headers)))
8524 (setq gnus-newsgroup-end
8526 (gnus-last-element gnus-newsgroup-headers))))
8527 (setq gnus-reffed-article-number -1)
8528 ;; GROUP is successfully selected.
8529 (or gnus-newsgroup-headers t)))))
8531 (defun gnus-articles-to-read (group read-all)
8532 ;; Find out what articles the user wants to read.
8534 ;; Select all articles if `read-all' is non-nil, or if there
8535 ;; are no unread articles.
8537 (and (zerop (length gnus-newsgroup-marked))
8538 (zerop (length gnus-newsgroup-unreads))))
8539 (gnus-uncompress-range (gnus-active group))
8540 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8541 (copy-sequence gnus-newsgroup-unreads))
8543 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8544 (scored (length scored-list))
8545 (number (length articles))
8546 (marked (+ (length gnus-newsgroup-marked)
8547 (length gnus-newsgroup-dormant)))
8555 ((and (or (<= scored marked) (= scored number))
8556 (numberp gnus-large-newsgroup)
8557 (> number gnus-large-newsgroup))
8561 "How many articles from %s (default %d): "
8562 gnus-newsgroup-name number))))
8563 (if (string-match "^[ \t]*$" input) number input)))
8564 ((and (> scored marked) (< scored number))
8567 (format "%s %s (%d scored, %d total): "
8568 "How many articles from"
8569 group scored number))))
8570 (if (string-match "^[ \t]*$" input)
8574 (setq select (if (stringp select) (string-to-number select) select))
8575 (if (or (null select) (zerop select))
8577 (if (and (not (zerop scored)) (<= (abs select) scored))
8579 (setq articles (sort scored-list '<))
8580 (setq number (length articles)))
8581 (setq articles (copy-sequence articles)))
8583 (if (< (abs select) number)
8585 ;; Select the N oldest articles.
8586 (setcdr (nthcdr (1- (abs select)) articles) nil)
8587 ;; Select the N most recent articles.
8588 (setq articles (nthcdr (- number select) articles))))
8589 (setq gnus-newsgroup-unselected
8590 (gnus-sorted-intersection
8591 gnus-newsgroup-unreads
8592 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8595 (defun gnus-killed-articles (killed articles)
8598 (if (inline (gnus-member-of-range (car articles) killed))
8599 (setq out (cons (car articles) out)))
8600 (setq articles (cdr articles)))
8603 (defun gnus-uncompress-marks (marks)
8604 "Uncompress the mark ranges in MARKS."
8605 (let ((uncompressed '(score bookmark))
8608 (if (memq (caar marks) uncompressed)
8609 (push (car marks) out)
8610 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8611 (setq marks (cdr marks)))
8614 (defun gnus-adjust-marked-articles (info)
8615 "Set all article lists and remove all marks that are no longer legal."
8616 (let* ((marked-lists (gnus-info-marks info))
8617 (active (gnus-active (gnus-info-group info)))
8620 (types gnus-article-mark-lists)
8621 (uncompressed '(score bookmark))
8622 marks var articles article mark)
8625 (setq marks (pop marked-lists))
8626 (set (setq var (intern (format "gnus-newsgroup-%s"
8627 (car (rassq (setq mark (car marks))
8629 (if (memq (car marks) uncompressed) (cdr marks)
8630 (gnus-uncompress-range (cdr marks))))
8632 (setq articles (symbol-value var))
8634 ;; All articles have to be subsets of the active articles.
8636 ;; Adjust "simple" lists.
8637 ((memq mark '(tick dormant expirable reply killed save))
8639 (when (or (< (setq article (pop articles)) min) (> article max))
8640 (set var (delq article (symbol-value var))))))
8642 ((memq mark '(score bookmark))
8644 (when (or (< (car (setq article (pop articles))) min)
8645 (> (car article) max))
8646 (set var (delq article (symbol-value var))))))))))
8648 (defun gnus-update-missing-marks (missing)
8649 "Go through the list of MISSING articles and remove them mark lists."
8651 (let ((types gnus-article-mark-lists)
8653 ;; Go through all types.
8655 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8656 (when (symbol-value var)
8657 ;; This list has articles. So we delete all missing articles
8661 (set var (delq (pop m) (symbol-value var)))))))))
8663 (defun gnus-update-marks ()
8664 "Enter the various lists of marked articles into the newsgroup info list."
8665 (let ((types gnus-article-mark-lists)
8666 (info (gnus-get-info gnus-newsgroup-name))
8667 (uncompressed '(score bookmark killed))
8668 type list newmarked symbol)
8670 ;; Add all marks lists that are non-nil to the list of marks lists.
8672 (setq type (pop types))
8673 (when (setq list (symbol-value
8675 (intern (format "gnus-newsgroup-%s"
8677 (push (cons (cdr type)
8678 (if (memq (cdr type) uncompressed) list
8679 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8682 ;; Enter these new marks into the info of the group.
8684 (setcar (nthcdr 3 info) newmarked)
8685 ;; Add the marks lists to the end of the info.
8687 (setcdr (nthcdr 2 info) (list newmarked))))
8689 ;; Cut off the end of the info if there's nothing else there.
8693 (when (nthcdr (decf i) info)
8694 (setcdr (nthcdr i info) nil)))))))
8696 (defun gnus-add-marked-articles (group type articles &optional info force)
8697 ;; Add ARTICLES of TYPE to the info of GROUP.
8698 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8699 ;; add, but replace marked articles of TYPE with ARTICLES.
8700 (let ((info (or info (gnus-get-info group)))
8701 (uncompressed '(score bookmark killed))
8704 (and (not (setq marked (nthcdr 3 info)))
8706 (setcdr (nthcdr 2 info)
8707 (list (list (cons type (gnus-compress-sequence
8709 (and (not (setq m (assq type (car marked))))
8712 (cons (cons type (gnus-compress-sequence articles t) )
8716 (setcar (nthcdr 3 info)
8717 (delq (assq type (car marked)) (car marked)))
8718 (setcdr m (gnus-compress-sequence articles t)))
8719 (setcdr m (gnus-compress-sequence
8720 (sort (nconc (gnus-uncompress-range m)
8721 (copy-sequence articles)) '<) t))))))
8723 (defun gnus-set-mode-line (where)
8724 "This function sets the mode line of the article or summary buffers.
8725 If WHERE is `summary', the summary mode line format will be used."
8726 ;; Is this mode line one we keep updated?
8727 (when (memq where gnus-updated-mode-lines)
8730 ;; We evaluate this in the summary buffer since these
8731 ;; variables are buffer-local to that buffer.
8732 (set-buffer gnus-summary-buffer)
8733 ;; We bind all these variables that are used in the `eval' form
8735 (let* ((mformat (symbol-value
8737 (format "gnus-%s-mode-line-format-spec" where))))
8738 (gnus-tmp-group-name gnus-newsgroup-name)
8739 (gnus-tmp-article-number (or gnus-current-article 0))
8740 (gnus-tmp-unread gnus-newsgroup-unreads)
8741 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8742 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8743 (gnus-tmp-unread-and-unselected
8744 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8745 (zerop gnus-tmp-unselected)) "")
8746 ((zerop gnus-tmp-unselected)
8747 (format "{%d more}" gnus-tmp-unread-and-unticked))
8748 (t (format "{%d(+%d) more}"
8749 gnus-tmp-unread-and-unticked
8750 gnus-tmp-unselected))))
8752 (if (and gnus-current-headers
8753 (vectorp gnus-current-headers))
8754 (mail-header-subject gnus-current-headers) ""))
8756 gnus-tmp-header);; passed as argument to any user-format-funcs
8757 (setq mode-string (eval mformat))
8758 (setq max-len (max 4 (if gnus-mode-non-string-length
8760 gnus-mode-non-string-length)
8761 (length mode-string))))
8762 ;; We might have to chop a bit of the string off...
8763 (when (> (length mode-string) max-len)
8765 (concat (gnus-truncate-string mode-string (- max-len 3))
8767 ;; Pad the mode string a bit.
8768 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8769 ;; Update the mode line.
8770 (setq mode-line-buffer-identification (list mode-string))
8771 (set-buffer-modified-p t))))
8773 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8774 "Go through the HEADERS list and add all Xrefs to a hash table.
8775 The resulting hash table is returned, or nil if no Xrefs were found."
8776 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8777 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8778 (xref-hashtb (make-vector 63 0))
8779 start group entry number xrefs header)
8781 (setq header (pop headers))
8782 (when (and (setq xrefs (mail-header-xref header))
8783 (not (memq (setq number (mail-header-number header))
8786 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8787 (setq start (match-end 0))
8788 (setq group (concat prefix (substring xrefs (match-beginning 1)
8791 (string-to-int (substring xrefs (match-beginning 2)
8793 (if (setq entry (gnus-gethash group xref-hashtb))
8794 (setcdr entry (cons number (cdr entry)))
8795 (gnus-sethash group (cons number nil) xref-hashtb)))))
8796 (and start xref-hashtb)))
8798 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8799 "Look through all the headers and mark the Xrefs as read."
8800 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8801 name entry info xref-hashtb idlist method nth4)
8803 (set-buffer gnus-group-buffer)
8804 (when (setq xref-hashtb
8805 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8808 (unless (string= from-newsgroup (setq name (symbol-name group)))
8809 (setq idlist (symbol-value group))
8810 ;; Dead groups are not updated.
8812 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8814 (if (stringp (setq nth4 (gnus-info-method info)))
8815 (setq nth4 (gnus-server-to-method nth4))))
8816 ;; Only do the xrefs if the group has the same
8817 ;; select method as the group we have just read.
8818 (or (gnus-methods-equal-p
8819 nth4 (gnus-find-method-for-group from-newsgroup))
8821 (equal nth4 (setq method (gnus-find-method-for-group
8823 (and (equal (car nth4) (car method))
8824 (equal (nth 1 nth4) (nth 1 method))))
8825 gnus-use-cross-reference
8826 (or (not (eq gnus-use-cross-reference t))
8828 ;; Only do cross-references on subscribed
8829 ;; groups, if that is what is wanted.
8830 (<= (gnus-info-level info) gnus-level-subscribed))
8831 (gnus-group-make-articles-read name idlist))))
8834 (defun gnus-group-make-articles-read (group articles)
8836 (entry (gnus-gethash group gnus-newsrc-hashtb))
8837 (info (nth 2 entry))
8838 (active (gnus-active group))
8840 ;; First peel off all illegal article numbers.
8842 (let ((ids articles)
8846 (if (and first (> id (cdr active)))
8848 ;; We'll end up in this situation in one particular
8849 ;; obscure situation. If you re-scan a group and get
8850 ;; a new article that is cross-posted to a different
8851 ;; group that has not been re-scanned, you might get
8852 ;; crossposted article that has a higher number than
8853 ;; Gnus believes possible. So we re-activate this
8854 ;; group as well. This might mean doing the
8855 ;; crossposting thingy will *increase* the number
8856 ;; of articles in some groups. Tsk, tsk.
8857 (setq active (or (gnus-activate-group group) active))))
8858 (if (or (> id (cdr active))
8859 (< id (car active)))
8860 (setq articles (delq id articles)))
8861 (setq ids (cdr ids)))))
8862 ;; If the read list is nil, we init it.
8864 (null (gnus-info-read info))
8866 (gnus-info-set-read info (cons 1 (1- (car active)))))
8867 ;; Then we add the read articles to the range.
8872 (gnus-info-read info) (setq articles (sort articles '<)))))
8873 ;; Then we have to re-compute how many unread
8874 ;; articles there are in this group.
8879 (setq num (- (1+ (cdr active)) (car active))))
8880 ((not (listp (cdr range)))
8881 (setq num (- (cdr active) (- (1+ (cdr range))
8885 (if (numberp (car range))
8887 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
8888 (setq range (cdr range)))
8889 (setq num (- (cdr active) num))))
8890 ;; Update the number of unread articles.
8892 ;; Update the group buffer.
8893 (gnus-group-update-group group t)))))
8895 (defun gnus-methods-equal-p (m1 m2)
8896 (let ((m1 (or m1 gnus-select-method))
8897 (m2 (or m2 gnus-select-method)))
8899 (and (eq (car m1) (car m2))
8900 (or (not (memq 'address (assoc (symbol-name (car m1))
8901 gnus-valid-select-methods)))
8902 (equal (nth 1 m1) (nth 1 m2)))))))
8904 (defsubst gnus-header-value ()
8905 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8907 (defvar gnus-newsgroup-none-id 0)
8909 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8910 (let ((cur nntp-server-buffer)
8913 (save-excursion (set-buffer gnus-summary-buffer)
8914 gnus-newsgroup-dependencies)))
8915 headers id id-dep ref-dep end ref)
8917 (set-buffer nntp-server-buffer)
8918 (let ((case-fold-search t)
8919 in-reply-to header p lines)
8920 (goto-char (point-min))
8921 ;; Search to the beginning of the next header. Error messages
8922 ;; do not begin with 2 or 3.
8923 (while (re-search-forward "^[23][0-9]+ " nil t)
8926 ;; This implementation of this function, with nine
8927 ;; search-forwards instead of the one re-search-forward and
8928 ;; a case (which basically was the old function) is actually
8929 ;; about twice as fast, even though it looks messier. You
8930 ;; can't have everything, I guess. Speed and elegance
8931 ;; doesn't always go hand in hand.
8940 (narrow-to-region (point)
8941 (or (and (search-forward "\n.\n" nil t)
8947 (if (search-forward "\nsubject: " nil t)
8948 (gnus-header-value) "(none)"))
8952 (if (search-forward "\nfrom: " nil t)
8953 (gnus-header-value) "(nobody)"))
8957 (if (search-forward "\ndate: " nil t)
8958 (gnus-header-value) ""))
8962 (if (search-forward "\nmessage-id: " nil t)
8963 (setq id (gnus-header-value))
8964 ;; If there was no message-id, we just fake one to make
8965 ;; subsequent routines simpler.
8966 (setq id (concat "none+"
8968 (setq gnus-newsgroup-none-id
8969 (1+ gnus-newsgroup-none-id)))))))
8973 (if (search-forward "\nreferences: " nil t)
8976 (setq end (match-end 0))
8982 (search-backward ">" end t)
8985 (search-backward "<" end t)
8987 ;; Get the references from the in-reply-to header if there
8988 ;; were no references and the in-reply-to header looks
8990 (if (and (search-forward "\nin-reply-to: " nil t)
8991 (setq in-reply-to (gnus-header-value))
8992 (string-match "<[^>]+>" in-reply-to))
8994 (setq ref (substring in-reply-to (match-beginning 0)
9003 (if (search-forward "\nlines: " nil t)
9004 (if (numberp (setq lines (read cur)))
9010 (and (search-forward "\nxref: " nil t)
9011 (gnus-header-value)))))
9012 ;; We do the threading while we read the headers. The
9013 ;; message-id and the last reference are both entered into
9014 ;; the same hash table. Some tippy-toeing around has to be
9015 ;; done in case an article has arrived before the article
9016 ;; which it refers to.
9017 (if (boundp (setq id-dep (intern id dependencies)))
9018 (if (and (car (symbol-value id-dep))
9020 ;; An article with this Message-ID has already
9021 ;; been seen, so we ignore this one, except we add
9022 ;; any additional Xrefs (in case the two articles
9023 ;; came from different servers).
9025 (mail-header-set-xref
9026 (car (symbol-value id-dep))
9027 (concat (or (mail-header-xref
9028 (car (symbol-value id-dep))) "")
9029 (or (mail-header-xref header) "")))
9031 (setcar (symbol-value id-dep) header))
9032 (set id-dep (list header)))
9034 (if (boundp (setq ref-dep (intern ref dependencies)))
9035 (setcdr (symbol-value ref-dep)
9036 (nconc (cdr (symbol-value ref-dep))
9037 (list (symbol-value id-dep))))
9038 (set ref-dep (list nil (symbol-value id-dep))))
9039 (setq headers (cons header headers)))
9040 (goto-char (point-max))
9042 (nreverse headers)))))
9044 ;; The following macros and functions were written by Felix Lee
9045 ;; <flee@cse.psu.edu>.
9047 (defmacro gnus-nov-read-integer ()
9049 (if (= (following-char) ?\t)
9051 (let ((num (condition-case nil (read buffer) (error nil))))
9052 (if (numberp num) num 0)))
9053 (or (eobp) (forward-char 1))))
9055 (defmacro gnus-nov-skip-field ()
9056 '(search-forward "\t" eol 'move))
9058 (defmacro gnus-nov-field ()
9059 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9061 ;; Goes through the xover lines and returns a list of vectors
9062 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
9063 "Parse the news overview data in the server buffer, and return a
9064 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9065 ;; Get the Xref when the users reads the articles since most/some
9066 ;; NNTP servers do not include Xrefs when using XOVER.
9067 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9068 (let ((cur nntp-server-buffer)
9069 (dependencies gnus-newsgroup-dependencies)
9070 number headers header)
9072 (set-buffer nntp-server-buffer)
9073 ;; Allow the user to mangle the headers before parsing them.
9074 (run-hooks 'gnus-parse-headers-hook)
9075 ;; Allow the user to mangle the headers before parsing them.
9076 (run-hooks 'gnus-parse-headers-hook)
9077 (goto-char (point-min))
9078 (while (and sequence (not (eobp)))
9079 (setq number (read cur))
9080 (while (and sequence (< (car sequence) number))
9081 (setq sequence (cdr sequence)))
9083 (eq number (car sequence))
9085 (setq sequence (cdr sequence))
9087 (inline (gnus-nov-parse-line
9088 number dependencies force-new)))
9089 (setq headers (cons header headers)))))
9091 (setq headers (nreverse headers)))
9094 ;; This function has to be called with point after the article number
9095 ;; on the beginning of the line.
9096 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9098 (eol (gnus-point-at-eol))
9099 (buffer (current-buffer))
9100 header ref id id-dep ref-dep)
9102 ;; overview: [num subject from date id refs chars lines misc]
9103 (narrow-to-region (point) eol)
9104 (or (eobp) (forward-char))
9110 (gnus-nov-field) ; subject
9111 (gnus-nov-field) ; from
9112 (gnus-nov-field) ; date
9113 (setq id (or (gnus-nov-field)
9116 (setq none (1+ none)))))) ; id
9119 (let ((beg (point)))
9120 (search-forward "\t" eol)
9121 (if (search-backward ">" beg t)
9125 (search-backward "<" beg t)))
9127 (gnus-nov-field)) ; refs
9128 (gnus-nov-read-integer) ; chars
9129 (gnus-nov-read-integer) ; lines
9130 (if (= (following-char) ?\n)
9132 (gnus-nov-field)) ; misc
9136 (gnus-message 4 "Strange nov line")
9142 ;; We build the thread tree.
9144 (if (boundp (setq id-dep (intern id dependencies)))
9145 (if (and (car (symbol-value id-dep))
9147 ;; An article with this Message-ID has already been seen,
9148 ;; so we ignore this one, except we add any additional
9149 ;; Xrefs (in case the two articles came from different
9152 (mail-header-set-xref
9153 (car (symbol-value id-dep))
9154 (concat (or (mail-header-xref
9155 (car (symbol-value id-dep))) "")
9156 (or (mail-header-xref header) "")))
9158 (setcar (symbol-value id-dep) header))
9159 (set id-dep (list header))))
9162 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9163 (setcdr (symbol-value ref-dep)
9164 (nconc (cdr (symbol-value ref-dep))
9165 (list (symbol-value id-dep))))
9166 (set ref-dep (list nil (symbol-value id-dep))))))
9169 (defun gnus-article-get-xrefs ()
9170 "Fill in the Xref value in `gnus-current-headers', if necessary.
9171 This is meant to be called in `gnus-article-internal-prepare-hook'."
9172 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9173 gnus-current-headers)))
9174 (or (not gnus-use-cross-reference)
9176 (and (mail-header-xref headers)
9177 (not (string= (mail-header-xref headers) "")))
9178 (let ((case-fold-search t)
9181 (nnheader-narrow-to-headers)
9182 (goto-char (point-min))
9183 (if (or (and (eq (downcase (following-char)) ?x)
9184 (looking-at "Xref:"))
9185 (search-forward "\nXref:" nil t))
9187 (goto-char (1+ (match-end 0)))
9188 (setq xref (buffer-substring (point)
9189 (progn (end-of-line) (point))))
9190 (mail-header-set-xref headers xref))))))))
9192 (defun gnus-summary-insert-subject (id)
9193 "Find article ID and insert the summary line for that article."
9194 (let ((header (gnus-read-header id))
9195 (number (and (numberp id) id)))
9197 ;; Rebuild the thread that this article is part of and go to the
9198 ;; article we have fetched.
9199 (gnus-rebuild-thread (mail-header-id header))
9200 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9201 (when (and (numberp number)
9203 ;; We have to update the boundaries even if we can't fetch the
9204 ;; article if ID is a number -- so that the next `P' or `N'
9205 ;; command will fetch the previous (or next) article even
9206 ;; if the one we tried to fetch this time has been canceled.
9207 (and (> number gnus-newsgroup-end)
9208 (setq gnus-newsgroup-end number))
9209 (and (< number gnus-newsgroup-begin)
9210 (setq gnus-newsgroup-begin number))
9211 (setq gnus-newsgroup-unselected
9212 (delq number gnus-newsgroup-unselected)))
9213 ;; Report back a success?
9214 (and header number)))
9216 (defun gnus-summary-work-articles (n)
9217 "Return a list of articles to be worked upon. The prefix argument,
9218 the list of process marked articles, and the current article will be
9219 taken into consideration."
9221 ((and n (numberp n))
9222 ;; A numerical prefix has been given.
9223 (let ((backward (< n 0))
9229 (push (setq article (gnus-summary-article-number))
9232 (gnus-summary-find-prev nil article)
9233 (gnus-summary-find-next nil article)))
9235 (nreverse articles)))
9236 ((and (boundp 'transient-mark-mode)
9239 ;; Work on the region between point and mark.
9240 (let ((max (max (point) (mark)))
9243 (goto-char (min (point) (mark)))
9246 (push (setq article (gnus-summary-article-number)) articles)
9247 (gnus-summary-find-next nil article)
9249 (nreverse articles))))
9250 (gnus-newsgroup-processable
9251 ;; There are process-marked articles present.
9252 (reverse gnus-newsgroup-processable))
9254 ;; Just return the current article.
9255 (list (gnus-summary-article-number)))))
9257 (defun gnus-summary-search-group (&optional backward use-level)
9258 "Search for next unread newsgroup.
9259 If optional argument BACKWARD is non-nil, search backward instead."
9261 (set-buffer gnus-group-buffer)
9262 (if (gnus-group-search-forward
9263 backward nil (if use-level (gnus-group-group-level) nil))
9264 (gnus-group-group-name))))
9266 (defun gnus-summary-best-group (&optional exclude-group)
9267 "Find the name of the best unread group.
9268 If EXCLUDE-GROUP, do not go to this group."
9270 (set-buffer gnus-group-buffer)
9272 (gnus-group-best-unread-group exclude-group))))
9274 (defun gnus-summary-find-next (&optional unread article backward)
9275 (if backward (gnus-summary-find-prev)
9276 (let* ((article (or article (gnus-summary-article-number)))
9277 (arts (gnus-data-find-list article))
9279 (when (or (not gnus-summary-check-current)
9281 (not (gnus-data-unread-p (car arts))))
9282 (setq arts (cdr arts)))
9287 (when (gnus-data-unread-p (car arts))
9288 (setq result (car arts)
9290 (setq arts (cdr arts)))
9293 (goto-char (gnus-data-pos result))
9294 (gnus-data-number result)))))
9296 (defun gnus-summary-find-prev (&optional unread article)
9297 (let* ((article (or article (gnus-summary-article-number)))
9298 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9300 (when (or (not gnus-summary-check-current)
9302 (not (gnus-data-unread-p (car arts))))
9303 (setq arts (cdr arts)))
9308 (and (gnus-data-unread-p (car arts))
9309 (setq result (car arts)
9311 (setq arts (cdr arts)))
9315 (goto-char (gnus-data-pos result))
9316 (gnus-data-number result)))))
9318 (defun gnus-summary-find-subject (subject &optional unread backward article)
9319 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9320 (article (or article (gnus-summary-article-number)))
9321 (articles (gnus-data-list backward))
9322 (arts (gnus-data-find-list article articles))
9324 (when (or (not gnus-summary-check-current)
9326 (not (gnus-data-unread-p (car arts))))
9327 (setq arts (cdr arts)))
9329 (and (or (not unread)
9330 (gnus-data-unread-p (car arts)))
9331 (vectorp (gnus-data-header (car arts)))
9333 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9334 (setq result (car arts)
9336 (setq arts (cdr arts)))
9338 (goto-char (gnus-data-pos result))
9339 (gnus-data-number result))))
9341 (defun gnus-summary-search-forward (&optional unread subject backward)
9342 "Search forward for an article.
9343 If UNREAD, look for unread articles. If SUBJECT, look for
9344 articles with that subject. If BACKWARD, search backward instead."
9345 (cond (subject (gnus-summary-find-subject subject unread backward))
9346 (backward (gnus-summary-find-prev unread))
9347 (t (gnus-summary-find-next unread))))
9349 (defun gnus-recenter (&optional n)
9350 "Center point in window and redisplay frame.
9351 Also do horizontal recentering."
9353 (when (and gnus-auto-center-summary
9354 (not (eq gnus-auto-center-summary 'vertical)))
9355 (gnus-horizontal-recenter))
9358 (defun gnus-summary-recenter ()
9359 "Center point in the summary window.
9360 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9361 displayed, no centering will be performed."
9362 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9363 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9364 (let* ((top (cond ((< (window-height) 4) 0)
9365 ((< (window-height) 7) 1)
9367 (height (1- (window-height)))
9368 (bottom (save-excursion (goto-char (point-max))
9369 (forward-line (- height))
9371 (window (get-buffer-window (current-buffer))))
9372 ;; The user has to want it.
9373 (when gnus-auto-center-summary
9374 (when (get-buffer-window gnus-article-buffer)
9375 ;; Only do recentering when the article buffer is displayed,
9376 ;; Set the window start to either `bottom', which is the biggest
9377 ;; possible valid number, or the second line from the top,
9378 ;; whichever is the least.
9380 window (min bottom (save-excursion
9381 (forward-line (- top)) (point)))))
9382 ;; Do horizontal recentering while we're at it.
9383 (when (and (get-buffer-window (current-buffer) t)
9384 (not (eq gnus-auto-center-summary 'vertical)))
9385 (let ((selected (selected-window)))
9386 (select-window (get-buffer-window (current-buffer) t))
9387 (gnus-summary-position-point)
9388 (gnus-horizontal-recenter)
9389 (select-window selected))))))
9391 (defun gnus-horizontal-recenter ()
9392 "Recenter the current buffer horizontally."
9393 (if (< (current-column) (/ (window-width) 2))
9394 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9395 (let* ((orig (point))
9396 (end (window-end (get-buffer-window (current-buffer) t)))
9398 ;; Find the longest line currently displayed in the window.
9399 (goto-char (window-start))
9400 (while (and (not (eobp))
9403 (setq max (max max (current-column)))
9406 ;; Scroll horizontally to center (sort of) the point.
9407 (if (> max (window-width))
9409 (get-buffer-window (current-buffer) t)
9410 (min (- (current-column) (/ (window-width) 3))
9411 (+ 2 (- max (window-width)))))
9412 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9415 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9416 (defun gnus-short-group-name (group &optional levels)
9417 "Collapse GROUP name LEVELS."
9424 (while (string-match "\\." group skip)
9425 (setq skip (match-end 0)
9428 (if (string-match ":" group)
9429 (setq foreign (substring group 0 (match-end 0))
9430 group (substring group (match-end 0))))
9432 (if (and (string-match "\\." group)
9433 (> levels (- gnus-group-uncollapsed-levels 1)))
9434 (setq name (concat name (substring group 0 1))
9435 group (substring group (match-end 0))
9437 name (concat name "."))
9438 (setq name (concat foreign name group)
9442 (defun gnus-summary-jump-to-group (newsgroup)
9443 "Move point to NEWSGROUP in group mode buffer."
9444 ;; Keep update point of group mode buffer if visible.
9445 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9446 (save-window-excursion
9447 ;; Take care of tree window mode.
9448 (if (get-buffer-window gnus-group-buffer)
9449 (pop-to-buffer gnus-group-buffer))
9450 (gnus-group-jump-to-group newsgroup))
9452 ;; Take care of tree window mode.
9453 (if (get-buffer-window gnus-group-buffer)
9454 (pop-to-buffer gnus-group-buffer)
9455 (set-buffer gnus-group-buffer))
9456 (gnus-group-jump-to-group newsgroup))))
9458 ;; This function returns a list of article numbers based on the
9459 ;; difference between the ranges of read articles in this group and
9460 ;; the range of active articles.
9461 (defun gnus-list-of-unread-articles (group)
9462 (let* ((read (gnus-info-read (gnus-get-info group)))
9463 (active (gnus-active group))
9466 ;; If none are read, then all are unread.
9468 (setq first (car active))
9469 ;; If the range of read articles is a single range, then the
9470 ;; first unread article is the article after the last read
9471 ;; article. Sounds logical, doesn't it?
9472 (if (not (listp (cdr read)))
9473 (setq first (1+ (cdr read)))
9474 ;; `read' is a list of ranges.
9475 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9480 (while (< first nlast)
9481 (setq unread (cons first unread))
9482 (setq first (1+ first))))
9483 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9484 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9485 (setq read (cdr read)))))
9486 ;; And add the last unread articles.
9487 (while (<= first last)
9488 (setq unread (cons first unread))
9489 (setq first (1+ first)))
9490 ;; Return the list of unread articles.
9493 (defun gnus-list-of-read-articles (group)
9494 "Return a list of unread, unticked and non-dormant articles."
9495 (let* ((info (gnus-get-info group))
9496 (marked (gnus-info-marks info))
9497 (active (gnus-active group)))
9499 (gnus-set-difference
9500 (gnus-sorted-complement
9501 (gnus-uncompress-range active)
9502 (gnus-list-of-unread-articles group))
9504 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9505 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9507 ;; Various summary commands
9509 (defun gnus-summary-universal-argument (arg)
9510 "Perform any operation on all articles that are process/prefixed."
9512 (gnus-set-global-variables)
9513 (let ((articles (gnus-summary-work-articles arg))
9520 (substitute-command-keys
9521 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9525 (message "Undefined key")
9529 (gnus-summary-goto-subject (setq article (pop articles)))
9530 (command-execute func)
9531 (gnus-summary-remove-process-mark article)))))
9532 (gnus-summary-position-point))
9534 (defun gnus-summary-toggle-truncation (&optional arg)
9535 "Toggle truncation of summary lines.
9536 With arg, turn line truncation on iff arg is positive."
9538 (setq truncate-lines
9539 (if (null arg) (not truncate-lines)
9540 (> (prefix-numeric-value arg) 0)))
9543 (defun gnus-summary-reselect-current-group (&optional all rescan)
9544 "Exit and then reselect the current newsgroup.
9545 The prefix argument ALL means to select all articles."
9547 (gnus-set-global-variables)
9548 (let ((current-subject (gnus-summary-article-number))
9549 (group gnus-newsgroup-name))
9550 (setq gnus-newsgroup-begin nil)
9552 ;; We have to adjust the point of group mode buffer because the
9553 ;; current point was moved to the next unread newsgroup by
9555 (gnus-summary-jump-to-group group)
9558 (gnus-group-get-new-news-this-group 1)))
9559 (gnus-group-read-group all t)
9560 (gnus-summary-goto-subject current-subject)))
9562 (defun gnus-summary-rescan-group (&optional all)
9563 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9565 (gnus-summary-reselect-current-group all t))
9567 (defun gnus-summary-update-info ()
9568 (let* ((group gnus-newsgroup-name))
9569 (when gnus-newsgroup-kill-headers
9570 (setq gnus-newsgroup-killed
9571 (gnus-compress-sequence
9573 (gnus-set-sorted-intersection
9574 (gnus-uncompress-range gnus-newsgroup-killed)
9575 (setq gnus-newsgroup-unselected
9576 (sort gnus-newsgroup-unselected '<)))
9577 (setq gnus-newsgroup-unreads
9578 (sort gnus-newsgroup-unreads '<))) t)))
9579 (unless (listp (cdr gnus-newsgroup-killed))
9580 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9581 (let ((headers gnus-newsgroup-headers))
9582 (run-hooks 'gnus-exit-group-hook)
9583 (unless gnus-save-score
9584 (setq gnus-newsgroup-scored nil))
9585 ;; Set the new ranges of read articles.
9586 (gnus-update-read-articles
9587 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9588 ;; Set the current article marks.
9590 ;; Do the cross-ref thing.
9591 (when gnus-use-cross-reference
9592 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9593 ;; Do adaptive scoring, and possibly save score files.
9594 (when gnus-newsgroup-adaptive
9595 (gnus-score-adaptive))
9596 (when gnus-use-scoring
9598 ;; Do not switch windows but change the buffer to work.
9599 (set-buffer gnus-group-buffer)
9600 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9601 (gnus-group-update-group group)))))
9603 (defun gnus-summary-exit (&optional temporary)
9604 "Exit reading current newsgroup, and then return to group selection mode.
9605 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9607 (gnus-set-global-variables)
9608 (gnus-kill-save-kill-buffer)
9609 (let* ((group gnus-newsgroup-name)
9610 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9612 (buf (current-buffer)))
9613 (run-hooks 'gnus-summary-prepare-exit-hook)
9614 ;; If we have several article buffers, we kill them at exit.
9615 (unless gnus-single-article-buffer
9616 (gnus-kill-buffer gnus-article-buffer)
9617 (gnus-kill-buffer gnus-original-article-buffer))
9618 (when gnus-use-cache
9619 (gnus-cache-possibly-remove-articles)
9620 (gnus-cache-save-buffers))
9621 (when gnus-use-trees
9622 (gnus-tree-close group))
9623 ;; Make all changes in this group permanent.
9625 (gnus-summary-update-info))
9626 (gnus-close-group group)
9627 ;; Make sure where I was, and go to next newsgroup.
9628 (set-buffer gnus-group-buffer)
9630 (gnus-group-jump-to-group group)
9631 (gnus-group-next-unread-group 1))
9632 (run-hooks 'gnus-summary-exit-hook)
9635 ;; If we have several article buffers, we kill them at exit.
9636 (unless gnus-single-article-buffer
9637 (gnus-kill-buffer gnus-article-buffer)
9638 (gnus-kill-buffer gnus-original-article-buffer))
9640 (if (not gnus-kill-summary-on-exit)
9641 (gnus-deaden-summary)
9642 ;; We set all buffer-local variables to nil. It is unclear why
9643 ;; this is needed, but if we don't, buffer-local variables are
9644 ;; not garbage-collected, it seems. This would the lead to en
9645 ;; ever-growing Emacs.
9646 (gnus-summary-clear-local-variables)
9647 (when (get-buffer gnus-article-buffer)
9648 (bury-buffer gnus-article-buffer))
9649 ;; We clear the global counterparts of the buffer-local
9650 ;; variables as well, just to be on the safe side.
9651 (gnus-configure-windows 'group 'force)
9652 (gnus-summary-clear-local-variables)
9653 ;; Return to group mode buffer.
9654 (if (eq mode 'gnus-summary-mode)
9655 (gnus-kill-buffer buf)))
9656 (setq gnus-current-select-method gnus-select-method)
9657 (pop-to-buffer gnus-group-buffer)
9658 ;; Clear the current group name.
9659 (if (not quit-config)
9661 (gnus-group-jump-to-group group)
9662 (gnus-group-next-unread-group 1)
9663 (gnus-configure-windows 'group 'force))
9664 (if (not (buffer-name (car quit-config)))
9665 (gnus-configure-windows 'group 'force)
9666 (set-buffer (car quit-config))
9667 (and (eq major-mode 'gnus-summary-mode)
9668 (gnus-set-global-variables))
9669 (gnus-configure-windows (cdr quit-config))))
9671 (setq gnus-newsgroup-name nil)))))
9673 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9674 (defun gnus-summary-exit-no-update (&optional no-questions)
9675 "Quit reading current newsgroup without updating read article info."
9677 (gnus-set-global-variables)
9678 (let* ((group gnus-newsgroup-name)
9679 (quit-config (gnus-group-quit-config group)))
9680 (when (or no-questions
9682 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9683 ;; If we have several article buffers, we kill them at exit.
9684 (unless gnus-single-article-buffer
9685 (gnus-kill-buffer gnus-article-buffer)
9686 (gnus-kill-buffer gnus-original-article-buffer))
9687 (if (not gnus-kill-summary-on-exit)
9688 (gnus-deaden-summary)
9689 (gnus-close-group group)
9690 (gnus-summary-clear-local-variables)
9691 (set-buffer gnus-group-buffer)
9692 (gnus-summary-clear-local-variables)
9693 (when (get-buffer gnus-summary-buffer)
9694 (kill-buffer gnus-summary-buffer)))
9695 (when gnus-use-trees
9696 (gnus-tree-close group))
9697 (when (get-buffer gnus-article-buffer)
9698 (bury-buffer gnus-article-buffer))
9699 ;; Return to the group buffer.
9700 (gnus-configure-windows 'group 'force)
9701 ;; Clear the current group name.
9702 (setq gnus-newsgroup-name nil)
9703 (when (equal (gnus-group-group-name) group)
9704 (gnus-group-next-unread-group 1))
9706 (if (not (buffer-name (car quit-config)))
9707 (gnus-configure-windows 'group 'force)
9708 (set-buffer (car quit-config))
9709 (when (eq major-mode 'gnus-summary-mode)
9710 (gnus-set-global-variables))
9711 (gnus-configure-windows (cdr quit-config)))))))
9715 (defvar gnus-dead-summary-mode-map nil)
9717 (if gnus-dead-summary-mode-map
9719 (setq gnus-dead-summary-mode-map (make-keymap))
9720 (suppress-keymap gnus-dead-summary-mode-map)
9721 (substitute-key-definition
9722 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9723 (let ((keys '("\C-d" "\r" "\177")))
9725 (define-key gnus-dead-summary-mode-map
9726 (pop keys) 'gnus-summary-wake-up-the-dead))))
9728 (defvar gnus-dead-summary-mode nil
9729 "Minor mode for Gnus summary buffers.")
9731 (defun gnus-dead-summary-mode (&optional arg)
9732 "Minor mode for Gnus summary buffers."
9734 (when (eq major-mode 'gnus-summary-mode)
9735 (make-local-variable 'gnus-dead-summary-mode)
9736 (setq gnus-dead-summary-mode
9737 (if (null arg) (not gnus-dead-summary-mode)
9738 (> (prefix-numeric-value arg) 0)))
9739 (when gnus-dead-summary-mode
9740 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9741 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9742 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9743 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9744 minor-mode-map-alist)))))
9746 (defun gnus-deaden-summary ()
9747 "Make the current summary buffer into a dead summary buffer."
9748 ;; Kill any previous dead summary buffer.
9749 (when (and gnus-dead-summary
9750 (buffer-name gnus-dead-summary))
9752 (set-buffer gnus-dead-summary)
9753 (when gnus-dead-summary-mode
9754 (kill-buffer (current-buffer)))))
9755 ;; Make this the current dead summary.
9756 (setq gnus-dead-summary (current-buffer))
9757 (gnus-dead-summary-mode 1)
9758 (let ((name (buffer-name)))
9759 (when (string-match "Summary" name)
9761 (concat (substring name 0 (match-beginning 0)) "Dead "
9762 (substring name (match-beginning 0))) t))))
9764 (defun gnus-kill-or-deaden-summary (buffer)
9765 "Kill or deaden the summary BUFFER."
9766 (cond (gnus-kill-summary-on-exit
9767 (when (and gnus-use-trees
9768 (and (get-buffer buffer)
9769 (buffer-name (get-buffer buffer))))
9771 (set-buffer (get-buffer buffer))
9772 (gnus-tree-close gnus-newsgroup-name)))
9773 (gnus-kill-buffer buffer))
9774 ((and (get-buffer buffer)
9775 (buffer-name (get-buffer buffer)))
9778 (gnus-deaden-summary)))))
9780 (defun gnus-summary-wake-up-the-dead (&rest args)
9781 "Wake up the dead summary buffer."
9783 (gnus-dead-summary-mode -1)
9784 (let ((name (buffer-name)))
9785 (when (string-match "Dead " name)
9787 (concat (substring name 0 (match-beginning 0))
9788 (substring name (match-end 0))) t)))
9789 (gnus-message 3 "This dead summary is now alive again"))
9791 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9792 (defun gnus-summary-fetch-faq (&optional faq-dir)
9793 "Fetch the FAQ for the current group.
9794 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9798 (if current-prefix-arg
9800 "Faq dir: " (and (listp gnus-group-faq-directory)
9801 gnus-group-faq-directory)))))
9802 (let (gnus-faq-buffer)
9803 (and (setq gnus-faq-buffer
9804 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9805 (gnus-configure-windows 'summary-faq))))
9807 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9808 (defun gnus-summary-describe-group (&optional force)
9809 "Describe the current newsgroup."
9811 (gnus-group-describe-group force gnus-newsgroup-name))
9813 (defun gnus-summary-describe-briefly ()
9814 "Describe summary mode commands briefly."
9817 (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")))
9819 ;; Walking around group mode buffer from summary mode.
9821 (defun gnus-summary-next-group (&optional no-article target-group backward)
9822 "Exit current newsgroup and then select next unread newsgroup.
9823 If prefix argument NO-ARTICLE is non-nil, no article is selected
9824 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9825 previous group instead."
9827 (gnus-set-global-variables)
9828 (let ((current-group gnus-newsgroup-name)
9829 (current-buffer (current-buffer))
9831 ;; First we semi-exit this group to update Xrefs and all variables.
9832 ;; We can't do a real exit, because the window conf must remain
9833 ;; the same in case the user is prompted for info, and we don't
9834 ;; want the window conf to change before that...
9835 (gnus-summary-exit t)
9836 (while (not entered)
9837 ;; Then we find what group we are supposed to enter.
9838 (set-buffer gnus-group-buffer)
9839 (gnus-group-jump-to-group current-group)
9842 (if (eq gnus-keep-same-level 'best)
9843 (gnus-summary-best-group gnus-newsgroup-name)
9844 (gnus-summary-search-group backward gnus-keep-same-level))))
9845 (if (not target-group)
9846 ;; There are no further groups, so we return to the group
9849 (gnus-message 5 "Returning to the group buffer")
9851 (set-buffer current-buffer)
9852 (gnus-summary-exit))
9853 ;; We try to enter the target group.
9854 (gnus-group-jump-to-group target-group)
9855 (let ((unreads (gnus-group-group-unread)))
9856 (if (and (or (eq t unreads)
9857 (and unreads (not (zerop unreads))))
9858 (gnus-summary-read-group
9859 target-group nil no-article current-buffer))
9861 (setq current-group target-group
9862 target-group nil)))))))
9864 (defun gnus-summary-prev-group (&optional no-article)
9865 "Exit current newsgroup and then select previous unread newsgroup.
9866 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9868 (gnus-summary-next-group no-article nil t))
9870 ;; Walking around summary lines.
9872 (defun gnus-summary-first-subject (&optional unread)
9873 "Go to the first unread subject.
9874 If UNREAD is non-nil, go to the first unread article.
9875 Returns the article selected or nil if there are no unread articles."
9880 ((null gnus-newsgroup-data)
9881 (gnus-message 3 "No articles in the group")
9883 ;; Pick the first article.
9885 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9886 (gnus-data-number (car gnus-newsgroup-data)))
9887 ;; No unread articles.
9888 ((null gnus-newsgroup-unreads)
9889 (gnus-message 3 "No more unread articles")
9891 ;; Find the first unread article.
9893 (let ((data gnus-newsgroup-data))
9895 (not (gnus-data-unread-p (car data))))
9896 (setq data (cdr data)))
9899 (goto-char (gnus-data-pos (car data)))
9900 (gnus-data-number (car data)))))))
9901 (gnus-summary-position-point)))
9903 (defun gnus-summary-next-subject (n &optional unread dont-display)
9904 "Go to next N'th summary line.
9905 If N is negative, go to the previous N'th subject line.
9906 If UNREAD is non-nil, only unread articles are selected.
9907 The difference between N and the actual number of steps taken is
9910 (let ((backward (< n 0))
9914 (gnus-summary-find-prev unread)
9915 (gnus-summary-find-next unread)))
9917 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9918 (if unread " unread" "")))
9919 (unless dont-display
9920 (gnus-summary-recenter)
9921 (gnus-summary-position-point))
9924 (defun gnus-summary-next-unread-subject (n)
9925 "Go to next N'th unread summary line."
9927 (gnus-summary-next-subject n t))
9929 (defun gnus-summary-prev-subject (n &optional unread)
9930 "Go to previous N'th summary line.
9931 If optional argument UNREAD is non-nil, only unread article is selected."
9933 (gnus-summary-next-subject (- n) unread))
9935 (defun gnus-summary-prev-unread-subject (n)
9936 "Go to previous N'th unread summary line."
9938 (gnus-summary-next-subject (- n) t))
9940 (defun gnus-summary-goto-subject (article &optional force silent)
9941 "Go the subject line of ARTICLE.
9942 If FORCE, also allow jumping to articles not currently shown."
9944 (data (gnus-data-find article)))
9945 ;; We read in the article if we have to.
9948 (gnus-summary-insert-subject article)
9949 (setq data (gnus-data-find article)))
9954 (gnus-message 3 "Can't find article %d" article))
9956 (goto-char (gnus-data-pos data))
9959 ;; Walking around summary lines with displaying articles.
9961 (defun gnus-summary-expand-window (&optional arg)
9962 "Make the summary buffer take up the entire Emacs frame.
9963 Given a prefix, will force an `article' buffer configuration."
9965 (gnus-set-global-variables)
9967 (gnus-configure-windows 'article 'force)
9968 (gnus-configure-windows 'summary 'force)))
9970 (defun gnus-summary-display-article (article &optional all-header)
9971 "Display ARTICLE in article buffer."
9972 (gnus-set-global-variables)
9976 (if gnus-summary-display-article-function
9977 (funcall gnus-summary-display-article-function article all-header)
9978 (gnus-article-prepare article all-header))
9979 (run-hooks 'gnus-select-article-hook)
9980 (gnus-summary-recenter)
9981 (gnus-summary-goto-subject article)
9982 (when gnus-use-trees
9983 (gnus-possibly-generate-tree article)
9984 (gnus-highlight-selected-tree article))
9985 ;; Successfully display article.
9986 (gnus-article-set-window-start
9987 (cdr (assq article gnus-newsgroup-bookmarks)))
9990 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
9991 "Select the current article.
9992 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
9993 non-nil, the article will be re-fetched even if it already present in
9994 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
9996 (let ((article (or article (gnus-summary-article-number)))
9997 (all-headers (not (not all-headers))) ;Must be T or NIL.
9998 gnus-summary-display-article-function
10001 (gnus-summary-article-pseudo-p article)
10002 (error "This is a pseudo-article."))
10005 (set-buffer gnus-summary-buffer)
10006 (if (or (and gnus-single-article-buffer
10007 (or (null gnus-current-article)
10008 (null gnus-article-current)
10009 (null (get-buffer gnus-article-buffer))
10010 (not (eq article (cdr gnus-article-current)))
10011 (not (equal (car gnus-article-current)
10012 gnus-newsgroup-name))))
10013 (and (not gnus-single-article-buffer)
10014 (null gnus-current-article))
10016 ;; The requested article is different from the current article.
10018 (gnus-summary-display-article article all-headers)
10019 (setq did article))
10020 (if (or all-headers gnus-show-all-headers)
10021 (gnus-article-show-all-headers))
10024 (gnus-article-set-window-start
10025 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10027 (defun gnus-summary-set-current-mark (&optional current-mark)
10028 "Obsolete function."
10031 (defun gnus-summary-next-article (&optional unread subject backward push)
10032 "Select the next article.
10033 If UNREAD, only unread articles are selected.
10034 If SUBJECT, only articles with SUBJECT are selected.
10035 If BACKWARD, the previous article is selected instead of the next."
10037 (gnus-set-global-variables)
10039 ;; Is there such an article?
10040 ((and (gnus-summary-search-forward unread subject backward)
10041 (or (gnus-summary-display-article (gnus-summary-article-number))
10042 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10043 (gnus-summary-position-point))
10044 ;; If not, we try the first unread, if that is wanted.
10046 gnus-auto-select-same
10047 (or (gnus-summary-first-unread-article)
10048 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10049 (gnus-summary-position-point)
10050 (gnus-message 6 "Wrapped"))
10051 ;; Try to get next/previous article not displayed in this group.
10052 ((and gnus-auto-extend-newsgroup
10053 (not unread) (not subject))
10054 (gnus-summary-goto-article
10055 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10057 ;; Go to next/previous group.
10059 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10060 (gnus-summary-jump-to-group gnus-newsgroup-name))
10061 (let ((cmd last-command-char)
10063 (if (eq gnus-keep-same-level 'best)
10064 (gnus-summary-best-group gnus-newsgroup-name)
10065 (gnus-summary-search-group backward gnus-keep-same-level))))
10066 ;; For some reason, the group window gets selected. We change
10068 (select-window (get-buffer-window (current-buffer)))
10069 ;; Select next unread newsgroup automagically.
10071 ((not gnus-auto-select-next)
10072 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10073 ((or (eq gnus-auto-select-next 'quietly)
10074 (and (eq gnus-auto-select-next 'slightly-quietly)
10076 (and (eq gnus-auto-select-next 'almost-quietly)
10077 (gnus-summary-last-article-p)))
10079 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10080 (gnus-summary-exit)
10081 (gnus-message 7 "No more%s articles (%s)..."
10082 (if unread " unread" "")
10083 (if group (concat "selecting " group)
10085 (gnus-summary-next-group nil group backward)))
10087 (gnus-summary-walk-group-buffer
10088 gnus-newsgroup-name cmd unread backward)))))))
10090 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10091 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10092 (?\C-p (gnus-group-prev-unread-group 1))))
10093 keve key group ended)
10095 (set-buffer gnus-group-buffer)
10096 (gnus-summary-jump-to-group from-group)
10098 (if (eq gnus-keep-same-level 'best)
10099 (gnus-summary-best-group gnus-newsgroup-name)
10100 (gnus-summary-search-group backward gnus-keep-same-level))))
10103 5 "No more%s articles%s" (if unread " unread" "")
10105 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10106 (format " (Type %s for %s [%s])"
10107 (single-key-description cmd) group
10108 (car (gnus-gethash group gnus-newsrc-hashtb)))
10109 (format " (Type %s to exit %s)"
10110 (single-key-description cmd)
10111 gnus-newsgroup-name)))
10112 ;; Confirm auto selection.
10113 (setq key (car (setq keve (gnus-read-event-char))))
10116 ((assq key keystrokes)
10117 (let ((obuf (current-buffer)))
10118 (switch-to-buffer gnus-group-buffer)
10120 (gnus-group-jump-to-group group))
10121 (eval (cadr (assq key keystrokes)))
10122 (setq group (gnus-group-group-name))
10123 (switch-to-buffer obuf))
10126 (if (or (not group)
10127 (gnus-ephemeral-group-p gnus-newsgroup-name))
10128 (gnus-summary-exit)
10129 (gnus-summary-next-group nil group backward)))
10131 (push (cdr keve) unread-command-events))))))
10133 (defun gnus-read-event-char ()
10134 "Get the next event."
10135 (let ((event (read-event)))
10136 (cons (and (numberp event) event) event)))
10138 (defun gnus-summary-next-unread-article ()
10139 "Select unread article after current one."
10141 (gnus-summary-next-article t (and gnus-auto-select-same
10142 (gnus-summary-article-subject))))
10144 (defun gnus-summary-prev-article (&optional unread subject)
10145 "Select the article after the current one.
10146 If UNREAD is non-nil, only unread articles are selected."
10148 (gnus-summary-next-article unread subject t))
10150 (defun gnus-summary-prev-unread-article ()
10151 "Select unred article before current one."
10153 (gnus-summary-prev-article t (and gnus-auto-select-same
10154 (gnus-summary-article-subject))))
10156 (defun gnus-summary-next-page (&optional lines circular)
10157 "Show next page of the selected article.
10158 If at the end of the current article, select the next article.
10159 LINES says how many lines should be scrolled up.
10161 If CIRCULAR is non-nil, go to the start of the article instead of
10162 selecting the next article when reaching the end of the current
10165 (setq gnus-summary-buffer (current-buffer))
10166 (gnus-set-global-variables)
10167 (let ((article (gnus-summary-article-number))
10169 (gnus-configure-windows 'article)
10170 (if (or (null gnus-current-article)
10171 (null gnus-article-current)
10172 (/= article (cdr gnus-article-current))
10173 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10174 ;; Selected subject is different from current article's.
10175 (gnus-summary-display-article article)
10176 (gnus-eval-in-buffer-window
10177 gnus-article-buffer
10178 (setq endp (gnus-article-next-page lines)))
10181 (gnus-summary-beginning-of-article))
10183 (gnus-message 3 "End of message"))
10185 (if (and (eq gnus-summary-goto-unread 'never)
10186 (not (eq article gnus-newsgroup-end)))
10187 (gnus-summary-next-article)
10188 (gnus-summary-next-unread-article))))))
10189 (gnus-summary-recenter)
10190 (gnus-summary-position-point)))
10192 (defun gnus-summary-prev-page (&optional lines)
10193 "Show previous page of selected article.
10194 Argument LINES specifies lines to be scrolled down."
10196 (gnus-set-global-variables)
10197 (let ((article (gnus-summary-article-number)))
10198 (gnus-configure-windows 'article)
10199 (if (or (null gnus-current-article)
10200 (null gnus-article-current)
10201 (/= article (cdr gnus-article-current))
10202 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10203 ;; Selected subject is different from current article's.
10204 (gnus-summary-display-article article)
10205 (gnus-summary-recenter)
10206 (gnus-eval-in-buffer-window gnus-article-buffer
10207 (gnus-article-prev-page lines))))
10208 (gnus-summary-position-point))
10210 (defun gnus-summary-scroll-up (lines)
10211 "Scroll up (or down) one line current article.
10212 Argument LINES specifies lines to be scrolled up (or down if negative)."
10214 (gnus-set-global-variables)
10215 (gnus-configure-windows 'article)
10216 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10217 (gnus-eval-in-buffer-window
10218 gnus-article-buffer
10220 (if (gnus-article-next-page lines)
10221 (gnus-message 3 "End of message")))
10223 (gnus-article-prev-page (- lines))))))
10224 (gnus-summary-recenter)
10225 (gnus-summary-position-point))
10227 (defun gnus-summary-next-same-subject ()
10228 "Select next article which has the same subject as current one."
10230 (gnus-set-global-variables)
10231 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10233 (defun gnus-summary-prev-same-subject ()
10234 "Select previous article which has the same subject as current one."
10236 (gnus-set-global-variables)
10237 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10239 (defun gnus-summary-next-unread-same-subject ()
10240 "Select next unread article which has the same subject as current one."
10242 (gnus-set-global-variables)
10243 (gnus-summary-next-article t (gnus-summary-article-subject)))
10245 (defun gnus-summary-prev-unread-same-subject ()
10246 "Select previous unread article which has the same subject as current one."
10248 (gnus-set-global-variables)
10249 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10251 (defun gnus-summary-first-unread-article ()
10252 "Select the first unread article.
10253 Return nil if there are no unread articles."
10255 (gnus-set-global-variables)
10257 (if (gnus-summary-first-subject t)
10259 (gnus-summary-show-thread)
10260 (gnus-summary-first-subject t)
10261 (gnus-summary-display-article (gnus-summary-article-number))))
10262 (gnus-summary-position-point)))
10264 (defun gnus-summary-best-unread-article ()
10265 "Select the unread article with the highest score."
10267 (gnus-set-global-variables)
10268 (let ((best -1000000)
10269 (data gnus-newsgroup-data)
10272 (and (gnus-data-unread-p (car data))
10274 (gnus-summary-article-score (gnus-data-number (car data))))
10277 article (gnus-data-number (car data))))
10278 (setq data (cdr data)))
10280 (gnus-summary-goto-article article)
10281 (error "No unread articles"))
10282 (gnus-summary-position-point)))
10284 (defun gnus-summary-last-subject ()
10285 "Go to the last displayed subject line in the group."
10286 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10288 (gnus-summary-goto-subject article))))
10290 (defun gnus-summary-goto-article (article &optional all-headers force)
10291 "Fetch ARTICLE and display it if it exists.
10292 If ALL-HEADERS is non-nil, no header lines are hidden."
10298 (mapcar (lambda (number) (list (int-to-string number)))
10299 gnus-newsgroup-limit)))
10303 (if (gnus-summary-goto-subject article force)
10304 (gnus-summary-display-article article all-headers)
10305 (gnus-message 4 "Couldn't go to article %s" article) nil)
10306 (gnus-summary-position-point)))
10308 (defun gnus-summary-goto-last-article ()
10309 "Go to the previously read article."
10312 (and gnus-last-article
10313 (gnus-summary-goto-article gnus-last-article))
10314 (gnus-summary-position-point)))
10316 (defun gnus-summary-pop-article (number)
10317 "Pop one article off the history and go to the previous.
10318 NUMBER articles will be popped off."
10321 (setq gnus-newsgroup-history
10322 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10324 (gnus-summary-goto-article (car to))
10325 (error "Article history empty")))
10326 (gnus-summary-position-point))
10328 ;; Summary commands and functions for limiting the summary buffer.
10330 (defun gnus-summary-limit-to-articles (n)
10331 "Limit the summary buffer to the next N articles.
10332 If not given a prefix, use the process marked articles instead."
10334 (gnus-set-global-variables)
10336 (let ((articles (gnus-summary-work-articles n)))
10337 (setq gnus-newsgroup-processable nil)
10338 (gnus-summary-limit articles))
10339 (gnus-summary-position-point)))
10341 (defun gnus-summary-pop-limit (&optional total)
10342 "Restore the previous limit.
10343 If given a prefix, remove all limits."
10345 (gnus-set-global-variables)
10347 (setq gnus-newsgroup-limits
10348 (list (mapcar (lambda (h) (mail-header-number h))
10349 gnus-newsgroup-headers))))
10350 (unless gnus-newsgroup-limits
10351 (error "No limit to pop"))
10353 (gnus-summary-limit nil 'pop)
10354 (gnus-summary-position-point)))
10356 (defun gnus-summary-limit-to-subject (subject &optional header)
10357 "Limit the summary buffer to articles that have subjects that match a regexp."
10358 (interactive "sRegexp: ")
10360 (setq header "subject"))
10361 (when (not (equal "" subject))
10363 (let ((articles (gnus-summary-find-matching
10364 (or header "subject") subject 'all)))
10365 (or articles (error "Found no matches for \"%s\"" subject))
10366 (gnus-summary-limit articles))
10367 (gnus-summary-position-point))))
10369 (defun gnus-summary-limit-to-author (from)
10370 "Limit the summary buffer to articles that have authors that match a regexp."
10371 (interactive "sRegexp: ")
10372 (gnus-summary-limit-to-subject from "from"))
10374 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10376 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10378 (defun gnus-summary-limit-to-unread (&optional all)
10379 "Limit the summary buffer to articles that are not marked as read.
10380 If ALL is non-nil, limit strictly to unread articles."
10383 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10384 (gnus-summary-limit-to-marks
10385 ;; Concat all the marks that say that an article is read and have
10387 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10388 gnus-killed-mark gnus-kill-file-mark
10389 gnus-low-score-mark gnus-expirable-mark
10390 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10393 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10394 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10396 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10397 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10398 If REVERSE, limit the summary buffer to articles that are not marked
10399 with MARKS. MARKS can either be a string of marks or a list of marks.
10400 Returns how many articles were removed."
10401 (interactive "sMarks: ")
10402 (gnus-set-global-variables)
10404 (let ((data gnus-newsgroup-data)
10405 (marks (if (listp marks) marks
10406 (append marks nil))) ; Transform to list.
10409 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10410 (memq (gnus-data-mark (car data)) marks))
10411 (setq articles (cons (gnus-data-number (car data)) articles)))
10412 (setq data (cdr data)))
10413 (gnus-summary-limit articles))
10414 (gnus-summary-position-point)))
10416 (defun gnus-summary-limit-to-score (&optional score)
10417 "Limit to articles with score at or above SCORE."
10419 (gnus-set-global-variables)
10420 (setq score (if score
10421 (prefix-numeric-value score)
10422 (or gnus-summary-default-score 0)))
10423 (let ((data gnus-newsgroup-data)
10426 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10428 (push (gnus-data-number (car data)) articles))
10429 (setq data (cdr data)))
10431 (gnus-summary-limit articles)
10432 (gnus-summary-position-point))))
10434 (defun gnus-summary-limit-include-dormant ()
10435 "Display all the hidden articles that are marked as dormant."
10437 (gnus-set-global-variables)
10438 (or gnus-newsgroup-dormant
10439 (error "There are no dormant articles in this group"))
10441 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10442 (gnus-summary-position-point)))
10444 (defun gnus-summary-limit-exclude-dormant ()
10445 "Hide all dormant articles."
10447 (gnus-set-global-variables)
10449 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10450 (gnus-summary-position-point)))
10452 (defun gnus-summary-limit-exclude-childless-dormant ()
10453 "Hide all dormant articles that have no children."
10455 (gnus-set-global-variables)
10456 (let ((data (gnus-data-list t))
10457 articles d children)
10458 ;; Find all articles that are either not dormant or have
10460 (while (setq d (pop data))
10461 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10462 (and (setq children
10463 (gnus-article-children (gnus-data-number d)))
10466 (when (memq (car children) articles)
10471 (push (gnus-data-number d) articles)))
10472 ;; Do the limiting.
10474 (gnus-summary-limit articles)
10475 (gnus-summary-position-point))))
10477 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10478 "Mark all unread excluded articles as read.
10479 If ALL, mark even excluded ticked and dormants as read."
10481 (let ((articles (gnus-sorted-complement
10483 (mapcar (lambda (h) (mail-header-number h))
10484 gnus-newsgroup-headers)
10486 (sort gnus-newsgroup-limit '<)))
10488 (setq gnus-newsgroup-unreads nil)
10490 (setq gnus-newsgroup-dormant nil
10491 gnus-newsgroup-marked nil
10492 gnus-newsgroup-reads
10494 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10495 gnus-newsgroup-reads))
10496 (while (setq article (pop articles))
10497 (unless (or (memq article gnus-newsgroup-dormant)
10498 (memq article gnus-newsgroup-marked))
10499 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10501 (defun gnus-summary-limit (articles &optional pop)
10503 ;; We pop the previous limit off the stack and use that.
10504 (setq articles (car gnus-newsgroup-limits)
10505 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10506 ;; We use the new limit, so we push the old limit on the stack.
10507 (setq gnus-newsgroup-limits
10508 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10510 (setq gnus-newsgroup-limit articles)
10511 (let ((total (length gnus-newsgroup-data))
10512 (data (gnus-data-find-list (gnus-summary-article-number)))
10514 ;; This will do all the work of generating the new summary buffer
10515 ;; according to the new limit.
10516 (gnus-summary-prepare)
10517 ;; Hide any threads, possibly.
10518 (and gnus-show-threads
10519 gnus-thread-hide-subtree
10520 (gnus-summary-hide-all-threads))
10521 ;; Try to return to the article you were at, or one in the
10524 ;; We try to find some article after the current one.
10526 (and (gnus-summary-goto-subject
10527 (gnus-data-number (car data)) nil t)
10530 (setq data (cdr data))))
10532 ;; If there is no data, that means that we were after the last
10533 ;; article. The same goes when we can't find any articles
10534 ;; after the current one.
10536 (goto-char (point-max))
10537 (gnus-summary-find-prev)))
10538 ;; We return how many articles were removed from the summary
10539 ;; buffer as a result of the new limit.
10540 (- total (length gnus-newsgroup-data))))
10542 (defsubst gnus-cut-thread (thread)
10543 "Go forwards in the thread until we find an article that we want to display."
10544 (if (eq gnus-fetch-old-headers 'some)
10546 (memq (mail-header-number (car thread))
10547 gnus-newsgroup-ancient)
10548 (<= (length (cdr thread)) 1))
10549 (setq thread (cadr thread)))
10551 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10552 (= (length (cdr thread)) 1))
10553 (setq thread (cadr thread))))
10556 (defun gnus-cut-threads (threads)
10557 "Cut off all uninteresting articles from the beginning of threads."
10558 (when (or (eq gnus-fetch-old-headers 'some)
10559 (eq gnus-build-sparse-threads 'some)
10560 (eq gnus-build-sparse-threads 'more))
10561 (let ((th threads))
10563 (setcar th (gnus-cut-thread (car th)))
10564 (setq th (cdr th)))))
10567 (defun gnus-summary-initial-limit (&optional show-if-empty)
10568 "Figure out what the initial limit is supposed to be on group entry.
10569 This entails weeding out unwanted dormants, low-scored articles,
10570 fetch-old-headers verbiage, and so on."
10571 ;; Most groups have nothing to remove.
10572 (if (or gnus-inhibit-limiting
10573 (and (null gnus-newsgroup-dormant)
10574 (not (eq gnus-fetch-old-headers 'some))
10575 (null gnus-summary-expunge-below)
10576 (not (eq gnus-build-sparse-threads 'some))
10577 (not (eq gnus-build-sparse-threads 'more))
10578 (null gnus-thread-expunge-below)
10579 (not gnus-use-nocem)))
10581 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10582 (setq gnus-newsgroup-limit nil)
10585 (unless (car (symbol-value node))
10586 ;; These threads have no parents -- they are roots.
10587 (let ((nodes (cdr (symbol-value node)))
10590 (if (and gnus-thread-expunge-below
10591 (< (gnus-thread-total-score (car nodes))
10592 gnus-thread-expunge-below))
10593 (gnus-expunge-thread (pop nodes))
10594 (setq thread (pop nodes))
10595 (gnus-summary-limit-children thread))))))
10596 gnus-newsgroup-dependencies)
10597 ;; If this limitation resulted in an empty group, we might
10598 ;; pop the previous limit and use it instead.
10599 (when (and (not gnus-newsgroup-limit)
10601 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10602 gnus-newsgroup-limit))
10604 (defun gnus-summary-limit-children (thread)
10605 "Return 1 if this subthread is visible and 0 if it is not."
10606 ;; First we get the number of visible children to this thread. This
10607 ;; is done by recursing down the thread using this function, so this
10608 ;; will really go down to a leaf article first, before slowly
10609 ;; working its way up towards the root.
10613 (apply '+ (mapcar 'gnus-summary-limit-children
10616 (number (mail-header-number (car thread)))
10619 ;; If this article is dormant and has absolutely no visible
10620 ;; children, then this article isn't visible.
10621 (and (memq number gnus-newsgroup-dormant)
10623 ;; If this is a "fetch-old-headered" and there is only one
10624 ;; visible child (or less), then we don't want this article.
10625 (and (eq gnus-fetch-old-headers 'some)
10626 (memq number gnus-newsgroup-ancient)
10628 ;; If this is a sparsely inserted article with no children,
10629 ;; we don't want it.
10630 (and (eq gnus-build-sparse-threads 'some)
10631 (memq number gnus-newsgroup-sparse)
10633 ;; If we use expunging, and this article is really
10634 ;; low-scored, then we don't want this article.
10635 (when (and gnus-summary-expunge-below
10637 (or (cdr (assq number gnus-newsgroup-scored))
10638 gnus-summary-default-score))
10639 gnus-summary-expunge-below))
10640 ;; We increase the expunge-tally here, but that has
10641 ;; nothing to do with the limits, really.
10642 (incf gnus-newsgroup-expunged-tally)
10643 ;; We also mark as read here, if that's wanted.
10644 (when (and gnus-summary-mark-below
10645 (< score gnus-summary-mark-below))
10646 (setq gnus-newsgroup-unreads
10647 (delq number gnus-newsgroup-unreads))
10648 (if gnus-newsgroup-auto-expire
10649 (push number gnus-newsgroup-expirable)
10650 (push (cons number gnus-low-score-mark)
10651 gnus-newsgroup-reads)))
10653 (and gnus-use-nocem
10654 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10655 ;; Nope, invisible article.
10657 ;; Ok, this article is to be visible, so we add it to the limit
10659 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10662 (defun gnus-expunge-thread (thread)
10663 "Mark all articles in THREAD as read."
10664 (let* ((number (mail-header-number (car thread))))
10665 (incf gnus-newsgroup-expunged-tally)
10666 ;; We also mark as read here, if that's wanted.
10667 (setq gnus-newsgroup-unreads
10668 (delq number gnus-newsgroup-unreads))
10669 (if gnus-newsgroup-auto-expire
10670 (push number gnus-newsgroup-expirable)
10671 (push (cons number gnus-low-score-mark)
10672 gnus-newsgroup-reads)))
10673 ;; Go recursively through all subthreads.
10674 (mapcar 'gnus-expunge-thread (cdr thread)))
10676 ;; Summary article oriented commands
10678 (defun gnus-summary-refer-parent-article (n)
10679 "Refer parent article N times.
10680 The difference between N and the number of articles fetched is returned."
10682 (gnus-set-global-variables)
10686 (let* ((header (gnus-summary-article-header))
10688 ;; If we try to find the parent of the currently
10689 ;; displayed article, then we take a look at the actual
10690 ;; References header, since this is slightly more
10691 ;; reliable than the References field we got from the
10693 (if (and (eq (mail-header-number header)
10694 (cdr gnus-article-current))
10695 (equal gnus-newsgroup-name
10696 (car gnus-article-current)))
10698 (set-buffer gnus-original-article-buffer)
10699 (nnheader-narrow-to-headers)
10701 (mail-fetch-field "references")
10703 ;; It's not the current article, so we take a bet on
10704 ;; the value we got from the server.
10705 (mail-header-references header))))
10706 (if (setq ref (or ref (mail-header-references header)))
10707 (or (gnus-summary-refer-article (gnus-parent-id ref))
10708 (gnus-message 1 "Couldn't find parent"))
10709 (gnus-message 1 "No references in article %d"
10710 (gnus-summary-article-number))
10713 (gnus-summary-position-point)
10716 (defun gnus-summary-refer-references ()
10717 "Fetch all articles mentioned in the References header.
10718 Return how many articles were fetched."
10720 (gnus-set-global-variables)
10721 (let ((ref (mail-header-references (gnus-summary-article-header)))
10722 (current (gnus-summary-article-number))
10724 ;; For each Message-ID in the References header...
10725 (while (string-match "<[^>]*>" ref)
10727 ;; ... fetch that article.
10728 (gnus-summary-refer-article
10729 (prog1 (match-string 0 ref)
10730 (setq ref (substring ref (match-end 0))))))
10731 (gnus-summary-goto-subject current)
10732 (gnus-summary-position-point)
10735 (defun gnus-summary-refer-article (message-id)
10736 "Fetch an article specified by MESSAGE-ID."
10737 (interactive "sMessage-ID: ")
10738 (when (and (stringp message-id)
10739 (not (zerop (length message-id))))
10740 ;; Construct the correct Message-ID if necessary.
10741 ;; Suggested by tale@pawl.rpi.edu.
10742 (unless (string-match "^<" message-id)
10743 (setq message-id (concat "<" message-id)))
10744 (unless (string-match ">$" message-id)
10745 (setq message-id (concat message-id ">")))
10746 (let ((header (car (gnus-gethash message-id
10747 gnus-newsgroup-dependencies))))
10749 ;; The article is present in the buffer, to we just go to it.
10750 (gnus-summary-goto-article (mail-header-number header) nil t)
10751 ;; We fetch the article
10752 (let ((gnus-override-method gnus-refer-article-method)
10754 ;; Start the special refer-article method, if necessary.
10755 (when gnus-refer-article-method
10756 (gnus-check-server gnus-refer-article-method))
10757 ;; Fetch the header, and display the article.
10758 (if (setq number (gnus-summary-insert-subject message-id))
10759 (gnus-summary-select-article nil nil nil number)
10760 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10762 (defun gnus-summary-enter-digest-group (&optional force)
10763 "Enter a digest group based on the current article."
10765 (gnus-set-global-variables)
10766 (gnus-summary-select-article)
10767 (let ((name (format "%s-%d"
10768 (gnus-group-prefixed-name
10769 gnus-newsgroup-name (list 'nndoc ""))
10770 gnus-current-article))
10771 (ogroup gnus-newsgroup-name)
10772 (case-fold-search t)
10773 (buf (current-buffer))
10776 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10777 (insert-buffer-substring gnus-original-article-buffer)
10779 (goto-char (point-min))
10780 (or (search-forward "\n\n" nil t) (point)))
10781 (goto-char (point-min))
10782 (delete-matching-lines "^\\(Path\\):\\|^From ")
10785 (if (gnus-group-read-ephemeral-group
10786 name `(nndoc ,name (nndoc-address
10788 (nndoc-article-type ,(if force 'digest 'guess))) t)
10789 ;; Make all postings to this group go to the parent group.
10790 (nconc (gnus-info-params (gnus-get-info name))
10791 (list (cons 'to-group ogroup)))
10792 ;; Couldn't select this doc group.
10793 (switch-to-buffer buf)
10794 (gnus-set-global-variables)
10795 (gnus-configure-windows 'summary)
10796 (gnus-message 3 "Article couldn't be entered?"))
10797 (kill-buffer dig))))
10799 (defun gnus-summary-isearch-article (&optional regexp-p)
10800 "Do incremental search forward on the current article.
10801 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10803 (gnus-set-global-variables)
10804 (gnus-summary-select-article)
10805 (gnus-configure-windows 'article)
10806 (gnus-eval-in-buffer-window
10807 gnus-article-buffer
10808 (goto-char (point-min))
10809 (isearch-forward regexp-p)))
10811 (defun gnus-summary-search-article-forward (regexp &optional backward)
10812 "Search for an article containing REGEXP forward.
10813 If BACKWARD, search backward instead."
10816 (format "Search article %s (regexp%s): "
10817 (if current-prefix-arg "backward" "forward")
10818 (if gnus-last-search-regexp
10819 (concat ", default " gnus-last-search-regexp)
10821 current-prefix-arg))
10822 (gnus-set-global-variables)
10823 (if (string-equal regexp "")
10824 (setq regexp (or gnus-last-search-regexp ""))
10825 (setq gnus-last-search-regexp regexp))
10826 (if (gnus-summary-search-article regexp backward)
10827 (gnus-article-set-window-start
10828 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10829 (error "Search failed: \"%s\"" regexp)))
10831 (defun gnus-summary-search-article-backward (regexp)
10832 "Search for an article containing REGEXP backward."
10835 (format "Search article backward (regexp%s): "
10836 (if gnus-last-search-regexp
10837 (concat ", default " gnus-last-search-regexp)
10839 (gnus-summary-search-article-forward regexp 'backward))
10841 (defun gnus-summary-search-article (regexp &optional backward)
10842 "Search for an article containing REGEXP.
10843 Optional argument BACKWARD means do search for backward.
10844 gnus-select-article-hook is not called during the search."
10845 (let ((gnus-select-article-hook nil) ;Disable hook.
10846 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10849 (function re-search-backward) (function re-search-forward)))
10852 ;; Hidden thread subtrees must be searched for ,too.
10853 (gnus-summary-show-all-threads)
10854 ;; First of all, search current article.
10855 ;; We don't want to read article again from NNTP server nor reset
10857 (gnus-summary-select-article)
10858 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10859 (setq last gnus-current-article)
10860 (gnus-eval-in-buffer-window
10861 gnus-article-buffer
10864 ;; Begin search from current point.
10865 (setq found (funcall re-search regexp nil t))))
10866 ;; Then search next articles.
10867 (while (and (not found)
10868 (gnus-summary-display-article
10869 (if backward (gnus-summary-find-prev)
10870 (gnus-summary-find-next))))
10871 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10872 (gnus-eval-in-buffer-window
10873 gnus-article-buffer
10876 (goto-char (if backward (point-max) (point-min)))
10877 (setq found (funcall re-search regexp nil t)))))
10879 ;; Adjust article pointer.
10880 (or (eq last gnus-current-article)
10881 (setq gnus-last-article last))
10882 ;; Return T if found such article.
10885 (defun gnus-summary-find-matching (header regexp &optional backward unread
10887 "Return a list of all articles that match REGEXP on HEADER.
10888 The search stars on the current article and goes forwards unless
10889 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10890 If UNREAD is non-nil, only unread articles will
10891 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10892 in the comparisons."
10893 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10894 (gnus-data-find-list
10895 (gnus-summary-article-number) (gnus-data-list backward))))
10896 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10897 (case-fold-search (not not-case-fold))
10899 (or (fboundp (intern (concat "mail-header-" header)))
10900 (error "%s is not a valid header" header))
10902 (setq d (car data))
10903 (and (or (not unread) ; We want all articles...
10904 (gnus-data-unread-p d)) ; Or just unreads.
10905 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10906 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10907 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10908 (setq data (cdr data)))
10909 (nreverse articles)))
10911 (defun gnus-summary-execute-command (header regexp command &optional backward)
10912 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10913 If HEADER is an empty string (or nil), the match is done on the entire
10914 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10916 (list (let ((completion-ignore-case t))
10919 (mapcar (lambda (string) (list string))
10920 '("Number" "Subject" "From" "Lines" "Date"
10921 "Message-ID" "Xref" "References" "Body"))
10922 nil 'require-match))
10923 (read-string "Regexp: ")
10924 (read-key-sequence "Command: ")
10925 current-prefix-arg))
10926 (when (equal header "Body")
10928 (gnus-set-global-variables)
10929 ;; Hidden thread subtrees must be searched as well.
10930 (gnus-summary-show-all-threads)
10931 ;; We don't want to change current point nor window configuration.
10933 (save-window-excursion
10934 (gnus-message 6 "Executing %s..." (key-description command))
10935 ;; We'd like to execute COMMAND interactively so as to give arguments.
10936 (gnus-execute header regexp
10937 `(lambda () (call-interactively ',(key-binding command)))
10939 (gnus-message 6 "Executing %s...done" (key-description command)))))
10941 (defun gnus-summary-beginning-of-article ()
10942 "Scroll the article back to the beginning."
10944 (gnus-set-global-variables)
10945 (gnus-summary-select-article)
10946 (gnus-configure-windows 'article)
10947 (gnus-eval-in-buffer-window
10948 gnus-article-buffer
10950 (goto-char (point-min))
10951 (and gnus-break-pages (gnus-narrow-to-page))))
10953 (defun gnus-summary-end-of-article ()
10954 "Scroll to the end of the article."
10956 (gnus-set-global-variables)
10957 (gnus-summary-select-article)
10958 (gnus-configure-windows 'article)
10959 (gnus-eval-in-buffer-window
10960 gnus-article-buffer
10962 (goto-char (point-max))
10964 (and gnus-break-pages (gnus-narrow-to-page))))
10966 (defun gnus-summary-show-article (&optional arg)
10967 "Force re-fetching of the current article.
10968 If ARG (the prefix) is non-nil, show the raw article without any
10969 article massaging functions being run."
10971 (gnus-set-global-variables)
10973 ;; Select the article the normal way.
10974 (gnus-summary-select-article nil 'force)
10975 ;; Bind the article treatment functions to nil.
10976 (let ((gnus-have-all-headers t)
10977 gnus-article-display-hook
10978 gnus-article-prepare-hook
10980 (gnus-summary-select-article nil 'force)))
10981 ; (gnus-configure-windows 'article)
10982 (gnus-summary-position-point))
10984 (defun gnus-summary-verbose-headers (&optional arg)
10985 "Toggle permanent full header display.
10986 If ARG is a positive number, turn header display on.
10987 If ARG is a negative number, turn header display off."
10989 (gnus-set-global-variables)
10990 (gnus-summary-toggle-header arg)
10991 (setq gnus-show-all-headers
10992 (cond ((or (not (numberp arg))
10994 (not gnus-show-all-headers))
10998 (defun gnus-summary-toggle-header (&optional arg)
10999 "Show the headers if they are hidden, or hide them if they are shown.
11000 If ARG is a positive number, show the entire header.
11001 If ARG is a negative number, hide the unwanted header lines."
11003 (gnus-set-global-variables)
11005 (set-buffer gnus-article-buffer)
11006 (let* ((buffer-read-only nil)
11007 (inhibit-point-motion-hooks t)
11008 (hidden (text-property-any
11009 (goto-char (point-min)) (search-forward "\n\n")
11012 (goto-char (point-min))
11013 (when (search-forward "\n\n" nil t)
11014 (delete-region (point-min) (1- (point))))
11015 (goto-char (point-min))
11017 (set-buffer gnus-original-article-buffer)
11018 (goto-char (point-min))
11019 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11020 (insert-buffer-substring gnus-original-article-buffer 1 e)
11021 (let ((gnus-inhibit-hiding t))
11022 (run-hooks 'gnus-article-display-hook))
11023 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11024 (gnus-article-hide-headers)))))
11026 (defun gnus-summary-show-all-headers ()
11027 "Make all header lines visible."
11029 (gnus-set-global-variables)
11030 (gnus-article-show-all-headers))
11032 (defun gnus-summary-toggle-mime (&optional arg)
11033 "Toggle MIME processing.
11034 If ARG is a positive number, turn MIME processing on."
11036 (gnus-set-global-variables)
11037 (setq gnus-show-mime
11038 (if (null arg) (not gnus-show-mime)
11039 (> (prefix-numeric-value arg) 0)))
11040 (gnus-summary-select-article t 'force))
11042 (defun gnus-summary-caesar-message (&optional arg)
11043 "Caesar rotate the current article by 13.
11044 The numerical prefix specifies how manu places to rotate each letter
11047 (gnus-set-global-variables)
11048 (gnus-summary-select-article)
11049 (let ((mail-header-separator ""))
11050 (gnus-eval-in-buffer-window
11051 gnus-article-buffer
11054 (let ((start (window-start)))
11055 (news-caesar-buffer-body arg)
11056 (set-window-start (get-buffer-window (current-buffer)) start))))))
11058 (defun gnus-summary-stop-page-breaking ()
11059 "Stop page breaking in the current article."
11061 (gnus-set-global-variables)
11062 (gnus-summary-select-article)
11063 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11065 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11066 "Move the current article to a different newsgroup.
11067 If N is a positive number, move the N next articles.
11068 If N is a negative number, move the N previous articles.
11069 If N is nil and any articles have been marked with the process mark,
11070 move those articles instead.
11071 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11072 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11073 re-spool using this method.
11075 For this function to work, both the current newsgroup and the
11076 newsgroup that you want to move to have to support the `request-move'
11077 and `request-accept' functions."
11079 (unless action (setq action 'move))
11080 (gnus-set-global-variables)
11081 ;; Check whether the source group supports the required functions.
11082 (cond ((and (eq action 'move)
11083 (not (gnus-check-backend-function
11084 'request-move-article gnus-newsgroup-name)))
11085 (error "The current group does not support article moving"))
11086 ((and (eq action 'crosspost)
11087 (not (gnus-check-backend-function
11088 'request-replace-article gnus-newsgroup-name)))
11089 (error "The current group does not support article editing")))
11090 (let ((articles (gnus-summary-work-articles n))
11091 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11092 (names '((move "move" "Moving")
11093 (copy "copy" "Copying")
11094 (crosspost "crosspost" "Crossposting")))
11095 (copy-buf (save-excursion
11096 (nnheader-set-temp-buffer " *copy article*")))
11097 art-group to-method new-xref article)
11098 (unless (assq action names)
11099 (error "Unknown action %s" action))
11100 ;; Read the newsgroup name.
11101 (when (and (not to-newsgroup)
11102 (not select-method))
11104 (gnus-read-move-group-name
11105 (cadr (assq action names))
11106 gnus-current-move-group articles prefix))
11107 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11108 (setq to-method (if select-method (list select-method "")
11109 (gnus-find-method-for-group to-newsgroup)))
11110 ;;(when (equal to-newsgroup gnus-newsgroup-name)
11111 ;;(error "Can't %s to the same group you're already in" action))
11112 ;; Check the method we are to move this article to...
11113 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11114 (error "%s does not support article copying" (car to-method)))
11115 (or (gnus-check-server to-method)
11116 (error "Can't open server %s" (car to-method)))
11117 (gnus-message 6 "%s to %s: %s..."
11118 (caddr (assq action names))
11119 (or select-method to-newsgroup) articles)
11121 (setq article (pop articles))
11125 ;; Move the article.
11127 (gnus-request-move-article
11128 article ; Article to move
11129 gnus-newsgroup-name ; From newsgrouo
11130 (nth 1 (gnus-find-method-for-group
11131 gnus-newsgroup-name)) ; Server
11132 (list 'gnus-request-accept-article
11134 (list 'quote select-method)
11136 (not articles)) ; Accept form
11137 (not articles))) ; Only save nov last time
11138 ;; Copy the article.
11141 (set-buffer copy-buf)
11142 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11143 (gnus-request-accept-article
11144 (if select-method select-method to-newsgroup)
11146 ;; Crosspost the article.
11147 ((eq action 'crosspost)
11148 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11149 (setq new-xref (concat gnus-newsgroup-name ":" article))
11150 (if (and xref (not (string= xref "")))
11152 (when (string-match "^Xref: " xref)
11153 (setq xref (substring xref (match-end 0))))
11154 (setq new-xref (concat xref " " new-xref)))
11155 (setq new-xref (concat (system-name) " " new-xref)))
11157 (set-buffer copy-buf)
11158 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11159 (nnheader-replace-header "xref" new-xref)
11160 (gnus-request-accept-article
11161 (if select-method select-method to-newsgroup)
11162 (not articles)))))))
11163 (if (not art-group)
11164 (gnus-message 1 "Couldn't %s article %s"
11165 (cadr (assq action names)) article)
11168 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11170 (gnus-group-prefixed-name
11172 (if select-method (list select-method "")
11173 (gnus-find-method-for-group to-newsgroup)))
11174 gnus-newsrc-hashtb)))
11175 (info (nth 2 entry)))
11176 ;; Update the group that has been moved to.
11178 (memq action '(move copy)))
11179 (unless (memq article gnus-newsgroup-unreads)
11180 (gnus-info-set-read
11181 info (gnus-add-to-range (gnus-info-read info)
11182 (list (cdr art-group)))))
11184 ;; Copy any marks over to the new group.
11185 (let ((marks gnus-article-mark-lists)
11186 (to-article (cdr art-group)))
11188 ;; See whether the article is to be put in the cache.
11189 (when gnus-use-cache
11190 (gnus-cache-possibly-enter-article
11191 (gnus-info-group info) to-article
11192 (let ((header (copy-sequence
11193 (gnus-summary-article-header article))))
11194 (mail-header-set-number header to-article)
11196 (memq article gnus-newsgroup-marked)
11197 (memq article gnus-newsgroup-dormant)
11198 (memq article gnus-newsgroup-unreads)))
11201 (when (memq article (symbol-value
11202 (intern (format "gnus-newsgroup-%s"
11204 (gnus-add-marked-articles
11205 (gnus-info-group info) (cdar marks)
11206 (list to-article) info))
11207 (setq marks (cdr marks)))))
11209 ;; Update the Xref header in this article to point to
11210 ;; the new crossposted article we have just created.
11211 (when (eq action 'crosspost)
11213 (set-buffer copy-buf)
11214 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11215 (nnheader-replace-header
11216 "xref" (concat new-xref " " (gnus-group-prefixed-name
11217 (car art-group) to-method)
11218 ":" (cdr art-group)))
11219 (gnus-request-replace-article
11220 article gnus-newsgroup-name (current-buffer)))))
11222 (gnus-summary-goto-subject article)
11223 (when (eq action 'move)
11224 (gnus-summary-mark-article article gnus-canceled-mark)))
11225 (gnus-summary-remove-process-mark article))
11226 (gnus-kill-buffer copy-buf)
11227 (gnus-summary-position-point)
11228 (gnus-set-mode-line 'summary)))
11230 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11231 "Move the current article to a different newsgroup.
11232 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11233 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11234 re-spool using this method."
11236 (gnus-summary-move-article n nil select-method 'copy))
11238 (defun gnus-summary-crosspost-article (&optional n)
11239 "Crosspost the current article to some other group."
11241 (gnus-summary-move-article n nil nil 'crosspost))
11243 (defun gnus-summary-respool-article (&optional n respool-method)
11244 "Respool the current article.
11245 The article will be squeezed through the mail spooling process again,
11246 which means that it will be put in some mail newsgroup or other
11247 depending on `nnmail-split-methods'.
11248 If N is a positive number, respool the N next articles.
11249 If N is a negative number, respool the N previous articles.
11250 If N is nil and any articles have been marked with the process mark,
11251 respool those articles instead.
11253 Respooling can be done both from mail groups and \"real\" newsgroups.
11254 In the former case, the articles in question will be moved from the
11255 current group into whatever groups they are destined to. In the
11256 latter case, they will be copied into the relevant groups."
11258 (gnus-set-global-variables)
11259 (let ((respool-methods (gnus-methods-using 'respool))
11261 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11263 (setq respool-method
11265 "What method do you want to use when respooling? "
11266 respool-methods nil t methname)))
11267 (or (string= respool-method "")
11268 (if (assoc (symbol-name
11269 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11271 (gnus-summary-move-article n nil (intern respool-method))
11272 (gnus-summary-copy-article n nil (intern respool-method))))))
11274 (defun gnus-summary-import-article (file)
11275 "Import a random file into a mail newsgroup."
11276 (interactive "fImport file: ")
11277 (gnus-set-global-variables)
11278 (let ((group gnus-newsgroup-name)
11279 (now (current-time))
11281 (or (gnus-check-backend-function 'request-accept-article group)
11282 (error "%s does not support article importing" group))
11283 (or (file-readable-p file)
11284 (not (file-regular-p file))
11285 (error "Can't read %s" file))
11287 (set-buffer (get-buffer-create " *import file*"))
11288 (buffer-disable-undo (current-buffer))
11290 (insert-file-contents file)
11291 (goto-char (point-min))
11292 (unless (nnheader-article-p)
11293 ;; This doesn't look like an article, so we fudge some headers.
11294 (setq atts (file-attributes file)
11295 lines (count-lines (point-min) (point-max)))
11296 (insert "From: " (read-string "From: ") "\n"
11297 "Subject: " (read-string "Subject: ") "\n"
11298 "Date: " (timezone-make-date-arpa-standard
11299 (current-time-string (nth 5 atts))
11300 (current-time-zone now)
11301 (current-time-zone now)) "\n"
11302 "Message-ID: " (gnus-inews-message-id) "\n"
11303 "Lines: " (int-to-string lines) "\n"
11304 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11305 (gnus-request-accept-article group t)
11306 (kill-buffer (current-buffer)))))
11308 (defun gnus-summary-expire-articles ()
11309 "Expire all articles that are marked as expirable in the current group."
11311 (gnus-set-global-variables)
11312 (when (gnus-check-backend-function
11313 'request-expire-articles gnus-newsgroup-name)
11314 ;; This backend supports expiry.
11315 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11316 (expirable (if total
11317 (gnus-list-of-read-articles gnus-newsgroup-name)
11318 (setq gnus-newsgroup-expirable
11319 (sort gnus-newsgroup-expirable '<))))
11320 (expiry-wait (gnus-group-get-parameter
11321 gnus-newsgroup-name 'expiry-wait))
11324 ;; There are expirable articles in this group, so we run them
11325 ;; through the expiry process.
11326 (gnus-message 6 "Expiring articles...")
11327 ;; The list of articles that weren't expired is returned.
11329 (let ((nnmail-expiry-wait-function nil)
11330 (nnmail-expiry-wait expiry-wait))
11331 (setq es (gnus-request-expire-articles
11332 expirable gnus-newsgroup-name)))
11333 (setq es (gnus-request-expire-articles
11334 expirable gnus-newsgroup-name)))
11335 (or total (setq gnus-newsgroup-expirable es))
11336 ;; We go through the old list of expirable, and mark all
11337 ;; really expired articles as nonexistent.
11338 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11339 (let ((gnus-use-cache nil))
11341 (unless (memq (car expirable) es)
11342 (when (gnus-data-find (car expirable))
11343 (gnus-summary-mark-article
11344 (car expirable) gnus-canceled-mark)))
11345 (setq expirable (cdr expirable)))))
11346 (gnus-message 6 "Expiring articles...done")))))
11348 (defun gnus-summary-expire-articles-now ()
11349 "Expunge all expirable articles in the current group.
11350 This means that *all* articles that are marked as expirable will be
11351 deleted forever, right now."
11353 (gnus-set-global-variables)
11354 (or gnus-expert-user
11356 "Are you really, really, really sure you want to expunge? ")
11358 (let ((nnmail-expiry-wait 'immediate)
11359 (nnmail-expiry-wait-function nil))
11360 (gnus-summary-expire-articles)))
11362 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11363 (defun gnus-summary-delete-article (&optional n)
11364 "Delete the N next (mail) articles.
11365 This command actually deletes articles. This is not a marking
11366 command. The article will disappear forever from your life, never to
11368 If N is negative, delete backwards.
11369 If N is nil and articles have been marked with the process mark,
11370 delete these instead."
11372 (gnus-set-global-variables)
11373 (or (gnus-check-backend-function 'request-expire-articles
11374 gnus-newsgroup-name)
11375 (error "The current newsgroup does not support article deletion."))
11376 ;; Compute the list of articles to delete.
11377 (let ((articles (gnus-summary-work-articles n))
11379 (if (and gnus-novice-user
11380 (not (gnus-y-or-n-p
11381 (format "Do you really want to delete %s forever? "
11382 (if (> (length articles) 1) "these articles"
11383 "this article")))))
11385 ;; Delete the articles.
11386 (setq not-deleted (gnus-request-expire-articles
11387 articles gnus-newsgroup-name 'force))
11389 (gnus-summary-remove-process-mark (car articles))
11390 ;; The backend might not have been able to delete the article
11392 (or (memq (car articles) not-deleted)
11393 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11394 (setq articles (cdr articles))))
11395 (gnus-summary-position-point)
11396 (gnus-set-mode-line 'summary)
11399 (defun gnus-summary-edit-article (&optional force)
11400 "Enter into a buffer and edit the current article.
11401 This will have permanent effect only in mail groups.
11402 If FORCE is non-nil, allow editing of articles even in read-only
11406 (set-buffer gnus-summary-buffer)
11407 (gnus-set-global-variables)
11408 (when (and (not force)
11409 (gnus-group-read-only-p))
11410 (error "The current newsgroup does not support article editing."))
11411 (gnus-summary-select-article t nil t)
11412 (gnus-configure-windows 'article)
11413 (select-window (get-buffer-window gnus-article-buffer))
11414 (gnus-message 6 "C-c C-c to end edits")
11415 (setq buffer-read-only nil)
11417 (use-local-map (copy-keymap (current-local-map)))
11418 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11419 (buffer-enable-undo)
11421 (goto-char (point-min))
11422 (search-forward "\n\n" nil t)))
11424 (defun gnus-summary-edit-article-done ()
11425 "Make edits to the current article permanent."
11427 (if (gnus-group-read-only-p)
11429 (gnus-summary-edit-article-postpone)
11431 1 "The current newsgroup does not support article editing.")
11433 (let ((buf (format "%s" (buffer-string))))
11436 (if (not (gnus-request-replace-article
11437 (cdr gnus-article-current) (car gnus-article-current)
11439 (error "Couldn't replace article.")
11440 (gnus-article-mode)
11441 (use-local-map gnus-article-mode-map)
11442 (setq buffer-read-only t)
11443 (buffer-disable-undo (current-buffer))
11444 (gnus-configure-windows 'summary)
11445 (gnus-summary-update-article (cdr gnus-article-current))
11446 (when gnus-use-cache
11447 (gnus-cache-update-article
11448 (cdr gnus-article-current) (car gnus-article-current))))
11449 (run-hooks 'gnus-article-display-hook)
11450 (and (gnus-visual-p 'summary-highlight 'highlight)
11451 (run-hooks 'gnus-visual-mark-article-hook)))))
11453 (defun gnus-summary-edit-article-postpone ()
11454 "Postpone changes to the current article."
11456 (gnus-article-mode)
11457 (use-local-map gnus-article-mode-map)
11458 (setq buffer-read-only t)
11459 (buffer-disable-undo (current-buffer))
11460 (gnus-configure-windows 'summary)
11461 (and (gnus-visual-p 'summary-highlight 'highlight)
11462 (run-hooks 'gnus-visual-mark-article-hook)))
11464 (defun gnus-summary-respool-query ()
11465 "Query where the respool algorithm would put this article."
11467 (gnus-set-global-variables)
11468 (gnus-summary-select-article)
11470 (set-buffer gnus-article-buffer)
11472 (goto-char (point-min))
11473 (search-forward "\n\n")
11474 (narrow-to-region (point-min) (point))
11475 (pp-eval-expression
11476 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11478 ;; Summary score commands.
11480 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11482 (defun gnus-summary-raise-score (n)
11483 "Raise the score of the current article by N."
11485 (gnus-set-global-variables)
11486 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11488 (defun gnus-summary-set-score (n)
11489 "Set the score of the current article to N."
11491 (gnus-set-global-variables)
11493 (gnus-summary-show-thread)
11494 (let ((buffer-read-only nil))
11496 (gnus-summary-update-mark
11497 (if (= n (or gnus-summary-default-score 0)) ?
11498 (if (< n (or gnus-summary-default-score 0))
11499 gnus-score-below-mark gnus-score-over-mark)) 'score))
11500 (let* ((article (gnus-summary-article-number))
11501 (score (assq article gnus-newsgroup-scored)))
11502 (if score (setcdr score n)
11503 (setq gnus-newsgroup-scored
11504 (cons (cons article n) gnus-newsgroup-scored))))
11505 (gnus-summary-update-line)))
11507 (defun gnus-summary-current-score ()
11508 "Return the score of the current article."
11510 (gnus-set-global-variables)
11511 (message "%s" (gnus-summary-article-score)))
11513 ;; Summary marking commands.
11515 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11516 "Mark articles which has the same subject as read, and then select the next.
11517 If UNMARK is positive, remove any kind of mark.
11518 If UNMARK is negative, tick articles."
11520 (gnus-set-global-variables)
11522 (setq unmark (prefix-numeric-value unmark)))
11524 (gnus-summary-mark-same-subject
11525 (gnus-summary-article-subject) unmark)))
11526 ;; Select next unread article. If auto-select-same mode, should
11527 ;; select the first unread article.
11528 (gnus-summary-next-article t (and gnus-auto-select-same
11529 (gnus-summary-article-subject)))
11530 (gnus-message 7 "%d article%s marked as %s"
11531 count (if (= count 1) " is" "s are")
11532 (if unmark "unread" "read"))))
11534 (defun gnus-summary-kill-same-subject (&optional unmark)
11535 "Mark articles which has the same subject as read.
11536 If UNMARK is positive, remove any kind of mark.
11537 If UNMARK is negative, tick articles."
11539 (gnus-set-global-variables)
11541 (setq unmark (prefix-numeric-value unmark)))
11543 (gnus-summary-mark-same-subject
11544 (gnus-summary-article-subject) unmark)))
11545 ;; If marked as read, go to next unread subject.
11547 ;; Go to next unread subject.
11548 (gnus-summary-next-subject 1 t))
11549 (gnus-message 7 "%d articles are marked as %s"
11550 count (if unmark "unread" "read"))))
11552 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11553 "Mark articles with same SUBJECT as read, and return marked number.
11554 If optional argument UNMARK is positive, remove any kinds of marks.
11555 If optional argument UNMARK is negative, mark articles as unread instead."
11559 ((null unmark) ; Mark as read.
11562 (gnus-summary-mark-article-as-read gnus-killed-mark)
11563 (gnus-summary-show-thread) t)
11564 (gnus-summary-find-subject subject))
11565 (setq count (1+ count))))
11566 ((> unmark 0) ; Tick.
11569 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11570 (gnus-summary-show-thread) t)
11571 (gnus-summary-find-subject subject))
11572 (setq count (1+ count))))
11573 (t ; Mark as unread.
11576 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11577 (gnus-summary-show-thread) t)
11578 (gnus-summary-find-subject subject))
11579 (setq count (1+ count)))))
11580 (gnus-set-mode-line 'summary)
11581 ;; Return the number of marked articles.
11584 (defun gnus-summary-mark-as-processable (n &optional unmark)
11585 "Set the process mark on the next N articles.
11586 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11587 the process mark instead. The difference between N and the actual
11588 number of articles marked is returned."
11590 (gnus-set-global-variables)
11591 (let ((backward (< n 0))
11596 (gnus-summary-remove-process-mark
11597 (gnus-summary-article-number))
11598 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11599 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11601 (if (/= 0 n) (gnus-message 7 "No more articles"))
11602 (gnus-summary-recenter)
11603 (gnus-summary-position-point)
11606 (defun gnus-summary-unmark-as-processable (n)
11607 "Remove the process mark from the next N articles.
11608 If N is negative, mark backward instead. The difference between N and
11609 the actual number of articles marked is returned."
11611 (gnus-set-global-variables)
11612 (gnus-summary-mark-as-processable n t))
11614 (defun gnus-summary-unmark-all-processable ()
11615 "Remove the process mark from all articles."
11617 (gnus-set-global-variables)
11619 (while gnus-newsgroup-processable
11620 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11621 (gnus-summary-position-point))
11623 (defun gnus-summary-mark-as-expirable (n)
11624 "Mark N articles forward as expirable.
11625 If N is negative, mark backward instead. The difference between N and
11626 the actual number of articles marked is returned."
11628 (gnus-set-global-variables)
11629 (gnus-summary-mark-forward n gnus-expirable-mark))
11631 (defun gnus-summary-mark-article-as-replied (article)
11632 "Mark ARTICLE replied and update the summary line."
11633 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11634 (let ((buffer-read-only nil))
11635 (when (gnus-summary-goto-subject article)
11636 (gnus-summary-update-secondary-mark article))))
11638 (defun gnus-summary-set-bookmark (article)
11639 "Set a bookmark in current article."
11640 (interactive (list (gnus-summary-article-number)))
11641 (gnus-set-global-variables)
11642 (if (or (not (get-buffer gnus-article-buffer))
11643 (not gnus-current-article)
11644 (not gnus-article-current)
11645 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11646 (error "No current article selected"))
11647 ;; Remove old bookmark, if one exists.
11648 (let ((old (assq article gnus-newsgroup-bookmarks)))
11649 (if old (setq gnus-newsgroup-bookmarks
11650 (delq old gnus-newsgroup-bookmarks))))
11651 ;; Set the new bookmark, which is on the form
11652 ;; (article-number . line-number-in-body).
11653 (setq gnus-newsgroup-bookmarks
11657 (set-buffer gnus-article-buffer)
11661 (goto-char (point-min))
11662 (search-forward "\n\n" nil t)
11665 gnus-newsgroup-bookmarks))
11666 (gnus-message 6 "A bookmark has been added to the current article."))
11668 (defun gnus-summary-remove-bookmark (article)
11669 "Remove the bookmark from the current article."
11670 (interactive (list (gnus-summary-article-number)))
11671 (gnus-set-global-variables)
11672 ;; Remove old bookmark, if one exists.
11673 (let ((old (assq article gnus-newsgroup-bookmarks)))
11676 (setq gnus-newsgroup-bookmarks
11677 (delq old gnus-newsgroup-bookmarks))
11678 (gnus-message 6 "Removed bookmark."))
11679 (gnus-message 6 "No bookmark in current article."))))
11681 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11682 (defun gnus-summary-mark-as-dormant (n)
11683 "Mark N articles forward as dormant.
11684 If N is negative, mark backward instead. The difference between N and
11685 the actual number of articles marked is returned."
11687 (gnus-set-global-variables)
11688 (gnus-summary-mark-forward n gnus-dormant-mark))
11690 (defun gnus-summary-set-process-mark (article)
11691 "Set the process mark on ARTICLE and update the summary line."
11692 (setq gnus-newsgroup-processable
11694 (delq article gnus-newsgroup-processable)))
11695 (when (gnus-summary-goto-subject article)
11696 (gnus-summary-show-thread)
11697 (gnus-summary-update-secondary-mark article)))
11699 (defun gnus-summary-remove-process-mark (article)
11700 "Remove the process mark from ARTICLE and update the summary line."
11701 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11702 (when (gnus-summary-goto-subject article)
11703 (gnus-summary-show-thread)
11704 (gnus-summary-update-secondary-mark article)))
11706 (defun gnus-summary-set-saved-mark (article)
11707 "Set the process mark on ARTICLE and update the summary line."
11708 (push article gnus-newsgroup-saved)
11709 (when (gnus-summary-goto-subject article)
11710 (gnus-summary-update-secondary-mark article)))
11712 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11713 "Mark N articles as read forwards.
11714 If N is negative, mark backwards instead.
11715 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11717 The difference between N and the actual number of articles marked is
11720 (gnus-set-global-variables)
11721 (let ((backward (< n 0))
11722 (gnus-summary-goto-unread
11723 (and gnus-summary-goto-unread
11724 (not (eq gnus-summary-goto-unread 'never))
11725 (not (memq mark (list gnus-unread-mark
11726 gnus-ticked-mark gnus-dormant-mark)))))
11728 (mark (or mark gnus-del-mark)))
11729 (while (and (> n 0)
11730 (gnus-summary-mark-article nil mark no-expire)
11731 (zerop (gnus-summary-next-subject
11733 (and gnus-summary-goto-unread
11734 (not (eq gnus-summary-goto-unread 'never)))
11737 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11738 (gnus-summary-recenter)
11739 (gnus-summary-position-point)
11740 (gnus-set-mode-line 'summary)
11743 (defun gnus-summary-mark-article-as-read (mark)
11744 "Mark the current article quickly as read with MARK."
11745 (let ((article (gnus-summary-article-number)))
11746 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11747 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11748 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11749 (setq gnus-newsgroup-reads
11750 (cons (cons article mark) gnus-newsgroup-reads))
11751 ;; Possibly remove from cache, if that is used.
11752 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11753 ;; Allow the backend to change the mark.
11754 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11755 ;; Check for auto-expiry.
11756 (when (and gnus-newsgroup-auto-expire
11757 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11758 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11759 (= mark gnus-ancient-mark)
11760 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11761 (setq mark gnus-expirable-mark)
11762 (push article gnus-newsgroup-expirable))
11763 ;; Set the mark in the buffer.
11764 (gnus-summary-update-mark mark 'unread)
11767 (defun gnus-summary-mark-article-as-unread (mark)
11768 "Mark the current article quickly as unread with MARK."
11769 (let ((article (gnus-summary-article-number)))
11770 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11771 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11772 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11773 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11774 (cond ((= mark gnus-ticked-mark)
11775 (push article gnus-newsgroup-marked))
11776 ((= mark gnus-dormant-mark)
11777 (push article gnus-newsgroup-dormant))
11779 (push article gnus-newsgroup-unreads)))
11780 (setq gnus-newsgroup-reads
11781 (delq (assq article gnus-newsgroup-reads)
11782 gnus-newsgroup-reads))
11784 ;; See whether the article is to be put in the cache.
11785 (and gnus-use-cache
11786 (vectorp (gnus-summary-article-header article))
11788 (gnus-cache-possibly-enter-article
11789 gnus-newsgroup-name article
11790 (gnus-summary-article-header article)
11791 (= mark gnus-ticked-mark)
11792 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11795 (gnus-summary-update-mark mark 'unread)
11798 (defun gnus-summary-mark-article (&optional article mark no-expire)
11799 "Mark ARTICLE with MARK. MARK can be any character.
11800 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11801 `??' (dormant) and `?E' (expirable).
11802 If MARK is nil, then the default character `?D' is used.
11803 If ARTICLE is nil, then the article on the current line will be
11805 ;; The mark might be a string.
11806 (and (stringp mark)
11807 (setq mark (aref mark 0)))
11808 ;; If no mark is given, then we check auto-expiring.
11809 (and (not no-expire)
11810 gnus-newsgroup-auto-expire
11812 (and (numberp mark)
11813 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11814 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11815 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11816 (setq mark gnus-expirable-mark))
11817 (let* ((mark (or mark gnus-del-mark))
11818 (article (or article (gnus-summary-article-number))))
11819 (or article (error "No article on current line"))
11820 (if (or (= mark gnus-unread-mark)
11821 (= mark gnus-ticked-mark)
11822 (= mark gnus-dormant-mark))
11823 (gnus-mark-article-as-unread article mark)
11824 (gnus-mark-article-as-read article mark))
11826 ;; See whether the article is to be put in the cache.
11827 (and gnus-use-cache
11828 (not (= mark gnus-canceled-mark))
11829 (vectorp (gnus-summary-article-header article))
11831 (gnus-cache-possibly-enter-article
11832 gnus-newsgroup-name article
11833 (gnus-summary-article-header article)
11834 (= mark gnus-ticked-mark)
11835 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11837 (if (gnus-summary-goto-subject article nil t)
11838 (let ((buffer-read-only nil))
11839 (gnus-summary-show-thread)
11841 (gnus-summary-update-mark mark 'unread)
11844 (defun gnus-summary-update-secondary-mark (article)
11845 "Update the secondary (read, process, cache) mark."
11846 (gnus-summary-update-mark
11847 (cond ((memq article gnus-newsgroup-processable)
11849 ((memq article gnus-newsgroup-cached)
11851 ((memq article gnus-newsgroup-replied)
11853 ((memq article gnus-newsgroup-saved)
11855 (t gnus-unread-mark))
11857 (when (gnus-visual-p 'summary-highlight 'highlight)
11858 (run-hooks 'gnus-summary-update-hook))
11861 (defun gnus-summary-update-mark (mark type)
11862 (beginning-of-line)
11863 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11864 (buffer-read-only nil))
11866 ;; Go to the right position on the line.
11867 (forward-char forward)
11868 ;; Replace the old mark with the new mark.
11869 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11870 ;; Optionally update the marks by some user rule.
11871 (when (eq type 'unread)
11872 (gnus-data-set-mark
11873 (gnus-data-find (gnus-summary-article-number)) mark)
11874 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11876 (defun gnus-mark-article-as-read (article &optional mark)
11877 "Enter ARTICLE in the pertinent lists and remove it from others."
11878 ;; Make the article expirable.
11879 (let ((mark (or mark gnus-del-mark)))
11880 (if (= mark gnus-expirable-mark)
11881 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11882 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11883 ;; Remove from unread and marked lists.
11884 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11885 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11886 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11887 (push (cons article mark) gnus-newsgroup-reads)
11888 ;; Possibly remove from cache, if that is used.
11889 (when gnus-use-cache
11890 (gnus-cache-enter-remove-article article))))
11892 (defun gnus-mark-article-as-unread (article &optional mark)
11893 "Enter ARTICLE in the pertinent lists and remove it from others."
11894 (let ((mark (or mark gnus-ticked-mark)))
11895 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11896 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11897 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11898 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11899 (cond ((= mark gnus-ticked-mark)
11900 (push article gnus-newsgroup-marked))
11901 ((= mark gnus-dormant-mark)
11902 (push article gnus-newsgroup-dormant))
11904 (push article gnus-newsgroup-unreads)))
11905 (setq gnus-newsgroup-reads
11906 (delq (assq article gnus-newsgroup-reads)
11907 gnus-newsgroup-reads))))
11909 (defalias 'gnus-summary-mark-as-unread-forward
11910 'gnus-summary-tick-article-forward)
11911 (make-obsolete 'gnus-summary-mark-as-unread-forward
11912 'gnus-summary-tick-article-forward)
11913 (defun gnus-summary-tick-article-forward (n)
11914 "Tick N articles forwards.
11915 If N is negative, tick backwards instead.
11916 The difference between N and the number of articles ticked is returned."
11918 (gnus-summary-mark-forward n gnus-ticked-mark))
11920 (defalias 'gnus-summary-mark-as-unread-backward
11921 'gnus-summary-tick-article-backward)
11922 (make-obsolete 'gnus-summary-mark-as-unread-backward
11923 'gnus-summary-tick-article-backward)
11924 (defun gnus-summary-tick-article-backward (n)
11925 "Tick N articles backwards.
11926 The difference between N and the number of articles ticked is returned."
11928 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11930 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11931 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11932 (defun gnus-summary-tick-article (&optional article clear-mark)
11933 "Mark current article as unread.
11934 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11935 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11937 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11938 gnus-ticked-mark)))
11940 (defun gnus-summary-mark-as-read-forward (n)
11941 "Mark N articles as read forwards.
11942 If N is negative, mark backwards instead.
11943 The difference between N and the actual number of articles marked is
11946 (gnus-summary-mark-forward n gnus-del-mark t))
11948 (defun gnus-summary-mark-as-read-backward (n)
11949 "Mark the N articles as read backwards.
11950 The difference between N and the actual number of articles marked is
11953 (gnus-summary-mark-forward (- n) gnus-del-mark t))
11955 (defun gnus-summary-mark-as-read (&optional article mark)
11956 "Mark current article as read.
11957 ARTICLE specifies the article to be marked as read.
11958 MARK specifies a string to be inserted at the beginning of the line."
11959 (gnus-summary-mark-article article mark))
11961 (defun gnus-summary-clear-mark-forward (n)
11962 "Clear marks from N articles forward.
11963 If N is negative, clear backward instead.
11964 The difference between N and the number of marks cleared is returned."
11966 (gnus-summary-mark-forward n gnus-unread-mark))
11968 (defun gnus-summary-clear-mark-backward (n)
11969 "Clear marks from N articles backward.
11970 The difference between N and the number of marks cleared is returned."
11972 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11974 (defun gnus-summary-mark-unread-as-read ()
11975 "Intended to be used by `gnus-summary-mark-article-hook'."
11976 (when (memq gnus-current-article gnus-newsgroup-unreads)
11977 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11979 (defun gnus-summary-mark-read-and-unread-as-read ()
11980 "Intended to be used by `gnus-summary-mark-article-hook'."
11981 (let ((mark (gnus-summary-article-mark)))
11982 (when (or (gnus-unread-mark-p mark)
11983 (gnus-read-mark-p mark))
11984 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
11986 (defun gnus-summary-mark-region-as-read (point mark all)
11987 "Mark all unread articles between point and mark as read.
11988 If given a prefix, mark all articles between point and mark as read,
11989 even ticked and dormant ones."
11990 (interactive "r\nP")
11994 (beginning-of-line)
11999 (memq (setq article (gnus-summary-article-number))
12000 gnus-newsgroup-unreads))
12001 (gnus-summary-mark-article article gnus-del-mark))
12003 (gnus-summary-find-next))))))
12005 (defun gnus-summary-mark-below (score mark)
12006 "Mark articles with score less than SCORE with MARK."
12007 (interactive "P\ncMark: ")
12008 (gnus-set-global-variables)
12009 (setq score (if score
12010 (prefix-numeric-value score)
12011 (or gnus-summary-default-score 0)))
12013 (set-buffer gnus-summary-buffer)
12014 (goto-char (point-min))
12017 (and (< (gnus-summary-article-score) score)
12018 (gnus-summary-mark-article nil mark))
12019 (gnus-summary-find-next)))))
12021 (defun gnus-summary-kill-below (&optional score)
12022 "Mark articles with score below SCORE as read."
12024 (gnus-set-global-variables)
12025 (gnus-summary-mark-below score gnus-killed-mark))
12027 (defun gnus-summary-clear-above (&optional score)
12028 "Clear all marks from articles with score above SCORE."
12030 (gnus-set-global-variables)
12031 (gnus-summary-mark-above score gnus-unread-mark))
12033 (defun gnus-summary-tick-above (&optional score)
12034 "Tick all articles with score above SCORE."
12036 (gnus-set-global-variables)
12037 (gnus-summary-mark-above score gnus-ticked-mark))
12039 (defun gnus-summary-mark-above (score mark)
12040 "Mark articles with score over SCORE with MARK."
12041 (interactive "P\ncMark: ")
12042 (gnus-set-global-variables)
12043 (setq score (if score
12044 (prefix-numeric-value score)
12045 (or gnus-summary-default-score 0)))
12047 (set-buffer gnus-summary-buffer)
12048 (goto-char (point-min))
12050 (if (> (gnus-summary-article-score) score)
12051 (gnus-summary-mark-article nil mark))
12053 (gnus-summary-find-next)))))
12055 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12056 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12057 (defun gnus-summary-limit-include-expunged ()
12058 "Display all the hidden articles that were expunged for low scores."
12060 (gnus-set-global-variables)
12061 (let ((buffer-read-only nil))
12062 (let ((scored gnus-newsgroup-scored)
12065 (or (gnus-summary-goto-subject (caar scored))
12066 (and (setq h (gnus-summary-article-header (caar scored)))
12067 (< (cdar scored) gnus-summary-expunge-below)
12068 (setq headers (cons h headers))))
12069 (setq scored (cdr scored)))
12070 (or headers (error "No expunged articles hidden."))
12071 (goto-char (point-min))
12072 (gnus-summary-prepare-unthreaded (nreverse headers)))
12073 (goto-char (point-min))
12074 (gnus-summary-position-point)))
12076 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12077 "Mark all articles not marked as unread in this newsgroup as read.
12078 If prefix argument ALL is non-nil, all articles are marked as read.
12079 If QUIETLY is non-nil, no questions will be asked.
12080 If TO-HERE is non-nil, it should be a point in the buffer. All
12081 articles before this point will be marked as read.
12082 The number of articles marked as read is returned."
12084 (gnus-set-global-variables)
12087 (not gnus-interactive-catchup) ;Without confirmation?
12091 "Mark absolutely all articles as read? "
12092 "Mark all unread articles as read? ")))
12094 (not gnus-newsgroup-adaptive)
12095 (not gnus-newsgroup-auto-expire))
12098 (setq gnus-newsgroup-marked nil
12099 gnus-newsgroup-dormant nil))
12100 (setq gnus-newsgroup-unreads nil))
12101 ;; We actually mark all articles as canceled, which we
12102 ;; have to do when using auto-expiry or adaptive scoring.
12103 (gnus-summary-show-all-threads)
12104 (if (gnus-summary-first-subject (not all))
12106 (if to-here (< (point) to-here) t)
12107 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12108 (gnus-summary-find-next (not all)))))
12110 (setq gnus-newsgroup-unreads nil))
12111 (gnus-set-mode-line 'summary)))
12112 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12113 (if (and (not to-here) (eq 'nnvirtual (car method)))
12114 (nnvirtual-catchup-group
12115 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12116 (gnus-summary-position-point)))
12118 (defun gnus-summary-catchup-to-here (&optional all)
12119 "Mark all unticked articles before the current one as read.
12120 If ALL is non-nil, also mark ticked and dormant articles as read."
12122 (gnus-set-global-variables)
12124 (let ((beg (point)))
12125 ;; We check that there are unread articles.
12126 (when (or all (gnus-summary-find-prev))
12127 (gnus-summary-catchup all t beg))))
12128 (gnus-summary-position-point))
12130 (defun gnus-summary-catchup-all (&optional quietly)
12131 "Mark all articles in this newsgroup as read."
12133 (gnus-set-global-variables)
12134 (gnus-summary-catchup t quietly))
12136 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12137 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12138 If prefix argument ALL is non-nil, all articles are marked as read."
12140 (gnus-set-global-variables)
12141 (gnus-summary-catchup all quietly nil 'fast)
12142 ;; Select next newsgroup or exit.
12143 (if (eq gnus-auto-select-next 'quietly)
12144 (gnus-summary-next-group nil)
12145 (gnus-summary-exit)))
12147 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12148 "Mark all articles in this newsgroup as read, and then exit."
12150 (gnus-set-global-variables)
12151 (gnus-summary-catchup-and-exit t quietly))
12153 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12154 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12155 "Mark all articles in this group as read and select the next group.
12156 If given a prefix, mark all articles, unread as well as ticked, as
12159 (gnus-set-global-variables)
12161 (gnus-summary-catchup all))
12162 (gnus-summary-next-article t nil nil t))
12164 ;; Thread-based commands.
12166 (defun gnus-summary-articles-in-thread (&optional article)
12167 "Return a list of all articles in the current thread.
12168 If ARTICLE is non-nil, return all articles in the thread that starts
12169 with that article."
12170 (let* ((article (or article (gnus-summary-article-number)))
12171 (data (gnus-data-find-list article))
12172 (top-level (gnus-data-level (car data)))
12174 (cond ((null gnus-thread-operation-ignore-subject)
12175 (gnus-simplify-subject-re
12176 (mail-header-subject (gnus-data-header (car data)))))
12177 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12178 (gnus-simplify-subject-fuzzy
12179 (mail-header-subject (gnus-data-header (car data)))))
12183 () ; This article doesn't exist.
12185 (and (or (not top-subject)
12186 (string= top-subject
12187 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12188 (gnus-simplify-subject-fuzzy
12189 (mail-header-subject
12190 (gnus-data-header (car data))))
12191 (gnus-simplify-subject-re
12192 (mail-header-subject
12193 (gnus-data-header (car data)))))))
12194 (setq articles (cons (gnus-data-number (car data)) articles)))
12195 (if (and (setq data (cdr data))
12196 (> (gnus-data-level (car data)) top-level))
12199 ;; Return the list of articles.
12200 (nreverse articles))))
12202 (defun gnus-summary-rethread-current ()
12203 "Rethread the thread the current article is part of."
12205 (gnus-set-global-variables)
12206 (let* ((gnus-show-threads t)
12207 (article (gnus-summary-article-number))
12208 (id (mail-header-id (gnus-summary-article-header)))
12209 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12211 (error "No article on the current line"))
12212 (gnus-rebuild-thread id)
12213 (gnus-summary-goto-subject article)))
12215 (defun gnus-summary-reparent-thread ()
12216 "Make current article child of the marked (or previous) article.
12218 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12219 is non-nil or the Subject: of both articles are the same."
12221 (or (not (gnus-group-read-only-p))
12222 (error "The current newsgroup does not support article editing."))
12223 (or (<= (length gnus-newsgroup-processable) 1)
12224 (error "No more than one article may be marked."))
12225 (save-window-excursion
12226 (let ((gnus-article-buffer " *reparent*")
12227 (current-article (gnus-summary-article-number))
12228 ; first grab the marked article, otherwise one line up.
12229 (parent-article (if (not (null gnus-newsgroup-processable))
12230 (car gnus-newsgroup-processable)
12232 (if (eq (forward-line -1) 0)
12233 (gnus-summary-article-number)
12234 (error "Beginning of summary buffer."))))))
12235 (or (not (eq current-article parent-article))
12236 (error "An article may not be self-referential."))
12237 (let ((message-id (mail-header-id
12238 (gnus-summary-article-header parent-article))))
12239 (or (and message-id (not (equal message-id "")))
12240 (error "No message-id in desired parent."))
12241 (gnus-summary-select-article t t nil current-article)
12242 (set-buffer gnus-article-buffer)
12243 (setq buffer-read-only nil)
12244 (let ((buf (format "%s" (buffer-string))))
12247 (goto-char (point-min))
12248 (if (search-forward-regexp "^References: " nil t)
12249 (insert message-id " " )
12250 (insert "References: " message-id "\n"))
12251 (or (gnus-request-replace-article current-article
12252 (car gnus-article-current)
12253 gnus-article-buffer)
12254 (error "Couldn't replace article."))
12255 (set-buffer gnus-summary-buffer)
12256 (gnus-summary-unmark-all-processable)
12257 (gnus-summary-rethread-current)
12258 (message "Article %d is now the child of article %d."
12259 current-article parent-article)))))
12261 (defun gnus-summary-toggle-threads (&optional arg)
12262 "Toggle showing conversation threads.
12263 If ARG is positive number, turn showing conversation threads on."
12265 (gnus-set-global-variables)
12266 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12267 (setq gnus-show-threads
12268 (if (null arg) (not gnus-show-threads)
12269 (> (prefix-numeric-value arg) 0)))
12270 (gnus-summary-prepare)
12271 (gnus-summary-goto-subject current)
12272 (gnus-summary-position-point)))
12274 (defun gnus-summary-show-all-threads ()
12275 "Show all threads."
12277 (gnus-set-global-variables)
12279 (let ((buffer-read-only nil))
12280 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12281 (gnus-summary-position-point))
12283 (defun gnus-summary-show-thread ()
12284 "Show thread subtrees.
12285 Returns nil if no thread was there to be shown."
12287 (gnus-set-global-variables)
12288 (let ((buffer-read-only nil)
12290 ;; first goto end then to beg, to have point at beg after let
12291 (end (progn (end-of-line) (point)))
12292 (beg (progn (beginning-of-line) (point))))
12294 ;; Any hidden lines here?
12295 (search-forward "\r" end t)
12296 (subst-char-in-region beg end ?\^M ?\n t)
12298 (gnus-summary-position-point))))
12300 (defun gnus-summary-hide-all-threads ()
12301 "Hide all thread subtrees."
12303 (gnus-set-global-variables)
12305 (goto-char (point-min))
12306 (gnus-summary-hide-thread)
12307 (while (zerop (gnus-summary-next-thread 1 t))
12308 (gnus-summary-hide-thread)))
12309 (gnus-summary-position-point))
12311 (defun gnus-summary-hide-thread ()
12312 "Hide thread subtrees.
12313 Returns nil if no threads were there to be hidden."
12315 (gnus-set-global-variables)
12316 (let ((buffer-read-only nil)
12318 (article (gnus-summary-article-number)))
12320 ;; Go forward until either the buffer ends or the subthread
12322 (when (and (not (eobp))
12323 (or (zerop (gnus-summary-next-thread 1 t))
12324 (goto-char (point-max))))
12326 (if (and (> (point) start)
12327 (search-backward "\n" start t))
12329 (subst-char-in-region start (point) ?\n ?\^M)
12330 (gnus-summary-goto-subject article))
12333 ;;(gnus-summary-position-point)
12336 (defun gnus-summary-go-to-next-thread (&optional previous)
12337 "Go to the same level (or less) next thread.
12338 If PREVIOUS is non-nil, go to previous thread instead.
12339 Return the article number moved to, or nil if moving was impossible."
12340 (let ((level (gnus-summary-thread-level))
12341 (way (if previous -1 1))
12344 (while (and (not (eobp))
12345 (< level (gnus-summary-thread-level)))
12346 (forward-line way))
12353 (gnus-summary-article-number)
12354 (goto-char beg)))))
12356 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12357 "Go to the same level (or less) next thread.
12358 If PREVIOUS is non-nil, go to previous thread instead.
12359 Return the article number moved to, or nil if moving was impossible."
12360 (if (and (eq gnus-summary-make-false-root 'dummy)
12361 (gnus-summary-article-intangible-p))
12362 (let ((beg (point)))
12363 (while (and (zerop (forward-line 1))
12364 (not (gnus-summary-article-intangible-p))
12365 (not (zerop (save-excursion
12366 (gnus-summary-thread-level))))))
12372 (let* ((level (gnus-summary-thread-level))
12373 (article (gnus-summary-article-number))
12374 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12377 (if (<= (gnus-data-level (car data)) level)
12378 (setq oart (gnus-data-number (car data))
12380 (setq data (cdr data))))
12382 (gnus-summary-goto-subject oart)))))
12384 (defun gnus-summary-next-thread (n &optional silent)
12385 "Go to the same level next N'th thread.
12386 If N is negative, search backward instead.
12387 Returns the difference between N and the number of skips actually
12390 If SILENT, don't output messages."
12392 (gnus-set-global-variables)
12393 (let ((backward (< n 0))
12396 (while (and (> n 0)
12397 (gnus-summary-go-to-next-thread backward))
12400 (gnus-summary-position-point))
12401 (when (and (not silent) (/= 0 n))
12402 (gnus-message 7 "No more threads"))
12405 (defun gnus-summary-prev-thread (n)
12406 "Go to the same level previous N'th thread.
12407 Returns the difference between N and the number of skips actually
12410 (gnus-set-global-variables)
12411 (gnus-summary-next-thread (- n)))
12413 (defun gnus-summary-go-down-thread ()
12414 "Go down one level in the current thread."
12415 (let ((children (gnus-summary-article-children)))
12417 (gnus-summary-goto-subject (car children)))))
12419 (defun gnus-summary-go-up-thread ()
12420 "Go up one level in the current thread."
12421 (let ((parent (gnus-summary-article-parent)))
12423 (gnus-summary-goto-subject parent))))
12425 (defun gnus-summary-down-thread (n)
12426 "Go down thread N steps.
12427 If N is negative, go up instead.
12428 Returns the difference between N and how many steps down that were
12431 (gnus-set-global-variables)
12434 (while (and (> n 0)
12435 (if up (gnus-summary-go-up-thread)
12436 (gnus-summary-go-down-thread)))
12438 (gnus-summary-position-point)
12439 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12442 (defun gnus-summary-up-thread (n)
12443 "Go up thread N steps.
12444 If N is negative, go up instead.
12445 Returns the difference between N and how many steps down that were
12448 (gnus-set-global-variables)
12449 (gnus-summary-down-thread (- n)))
12451 (defun gnus-summary-top-thread ()
12452 "Go to the top of the thread."
12454 (gnus-set-global-variables)
12455 (while (gnus-summary-go-up-thread))
12456 (gnus-summary-article-number))
12458 (defun gnus-summary-kill-thread (&optional unmark)
12459 "Mark articles under current thread as read.
12460 If the prefix argument is positive, remove any kinds of marks.
12461 If the prefix argument is negative, tick articles instead."
12463 (gnus-set-global-variables)
12465 (setq unmark (prefix-numeric-value unmark)))
12466 (let ((articles (gnus-summary-articles-in-thread)))
12468 ;; Expand the thread.
12469 (gnus-summary-show-thread)
12470 ;; Mark all the articles.
12472 (gnus-summary-goto-subject (car articles))
12473 (cond ((null unmark)
12474 (gnus-summary-mark-article-as-read gnus-killed-mark))
12476 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12478 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12479 (setq articles (cdr articles))))
12480 ;; Hide killed subtrees.
12482 gnus-thread-hide-killed
12483 (gnus-summary-hide-thread))
12484 ;; If marked as read, go to next unread subject.
12486 ;; Go to next unread subject.
12487 (gnus-summary-next-subject 1 t)))
12488 (gnus-set-mode-line 'summary))
12490 ;; Summary sorting commands
12492 (defun gnus-summary-sort-by-number (&optional reverse)
12493 "Sort summary buffer by article number.
12494 Argument REVERSE means reverse order."
12496 (gnus-summary-sort 'number reverse))
12498 (defun gnus-summary-sort-by-author (&optional reverse)
12499 "Sort summary buffer by author name alphabetically.
12500 If case-fold-search is non-nil, case of letters is ignored.
12501 Argument REVERSE means reverse order."
12503 (gnus-summary-sort 'author reverse))
12505 (defun gnus-summary-sort-by-subject (&optional reverse)
12506 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12507 If case-fold-search is non-nil, case of letters is ignored.
12508 Argument REVERSE means reverse order."
12510 (gnus-summary-sort 'subject reverse))
12512 (defun gnus-summary-sort-by-date (&optional reverse)
12513 "Sort summary buffer by date.
12514 Argument REVERSE means reverse order."
12516 (gnus-summary-sort 'date reverse))
12518 (defun gnus-summary-sort-by-score (&optional reverse)
12519 "Sort summary buffer by score.
12520 Argument REVERSE means reverse order."
12522 (gnus-summary-sort 'score reverse))
12524 (defun gnus-summary-sort (predicate reverse)
12525 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12526 (gnus-set-global-variables)
12527 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12528 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12529 (gnus-thread-sort-functions
12534 (,thread t2 t1)))))
12535 (gnus-article-sort-functions
12540 (,article t2 t1)))))
12542 (gnus-summary-prepare-hook nil))
12543 ;; We do the sorting by regenerating the threads.
12544 (gnus-summary-prepare)
12545 ;; Hide subthreads if needed.
12546 (when (and gnus-show-threads gnus-thread-hide-subtree)
12547 (gnus-summary-hide-all-threads)))
12548 ;; If in async mode, we send some info to the backend.
12549 (when gnus-newsgroup-async
12550 (gnus-request-asynchronous
12551 gnus-newsgroup-name gnus-newsgroup-data)))
12553 (defun gnus-sortable-date (date)
12554 "Make sortable string by string-lessp from DATE.
12555 Timezone package is used."
12556 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12557 (year (aref date 0))
12558 (month (aref date 1))
12559 (day (aref date 2)))
12560 (timezone-make-sortable-date
12562 (timezone-make-time-string
12563 (aref date 3) (aref date 4) (aref date 5)))))
12565 ;; Summary saving commands.
12567 (defun gnus-summary-save-article (&optional n not-saved)
12568 "Save the current article using the default saver function.
12569 If N is a positive number, save the N next articles.
12570 If N is a negative number, save the N previous articles.
12571 If N is nil and any articles have been marked with the process mark,
12572 save those articles instead.
12573 The variable `gnus-default-article-saver' specifies the saver function."
12575 (gnus-set-global-variables)
12576 (let ((articles (gnus-summary-work-articles n))
12577 file header article)
12579 (setq header (gnus-summary-article-header
12580 (setq article (pop articles))))
12581 (if (not (vectorp header))
12582 ;; This is a pseudo-article.
12583 (if (assq 'name header)
12584 (gnus-copy-file (cdr (assq 'name header)))
12585 (gnus-message 1 "Article %d is unsaveable" article))
12586 ;; This is a real article.
12587 (save-window-excursion
12588 (gnus-summary-select-article t nil nil article))
12589 (unless gnus-save-all-headers
12590 ;; Remove headers accoring to `gnus-saved-headers'.
12591 (let ((gnus-visible-headers
12592 (or gnus-saved-headers gnus-visible-headers)))
12593 (gnus-article-hide-headers nil t)))
12594 ;; Remove any X-Gnus lines.
12596 (set-buffer gnus-article-buffer)
12598 (let ((buffer-read-only nil))
12599 (nnheader-narrow-to-headers)
12600 (while (re-search-forward "^X-Gnus" nil t)
12601 (gnus-delete-line)))))
12602 (save-window-excursion
12603 (if (not gnus-default-article-saver)
12604 (error "No default saver is defined.")
12605 (setq file (funcall
12606 gnus-default-article-saver
12608 ((not gnus-prompt-before-saving)
12610 ((eq gnus-prompt-before-saving 'always)
12613 (gnus-summary-remove-process-mark article)
12615 (gnus-summary-set-saved-mark article))))
12616 (gnus-summary-position-point)
12619 (defun gnus-summary-pipe-output (&optional arg)
12620 "Pipe the current article to a subprocess.
12621 If N is a positive number, pipe the N next articles.
12622 If N is a negative number, pipe the N previous articles.
12623 If N is nil and any articles have been marked with the process mark,
12624 pipe those articles instead."
12626 (gnus-set-global-variables)
12627 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12628 (gnus-summary-save-article arg t))
12629 (gnus-configure-windows 'pipe))
12631 (defun gnus-summary-save-article-mail (&optional arg)
12632 "Append the current article to an mail file.
12633 If N is a positive number, save the N next articles.
12634 If N is a negative number, save the N previous articles.
12635 If N is nil and any articles have been marked with the process mark,
12636 save those articles instead."
12638 (gnus-set-global-variables)
12639 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12640 (gnus-summary-save-article arg)))
12642 (defun gnus-summary-save-article-rmail (&optional arg)
12643 "Append the current article to an rmail file.
12644 If N is a positive number, save the N next articles.
12645 If N is a negative number, save the N previous articles.
12646 If N is nil and any articles have been marked with the process mark,
12647 save those articles instead."
12649 (gnus-set-global-variables)
12650 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12651 (gnus-summary-save-article arg)))
12653 (defun gnus-summary-save-article-file (&optional arg)
12654 "Append the current article to a file.
12655 If N is a positive number, save the N next articles.
12656 If N is a negative number, save the N previous articles.
12657 If N is nil and any articles have been marked with the process mark,
12658 save those articles instead."
12660 (gnus-set-global-variables)
12661 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12662 (gnus-summary-save-article arg)))
12664 (defun gnus-summary-save-article-body-file (&optional arg)
12665 "Append the current article body to a file.
12666 If N is a positive number, save the N next articles.
12667 If N is a negative number, save the N previous articles.
12668 If N is nil and any articles have been marked with the process mark,
12669 save those articles instead."
12671 (gnus-set-global-variables)
12672 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12673 (gnus-summary-save-article arg)))
12675 (defun gnus-get-split-value (methods)
12676 "Return a value based on the split METHODS."
12677 (let (split-name method result match)
12680 (set-buffer gnus-original-article-buffer)
12682 (nnheader-narrow-to-headers)
12684 (goto-char (point-min))
12685 (setq method (pop methods))
12686 (setq match (car method))
12689 ;; Regular expression.
12691 (re-search-forward match nil t)
12693 ((gnus-functionp match)
12697 (setq result (funcall match gnus-newsgroup-name))))
12702 (setq result (eval match)))))
12703 (setq split-name (append (cdr method) split-name))
12704 (cond ((stringp result)
12705 (push result split-name))
12707 (setq split-name (append result split-name)))))))))
12710 (defun gnus-read-move-group-name (prompt default articles prefix)
12711 "Read a group name."
12712 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12714 (format "Where do you want to %s %s? "
12716 (if (> (length articles) 1)
12717 (format "these %d articles" (length articles))
12725 (format "(default %s) " default)
12727 gnus-active-hashtb nil nil prefix))
12728 ((= 1 (length split-name))
12729 (completing-read prom gnus-active-hashtb
12730 nil nil (cons (car split-name) 0)))
12733 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12736 (if (or (string= to-newsgroup "")
12737 (string= to-newsgroup prefix))
12738 (setq to-newsgroup (or default "")))
12739 (or (gnus-active to-newsgroup)
12740 (gnus-activate-group to-newsgroup)
12741 (error "No such group: %s" to-newsgroup)))
12744 (defun gnus-read-save-file-name (prompt default-name)
12745 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12747 ;; Let the split methods have their say.
12749 ;; No split name was found.
12752 (concat prompt " (default "
12753 (file-name-nondirectory default-name) ") ")
12754 (file-name-directory default-name)
12756 ;; A single split name was found
12757 ((= 1 (length split-name))
12759 (concat prompt " (default " (car split-name) ") ")
12760 gnus-article-save-directory
12761 (concat gnus-article-save-directory (car split-name))))
12762 ;; A list of splits was found.
12764 (setq split-name (mapcar (lambda (el) (list el))
12765 (nreverse split-name)))
12766 (let ((result (completing-read
12767 (concat prompt " ") split-name nil nil)))
12768 (concat gnus-article-save-directory
12769 (if (string= result "")
12772 ;; If we have read a directory, we append the default file name.
12773 (when (file-directory-p file)
12774 (setq file (concat (file-name-as-directory file)
12775 (file-name-nondirectory default-name))))
12776 ;; Possibly translate some charaters.
12777 (nnheader-translate-file-chars file)))
12779 (defun gnus-article-archive-name (group)
12780 "Return the first instance of an \"Archive-name\" in the current buffer."
12781 (let ((case-fold-search t))
12782 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12783 (match-string 1))))
12785 (defun gnus-summary-save-in-rmail (&optional filename)
12786 "Append this article to Rmail file.
12787 Optional argument FILENAME specifies file name.
12788 Directory to save to is default to `gnus-article-save-directory' which
12789 is initialized from the SAVEDIR environment variable."
12791 (gnus-set-global-variables)
12792 (let ((default-name
12793 (funcall gnus-rmail-save-name gnus-newsgroup-name
12794 gnus-current-headers gnus-newsgroup-last-rmail)))
12796 (cond ((eq filename 'default)
12798 (filename filename)
12799 (t (gnus-read-save-file-name
12800 "Save in rmail file:" default-name))))
12801 (gnus-make-directory (file-name-directory filename))
12802 (gnus-eval-in-buffer-window
12803 gnus-original-article-buffer
12807 (gnus-output-to-rmail filename))))
12808 ;; Remember the directory name to save articles
12809 (setq gnus-newsgroup-last-rmail filename)))
12811 (defun gnus-summary-save-in-mail (&optional filename)
12812 "Append this article to Unix mail file.
12813 Optional argument FILENAME specifies file name.
12814 Directory to save to is default to `gnus-article-save-directory' which
12815 is initialized from the SAVEDIR environment variable."
12817 (gnus-set-global-variables)
12818 (let ((default-name
12819 (funcall gnus-mail-save-name gnus-newsgroup-name
12820 gnus-current-headers gnus-newsgroup-last-mail)))
12822 (cond ((eq filename 'default)
12824 (filename filename)
12825 (t (gnus-read-save-file-name
12826 "Save in Unix mail file:" default-name))))
12828 (expand-file-name filename
12830 (file-name-directory default-name))))
12831 (gnus-make-directory (file-name-directory filename))
12832 (gnus-eval-in-buffer-window
12833 gnus-original-article-buffer
12837 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12838 (gnus-output-to-rmail filename)
12839 (let ((mail-use-rfc822 t))
12840 (rmail-output filename 1 t t))))))
12841 ;; Remember the directory name to save articles.
12842 (setq gnus-newsgroup-last-mail filename)))
12844 (defun gnus-summary-save-in-file (&optional filename)
12845 "Append this article to file.
12846 Optional argument FILENAME specifies file name.
12847 Directory to save to is default to `gnus-article-save-directory' which
12848 is initialized from the SAVEDIR environment variable."
12850 (gnus-set-global-variables)
12851 (let ((default-name
12852 (funcall gnus-file-save-name gnus-newsgroup-name
12853 gnus-current-headers gnus-newsgroup-last-file)))
12855 (cond ((eq filename 'default)
12857 (filename filename)
12858 (t (gnus-read-save-file-name
12859 "Save in file:" default-name))))
12860 (gnus-make-directory (file-name-directory filename))
12861 (gnus-eval-in-buffer-window
12862 gnus-original-article-buffer
12866 (gnus-output-to-file filename))))
12867 ;; Remember the directory name to save articles.
12868 (setq gnus-newsgroup-last-file filename)))
12870 (defun gnus-summary-save-body-in-file (&optional filename)
12871 "Append this article body to a file.
12872 Optional argument FILENAME specifies file name.
12873 The directory to save in defaults to `gnus-article-save-directory' which
12874 is initialized from the SAVEDIR environment variable."
12876 (gnus-set-global-variables)
12877 (let ((default-name
12878 (funcall gnus-file-save-name gnus-newsgroup-name
12879 gnus-current-headers gnus-newsgroup-last-file)))
12881 (cond ((eq filename 'default)
12883 (filename filename)
12884 (t (gnus-read-save-file-name
12885 "Save body in file:" default-name))))
12886 (gnus-make-directory (file-name-directory filename))
12887 (gnus-eval-in-buffer-window
12888 gnus-article-buffer
12892 (goto-char (point-min))
12893 (and (search-forward "\n\n" nil t)
12894 (narrow-to-region (point) (point-max)))
12895 (gnus-output-to-file filename))))
12896 ;; Remember the directory name to save articles.
12897 (setq gnus-newsgroup-last-file filename)))
12899 (defun gnus-summary-save-in-pipe (&optional command)
12900 "Pipe this article to subprocess."
12902 (gnus-set-global-variables)
12904 (cond ((eq command 'default)
12905 gnus-last-shell-command)
12907 (t (read-string "Shell command on article: "
12908 gnus-last-shell-command))))
12909 (if (string-equal command "")
12910 (setq command gnus-last-shell-command))
12911 (gnus-eval-in-buffer-window
12912 gnus-article-buffer
12915 (shell-command-on-region (point-min) (point-max) command nil)))
12916 (setq gnus-last-shell-command command))
12918 ;; Summary extract commands
12920 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12921 (let ((buffer-read-only nil)
12922 (article (gnus-summary-article-number))
12924 (or (gnus-summary-goto-subject article)
12925 (error (format "No such article: %d" article)))
12926 (gnus-summary-position-point)
12927 ;; If all commands are to be bunched up on one line, we collect
12929 (if gnus-view-pseudos-separately
12931 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12934 (setq action (cdr (assq 'action (car ps))))
12935 (setq files (list (cdr (assq 'name (car ps)))))
12936 (while (and ps (cdr ps)
12937 (string= (or action "1")
12938 (or (cdr (assq 'action (cadr ps))) "2")))
12939 (setq files (cons (cdr (assq 'name (cadr ps))) files))
12940 (setcdr ps (cddr ps)))
12943 (if (not (string-match "%s" action))
12944 (setq files (cons " " files)))
12945 (setq files (cons " " files))
12946 (and (assq 'execute (car ps))
12947 (setcdr (assq 'execute (car ps))
12948 (funcall (if (string-match "%s" action)
12951 (mapconcat (lambda (f) f) files " ")))))
12952 (setq ps (cdr ps)))))
12953 (if (and gnus-view-pseudos (not not-view))
12955 (and (assq 'execute (car pslist))
12956 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12957 (eq gnus-view-pseudos 'not-confirm)))
12958 (setq pslist (cdr pslist)))
12961 (setq after-article (or (cdr (assq 'article (car pslist)))
12962 (gnus-summary-article-number)))
12963 (gnus-summary-goto-subject after-article)
12966 (insert " " (file-name-nondirectory
12967 (cdr (assq 'name (car pslist))))
12968 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12970 (forward-line -1) ; back to `b'
12971 (add-text-properties
12972 b e (list 'gnus-number gnus-reffed-article-number
12973 gnus-mouse-face-prop gnus-mouse-face))
12975 after-article gnus-reffed-article-number
12976 gnus-unread-mark b (car pslist) 0 (- e b))
12977 (push gnus-reffed-article-number gnus-newsgroup-unreads)
12978 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12979 (setq pslist (cdr pslist)))))))
12981 (defun gnus-pseudos< (p1 p2)
12982 (let ((c1 (cdr (assq 'action p1)))
12983 (c2 (cdr (assq 'action p2))))
12984 (and c1 c2 (string< c1 c2))))
12986 (defun gnus-request-pseudo-article (props)
12987 (cond ((assq 'execute props)
12988 (gnus-execute-command (cdr (assq 'execute props)))))
12989 (let ((gnus-current-article (gnus-summary-article-number)))
12990 (run-hooks 'gnus-mark-article-hook)))
12992 (defun gnus-execute-command (command &optional automatic)
12994 (gnus-article-setup-buffer)
12995 (set-buffer gnus-article-buffer)
12996 (let ((command (if automatic command (read-string "Command: " command)))
12997 (buffer-read-only nil))
12999 (insert "$ " command "\n\n")
13000 (if gnus-view-pseudo-asynchronously
13001 (start-process "gnus-execute" nil "sh" "-c" command)
13002 (call-process "sh" nil t nil "-c" command)))))
13004 (defun gnus-copy-file (file &optional to)
13007 (list (read-file-name "Copy file: " default-directory)
13008 (read-file-name "Copy file to: " default-directory)))
13009 (gnus-set-global-variables)
13010 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13011 (and (file-directory-p to)
13012 (setq to (concat (file-name-as-directory to)
13013 (file-name-nondirectory file))))
13014 (copy-file file to))
13016 ;; Summary kill commands.
13018 (defun gnus-summary-edit-global-kill (article)
13019 "Edit the \"global\" kill file."
13020 (interactive (list (gnus-summary-article-number)))
13021 (gnus-set-global-variables)
13022 (gnus-group-edit-global-kill article))
13024 (defun gnus-summary-edit-local-kill ()
13025 "Edit a local kill file applied to the current newsgroup."
13027 (gnus-set-global-variables)
13028 (setq gnus-current-headers (gnus-summary-article-header))
13029 (gnus-set-global-variables)
13030 (gnus-group-edit-local-kill
13031 (gnus-summary-article-number) gnus-newsgroup-name))
13035 ;;; Gnus article mode
13038 (put 'gnus-article-mode 'mode-class 'special)
13040 (if gnus-article-mode-map
13042 (setq gnus-article-mode-map (make-keymap))
13043 (suppress-keymap gnus-article-mode-map)
13045 (gnus-define-keys gnus-article-mode-map
13046 " " gnus-article-goto-next-page
13047 "\177" gnus-article-goto-prev-page
13048 [delete] gnus-article-goto-prev-page
13049 "\C-c^" gnus-article-refer-article
13050 "h" gnus-article-show-summary
13051 "s" gnus-article-show-summary
13052 "\C-c\C-m" gnus-article-mail
13053 "?" gnus-article-describe-briefly
13054 gnus-mouse-2 gnus-article-push-button
13055 "\r" gnus-article-press-button
13056 "\t" gnus-article-next-button
13057 "\M-\t" gnus-article-prev-button
13058 "\C-c\C-b" gnus-bug)
13060 (substitute-key-definition
13061 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13063 (defun gnus-article-mode ()
13064 "Major mode for displaying an article.
13066 All normal editing commands are switched off.
13068 The following commands are available:
13070 \\<gnus-article-mode-map>
13071 \\[gnus-article-next-page]\t Scroll the article one page forwards
13072 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13073 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13074 \\[gnus-article-show-summary]\t Display the summary buffer
13075 \\[gnus-article-mail]\t Send a reply to the address near point
13076 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13077 \\[gnus-info-find-node]\t Go to the Gnus info node"
13079 (when (and menu-bar-mode
13080 (gnus-visual-p 'article-menu 'menu))
13081 (gnus-article-make-menu-bar))
13082 (kill-all-local-variables)
13083 (gnus-simplify-mode-line)
13084 (setq mode-name "Article")
13085 (setq major-mode 'gnus-article-mode)
13086 (make-local-variable 'minor-mode-alist)
13087 (or (assq 'gnus-show-mime minor-mode-alist)
13088 (setq minor-mode-alist
13089 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13090 (use-local-map gnus-article-mode-map)
13091 (make-local-variable 'page-delimiter)
13092 (setq page-delimiter gnus-page-delimiter)
13093 (buffer-disable-undo (current-buffer))
13094 (setq buffer-read-only t) ;Disable modification
13095 (run-hooks 'gnus-article-mode-hook))
13097 (defun gnus-article-setup-buffer ()
13098 "Initialize the article buffer."
13099 (let* ((name (if gnus-single-article-buffer "*Article*"
13100 (concat "*Article " gnus-newsgroup-name "*")))
13102 (progn (string-match "\\*Article" name)
13103 (concat " *Original Article"
13104 (substring name (match-end 0))))))
13105 (setq gnus-article-buffer name)
13106 (setq gnus-original-article-buffer original)
13107 ;; This might be a variable local to the summary buffer.
13108 (unless gnus-single-article-buffer
13110 (set-buffer gnus-summary-buffer)
13111 (setq gnus-article-buffer name)
13112 (setq gnus-original-article-buffer original)
13113 (gnus-set-global-variables))
13114 (make-local-variable 'gnus-summary-buffer))
13115 (if (get-buffer name)
13118 (buffer-disable-undo (current-buffer))
13119 (setq buffer-read-only t)
13120 (gnus-add-current-to-buffer-list)
13121 (or (eq major-mode 'gnus-article-mode)
13122 (gnus-article-mode))
13125 (set-buffer (get-buffer-create name))
13126 (gnus-add-current-to-buffer-list)
13127 (gnus-article-mode)
13128 (current-buffer)))))
13130 ;; Set article window start at LINE, where LINE is the number of lines
13131 ;; from the head of the article.
13132 (defun gnus-article-set-window-start (&optional line)
13134 (get-buffer-window gnus-article-buffer)
13136 (set-buffer gnus-article-buffer)
13137 (goto-char (point-min))
13140 (gnus-message 6 "Moved to bookmark")
13141 (search-forward "\n\n" nil t)
13142 (forward-line line)
13145 (defun gnus-kill-all-overlays ()
13146 "Delete all overlays in the current buffer."
13147 (when (fboundp 'overlay-lists)
13148 (let* ((overlayss (overlay-lists))
13149 (buffer-read-only nil)
13150 (overlays (nconc (car overlayss) (cdr overlayss))))
13152 (delete-overlay (pop overlays))))))
13154 (defun gnus-request-article-this-buffer (article group)
13155 "Get an article and insert it into this buffer."
13159 (gnus-kill-all-overlays)
13160 (setq group (or group gnus-newsgroup-name))
13162 ;; Open server if it has closed.
13163 (gnus-check-server (gnus-find-method-for-group group))
13165 ;; Using `gnus-request-article' directly will insert the article into
13166 ;; `nntp-server-buffer' - so we'll save some time by not having to
13167 ;; copy it from the server buffer into the article buffer.
13169 ;; We only request an article by message-id when we do not have the
13170 ;; headers for it, so we'll have to get those.
13171 (when (stringp article)
13172 (let ((gnus-override-method gnus-refer-article-method))
13173 (gnus-read-header article)))
13175 ;; If the article number is negative, that means that this article
13176 ;; doesn't belong in this newsgroup (possibly), so we find its
13177 ;; message-id and request it by id instead of number.
13178 (when (and (numberp article)
13179 gnus-summary-buffer
13180 (get-buffer gnus-summary-buffer)
13181 (buffer-name (get-buffer gnus-summary-buffer)))
13183 (set-buffer gnus-summary-buffer)
13184 (let ((header (gnus-summary-article-header article)))
13187 ((memq article gnus-newsgroup-sparse)
13188 ;; This is a sparse gap article.
13189 (setq article (mail-header-id header)))
13191 ;; It's a real article.
13192 (setq article (mail-header-id header)))
13194 ;; It is an extracted pseudo-article.
13195 (setq article 'pseudo)
13196 (gnus-request-pseudo-article header))))
13198 (let ((method (gnus-find-method-for-group
13199 gnus-newsgroup-name)))
13200 (if (not (eq (car method) 'nneething))
13202 (let ((dir (concat (file-name-as-directory (nth 1 method))
13203 (mail-header-subject header))))
13204 (if (file-directory-p dir)
13206 (setq article 'nneething)
13207 (gnus-group-enter-directory dir)))))))))
13210 ;; We first check `gnus-original-article-buffer'.
13211 ((and (equal (car gnus-original-article) group)
13212 (eq (cdr gnus-original-article) article)
13213 (get-buffer gnus-original-article-buffer))
13214 (insert-buffer-substring gnus-original-article-buffer)
13216 ;; Check the backlog.
13217 ((and gnus-keep-backlog
13218 (gnus-backlog-request-article group article (current-buffer)))
13220 ;; Check the cache.
13221 ((and gnus-use-cache
13223 (gnus-cache-request-article article group))
13225 ;; Get the article and put into the article buffer.
13226 ((or (stringp article) (numberp article))
13227 (let ((gnus-override-method
13228 (and (stringp article) gnus-refer-article-method))
13229 (buffer-read-only nil))
13231 (gnus-kill-all-overlays)
13232 (if (gnus-request-article article group (current-buffer))
13234 (and gnus-keep-backlog
13235 (gnus-backlog-enter-article
13236 group article (current-buffer)))
13238 ;; It was a pseudo.
13241 ;; Take the article from the original article buffer
13242 ;; and place it in the buffer it's supposed to be in.
13243 (when (and (get-buffer gnus-article-buffer)
13244 (equal (buffer-name (current-buffer))
13245 (buffer-name (get-buffer gnus-article-buffer))))
13247 (setq gnus-original-article (cons group article))
13248 (if (get-buffer gnus-original-article-buffer)
13249 (set-buffer (get-buffer gnus-original-article-buffer))
13250 (set-buffer (get-buffer-create gnus-original-article-buffer))
13251 (buffer-disable-undo (current-buffer))
13252 (setq major-mode 'gnus-original-article-mode)
13253 (setq buffer-read-only t)
13254 (gnus-add-current-to-buffer-list))
13255 (let (buffer-read-only)
13257 (insert-buffer-substring gnus-article-buffer))))
13259 ;; Update sparse articles.
13260 (when (memq article gnus-newsgroup-sparse)
13261 (gnus-summary-update-article article))))
13263 (defun gnus-read-header (id)
13264 "Read the headers of article ID and enter them into the Gnus system."
13265 (let ((group gnus-newsgroup-name)
13267 ;; First we check to see whether the header in question is already
13270 ;; This is a Message-ID.
13271 (setq header (gnus-id-to-header id))
13272 ;; This is an article number.
13273 (setq header (gnus-summary-article-header id)))
13275 ;; We have found the header.
13277 ;; We have to really fetch the header to this article.
13279 (if (gnus-check-backend-function 'request-head group)
13280 (gnus-request-head id group)
13281 (gnus-request-article id group)))
13283 (set-buffer nntp-server-buffer)
13284 (and (search-forward "\n\n" nil t)
13285 (delete-region (1- (point)) (point-max)))
13286 (goto-char (point-max))
13288 (goto-char (point-min))
13292 ((cdr where) (cdr where))
13293 (t gnus-reffed-article-number))
13295 (insert " Article retrieved.\n"))
13296 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13297 () ; Malformed head.
13298 (if (and (stringp id)
13299 (not (string= (gnus-group-real-name group)
13301 ;; If we fetched by Message-ID and the article came
13302 ;; from a different group, we fudge some bogus article
13303 ;; numbers for this article.
13304 (mail-header-set-number header gnus-reffed-article-number))
13305 (decf gnus-reffed-article-number)
13306 (push header gnus-newsgroup-headers)
13307 (setq gnus-current-headers header)
13308 (push (mail-header-number header) gnus-newsgroup-limit)
13311 (defun gnus-article-prepare (article &optional all-headers header)
13312 "Prepare ARTICLE in article mode buffer.
13313 ARTICLE should either be an article number or a Message-ID.
13314 If ARTICLE is an id, HEADER should be the article headers.
13315 If ALL-HEADERS is non-nil, no headers are hidden."
13317 ;; Make sure we start in a summary buffer.
13318 (unless (eq major-mode 'gnus-summary-mode)
13319 (set-buffer gnus-summary-buffer))
13320 (setq gnus-summary-buffer (current-buffer))
13321 ;; Make sure the connection to the server is alive.
13322 (unless (gnus-server-opened
13323 (gnus-find-method-for-group gnus-newsgroup-name))
13324 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13325 (gnus-request-group gnus-newsgroup-name t))
13326 (let* ((article (if header (mail-header-number header) article))
13327 (summary-buffer (current-buffer))
13328 (internal-hook gnus-article-internal-prepare-hook)
13329 (group gnus-newsgroup-name)
13332 (gnus-article-setup-buffer)
13333 (set-buffer gnus-article-buffer)
13334 ;; Deactivate active regions.
13335 (when (and (boundp 'transient-mark-mode)
13336 transient-mark-mode)
13337 (setq mark-active nil))
13338 (if (not (setq result (let ((buffer-read-only nil))
13339 (gnus-request-article-this-buffer
13341 ;; There is no such article.
13343 (when (and (numberp article)
13344 (not (memq article gnus-newsgroup-sparse)))
13345 (setq gnus-article-current
13346 (cons gnus-newsgroup-name article))
13347 (set-buffer gnus-summary-buffer)
13348 (setq gnus-current-article article)
13349 (gnus-summary-mark-article article gnus-canceled-mark))
13350 (unless (memq article gnus-newsgroup-sparse)
13352 1 "No such article (may have expired or been canceled)")
13355 (if (or (eq result 'pseudo) (eq result 'nneething))
13358 (set-buffer summary-buffer)
13359 (setq gnus-last-article gnus-current-article
13360 gnus-newsgroup-history (cons gnus-current-article
13361 gnus-newsgroup-history)
13362 gnus-current-article 0
13363 gnus-current-headers nil
13364 gnus-article-current nil)
13365 (if (eq result 'nneething)
13366 (gnus-configure-windows 'summary)
13367 (gnus-configure-windows 'article))
13368 (gnus-set-global-variables))
13369 (gnus-set-mode-line 'article))
13370 ;; The result from the `request' was an actual article -
13371 ;; or at least some text that is now displayed in the
13373 (if (and (numberp article)
13374 (not (eq article gnus-current-article)))
13375 ;; Seems like a new article has been selected.
13376 ;; `gnus-current-article' must be an article number.
13378 (set-buffer summary-buffer)
13379 (setq gnus-last-article gnus-current-article
13380 gnus-newsgroup-history (cons gnus-current-article
13381 gnus-newsgroup-history)
13382 gnus-current-article article
13383 gnus-current-headers
13384 (gnus-summary-article-header gnus-current-article)
13385 gnus-article-current
13386 (cons gnus-newsgroup-name gnus-current-article))
13387 (unless (vectorp gnus-current-headers)
13388 (setq gnus-current-headers nil))
13389 (gnus-summary-show-thread)
13390 (run-hooks 'gnus-mark-article-hook)
13391 (gnus-set-mode-line 'summary)
13392 (and (gnus-visual-p 'article-highlight 'highlight)
13393 (run-hooks 'gnus-visual-mark-article-hook))
13394 ;; Set the global newsgroup variables here.
13395 ;; Suggested by Jim Sisolak
13396 ;; <sisolak@trans4.neep.wisc.edu>.
13397 (gnus-set-global-variables)
13398 (setq gnus-have-all-headers
13399 (or all-headers gnus-show-all-headers))
13400 (and gnus-use-cache
13401 (vectorp (gnus-summary-article-header article))
13402 (gnus-cache-possibly-enter-article
13404 (gnus-summary-article-header article)
13405 (memq article gnus-newsgroup-marked)
13406 (memq article gnus-newsgroup-dormant)
13407 (memq article gnus-newsgroup-unreads)))))
13408 ;; Hooks for getting information from the article.
13409 ;; This hook must be called before being narrowed.
13410 (let (buffer-read-only)
13411 (run-hooks 'internal-hook)
13412 (run-hooks 'gnus-article-prepare-hook)
13413 ;; Decode MIME message.
13415 (if (or (not gnus-strict-mime)
13416 (gnus-fetch-field "Mime-Version"))
13417 (funcall gnus-show-mime-method)
13418 (funcall gnus-decode-encoded-word-method)))
13419 ;; Perform the article display hooks.
13420 (run-hooks 'gnus-article-display-hook))
13422 (goto-char (point-min))
13423 (and gnus-break-pages (gnus-narrow-to-page))
13424 (gnus-set-mode-line 'article)
13425 (gnus-configure-windows 'article)
13426 (goto-char (point-min))
13429 (defun gnus-article-show-all-headers ()
13430 "Show all article headers in article mode buffer."
13432 (gnus-article-setup-buffer)
13433 (set-buffer gnus-article-buffer)
13434 (let ((buffer-read-only nil))
13435 (gnus-unhide-text (point-min) (point-max)))))
13437 (defun gnus-article-hide-headers-if-wanted ()
13438 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13439 Provided for backwards compatibility."
13440 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13441 gnus-inhibit-hiding
13442 (gnus-article-hide-headers)))
13444 (defun gnus-article-hide-headers (&optional arg delete)
13445 "Toggle whether to hide unwanted headers and possibly sort them as well.
13446 If given a negative prefix, always show; if given a positive prefix,
13449 (unless (gnus-article-check-hidden-text 'headers arg)
13450 ;; This function might be inhibited.
13451 (unless gnus-inhibit-hiding
13453 (set-buffer gnus-article-buffer)
13455 (let ((buffer-read-only nil)
13456 (props (nconc (list 'gnus-type 'headers)
13457 gnus-hidden-properties))
13458 (ignored (when (not (stringp gnus-visible-headers))
13459 (cond ((stringp gnus-ignored-headers)
13460 gnus-ignored-headers)
13461 ((listp gnus-ignored-headers)
13462 (mapconcat 'identity gnus-ignored-headers
13465 (cond ((stringp gnus-visible-headers)
13466 gnus-visible-headers)
13467 ((and gnus-visible-headers
13468 (listp gnus-visible-headers))
13469 (mapconcat 'identity gnus-visible-headers "\\|"))))
13471 ;; First we narrow to just the headers.
13473 (goto-char (point-min))
13474 ;; Hide any "From " lines at the beginning of (mail) articles.
13475 (while (looking-at "From ")
13478 (gnus-hide-text (point-min) (point) props))
13479 ;; Then treat the rest of the header lines.
13482 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13483 ;; Then we use the two regular expressions
13484 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13485 ;; select which header lines is to remain visible in the
13487 (goto-char (point-min))
13488 (while (re-search-forward "^[^ \t]*:" nil t)
13489 (beginning-of-line)
13490 ;; We add the headers we want to keep to a list and delete
13491 ;; them from the buffer.
13492 (if (or (and visible (looking-at visible))
13493 (and ignored (not (looking-at ignored))))
13495 (push (buffer-substring
13499 ;; Be sure to get multi-line headers...
13500 (re-search-forward "^[^ \t]*:" nil t)
13501 (beginning-of-line)
13504 (delete-region beg (point)))
13506 ;; Sort the headers that we want to display.
13507 (setq want-list (sort want-list 'gnus-article-header-less))
13508 (goto-char (point-min))
13510 (insert (pop want-list)))
13511 ;; We make the unwanted headers invisible.
13513 (delete-region (point-min) (point-max))
13514 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13515 (gnus-hide-text-type (point) (point-max) 'headers))))))))
13517 (defsubst gnus-article-header-rank (header)
13518 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13519 (let ((list gnus-sorted-header-list)
13522 (when (string-match (car list) header)
13524 (setq list (cdr list))
13528 (defun gnus-article-header-less (h1 h2)
13529 "Say whether string H1 is \"less\" than string H2."
13530 (< (gnus-article-header-rank h1)
13531 (gnus-article-header-rank h2)))
13533 (defun gnus-article-hide-boring-headers (&optional arg)
13534 "Toggle hiding of headers that aren't very interesting.
13535 If given a negative prefix, always show; if given a positive prefix,
13538 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13540 (set-buffer gnus-article-buffer)
13542 (let ((buffer-read-only nil)
13543 (list gnus-boring-article-headers)
13544 (inhibit-point-motion-hooks t)
13546 (nnheader-narrow-to-headers)
13548 (setq elem (pop list))
13549 (goto-char (point-min))
13551 ;; Hide empty headers.
13553 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13555 (gnus-hide-text-type
13556 (progn (beginning-of-line) (point))
13559 (if (re-search-forward "^[^ \t]" nil t)
13560 (match-beginning 0)
13563 ;; Hide boring Newsgroups header.
13564 ((eq elem 'newsgroups)
13565 (when (equal (mail-fetch-field "newsgroups")
13566 (gnus-group-real-name gnus-newsgroup-name))
13567 (gnus-article-hide-header "newsgroups")))
13568 ((eq elem 'followup-to)
13569 (when (equal (mail-fetch-field "followup-to")
13570 (mail-fetch-field "newsgroups"))
13571 (gnus-article-hide-header "followup-to")))
13572 ((eq elem 'reply-to)
13573 (let ((from (mail-fetch-field "from"))
13574 (reply-to (mail-fetch-field "reply-to")))
13578 (nth 1 (mail-extract-address-components from))
13579 (nth 1 (mail-extract-address-components reply-to))))
13580 (gnus-article-hide-header "reply-to"))))
13582 (let ((date (mail-fetch-field "date")))
13584 (< (gnus-days-between date (current-time-string))
13586 (gnus-article-hide-header "date")))))))))))
13588 (defun gnus-article-hide-header (header)
13590 (goto-char (point-min))
13591 (when (re-search-forward (concat "^" header ":") nil t)
13592 (gnus-hide-text-type
13593 (progn (beginning-of-line) (point))
13596 (if (re-search-forward "^[^ \t]" nil t)
13597 (match-beginning 0)
13599 'boring-headers))))
13601 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13602 (defun gnus-article-treat-overstrike ()
13603 "Translate overstrikes into bold text."
13606 (set-buffer gnus-article-buffer)
13607 (let ((buffer-read-only nil))
13608 (while (search-forward "\b" nil t)
13609 (let ((next (following-char))
13610 (previous (char-after (- (point) 2))))
13611 (cond ((eq next previous)
13612 (put-text-property (- (point) 2) (point) 'invisible t)
13613 (put-text-property (point) (1+ (point)) 'face 'bold))
13615 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13617 (- (point) 2) (1- (point)) 'face 'underline))
13619 (put-text-property (- (point) 2) (point) 'invisible t)
13621 (point) (1+ (point)) 'face 'underline))))))))
13623 (defun gnus-article-word-wrap ()
13624 "Format too long lines."
13627 (set-buffer gnus-article-buffer)
13628 (let ((buffer-read-only nil))
13630 (goto-char (point-min))
13631 (search-forward "\n\n" nil t)
13633 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13634 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13635 (adaptive-fill-mode t))
13636 (while (not (eobp))
13637 (and (>= (current-column) (min fill-column (window-width)))
13638 (/= (preceding-char) ?:)
13639 (fill-paragraph nil))
13640 (end-of-line 2))))))
13642 (defun gnus-article-remove-cr ()
13643 "Remove carriage returns from an article."
13646 (set-buffer gnus-article-buffer)
13647 (let ((buffer-read-only nil))
13648 (goto-char (point-min))
13649 (while (search-forward "\r" nil t)
13650 (replace-match "" t t)))))
13652 (defun gnus-article-remove-trailing-blank-lines ()
13653 "Remove all trailing blank lines from the article."
13656 (set-buffer gnus-article-buffer)
13657 (let ((buffer-read-only nil))
13658 (goto-char (point-max))
13662 (while (looking-at "^[ \t]*$")
13667 (defun gnus-article-display-x-face (&optional force)
13668 "Look for an X-Face header and display it if present."
13669 (interactive (list 'force))
13671 (set-buffer gnus-article-buffer)
13672 ;; Delete the old process, if any.
13673 (when (process-status "gnus-x-face")
13674 (delete-process "gnus-x-face"))
13675 (let ((inhibit-point-motion-hooks t)
13676 (case-fold-search nil)
13679 (nnheader-narrow-to-headers)
13680 (setq from (mail-fetch-field "from"))
13681 (goto-char (point-min))
13682 (when (and gnus-article-x-face-command
13684 ;; Check whether this face is censored.
13685 (not gnus-article-x-face-too-ugly)
13686 (and gnus-article-x-face-too-ugly from
13687 (not (string-match gnus-article-x-face-too-ugly
13689 ;; Has to be present.
13690 (re-search-forward "^X-Face: " nil t))
13691 ;; We now have the area of the buffer where the X-Face is stored.
13692 (let ((beg (point))
13693 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13694 ;; We display the face.
13695 (if (symbolp gnus-article-x-face-command)
13696 ;; The command is a lisp function, so we call it.
13697 (if (gnus-functionp gnus-article-x-face-command)
13698 (funcall gnus-article-x-face-command beg end)
13699 (error "%s is not a function" gnus-article-x-face-command))
13700 ;; The command is a string, so we interpret the command
13701 ;; as a, well, command, and fork it off.
13702 (let ((process-connection-type nil))
13703 (process-kill-without-query
13705 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13706 (process-send-region "gnus-x-face" beg end)
13707 (process-send-eof "gnus-x-face")))))))))
13709 (defun gnus-headers-decode-quoted-printable ()
13710 "Hack to remove QP encoding from headers."
13711 (let ((case-fold-search t)
13712 (inhibit-point-motion-hooks t)
13714 (goto-char (point-min))
13715 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13716 (setq string (match-string 1))
13717 (narrow-to-region (match-beginning 0) (match-end 0))
13718 (delete-region (point-min) (point-max))
13720 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13721 (subst-char-in-region (point-min) (point-max) ?_ ? )
13723 (goto-char (point-min)))))
13725 (defun gnus-article-de-quoted-unreadable (&optional force)
13726 "Do a naive translation of a quoted-printable-encoded article.
13727 This is in no way, shape or form meant as a replacement for real MIME
13728 processing, but is simply a stop-gap measure until MIME support is
13730 If FORCE, decode the article whether it is marked as quoted-printable
13732 (interactive (list 'force))
13734 (set-buffer gnus-article-buffer)
13735 (let ((case-fold-search t)
13736 (buffer-read-only nil)
13737 (type (gnus-fetch-field "content-transfer-encoding")))
13739 (and type (string-match "quoted-printable" type)))
13740 (gnus-headers-decode-quoted-printable)
13741 (goto-char (point-min))
13742 (search-forward "\n\n" nil 'move)
13743 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13745 (defun gnus-mime-decode-quoted-printable (from to)
13746 "Decode Quoted-Printable in the region between FROM and TO."
13748 (while (search-forward "=" to t)
13749 (cond ((eq (following-char) ?\n)
13752 ((looking-at "[0-9A-F][0-9A-F]")
13754 (insert (hexl-hex-string-to-integer
13755 (buffer-substring (point) (+ 2 (point)))))
13759 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13761 (defun gnus-article-hide-pgp (&optional arg)
13762 "Toggle hiding of any PGP headers and signatures in the current article.
13763 If given a negative prefix, always show; if given a positive prefix,
13766 (unless (gnus-article-check-hidden-text 'pgp arg)
13768 (set-buffer gnus-article-buffer)
13769 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13770 buffer-read-only beg end)
13772 (goto-char (point-min))
13773 ;; Hide the "header".
13774 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13775 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13777 ;; Hide the actual signature.
13778 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13779 (setq end (match-beginning 0))
13781 (match-beginning 0)
13782 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13784 ;; Perhaps we shouldn't hide to the end of the buffer
13785 ;; if there is no end to the signature?
13788 ;; Hide "- " PGP quotation markers.
13789 (when (and beg end)
13790 (narrow-to-region beg end)
13791 (goto-char (point-min))
13792 (while (re-search-forward "^- " nil t)
13793 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13796 (defun gnus-article-hide-signature (&optional arg)
13797 "Hide the signature in the current article.
13798 If given a negative prefix, always show; if given a positive prefix,
13801 (unless (gnus-article-check-hidden-text 'signature arg)
13803 (set-buffer gnus-article-buffer)
13805 (let ((buffer-read-only nil))
13806 (when (gnus-narrow-to-signature)
13807 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
13809 (defun gnus-article-strip-leading-blank-lines ()
13810 "Remove all blank lines from the beginning of the article."
13813 (set-buffer gnus-article-buffer)
13814 (let (buffer-read-only)
13815 (goto-char (point-min))
13816 (when (search-forward "\n\n" nil t)
13817 (while (looking-at "[ \t]$")
13818 (gnus-delete-line))))))
13820 (defun gnus-narrow-to-signature ()
13821 "Narrow to the signature."
13823 (goto-char (point-max))
13824 (when (re-search-backward gnus-signature-separator nil t)
13826 (when (or (null gnus-signature-limit)
13827 (and (numberp gnus-signature-limit)
13828 (< (- (point-max) (point)) gnus-signature-limit))
13829 (and (gnus-functionp gnus-signature-limit)
13830 (funcall gnus-signature-limit))
13831 (and (stringp gnus-signature-limit)
13832 (not (re-search-forward gnus-signature-limit nil t))))
13833 (narrow-to-region (point) (point-max))
13836 (defun gnus-article-check-hidden-text (type arg)
13837 "Return nil if hiding is necessary."
13839 (set-buffer gnus-article-buffer)
13840 (let ((hide (gnus-article-hidden-text-p type)))
13841 (cond ((or (and (null arg) (eq hide 'hidden))
13842 (and arg (< 0 (prefix-numeric-value arg))))
13843 (gnus-article-show-hidden-text type))
13845 (gnus-article-show-hidden-text type t))
13848 (defun gnus-article-hidden-text-p (type)
13849 "Say whether the current buffer contains hidden text of type TYPE."
13850 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
13852 (if (get-text-property pos 'invisible)
13856 (defun gnus-article-hide (&optional arg force)
13857 "Hide all the gruft in the current article.
13858 This means that PGP stuff, signatures, cited text and (some)
13859 headers will be hidden.
13860 If given a prefix, show the hidden text instead."
13861 (interactive (list current-prefix-arg 'force))
13862 (gnus-article-hide-headers arg)
13863 (gnus-article-hide-pgp arg)
13864 (gnus-article-hide-citation-maybe arg force)
13865 (gnus-article-hide-signature arg))
13867 (defun gnus-article-show-hidden-text (type &optional hide)
13868 "Show all hidden text of type TYPE.
13869 If HIDE, hide the text instead."
13871 (set-buffer gnus-article-buffer)
13872 (let ((buffer-read-only nil)
13873 (inhibit-point-motion-hooks t)
13875 (while (gnus-goto-char (text-property-any
13876 beg (point-max) 'gnus-type type))
13880 (gnus-hide-text beg (point) gnus-hidden-properties)
13881 (gnus-unhide-text beg (point)))
13882 (setq beg (point)))
13885 (defvar gnus-article-time-units
13886 `((year . ,(* 365.25 24 60 60))
13887 (week . ,(* 7 24 60 60))
13888 (day . ,(* 24 60 60))
13889 (hour . ,(* 60 60))
13892 "Mapping from time units to seconds.")
13894 (defun gnus-article-date-ut (&optional type highlight)
13895 "Convert DATE date to universal time in the current article.
13896 If TYPE is `local', convert to local time; if it is `lapsed', output
13897 how much time has lapsed since DATE."
13898 (interactive (list 'ut t))
13899 (let* ((header (or gnus-current-headers
13900 (gnus-summary-article-header) ""))
13901 (date (and (vectorp header) (mail-header-date header)))
13902 (date-regexp "^Date: \\|^X-Sent: ")
13903 (now (current-time))
13904 (inhibit-point-motion-hooks t))
13905 (when (and date (not (string= date "")))
13907 (set-buffer gnus-article-buffer)
13909 (nnheader-narrow-to-headers)
13910 (let ((buffer-read-only nil))
13911 ;; Delete any old Date headers.
13912 (if (zerop (nnheader-remove-header date-regexp t))
13913 (beginning-of-line)
13914 (goto-char (point-max)))
13917 ;; Convert to the local timezone. We have to slap a
13918 ;; `condition-case' round the calls to the timezone
13919 ;; functions since they aren't particularly resistant to
13922 (concat "Date: " (condition-case ()
13923 (timezone-make-date-arpa-standard date)
13926 ;; Convert to Universal Time.
13930 (timezone-make-date-arpa-standard date nil "UT")
13933 ;; Get the original date from the article.
13934 ((eq type 'original)
13935 (concat "Date: " date "\n"))
13936 ;; Do an X-Sent lapsed format.
13938 ;; If the date is seriously mangled, the timezone
13939 ;; functions are liable to bug out, so we condition-case
13940 ;; the entire thing.
13945 (timezone-make-date-arpa-standard
13946 (current-time-string now)
13947 (current-time-zone now) "UT"))
13949 (timezone-make-date-arpa-standard
13952 (real-sec (+ (* (float (car real-time)) 65536)
13954 (sec (abs real-sec))
13960 ;; This is a bit convoluted, but basically we go
13961 ;; through the time units for years, weeks, etc,
13962 ;; and divide things to see whether that results
13963 ;; in positive answers.
13966 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
13967 ;; The (remaining) seconds are too few to
13968 ;; be divided into this time unit.
13970 ;; It's big enough, so we output it.
13971 (setq sec (- sec (* num (cdr unit))))
13973 (concat (if prev ", " "") (int-to-string
13975 " " (symbol-name (car unit))
13976 (if (> num 1) "s" ""))
13978 gnus-article-time-units "")
13979 ;; If dates are odd, then it might appear like the
13980 ;; article was sent in the future.
13983 " in the future\n")))))
13985 (error "Unknown conversion type: %s" type)))))
13986 ;; Do highlighting.
13987 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
13988 (gnus-article-highlight-headers)))))))
13990 (defun gnus-article-date-local (&optional highlight)
13991 "Convert the current article date to the local timezone."
13992 (interactive (list t))
13993 (gnus-article-date-ut 'local highlight))
13995 (defun gnus-article-date-original (&optional highlight)
13996 "Convert the current article date to what it was originally.
13997 This is only useful if you have used some other date conversion
13998 function and want to see what the date was before converting."
13999 (interactive (list t))
14000 (gnus-article-date-ut 'original highlight))
14002 (defun gnus-article-date-lapsed (&optional highlight)
14003 "Convert the current article date to time lapsed since it was sent."
14004 (interactive (list t))
14005 (gnus-article-date-ut 'lapsed highlight))
14007 (defun gnus-article-maybe-highlight ()
14008 "Do some article highlighting if `gnus-visual' is non-nil."
14009 (if (gnus-visual-p 'article-highlight 'highlight)
14010 (gnus-article-highlight-some)))
14014 (defun gnus-output-to-rmail (file-name)
14015 "Append the current article to an Rmail file named FILE-NAME."
14017 ;; Most of these codes are borrowed from rmailout.el.
14018 (setq file-name (expand-file-name file-name))
14019 (setq rmail-default-rmail-file file-name)
14020 (let ((artbuf (current-buffer))
14021 (tmpbuf (get-buffer-create " *Gnus-output*")))
14023 (or (get-file-buffer file-name)
14024 (file-exists-p file-name)
14025 (if (gnus-yes-or-no-p
14026 (concat "\"" file-name "\" does not exist, create it? "))
14027 (let ((file-buffer (create-file-buffer file-name)))
14029 (set-buffer file-buffer)
14030 (rmail-insert-rmail-file-header)
14031 (let ((require-final-newline nil))
14032 (write-region (point-min) (point-max) file-name t 1)))
14033 (kill-buffer file-buffer))
14034 (error "Output file does not exist")))
14035 (set-buffer tmpbuf)
14036 (buffer-disable-undo (current-buffer))
14038 (insert-buffer-substring artbuf)
14039 (gnus-convert-article-to-rmail)
14040 ;; Decide whether to append to a file or to an Emacs buffer.
14041 (let ((outbuf (get-file-buffer file-name)))
14043 (append-to-file (point-min) (point-max) file-name)
14044 ;; File has been visited, in buffer OUTBUF.
14045 (set-buffer outbuf)
14046 (let ((buffer-read-only nil)
14047 (msg (and (boundp 'rmail-current-message)
14048 (symbol-value 'rmail-current-message))))
14049 ;; If MSG is non-nil, buffer is in RMAIL mode.
14052 (narrow-to-region (point-max) (point-max))))
14053 (insert-buffer-substring tmpbuf)
14056 (goto-char (point-min))
14058 (search-backward "\^_")
14059 (narrow-to-region (point) (point-max))
14060 (goto-char (1+ (point-min)))
14061 (rmail-count-new-messages t)
14062 (rmail-show-message msg)))))))
14063 (kill-buffer tmpbuf)))
14065 (defun gnus-output-to-file (file-name)
14066 "Append the current article to a file named FILE-NAME."
14067 (setq file-name (expand-file-name file-name))
14068 (let ((artbuf (current-buffer))
14069 (tmpbuf (get-buffer-create " *Gnus-output*")))
14071 (set-buffer tmpbuf)
14072 (buffer-disable-undo (current-buffer))
14074 (insert-buffer-substring artbuf)
14075 ;; Append newline at end of the buffer as separator, and then
14076 ;; save it to file.
14077 (goto-char (point-max))
14079 (append-to-file (point-min) (point-max) file-name))
14080 (kill-buffer tmpbuf)))
14082 (defun gnus-convert-article-to-rmail ()
14083 "Convert article in current buffer to Rmail message format."
14084 (let ((buffer-read-only nil))
14085 ;; Convert article directly into Babyl format.
14086 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14087 (goto-char (point-min))
14088 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14089 (while (search-forward "\n\^_" nil t) ;single char
14090 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14091 (goto-char (point-max))
14094 (defun gnus-narrow-to-page (&optional arg)
14095 "Narrow the article buffer to a page.
14096 If given a numerical ARG, move forward ARG pages."
14098 (setq arg (if arg (prefix-numeric-value arg) 0))
14100 (set-buffer gnus-article-buffer)
14101 (goto-char (point-min))
14103 (when (gnus-visual-p 'page-marker)
14104 (let ((buffer-read-only nil))
14105 (gnus-remove-text-with-property 'gnus-prev)
14106 (gnus-remove-text-with-property 'gnus-next)))
14109 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14111 (re-search-forward page-delimiter nil 'move arg)))
14112 (goto-char (match-end 0)))
14115 (if (re-search-forward page-delimiter nil 'move)
14116 (match-beginning 0)
14118 (when (and (gnus-visual-p 'page-marker)
14119 (not (= (point-min) 1)))
14121 (goto-char (point-min))
14122 (gnus-insert-prev-page-button)))
14123 (when (and (gnus-visual-p 'page-marker)
14124 (not (= (1- (point-max)) (buffer-size))))
14126 (goto-char (point-max))
14127 (gnus-insert-next-page-button)))))
14129 ;; Article mode commands
14131 (defun gnus-article-goto-next-page ()
14132 "Show the next page of the article."
14134 (when (gnus-article-next-page)
14135 (gnus-article-read-summary-keys nil ?n)))
14137 (defun gnus-article-goto-prev-page ()
14138 "Show the next page of the article."
14140 (if (bobp) (gnus-article-read-summary-keys nil ?n)
14141 (gnus-article-prev-page nil)))
14143 (defun gnus-article-next-page (&optional lines)
14144 "Show the next page of the current article.
14145 If end of article, return non-nil. Otherwise return nil.
14146 Argument LINES specifies lines to be scrolled up."
14148 (move-to-window-line -1)
14149 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14150 (if (save-excursion
14152 (and (pos-visible-in-window-p) ;Not continuation line.
14154 ;; Nothing in this page.
14155 (if (or (not gnus-break-pages)
14158 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14160 (gnus-narrow-to-page 1) ;Go to next page.
14162 ;; More in this page.
14166 ;; Long lines may cause an end-of-buffer error.
14167 (goto-char (point-max))))
14168 (move-to-window-line 0)
14171 (defun gnus-article-prev-page (&optional lines)
14172 "Show previous page of current article.
14173 Argument LINES specifies lines to be scrolled down."
14175 (move-to-window-line 0)
14176 (if (and gnus-break-pages
14178 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14180 (gnus-narrow-to-page -1) ;Go to previous page.
14181 (goto-char (point-max))
14185 (scroll-down lines)
14187 (move-to-window-line 0))))
14189 (defun gnus-article-refer-article ()
14190 "Read article specified by message-id around point."
14192 (let ((point (point)))
14193 (search-forward ">" nil t) ;Move point to end of "<....>".
14194 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14195 (let ((message-id (match-string 1)))
14197 (set-buffer gnus-summary-buffer)
14198 (gnus-summary-refer-article message-id))
14199 (goto-char (point))
14200 (error "No references around point"))))
14202 (defun gnus-article-show-summary ()
14203 "Reconfigure windows to show summary buffer."
14205 (gnus-configure-windows 'article)
14206 (gnus-summary-goto-subject gnus-current-article))
14208 (defun gnus-article-describe-briefly ()
14209 "Describe article mode commands briefly."
14212 (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")))
14214 (defun gnus-article-summary-command ()
14215 "Execute the last keystroke in the summary buffer."
14217 (let ((obuf (current-buffer))
14218 (owin (current-window-configuration))
14220 (switch-to-buffer gnus-summary-buffer 'norecord)
14221 (setq func (lookup-key (current-local-map) (this-command-keys)))
14222 (call-interactively func)
14224 (set-window-configuration owin)
14225 (set-window-point (get-buffer-window (current-buffer)) (point))))
14227 (defun gnus-article-summary-command-nosave ()
14228 "Execute the last keystroke in the summary buffer."
14231 (pop-to-buffer gnus-summary-buffer 'norecord)
14232 (setq func (lookup-key (current-local-map) (this-command-keys)))
14233 (call-interactively func)))
14235 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14236 "Read a summary buffer key sequence and execute it from the article buffer."
14239 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14240 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14244 (set-buffer gnus-summary-buffer)
14245 (push (or key last-command-event) unread-command-events)
14246 (setq keys (read-key-sequence nil)))
14249 (if (member keys nosaves)
14251 (pop-to-buffer gnus-summary-buffer 'norecord)
14252 (if (setq func (lookup-key (current-local-map) keys))
14253 (call-interactively func)
14255 (let ((obuf (current-buffer))
14256 (owin (current-window-configuration))
14259 (if not-restore-window
14260 (pop-to-buffer gnus-summary-buffer 'norecord)
14261 (switch-to-buffer gnus-summary-buffer 'norecord))
14262 (setq in-buffer (current-buffer))
14263 (if (setq func (lookup-key (current-local-map) keys))
14264 (call-interactively func)
14266 (when (eq in-buffer (current-buffer))
14268 (unless not-restore-window
14269 (set-window-configuration owin))
14270 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14274 ;;; Kill file handling.
14278 (defalias 'gnus-batch-kill 'gnus-batch-score)
14280 (defun gnus-batch-score ()
14281 "Run batched scoring.
14282 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14283 Newsgroups is a list of strings in Bnews format. If you want to score
14284 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14285 score the alt hierarchy, you'd say \"!alt.all\"."
14288 (gnus-newsrc-parse-options
14289 (apply (function concat)
14290 (mapcar (lambda (g) (concat g " "))
14291 command-line-args-left))))
14292 (gnus-expert-user t)
14293 (nnmail-spool-file nil)
14294 (gnus-use-dribble-file nil)
14295 (yes (car yes-and-no))
14296 (no (cdr yes-and-no))
14298 ;; Disable verbose message.
14299 gnus-novice-user gnus-large-newsgroup)
14300 ;; Eat all arguments.
14301 (setq command-line-args-left nil)
14304 ;; Apply kills to specified newsgroups in command line arguments.
14305 (setq newsrc (cdr gnus-newsrc-alist))
14307 (setq group (caar newsrc))
14308 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14309 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14311 (or (eq (car entry) t)
14312 (not (zerop (car entry)))))
14313 (if yes (string-match yes group) t)
14314 (or (null no) (not (string-match no group))))
14316 (gnus-summary-read-group group nil t nil t)
14317 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14318 (gnus-summary-exit))))
14319 (setq newsrc (cdr newsrc)))
14321 (switch-to-buffer gnus-group-buffer)
14322 (gnus-group-save-newsrc)))
14324 (defun gnus-apply-kill-file ()
14325 "Apply a kill file to the current newsgroup.
14326 Returns the number of articles marked as read."
14327 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14328 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14329 (gnus-apply-kill-file-internal)
14332 (defun gnus-kill-save-kill-buffer ()
14333 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14334 (when (get-file-buffer file)
14336 (set-buffer (get-file-buffer file))
14337 (and (buffer-modified-p) (save-buffer))
14338 (kill-buffer (current-buffer))))))
14340 (defvar gnus-kill-file-name "KILL"
14341 "Suffix of the kill files.")
14343 (defun gnus-newsgroup-kill-file (newsgroup)
14344 "Return the name of a kill file name for NEWSGROUP.
14345 If NEWSGROUP is nil, return the global kill file name instead."
14347 ;; The global KILL file is placed at top of the directory.
14348 ((or (null newsgroup)
14349 (string-equal newsgroup ""))
14350 (expand-file-name gnus-kill-file-name
14351 (or gnus-kill-files-directory "~/News")))
14352 ;; Append ".KILL" to newsgroup name.
14353 ((gnus-use-long-file-name 'not-kill)
14354 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14355 "." gnus-kill-file-name)
14356 (or gnus-kill-files-directory "~/News")))
14357 ;; Place "KILL" under the hierarchical directory.
14359 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14360 "/" gnus-kill-file-name)
14361 (or gnus-kill-files-directory "~/News")))))
14368 (defvar gnus-dribble-ignore nil)
14369 (defvar gnus-dribble-eval-file nil)
14371 (defun gnus-dribble-file-name ()
14372 "Return the dribble file for the current .newsrc."
14374 (if gnus-dribble-directory
14375 (concat (file-name-as-directory gnus-dribble-directory)
14376 (file-name-nondirectory gnus-current-startup-file))
14377 gnus-current-startup-file)
14380 (defun gnus-dribble-enter (string)
14381 "Enter STRING into the dribble buffer."
14382 (if (and (not gnus-dribble-ignore)
14383 gnus-dribble-buffer
14384 (buffer-name gnus-dribble-buffer))
14385 (let ((obuf (current-buffer)))
14386 (set-buffer gnus-dribble-buffer)
14387 (insert string "\n")
14388 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14389 (set-buffer obuf))))
14391 (defun gnus-dribble-read-file ()
14392 "Read the dribble file from disk."
14393 (let ((dribble-file (gnus-dribble-file-name)))
14395 (set-buffer (setq gnus-dribble-buffer
14397 (file-name-nondirectory dribble-file))))
14398 (gnus-add-current-to-buffer-list)
14400 (setq buffer-file-name dribble-file)
14402 (buffer-disable-undo (current-buffer))
14403 (bury-buffer (current-buffer))
14404 (set-buffer-modified-p nil)
14405 (let ((auto (make-auto-save-file-name))
14406 (gnus-dribble-ignore t))
14407 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14408 ;; Load whichever file is newest -- the auto save file
14409 ;; or the "real" file.
14410 (if (file-newer-than-file-p auto dribble-file)
14411 (insert-file-contents auto)
14412 (insert-file-contents dribble-file))
14413 (unless (zerop (buffer-size))
14414 (set-buffer-modified-p t))
14415 ;; Set the file modes to reflect the .newsrc file modes.
14417 (when (file-exists-p gnus-current-startup-file)
14418 (set-file-modes dribble-file
14419 (file-modes gnus-current-startup-file)))
14420 ;; Possibly eval the file later.
14421 (when (gnus-y-or-n-p
14422 "Auto-save file exists. Do you want to read it? ")
14423 (setq gnus-dribble-eval-file t)))))))
14425 (defun gnus-dribble-eval-file ()
14426 (if (not gnus-dribble-eval-file)
14428 (setq gnus-dribble-eval-file nil)
14430 (let ((gnus-dribble-ignore t))
14431 (set-buffer gnus-dribble-buffer)
14432 (eval-buffer (current-buffer))))))
14434 (defun gnus-dribble-delete-file ()
14435 (if (file-exists-p (gnus-dribble-file-name))
14436 (delete-file (gnus-dribble-file-name)))
14437 (if gnus-dribble-buffer
14439 (set-buffer gnus-dribble-buffer)
14440 (let ((auto (make-auto-save-file-name)))
14441 (if (file-exists-p auto)
14442 (delete-file auto))
14444 (set-buffer-modified-p nil)))))
14446 (defun gnus-dribble-save ()
14447 (if (and gnus-dribble-buffer
14448 (buffer-name gnus-dribble-buffer))
14450 (set-buffer gnus-dribble-buffer)
14453 (defun gnus-dribble-clear ()
14455 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14457 (set-buffer gnus-dribble-buffer)
14459 (set-buffer-modified-p nil)
14460 (setq buffer-saved-size (buffer-size))))))
14464 ;;; Server Communication
14467 (defun gnus-start-news-server (&optional confirm)
14468 "Open a method for getting news.
14469 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14471 (if gnus-current-select-method
14472 ;; Stream is already opened.
14474 ;; Open NNTP server.
14475 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14478 ;; Read server name with completion.
14479 (setq gnus-nntp-server
14480 (completing-read "NNTP server: "
14481 (mapcar (lambda (server) (list server))
14482 (cons (list gnus-nntp-server)
14483 gnus-secondary-servers))
14484 nil nil gnus-nntp-server))))
14486 (if (and gnus-nntp-server
14487 (stringp gnus-nntp-server)
14488 (not (string= gnus-nntp-server "")))
14489 (setq gnus-select-method
14490 (cond ((or (string= gnus-nntp-server "")
14491 (string= gnus-nntp-server "::"))
14492 (list 'nnspool (system-name)))
14493 ((string-match "^:" gnus-nntp-server)
14494 (list 'nnmh gnus-nntp-server
14495 (list 'nnmh-directory
14496 (file-name-as-directory
14498 (concat "~/" (substring
14499 gnus-nntp-server 1)))))
14500 (list 'nnmh-get-new-mail nil)))
14502 (list 'nntp gnus-nntp-server)))))
14504 (setq how (car gnus-select-method))
14505 (cond ((eq how 'nnspool)
14507 (gnus-message 5 "Looking up local news spool..."))
14510 (gnus-message 5 "Looking up mh spool..."))
14513 (setq gnus-current-select-method gnus-select-method)
14514 (run-hooks 'gnus-open-server-hook)
14516 ;; gnus-open-server-hook might have opened it
14517 (gnus-server-opened gnus-select-method)
14518 (gnus-open-server gnus-select-method)
14521 "%s (%s) open error: '%s'. Continue? "
14522 (car gnus-select-method) (cadr gnus-select-method)
14523 (gnus-status-message gnus-select-method)))
14525 (gnus-message 1 "Couldn't open server on %s"
14526 (nth 1 gnus-select-method))
14530 (defun gnus-check-group (group)
14531 "Try to make sure that the server where GROUP exists is alive."
14532 (let ((method (gnus-find-method-for-group group)))
14533 (or (gnus-server-opened method)
14534 (gnus-open-server method))))
14536 (defun gnus-check-server (&optional method silent)
14537 "Check whether the connection to METHOD is down.
14538 If METHOD is nil, use `gnus-select-method'.
14539 If it is down, start it up (again)."
14540 (let ((method (or method gnus-select-method)))
14541 ;; Transform virtual server names into select methods.
14542 (when (stringp method)
14543 (setq method (gnus-server-to-method method)))
14544 (if (gnus-server-opened method)
14545 ;; The stream is already opened.
14547 ;; Open the server.
14549 (gnus-message 5 "Opening %s server%s..." (car method)
14550 (if (equal (nth 1 method) "") ""
14551 (format " on %s" (nth 1 method)))))
14552 (run-hooks 'gnus-open-server-hook)
14554 (gnus-open-server method)
14558 (defun gnus-get-function (method function)
14559 "Return a function symbol based on METHOD and FUNCTION."
14560 ;; Translate server names into methods.
14562 (error "Attempted use of a nil select method"))
14563 (when (stringp method)
14564 (setq method (gnus-server-to-method method)))
14565 (let ((func (intern (format "%s-%s" (car method) function))))
14566 ;; If the functions isn't bound, we require the backend in
14568 (unless (fboundp func)
14569 (require (car method))
14570 (unless (fboundp func)
14571 ;; This backend doesn't implement this function.
14572 (error "No such function: %s" func)))
14577 ;;; Interface functions to the backends.
14580 (defun gnus-open-server (method)
14581 "Open a connection to METHOD."
14582 (when (stringp method)
14583 (setq method (gnus-server-to-method method)))
14584 (let ((elem (assoc method gnus-opened-servers)))
14585 ;; If this method was previously denied, we just return nil.
14586 (if (eq (nth 1 elem) 'denied)
14588 (gnus-message 1 "Denied server")
14590 ;; Open the server.
14592 (funcall (gnus-get-function method 'open-server)
14593 (nth 1 method) (nthcdr 2 method))))
14594 ;; If this hasn't been opened before, we add it to the list.
14596 (setq elem (list method nil)
14597 gnus-opened-servers (cons elem gnus-opened-servers)))
14598 ;; Set the status of this server.
14599 (setcar (cdr elem) (if result 'ok 'denied))
14600 ;; Return the result from the "open" call.
14603 (defun gnus-close-server (method)
14604 "Close the connection to METHOD."
14605 (when (stringp method)
14606 (setq method (gnus-server-to-method method)))
14607 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14609 (defun gnus-request-list (method)
14610 "Request the active file from METHOD."
14611 (when (stringp method)
14612 (setq method (gnus-server-to-method method)))
14613 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14615 (defun gnus-request-list-newsgroups (method)
14616 "Request the newsgroups file from METHOD."
14617 (when (stringp method)
14618 (setq method (gnus-server-to-method method)))
14619 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14621 (defun gnus-request-newgroups (date method)
14622 "Request all new groups since DATE from METHOD."
14623 (when (stringp method)
14624 (setq method (gnus-server-to-method method)))
14625 (funcall (gnus-get-function method 'request-newgroups)
14626 date (nth 1 method)))
14628 (defun gnus-server-opened (method)
14629 "Check whether a connection to METHOD has been opened."
14630 (when (stringp method)
14631 (setq method (gnus-server-to-method method)))
14632 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14634 (defun gnus-status-message (method)
14635 "Return the status message from METHOD.
14636 If METHOD is a string, it is interpreted as a group name. The method
14637 this group uses will be queried."
14638 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14640 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14642 (defun gnus-request-group (group &optional dont-check method)
14643 "Request GROUP. If DONT-CHECK, no information is required."
14644 (let ((method (or method (gnus-find-method-for-group group))))
14645 (when (stringp method)
14646 (setq method (gnus-server-to-method method)))
14647 (funcall (gnus-get-function method 'request-group)
14648 (gnus-group-real-name group) (nth 1 method) dont-check)))
14650 (defun gnus-request-asynchronous (group &optional articles)
14651 "Request that GROUP behave asynchronously.
14652 ARTICLES is the `data' of the group."
14653 (let ((method (gnus-find-method-for-group group)))
14654 (funcall (gnus-get-function method 'request-asynchronous)
14655 (gnus-group-real-name group) (nth 1 method) articles)))
14657 (defun gnus-list-active-group (group)
14658 "Request active information on GROUP."
14659 (let ((method (gnus-find-method-for-group group))
14660 (func 'list-active-group))
14661 (when (gnus-check-backend-function func group)
14662 (funcall (gnus-get-function method func)
14663 (gnus-group-real-name group) (nth 1 method)))))
14665 (defun gnus-request-group-description (group)
14666 "Request a description of GROUP."
14667 (let ((method (gnus-find-method-for-group group))
14668 (func 'request-group-description))
14669 (when (gnus-check-backend-function func group)
14670 (funcall (gnus-get-function method func)
14671 (gnus-group-real-name group) (nth 1 method)))))
14673 (defun gnus-close-group (group)
14674 "Request the GROUP be closed."
14675 (let ((method (gnus-find-method-for-group group)))
14676 (funcall (gnus-get-function method 'close-group)
14677 (gnus-group-real-name group) (nth 1 method))))
14679 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14680 "Request headers for ARTICLES in GROUP.
14681 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14682 (let ((method (gnus-find-method-for-group group)))
14683 (if (and gnus-use-cache (numberp (car articles)))
14684 (gnus-cache-retrieve-headers articles group fetch-old)
14685 (funcall (gnus-get-function method 'retrieve-headers)
14686 articles (gnus-group-real-name group) (nth 1 method)
14689 (defun gnus-retrieve-groups (groups method)
14690 "Request active information on GROUPS from METHOD."
14691 (when (stringp method)
14692 (setq method (gnus-server-to-method method)))
14693 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14695 (defun gnus-request-type (group &optional article)
14696 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14697 (let ((method (gnus-find-method-for-group group)))
14698 (if (not (gnus-check-backend-function 'request-type (car method)))
14700 (funcall (gnus-get-function method 'request-type)
14701 (gnus-group-real-name group) article))))
14703 (defun gnus-request-update-mark (group article mark)
14704 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14705 (let ((method (gnus-find-method-for-group group)))
14706 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14708 (funcall (gnus-get-function method 'request-update-mark)
14709 (gnus-group-real-name group) article mark))))
14711 (defun gnus-request-article (article group &optional buffer)
14712 "Request the ARTICLE in GROUP.
14713 ARTICLE can either be an article number or an article Message-ID.
14714 If BUFFER, insert the article in that group."
14715 (let ((method (gnus-find-method-for-group group)))
14716 (funcall (gnus-get-function method 'request-article)
14717 article (gnus-group-real-name group) (nth 1 method) buffer)))
14719 (defun gnus-request-head (article group)
14720 "Request the head of ARTICLE in GROUP."
14721 (let ((method (gnus-find-method-for-group group)))
14722 (funcall (gnus-get-function method 'request-head)
14723 article (gnus-group-real-name group) (nth 1 method))))
14725 (defun gnus-request-body (article group)
14726 "Request the body of ARTICLE in GROUP."
14727 (let ((method (gnus-find-method-for-group group)))
14728 (funcall (gnus-get-function method 'request-body)
14729 article (gnus-group-real-name group) (nth 1 method))))
14731 (defun gnus-request-post (method)
14732 "Post the current buffer using METHOD."
14733 (when (stringp method)
14734 (setq method (gnus-server-to-method method)))
14735 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14737 (defun gnus-request-scan (group method)
14738 "Request a SCAN being performed in GROUP from METHOD.
14739 If GROUP is nil, all groups on METHOD are scanned."
14740 (let ((method (if group (gnus-find-method-for-group group) method)))
14741 (funcall (gnus-get-function method 'request-scan)
14742 (and group (gnus-group-real-name group)) (nth 1 method))))
14744 (defsubst gnus-request-update-info (info method)
14745 "Request that METHOD update INFO."
14746 (when (stringp method)
14747 (setq method (gnus-server-to-method method)))
14748 (when (gnus-check-backend-function 'request-update-info (car method))
14749 (funcall (gnus-get-function method 'request-update-info)
14750 (gnus-group-real-name (gnus-info-group info))
14751 info (nth 1 method))))
14753 (defun gnus-request-expire-articles (articles group &optional force)
14754 (let ((method (gnus-find-method-for-group group)))
14755 (funcall (gnus-get-function method 'request-expire-articles)
14756 articles (gnus-group-real-name group) (nth 1 method)
14759 (defun gnus-request-move-article
14760 (article group server accept-function &optional last)
14761 (let ((method (gnus-find-method-for-group group)))
14762 (funcall (gnus-get-function method 'request-move-article)
14763 article (gnus-group-real-name group)
14764 (nth 1 method) accept-function last)))
14766 (defun gnus-request-accept-article (group &optional last method)
14767 ;; Make sure there's a newline at the end of the article.
14768 (when (stringp method)
14769 (setq method (gnus-server-to-method method)))
14770 (goto-char (point-max))
14773 (let ((func (if (symbolp group) group
14774 (car (or method (gnus-find-method-for-group group))))))
14775 (funcall (intern (format "%s-request-accept-article" func))
14776 (if (stringp group) (gnus-group-real-name group) group)
14779 (defun gnus-request-replace-article (article group buffer)
14780 (let ((func (car (gnus-find-method-for-group group))))
14781 (funcall (intern (format "%s-request-replace-article" func))
14782 article (gnus-group-real-name group) buffer)))
14784 (defun gnus-request-associate-buffer (group)
14785 (let ((method (gnus-find-method-for-group group)))
14786 (funcall (gnus-get-function method 'request-associate-buffer)
14787 (gnus-group-real-name group))))
14789 (defun gnus-request-restore-buffer (article group)
14790 "Request a new buffer restored to the state of ARTICLE."
14791 (let ((method (gnus-find-method-for-group group)))
14792 (funcall (gnus-get-function method 'request-restore-buffer)
14793 article (gnus-group-real-name group) (nth 1 method))))
14795 (defun gnus-request-create-group (group &optional method)
14796 (when (stringp method)
14797 (setq method (gnus-server-to-method method)))
14798 (let ((method (or method (gnus-find-method-for-group group))))
14799 (funcall (gnus-get-function method 'request-create-group)
14800 (gnus-group-real-name group) (nth 1 method))))
14802 (defun gnus-request-delete-group (group &optional force)
14803 (let ((method (gnus-find-method-for-group group)))
14804 (funcall (gnus-get-function method 'request-delete-group)
14805 (gnus-group-real-name group) force (nth 1 method))))
14807 (defun gnus-request-rename-group (group new-name)
14808 (let ((method (gnus-find-method-for-group group)))
14809 (funcall (gnus-get-function method 'request-rename-group)
14810 (gnus-group-real-name group)
14811 (gnus-group-real-name new-name) (nth 1 method))))
14813 (defun gnus-member-of-valid (symbol group)
14814 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14815 (memq symbol (assoc
14816 (symbol-name (car (gnus-find-method-for-group group)))
14817 gnus-valid-select-methods)))
14819 (defun gnus-method-option-p (method option)
14820 "Return non-nil if select METHOD has OPTION as a parameter."
14821 (when (stringp method)
14822 (setq method (gnus-server-to-method method)))
14823 (memq option (assoc (format "%s" (car method))
14824 gnus-valid-select-methods)))
14826 (defun gnus-server-extend-method (group method)
14827 ;; This function "extends" a virtual server. If the server is
14828 ;; "hello", and the select method is ("hello" (my-var "something"))
14829 ;; in the group "alt.alt", this will result in a new virtual server
14830 ;; called "hello+alt.alt".
14832 (gnus-copy-sequence
14833 (if (equal (car method) "native") gnus-select-method
14834 (cdr (assoc (car method) gnus-server-alist))))))
14835 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14836 (nconc entry (cdr method))))
14838 (defun gnus-find-method-for-group (group &optional info)
14839 "Find the select method that GROUP uses."
14840 (or gnus-override-method
14842 gnus-select-method)
14843 (let ((info (or info (gnus-get-info group)))
14846 (not (setq method (gnus-info-method info)))
14847 (equal method "native"))
14850 (cond ((stringp method)
14851 (gnus-server-to-method method))
14852 ((stringp (car method))
14853 (gnus-server-extend-method group method))
14856 (if (equal (cadr method) "")
14858 (gnus-server-add-address method))))))
14860 (defun gnus-check-backend-function (func group)
14861 "Check whether GROUP supports function FUNC."
14862 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14864 (fboundp (intern (format "%s-%s" method func)))))
14866 (defun gnus-methods-using (feature)
14867 "Find all methods that have FEATURE."
14868 (let ((valids gnus-valid-select-methods)
14871 (if (memq feature (car valids))
14872 (setq outs (cons (car valids) outs)))
14873 (setq valids (cdr valids)))
14878 ;;; Active & Newsrc File Handling
14881 (defun gnus-setup-news (&optional rawfile level dont-connect)
14882 "Setup news information.
14883 If RAWFILE is non-nil, the .newsrc file will also be read.
14884 If LEVEL is non-nil, the news will be set up at level LEVEL."
14885 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
14888 ;; Clear some variables to re-initialize news information.
14889 (setq gnus-newsrc-alist nil
14890 gnus-active-hashtb nil)
14891 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
14892 (gnus-read-newsrc-file rawfile))
14894 (when (and (not (assoc "archive" gnus-server-alist))
14895 gnus-message-archive-method)
14896 (push (cons "archive" gnus-message-archive-method)
14897 gnus-server-alist))
14899 ;; If we don't read the complete active file, we fill in the
14901 (if (or (null gnus-read-active-file)
14902 (eq gnus-read-active-file 'some))
14903 (gnus-update-active-hashtb-from-killed))
14905 ;; Read the active file and create `gnus-active-hashtb'.
14906 ;; If `gnus-read-active-file' is nil, then we just create an empty
14907 ;; hash table. The partial filling out of the hash table will be
14908 ;; done in `gnus-get-unread-articles'.
14909 (and gnus-read-active-file
14911 (gnus-read-active-file))
14913 (or gnus-active-hashtb
14914 (setq gnus-active-hashtb (make-vector 4095 0)))
14916 ;; Initialize the cache.
14917 (when gnus-use-cache
14920 ;; Possibly eval the dribble file.
14921 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
14923 (gnus-update-format-specifications)
14925 ;; See whether we need to read the description file.
14926 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
14927 (not gnus-description-hashtb)
14929 gnus-read-active-file)
14930 (gnus-read-all-descriptions-files))
14932 ;; Find new newsgroups and treat them.
14933 (if (and init gnus-check-new-newsgroups (not level)
14934 (gnus-check-server gnus-select-method))
14935 (gnus-find-new-newsgroups))
14937 ;; We might read in new NoCeM messages here.
14938 (when gnus-use-nocem
14939 (gnus-nocem-scan-groups))
14941 ;; Find the number of unread articles in each non-dead group.
14942 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
14943 (gnus-get-unread-articles level))
14945 (if (and init gnus-check-bogus-newsgroups
14946 gnus-read-active-file (not level)
14947 (gnus-server-opened gnus-select-method))
14948 (gnus-check-bogus-newsgroups))))
14950 (defun gnus-find-new-newsgroups (&optional arg)
14951 "Search for new newsgroups and add them.
14952 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
14953 The `-n' option line from .newsrc is respected.
14954 If ARG (the prefix), use the `ask-server' method to query
14955 the server for new groups."
14957 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
14958 (null gnus-read-active-file)
14959 (eq gnus-read-active-file 'some))
14960 'ask-server gnus-check-new-newsgroups)))
14961 (unless (gnus-check-first-time-used)
14962 (if (or (consp check)
14963 (eq check 'ask-server))
14964 ;; Ask the server for new groups.
14965 (gnus-ask-server-for-new-groups)
14966 ;; Go through the active hashtb and look for new groups.
14968 group new-newsgroups)
14969 (gnus-message 5 "Looking for new newsgroups...")
14970 (unless gnus-have-read-active-file
14971 (gnus-read-active-file))
14972 (setq gnus-newsrc-last-checked-date (current-time-string))
14973 (unless gnus-killed-hashtb
14974 (gnus-make-hashtable-from-killed))
14975 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
14976 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
14979 (if (or (null (setq group (symbol-name sym)))
14981 (null (symbol-value sym))
14982 (gnus-gethash group gnus-killed-hashtb)
14983 (gnus-gethash group gnus-newsrc-hashtb))
14985 (let ((do-sub (gnus-matches-options-n group)))
14987 ((eq do-sub 'subscribe)
14988 (setq groups (1+ groups))
14989 (gnus-sethash group group gnus-killed-hashtb)
14990 (funcall gnus-subscribe-options-newsgroup-method group))
14991 ((eq do-sub 'ignore)
14994 (setq groups (1+ groups))
14995 (gnus-sethash group group gnus-killed-hashtb)
14996 (if gnus-subscribe-hierarchical-interactive
14997 (setq new-newsgroups (cons group new-newsgroups))
14998 (funcall gnus-subscribe-newsgroup-method group)))))))
14999 gnus-active-hashtb)
15000 (when new-newsgroups
15001 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15002 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15004 (gnus-message 6 "%d new newsgroup%s arrived."
15005 groups (if (> groups 1) "s have" " has"))
15006 (gnus-message 6 "No new newsgroups.")))))))
15008 (defun gnus-matches-options-n (group)
15009 ;; Returns `subscribe' if the group is to be unconditionally
15010 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15011 ;; no match for the group.
15013 ;; First we check the two user variables.
15015 ((and gnus-options-subscribe
15016 (string-match gnus-options-subscribe group))
15018 ((and gnus-auto-subscribed-groups
15019 (string-match gnus-auto-subscribed-groups group))
15021 ((and gnus-options-not-subscribe
15022 (string-match gnus-options-not-subscribe group))
15024 ;; Then we go through the list that was retrieved from the .newsrc
15025 ;; file. This list has elements on the form
15026 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15027 ;; is in the reverse order of the options line) is returned.
15029 (let ((regs gnus-newsrc-options-n))
15031 (not (string-match (caar regs) group)))
15032 (setq regs (cdr regs)))
15033 (and regs (cdar regs))))))
15035 (defun gnus-ask-server-for-new-groups ()
15036 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15037 (methods (cons gnus-select-method
15039 (when gnus-message-archive-method
15042 (and (consp gnus-check-new-newsgroups)
15043 gnus-check-new-newsgroups)
15044 gnus-secondary-select-methods))))
15046 (new-date (current-time-string))
15047 group new-newsgroups got-new method hashtb
15048 gnus-override-subscribe-method)
15049 ;; Go through both primary and secondary select methods and
15050 ;; request new newsgroups.
15051 (while (setq method (gnus-server-get-method nil (pop methods)))
15052 (setq new-newsgroups nil)
15053 (setq gnus-override-subscribe-method method)
15054 (when (and (gnus-check-server method)
15055 (gnus-request-newgroups date method))
15058 (setq hashtb (gnus-make-hashtable 100))
15059 (set-buffer nntp-server-buffer)
15060 ;; Enter all the new groups into a hashtable.
15061 (gnus-active-to-gnus-format method hashtb 'ignore)))
15062 ;; Now all new groups from `method' are in `hashtb'.
15064 (lambda (group-sym)
15065 (if (or (null (setq group (symbol-name group-sym)))
15066 (null (symbol-value group-sym))
15067 (gnus-gethash group gnus-newsrc-hashtb)
15068 (member group gnus-zombie-list)
15069 (member group gnus-killed-list))
15070 ;; The group is already known.
15072 ;; Make this group active.
15073 (when (symbol-value group-sym)
15074 (gnus-set-active group (symbol-value group-sym)))
15075 ;; Check whether we want it or not.
15076 (let ((do-sub (gnus-matches-options-n group)))
15078 ((eq do-sub 'subscribe)
15080 (gnus-sethash group group gnus-killed-hashtb)
15081 (funcall gnus-subscribe-options-newsgroup-method group))
15082 ((eq do-sub 'ignore)
15086 (gnus-sethash group group gnus-killed-hashtb)
15087 (if gnus-subscribe-hierarchical-interactive
15088 (push group new-newsgroups)
15089 (funcall gnus-subscribe-newsgroup-method group)))))))
15091 (when new-newsgroups
15092 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15093 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15095 (gnus-message 6 "%d new newsgroup%s arrived."
15096 groups (if (> groups 1) "s have" " has")))
15097 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15100 (defun gnus-check-first-time-used ()
15101 (if (or (> (length gnus-newsrc-alist) 1)
15102 (file-exists-p gnus-startup-file)
15103 (file-exists-p (concat gnus-startup-file ".el"))
15104 (file-exists-p (concat gnus-startup-file ".eld")))
15106 (gnus-message 6 "First time user; subscribing you to default groups")
15107 (unless gnus-have-read-active-file
15108 (gnus-read-active-file))
15109 (setq gnus-newsrc-last-checked-date (current-time-string))
15110 (let ((groups gnus-default-subscribed-newsgroups)
15114 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15117 (if (null (setq group (symbol-name sym)))
15119 (let ((do-sub (gnus-matches-options-n group)))
15121 ((eq do-sub 'subscribe)
15122 (gnus-sethash group group gnus-killed-hashtb)
15123 (funcall gnus-subscribe-options-newsgroup-method group))
15124 ((eq do-sub 'ignore)
15127 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15128 gnus-active-hashtb)
15130 (if (gnus-active (car groups))
15131 (gnus-group-change-level
15132 (car groups) gnus-level-default-subscribed gnus-level-killed))
15133 (setq groups (cdr groups)))
15134 (gnus-group-make-help-group)
15135 (and gnus-novice-user
15136 (gnus-message 7 "`A k' to list killed groups"))))))
15138 (defun gnus-subscribe-group (group previous &optional method)
15139 (gnus-group-change-level
15141 (list t group gnus-level-default-subscribed nil nil method)
15143 gnus-level-default-subscribed gnus-level-killed previous t))
15145 ;; `gnus-group-change-level' is the fundamental function for changing
15146 ;; subscription levels of newsgroups. This might mean just changing
15147 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15148 ;; again, which subscribes/unsubscribes a group, which is equally
15149 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15150 ;; from 8-9 to 1-7 means that you remove the group from the list of
15151 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15152 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15153 ;; which is trivial.
15154 ;; ENTRY can either be a string (newsgroup name) or a list (if
15155 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15156 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15158 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15159 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15161 (defun gnus-group-change-level (entry level &optional oldlevel
15162 previous fromkilled)
15163 (let (group info active num)
15164 ;; Glean what info we can from the arguments
15166 (if fromkilled (setq group (nth 1 entry))
15167 (setq group (car (nth 2 entry))))
15168 (setq group entry))
15169 (if (and (stringp entry)
15171 (< oldlevel gnus-level-zombie))
15172 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15173 (if (and (not oldlevel)
15175 (setq oldlevel (gnus-info-level (nth 2 entry)))
15176 (setq oldlevel (or oldlevel 9)))
15177 (if (stringp previous)
15178 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15180 (if (and (>= oldlevel gnus-level-zombie)
15181 (gnus-gethash group gnus-newsrc-hashtb))
15182 ;; We are trying to subscribe a group that is already
15186 (or (gnus-ephemeral-group-p group)
15187 (gnus-dribble-enter
15188 (format "(gnus-group-change-level %S %S %S %S %S)"
15189 group level oldlevel (car (nth 2 previous)) fromkilled)))
15191 ;; Then we remove the newgroup from any old structures, if needed.
15192 ;; If the group was killed, we remove it from the killed or zombie
15193 ;; list. If not, and it is in fact going to be killed, we remove
15194 ;; it from the newsrc hash table and assoc.
15196 ((>= oldlevel gnus-level-zombie)
15197 (if (= oldlevel gnus-level-zombie)
15198 (setq gnus-zombie-list (delete group gnus-zombie-list))
15199 (setq gnus-killed-list (delete group gnus-killed-list))))
15201 (if (and (>= level gnus-level-zombie)
15204 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15206 (setcdr (gnus-gethash (car (nth 3 entry))
15207 gnus-newsrc-hashtb)
15209 (setcdr (cdr entry) (cdddr entry))))))
15211 ;; Finally we enter (if needed) the list where it is supposed to
15212 ;; go, and change the subscription level. If it is to be killed,
15213 ;; we enter it into the killed or zombie list.
15215 ((>= level gnus-level-zombie)
15216 ;; Remove from the hash table.
15217 (gnus-sethash group nil gnus-newsrc-hashtb)
15218 ;; We do not enter foreign groups into the list of dead
15220 (unless (gnus-group-foreign-p group)
15221 (if (= level gnus-level-zombie)
15222 (setq gnus-zombie-list (cons group gnus-zombie-list))
15223 (setq gnus-killed-list (cons group gnus-killed-list)))))
15225 ;; If the list is to be entered into the newsrc assoc, and
15226 ;; it was killed, we have to create an entry in the newsrc
15227 ;; hashtb format and fix the pointers in the newsrc assoc.
15228 (if (< oldlevel gnus-level-zombie)
15229 ;; It was alive, and it is going to stay alive, so we
15230 ;; just change the level and don't change any pointers or
15231 ;; hash table entries.
15232 (setcar (cdaddr entry) level)
15234 (setq info (cdr entry)
15236 (setq active (gnus-active group))
15238 (if active (- (1+ (cdr active)) (car active)) t))
15239 ;; Check whether the group is foreign. If so, the
15240 ;; foreign select method has to be entered into the
15242 (let ((method (or gnus-override-subscribe-method
15243 (gnus-group-method group))))
15244 (if (eq method gnus-select-method)
15245 (setq info (list group level nil))
15246 (setq info (list group level nil nil method)))))
15249 (let ((p gnus-newsrc-alist))
15253 (setq entry (cons info (cddr previous)))
15256 (setcdr (cdr previous) entry)
15257 (gnus-sethash group (cons num (cdr previous))
15258 gnus-newsrc-hashtb))
15259 (setcdr previous entry)
15260 (gnus-sethash group (cons num previous)
15261 gnus-newsrc-hashtb))
15263 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15264 (when gnus-group-change-level-function
15265 (funcall gnus-group-change-level-function group level oldlevel)))))
15267 (defun gnus-kill-newsgroup (newsgroup)
15268 "Obsolete function. Kills a newsgroup."
15269 (gnus-group-change-level
15270 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15272 (defun gnus-check-bogus-newsgroups (&optional confirm)
15273 "Remove bogus newsgroups.
15274 If CONFIRM is non-nil, the user has to confirm the deletion of every
15276 (let ((newsrc (cdr gnus-newsrc-alist))
15277 bogus group entry info)
15278 (gnus-message 5 "Checking bogus newsgroups...")
15279 (unless gnus-have-read-active-file
15280 (gnus-read-active-file))
15281 (when (member gnus-select-method gnus-have-read-active-file)
15282 ;; Find all bogus newsgroup that are subscribed.
15284 (setq info (pop newsrc)
15285 group (gnus-info-group info))
15286 (unless (or (gnus-active group) ; Active
15287 (gnus-info-method info) ; Foreign
15289 (not (gnus-y-or-n-p
15290 (format "Remove bogus newsgroup: %s " group)))))
15291 ;; Found a bogus newsgroup.
15292 (push group bogus)))
15293 ;; Remove all bogus subscribed groups by first killing them, and
15294 ;; then removing them from the list of killed groups.
15296 (when (setq entry (gnus-gethash (setq group (pop bogus))
15297 gnus-newsrc-hashtb))
15298 (gnus-group-change-level entry gnus-level-killed)
15299 (setq gnus-killed-list (delete group gnus-killed-list))))
15300 ;; Then we remove all bogus groups from the list of killed and
15301 ;; zombie groups. They are are removed without confirmation.
15302 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15305 (setq killed (symbol-value (car dead-lists)))
15307 (unless (gnus-active (setq group (pop killed)))
15308 ;; The group is bogus.
15309 ;; !!!Slow as hell.
15310 (set (car dead-lists)
15311 (delete group (symbol-value (car dead-lists))))))
15312 (setq dead-lists (cdr dead-lists))))
15313 (gnus-message 5 "Checking bogus newsgroups...done"))))
15315 (defun gnus-check-duplicate-killed-groups ()
15316 "Remove duplicates from the list of killed groups."
15318 (let ((killed gnus-killed-list))
15320 (gnus-message 9 "%d" (length killed))
15321 (setcdr killed (delete (car killed) (cdr killed)))
15322 (setq killed (cdr killed)))))
15324 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15325 ;; and compute how many unread articles there are in each group.
15326 (defun gnus-get-unread-articles (&optional level)
15327 (let* ((newsrc (cdr gnus-newsrc-alist))
15328 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15331 (cond ((and gnus-activate-foreign-newsgroups
15332 (not (numberp gnus-activate-foreign-newsgroups)))
15333 (1+ gnus-level-subscribed))
15334 ((numberp gnus-activate-foreign-newsgroups)
15335 gnus-activate-foreign-newsgroups)
15338 info group active method)
15339 (gnus-message 5 "Checking new news...")
15342 (setq active (gnus-active (setq group (gnus-info-group
15343 (setq info (pop newsrc))))))
15345 ;; Check newsgroups. If the user doesn't want to check them, or
15346 ;; they can't be checked (for instance, if the news server can't
15347 ;; be reached) we just set the number of unread articles in this
15348 ;; newsgroup to t. This means that Gnus thinks that there are
15349 ;; unread articles, but it has no idea how many.
15350 (if (and (setq method (gnus-info-method info))
15351 (not (gnus-server-equal
15353 (gnus-server-get-method nil method)))
15354 (not (gnus-secondary-method-p method)))
15355 ;; These groups are foreign. Check the level.
15356 (when (<= (gnus-info-level info) foreign-level)
15357 (setq active (gnus-activate-group group 'scan))
15358 (gnus-close-group group))
15360 ;; These groups are native or secondary.
15361 (when (and (<= (gnus-info-level info) level)
15362 (not gnus-read-active-file))
15363 (setq active (gnus-activate-group group 'scan))
15364 (gnus-close-group group)))
15367 (gnus-get-unread-articles-in-group info active t)
15368 ;; The group couldn't be reached, so we nix out the number of
15369 ;; unread articles and stuff.
15370 (gnus-set-active group nil)
15371 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15373 (gnus-message 5 "Checking new news...done")))
15375 ;; Create a hash table out of the newsrc alist. The `car's of the
15376 ;; alist elements are used as keys.
15377 (defun gnus-make-hashtable-from-newsrc-alist ()
15378 (let ((alist gnus-newsrc-alist)
15379 (ohashtb gnus-newsrc-hashtb)
15381 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15383 (setq prev (setq gnus-newsrc-alist
15384 (if (equal (caar gnus-newsrc-alist)
15387 (cons (list "dummy.group" 0 nil) alist)))))
15391 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15393 gnus-newsrc-hashtb)
15395 alist (cdr alist)))))
15397 (defun gnus-make-hashtable-from-killed ()
15398 "Create a hash table from the killed and zombie lists."
15399 (let ((lists '(gnus-killed-list gnus-zombie-list))
15401 (setq gnus-killed-hashtb
15402 (gnus-make-hashtable
15403 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15404 (while (setq list (symbol-value (pop lists)))
15406 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15408 (defun gnus-get-unread-articles-in-group (info active &optional update)
15410 ;; Allow the backend to update the info in the group.
15412 (gnus-request-update-info
15413 info (gnus-find-method-for-group (gnus-info-group info))))
15414 (gnus-activate-group (gnus-info-group info)))
15415 (let* ((range (gnus-info-read info))
15417 ;; If a cache is present, we may have to alter the active info.
15418 (when (and gnus-use-cache info)
15419 (gnus-cache-possibly-alter-active (gnus-info-group info) active))
15420 ;; Modify the list of read articles according to what articles
15421 ;; are available; then tally the unread articles and add the
15422 ;; number to the group hash table entry.
15424 ((zerop (cdr active))
15427 (setq num (- (1+ (cdr active)) (car active))))
15428 ((not (listp (cdr range)))
15429 ;; Fix a single (num . num) range according to the
15430 ;; active hash table.
15431 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15432 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15433 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15434 ;; Compute number of unread articles.
15435 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15437 ;; The read list is a list of ranges. Fix them according to
15438 ;; the active hash table.
15439 ;; First peel off any elements that are below the lower
15441 (while (and (cdr range)
15443 (or (and (atom (cadr range)) (cadr range))
15445 (if (numberp (car range))
15448 (or (and (numberp (cadr range))
15451 (setcdr (car range)
15452 (or (and (numberp (nth 1 range)) (nth 1 range))
15454 (setcdr range (cddr range)))
15455 ;; Adjust the first element to be the same as the lower limit.
15456 (if (and (not (atom (car range)))
15457 (< (cdar range) (car active)))
15458 (setcdr (car range) (1- (car active))))
15459 ;; Then we want to peel off any elements that are higher
15460 ;; than the upper active limit.
15461 (let ((srange range))
15462 ;; Go past all legal elements.
15463 (while (and (cdr srange)
15464 (<= (or (and (atom (cadr srange))
15466 (caadr srange)) (cdr active)))
15467 (setq srange (cdr srange)))
15469 ;; Nuke all remaining illegal elements.
15470 (setcdr srange nil))
15472 ;; Adjust the final element.
15473 (if (and (not (atom (car srange)))
15474 (> (cdar srange) (cdr active)))
15475 (setcdr (car srange) (cdr active))))
15476 ;; Compute the number of unread articles.
15478 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15480 (or (and (atom (car range)) (car range))
15482 (setq range (cdr range)))
15483 (setq num (max 0 (- (cdr active) num)))))
15484 ;; Set the number of unread articles.
15486 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15489 (defun gnus-activate-group (group &optional scan)
15490 ;; Check whether a group has been activated or not.
15491 ;; If SCAN, request a scan of that group as well.
15492 (let ((method (gnus-find-method-for-group group))
15494 (and (gnus-check-server method)
15495 ;; We escape all bugs and quit here to make it possible to
15496 ;; continue if a group is so out-there that it reports bugs
15500 (gnus-check-backend-function 'request-scan (car method))
15501 (gnus-request-scan group method))
15504 (gnus-request-group group)
15508 (set-buffer nntp-server-buffer)
15509 (goto-char (point-min))
15510 ;; Parse the result we got from `gnus-request-group'.
15511 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15513 (goto-char (match-beginning 1))
15515 group (setq active (cons (read (current-buffer))
15516 (read (current-buffer)))))
15517 ;; Return the new active info.
15520 (defun gnus-update-read-articles (group unread)
15521 "Update the list of read and ticked articles in GROUP using the
15522 UNREAD and TICKED lists.
15523 Note: UNSELECTED has to be sorted over `<'.
15524 Returns whether the updating was successful."
15525 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15526 (entry (gnus-gethash group gnus-newsrc-hashtb))
15527 (info (nth 2 entry))
15529 (unread (sort (copy-sequence unread) '<))
15531 (if (or (not info) (not active))
15532 ;; There is no info on this group if it was, in fact,
15533 ;; killed. Gnus stores no information on killed groups, so
15534 ;; there's nothing to be done.
15535 ;; One could store the information somewhere temporarily,
15536 ;; perhaps... Hmmm...
15538 ;; Remove any negative articles numbers.
15539 (while (and unread (< (car unread) 0))
15540 (setq unread (cdr unread)))
15541 ;; Remove any expired article numbers
15542 (while (and unread (< (car unread) (car active)))
15543 (setq unread (cdr unread)))
15544 ;; Compute the ranges of read articles by looking at the list of
15545 ;; unread articles.
15547 (if (/= (car unread) prev)
15548 (setq read (cons (if (= prev (1- (car unread))) prev
15549 (cons prev (1- (car unread)))) read)))
15550 (setq prev (1+ (car unread)))
15551 (setq unread (cdr unread)))
15552 (when (<= prev (cdr active))
15553 (setq read (cons (cons prev (cdr active)) read)))
15554 ;; Enter this list into the group info.
15555 (gnus-info-set-read
15556 info (if (> (length read) 1) (nreverse read) read))
15557 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15558 (gnus-get-unread-articles-in-group info (gnus-active group))
15561 (defun gnus-make-articles-unread (group articles)
15562 "Mark ARTICLES in GROUP as unread."
15563 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15564 (gnus-gethash (gnus-group-real-name group)
15565 gnus-newsrc-hashtb))))
15566 (ranges (gnus-info-read info))
15569 (when (gnus-member-of-range
15570 (setq article (pop articles)) ranges)
15571 (setq news (cons article news))))
15573 (gnus-info-set-read
15574 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15575 (gnus-group-update-group group t))))
15577 ;; Enter all dead groups into the hashtb.
15578 (defun gnus-update-active-hashtb-from-killed ()
15579 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15580 (lists (list gnus-killed-list gnus-zombie-list))
15583 (setq killed (car lists))
15585 (gnus-sethash (car killed) nil hashtb)
15586 (setq killed (cdr killed)))
15587 (setq lists (cdr lists)))))
15589 ;; Get the active file(s) from the backend(s).
15590 (defun gnus-read-active-file ()
15591 (gnus-group-set-mode-line)
15594 (if (gnus-check-server gnus-select-method)
15595 ;; The native server is available.
15596 (cons gnus-select-method gnus-secondary-select-methods)
15597 ;; The native server is down, so we just do the
15599 gnus-secondary-select-methods)
15600 ;; Also read from the archive server.
15601 (when gnus-message-archive-method
15602 (list "archive"))))
15604 (setq gnus-have-read-active-file nil)
15606 (set-buffer nntp-server-buffer)
15608 (let* ((method (if (stringp (car methods))
15609 (gnus-server-get-method nil (car methods))
15611 (where (nth 1 method))
15612 (mesg (format "Reading active file%s via %s..."
15613 (if (and where (not (zerop (length where))))
15614 (concat " from " where) "")
15616 (gnus-message 5 mesg)
15617 (when (gnus-check-server method)
15618 ;; Request that the backend scan its incoming messages.
15619 (and (gnus-check-backend-function 'request-scan (car method))
15620 (gnus-request-scan nil method))
15622 ((and (eq gnus-read-active-file 'some)
15623 (gnus-check-backend-function 'retrieve-groups (car method)))
15624 (let ((newsrc (cdr gnus-newsrc-alist))
15625 (gmethod (if (stringp method)
15626 (gnus-server-get-method nil method)
15629 (while (setq info (pop newsrc))
15630 (when (gnus-server-equal
15631 (gnus-find-method-for-group
15632 (gnus-info-group info) info)
15634 (push (gnus-group-real-name (gnus-info-group info))
15637 (gnus-check-server method)
15638 (setq list-type (gnus-retrieve-groups groups method))
15642 1 "Cannot read partial active file from %s server."
15646 ((eq list-type 'active)
15647 (gnus-active-to-gnus-format method gnus-active-hashtb))
15649 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15651 (if (not (gnus-request-list method))
15653 (unless (equal method gnus-message-archive-method)
15654 (gnus-message 1 "Cannot read active file from %s server."
15657 (gnus-active-to-gnus-format method)
15658 ;; We mark this active file as read.
15659 (push method gnus-have-read-active-file)
15660 (gnus-message 5 "%sdone" mesg))))))
15661 (setq methods (cdr methods))))))
15663 ;; Read an active file and place the results in `gnus-active-hashtb'.
15664 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15666 (setq method gnus-select-method))
15667 (let ((cur (current-buffer))
15669 (if (and gnus-active-hashtb
15670 (not (equal method gnus-select-method)))
15672 (setq gnus-active-hashtb
15673 (if (equal method gnus-select-method)
15674 (gnus-make-hashtable
15675 (count-lines (point-min) (point-max)))
15676 (gnus-make-hashtable 4096)))))))
15677 ;; Delete unnecessary lines.
15678 (goto-char (point-min))
15679 (while (search-forward "\nto." nil t)
15680 (delete-region (1+ (match-beginning 0))
15681 (progn (forward-line 1) (point))))
15682 (or (string= gnus-ignored-newsgroups "")
15684 (goto-char (point-min))
15685 (delete-matching-lines gnus-ignored-newsgroups)))
15686 ;; Make the group names readable as a lisp expression even if they
15687 ;; contain special characters.
15688 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15689 (goto-char (point-max))
15690 (while (re-search-backward "[][';?()#]" nil t)
15692 ;; If these are groups from a foreign select method, we insert the
15693 ;; group prefix in front of the group names.
15694 (and method (not (gnus-server-equal
15695 (gnus-server-get-method nil method)
15696 (gnus-server-get-method nil gnus-select-method)))
15697 (let ((prefix (gnus-group-prefixed-name "" method)))
15698 (goto-char (point-min))
15699 (while (and (not (eobp))
15700 (progn (insert prefix)
15701 (zerop (forward-line 1)))))))
15702 ;; Store the active file in a hash table.
15703 (goto-char (point-min))
15704 (if (string-match "%[oO]" gnus-group-line-format)
15705 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15706 ;; If we want information on moderated groups, we use this
15708 (let* ((mod-hashtb (make-vector 7 0))
15709 (m (intern "m" mod-hashtb))
15711 (while (not (eobp))
15712 (condition-case nil
15714 (narrow-to-region (point) (gnus-point-at-eol))
15715 (setq group (let ((obarray hashtb)) (read cur)))
15716 (if (and (numberp (setq max (read cur)))
15717 (numberp (setq min (read cur)))
15719 (skip-chars-forward " \t")
15721 (or (= (following-char) ?=)
15722 (= (following-char) ?x)
15723 (= (following-char) ?j)))))
15724 (set group (cons min max))
15726 ;; Enter moderated groups into a list.
15727 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15728 (setq gnus-moderated-list
15729 (cons (symbol-name group) gnus-moderated-list))))
15736 ;; And if we do not care about moderation, we use this loop,
15737 ;; which is faster.
15738 (let (group max min)
15739 (while (not (eobp))
15742 (narrow-to-region (point) (gnus-point-at-eol))
15743 ;; group gets set to a symbol interned in the hash table
15744 ;; (what a hack!!) - jwz
15745 (setq group (let ((obarray hashtb)) (read cur)))
15746 (if (and (numberp (setq max (read cur)))
15747 (numberp (setq min (read cur)))
15749 (skip-chars-forward " \t")
15751 (or (= (following-char) ?=)
15752 (= (following-char) ?x)
15753 (= (following-char) ?j)))))
15754 (set group (cons min max))
15762 (gnus-message 3 "Warning - illegal active: %s"
15764 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15766 (forward-line 1))))))
15768 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15769 ;; Parse a "groups" active file.
15770 (let ((cur (current-buffer))
15772 (if (and method gnus-active-hashtb)
15774 (setq gnus-active-hashtb
15775 (gnus-make-hashtable
15776 (count-lines (point-min) (point-max)))))))
15777 (prefix (and method
15778 (not (gnus-server-equal
15779 (gnus-server-get-method nil method)
15780 (gnus-server-get-method nil gnus-select-method)))
15781 (gnus-group-prefixed-name "" method))))
15783 (goto-char (point-min))
15784 ;; We split this into to separate loops, one with the prefix
15785 ;; and one without to speed the reading up somewhat.
15787 (let (min max opoint group)
15788 (while (not (eobp))
15791 (read cur) (read cur)
15792 (setq min (read cur)
15795 (skip-chars-forward " \t")
15798 (set (let ((obarray hashtb)) (read cur))
15800 (error (and group (symbolp group) (set group nil))))
15802 (let (min max group)
15803 (while (not (eobp))
15805 (if (= (following-char) ?2)
15807 (read cur) (read cur)
15808 (setq min (read cur)
15810 (set (setq group (let ((obarray hashtb)) (read cur)))
15812 (error (and group (symbolp group) (set group nil))))
15813 (forward-line 1))))))
15815 (defun gnus-read-newsrc-file (&optional force)
15816 "Read startup file.
15817 If FORCE is non-nil, the .newsrc file is read."
15818 ;; Reset variables that might be defined in the .newsrc.eld file.
15819 (let ((variables gnus-variable-list))
15821 (set (car variables) nil)
15822 (setq variables (cdr variables))))
15823 (let* ((newsrc-file gnus-current-startup-file)
15824 (quick-file (concat newsrc-file ".el")))
15826 ;; We always load the .newsrc.eld file. If always contains
15827 ;; much information that can not be gotten from the .newsrc
15828 ;; file (ticked articles, killed groups, foreign methods, etc.)
15829 (gnus-read-newsrc-el-file quick-file)
15831 (if (and (file-exists-p gnus-current-startup-file)
15833 (and (file-newer-than-file-p newsrc-file quick-file)
15834 (file-newer-than-file-p newsrc-file
15835 (concat quick-file "d")))
15836 (not gnus-newsrc-alist)))
15837 ;; We read the .newsrc file. Note that if there if a
15838 ;; .newsrc.eld file exists, it has already been read, and
15839 ;; the `gnus-newsrc-hashtb' has been created. While reading
15840 ;; the .newsrc file, Gnus will only use the information it
15841 ;; can find there for changing the data already read -
15842 ;; ie. reading the .newsrc file will not trash the data
15843 ;; already read (except for read articles).
15845 (gnus-message 5 "Reading %s..." newsrc-file)
15846 (set-buffer (find-file-noselect newsrc-file))
15847 (buffer-disable-undo (current-buffer))
15848 (gnus-newsrc-to-gnus-format)
15849 (kill-buffer (current-buffer))
15850 (gnus-message 5 "Reading %s...done" newsrc-file)))
15852 ;; Read any slave files.
15854 (gnus-master-read-slave-newsrc)))))
15856 (defun gnus-read-newsrc-el-file (file)
15857 (let ((ding-file (concat file "d")))
15858 ;; We always, always read the .eld file.
15859 (gnus-message 5 "Reading %s..." ding-file)
15860 (let (gnus-newsrc-assoc)
15861 (condition-case nil
15862 (load ding-file t t t)
15864 (gnus-message 1 "Error in %s" ding-file)
15866 (when gnus-newsrc-assoc
15867 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15868 (gnus-make-hashtable-from-newsrc-alist)
15869 (when (file-newer-than-file-p file ding-file)
15870 ;; Old format quick file
15871 (gnus-message 5 "Reading %s..." file)
15872 ;; The .el file is newer than the .eld file, so we read that one
15874 (gnus-read-old-newsrc-el-file file))))
15876 ;; Parse the old-style quick startup file
15877 (defun gnus-read-old-newsrc-el-file (file)
15878 (let (newsrc killed marked group m info)
15880 (let ((gnus-killed-assoc nil)
15881 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
15883 (condition-case nil
15886 (setq newsrc gnus-newsrc-assoc
15887 killed gnus-killed-assoc
15888 marked gnus-marked-assoc)))
15889 (setq gnus-newsrc-alist nil)
15890 (while (setq info (gnus-get-info (setq group (pop newsrc))))
15893 (gnus-info-set-read info (cddr group))
15894 (gnus-info-set-level
15895 info (if (nth 1 group) gnus-level-default-subscribed
15896 gnus-level-default-unsubscribed))
15897 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
15900 (if (nth 1 group) gnus-level-default-subscribed
15901 gnus-level-default-unsubscribed)
15903 gnus-newsrc-alist))
15904 ;; Copy marks into info.
15905 (when (setq m (assoc (car group) marked))
15906 (unless (nthcdr 3 info)
15907 (nconc info (list nil)))
15908 (gnus-info-set-marks
15909 info (list (cons 'tick (gnus-compress-sequence
15910 (sort (cdr m) '<) t))))))
15911 (setq newsrc killed)
15913 (setcar newsrc (caar newsrc))
15914 (setq newsrc (cdr newsrc)))
15915 (setq gnus-killed-list killed))
15916 ;; The .el file version of this variable does not begin with
15917 ;; "options", while the .eld version does, so we just add it if it
15920 gnus-newsrc-options
15922 (and (not (string-match "^ *options" gnus-newsrc-options))
15923 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
15924 (and (not (string-match "\n$" gnus-newsrc-options))
15925 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
15926 ;; Finally, if we read some options lines, we parse them.
15927 (or (string= gnus-newsrc-options "")
15928 (gnus-newsrc-parse-options gnus-newsrc-options))))
15930 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
15931 (gnus-make-hashtable-from-newsrc-alist)))
15933 (defun gnus-make-newsrc-file (file)
15934 "Make server dependent file name by catenating FILE and server host name."
15935 (let* ((file (expand-file-name file nil))
15936 (real-file (concat file "-" (nth 1 gnus-select-method))))
15937 (if (or (file-exists-p real-file)
15938 (file-exists-p (concat real-file ".el"))
15939 (file-exists-p (concat real-file ".eld")))
15942 (defun gnus-newsrc-to-gnus-format ()
15943 (setq gnus-newsrc-options "")
15944 (setq gnus-newsrc-options-n nil)
15946 (or gnus-active-hashtb
15947 (setq gnus-active-hashtb (make-vector 4095 0)))
15948 (let ((buf (current-buffer))
15949 (already-read (> (length gnus-newsrc-alist) 1))
15950 group subscribed options-symbol newsrc Options-symbol
15952 (goto-char (point-min))
15953 ;; We intern the symbol `options' in the active hashtb so that we
15954 ;; can `eq' against it later.
15955 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
15956 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
15958 (while (not (eobp))
15959 ;; We first read the first word on the line by narrowing and
15960 ;; then reading into `gnus-active-hashtb'. Most groups will
15961 ;; already exist in that hashtb, so this will save some string
15965 (progn (skip-chars-forward "^ \t!:\n") (point)))
15966 (goto-char (point-min))
15968 (and (/= (point-min) (point-max))
15969 (let ((obarray gnus-active-hashtb)) (read buf))))
15971 ;; Now, the symbol we have read is either `options' or a group
15972 ;; name. If it is an options line, we just add it to a string.
15974 ((or (eq symbol options-symbol)
15975 (eq symbol Options-symbol))
15976 (setq gnus-newsrc-options
15977 ;; This concating is quite inefficient, but since our
15978 ;; thorough studies show that approx 99.37% of all
15979 ;; .newsrc files only contain a single options line, we
15980 ;; don't give a damn, frankly, my dear.
15981 (concat gnus-newsrc-options
15983 (gnus-point-at-bol)
15984 ;; Options may continue on the next line.
15985 (or (and (re-search-forward "^[^ \t]" nil 'move)
15986 (progn (beginning-of-line) (point)))
15990 ;; Group names can be just numbers.
15991 (when (numberp symbol)
15992 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
15993 (or (boundp symbol) (set symbol nil))
15994 ;; It was a group name.
15995 (setq subscribed (= (following-char) ?:)
15996 group (symbol-name symbol)
15999 ;; If the line ends here, this is clearly a buggy line, so
16000 ;; we put point a the beginning of line and let the cond
16001 ;; below do the error handling.
16002 (beginning-of-line)
16003 ;; We skip to the beginning of the ranges.
16004 (skip-chars-forward "!: \t"))
16005 ;; We are now at the beginning of the list of read articles.
16006 ;; We read them range by range.
16009 ((looking-at "[0-9]+")
16010 ;; We narrow and read a number instead of buffer-substring/
16011 ;; string-to-int because it's faster. narrow/widen is
16012 ;; faster than save-restriction/narrow, and save-restriction
16013 ;; produces a garbage object.
16015 (narrow-to-region (match-beginning 0) (match-end 0))
16018 ;; If the next character is a dash, then this is a range.
16019 (if (= (following-char) ?-)
16021 ;; We read the upper bound of the range.
16023 (if (not (looking-at "[0-9]+"))
16024 ;; This is a buggy line, by we pretend that
16025 ;; it's kinda OK. Perhaps the user should be
16027 (setq reads (cons num1 reads))
16032 (narrow-to-region (match-beginning 0)
16037 ;; It was just a simple number, so we add it to the
16039 (setq reads (cons num1 reads)))
16040 ;; If the next char in ?\n, then we have reached the end
16041 ;; of the line and return nil.
16042 (/= (following-char) ?\n))
16043 ((= (following-char) ?\n)
16044 ;; End of line, so we end.
16047 ;; Not numbers and not eol, so this might be a buggy
16050 ;; If it was eob instead of ?\n, we allow it.
16052 ;; The line was buggy.
16054 (gnus-message 3 "Mangled line: %s"
16055 (buffer-substring (gnus-point-at-bol)
16056 (gnus-point-at-eol)))
16060 ;; Skip past ", ". Spaces are illegal in these ranges, but
16061 ;; we allow them, because it's a common mistake to put a
16062 ;; space after the comma.
16063 (skip-chars-forward ", "))
16065 ;; We have already read .newsrc.eld, so we gently update the
16066 ;; data in the hash table with the information we have just
16069 (let ((info (gnus-get-info group))
16072 ;; There is an entry for this file in the alist.
16074 (gnus-info-set-read info (nreverse reads))
16075 ;; We update the level very gently. In fact, we
16076 ;; only change it if there's been a status change
16077 ;; from subscribed to unsubscribed, or vice versa.
16078 (setq level (gnus-info-level info))
16079 (cond ((and (<= level gnus-level-subscribed)
16081 (setq level (if reads
16082 gnus-level-default-unsubscribed
16083 (1+ gnus-level-default-unsubscribed))))
16084 ((and (> level gnus-level-subscribed) subscribed)
16085 (setq level gnus-level-default-subscribed)))
16086 (gnus-info-set-level info level))
16087 ;; This is a new group.
16088 (setq info (list group
16090 gnus-level-default-subscribed
16092 (1+ gnus-level-subscribed)
16093 gnus-level-default-unsubscribed))
16094 (nreverse reads))))
16095 (setq newsrc (cons info newsrc))))))
16098 (setq newsrc (nreverse newsrc))
16100 (if (not already-read)
16102 ;; We now have two newsrc lists - `newsrc', which is what we
16103 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16104 ;; what we've read from .newsrc.eld. We have to merge these
16105 ;; lists. We do this by "attaching" any (foreign) groups in the
16106 ;; gnus-newsrc-alist to the (native) group that precedes them.
16107 (let ((rc (cdr gnus-newsrc-alist))
16108 (prev gnus-newsrc-alist)
16111 (or (null (nth 4 (car rc))) ; It's a native group.
16112 (assoc (caar rc) newsrc) ; It's already in the alist.
16113 (if (setq entry (assoc (caar prev) newsrc))
16114 (setcdr (setq mentry (memq entry newsrc))
16115 (cons (car rc) (cdr mentry)))
16116 (setq newsrc (cons (car rc) newsrc))))
16120 (setq gnus-newsrc-alist newsrc)
16121 ;; We make the newsrc hashtb.
16122 (gnus-make-hashtable-from-newsrc-alist)
16124 ;; Finally, if we read some options lines, we parse them.
16125 (or (string= gnus-newsrc-options "")
16126 (gnus-newsrc-parse-options gnus-newsrc-options))))
16128 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16129 ;; The return value will be a list on the form
16130 ;; ((regexp1 . ignore)
16131 ;; (regexp2 . subscribe)...)
16132 ;; When handling new newsgroups, groups that match a `ignore' regexp
16133 ;; will be ignored, and groups that match a `subscribe' regexp will be
16134 ;; subscribed. A line like
16135 ;; options -n !all rec.all
16136 ;; will lead to a list that looks like
16137 ;; (("^rec\\..+" . subscribe)
16138 ;; ("^.+" . ignore))
16139 ;; So all "rec.*" groups will be subscribed, while all the other
16140 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16141 ;; different from "options -n rec.all !all".
16142 (defun gnus-newsrc-parse-options (options)
16145 (gnus-set-work-buffer)
16146 (insert (regexp-quote options))
16147 ;; First we treat all continuation lines.
16148 (goto-char (point-min))
16149 (while (re-search-forward "\n[ \t]+" nil t)
16150 (replace-match " " t t))
16151 ;; Then we transform all "all"s into ".+"s.
16152 (goto-char (point-min))
16153 (while (re-search-forward "\\ball\\b" nil t)
16154 (replace-match ".+" t t))
16155 (goto-char (point-min))
16156 ;; We remove all other options than the "-n" ones.
16157 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16158 (replace-match " ")
16160 (goto-char (point-min))
16162 ;; We are only interested in "options -n" lines - we
16163 ;; ignore the other option lines.
16164 (while (re-search-forward "[ \t]-n" nil t)
16166 (or (save-excursion
16167 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16169 (gnus-point-at-eol)))
16170 ;; Search for all "words"...
16171 (while (re-search-forward "[^ \t,\n]+" eol t)
16172 (if (= (char-after (match-beginning 0)) ?!)
16173 ;; If the word begins with a bang (!), this is a "not"
16174 ;; spec. We put this spec (minus the bang) and the
16175 ;; symbol `ignore' into the list.
16176 (setq out (cons (cons (concat
16177 "^" (buffer-substring
16178 (1+ (match-beginning 0))
16181 ;; There was no bang, so this is a "yes" spec.
16182 (setq out (cons (cons (concat "^" (match-string 0))
16183 'subscribe) out)))))
16185 (setq gnus-newsrc-options-n out))))
16187 (defun gnus-save-newsrc-file (&optional force)
16188 "Save .newsrc file."
16189 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16190 ;; from the variable gnus-newsrc-alist.
16191 (when (and (or gnus-newsrc-alist gnus-killed-list)
16192 gnus-current-startup-file)
16194 (if (and (or gnus-use-dribble-file gnus-slave)
16196 (or (not gnus-dribble-buffer)
16197 (not (buffer-name gnus-dribble-buffer))
16198 (zerop (save-excursion
16199 (set-buffer gnus-dribble-buffer)
16201 (gnus-message 4 "(No changes need to be saved)")
16202 (run-hooks 'gnus-save-newsrc-hook)
16204 (gnus-slave-save-newsrc)
16206 (when gnus-save-newsrc-file
16207 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16208 (gnus-gnus-to-newsrc-format)
16209 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16210 ;; Save .newsrc.eld.
16211 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16212 (make-local-variable 'version-control)
16213 (setq version-control 'never)
16214 (setq buffer-file-name
16215 (concat gnus-current-startup-file ".eld"))
16216 (gnus-add-current-to-buffer-list)
16217 (buffer-disable-undo (current-buffer))
16219 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16220 (gnus-gnus-to-quick-newsrc-format)
16221 (run-hooks 'gnus-save-quick-newsrc-hook)
16223 (kill-buffer (current-buffer))
16225 5 "Saving %s.eld...done" gnus-current-startup-file))
16226 (gnus-dribble-delete-file)))))
16228 (defun gnus-gnus-to-quick-newsrc-format ()
16229 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16230 (insert ";; Gnus startup file.\n")
16231 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16232 (insert ";; to read .newsrc.\n")
16233 (insert "(setq gnus-newsrc-file-version "
16234 (prin1-to-string gnus-version) ")\n")
16236 (if gnus-save-killed-list gnus-variable-list
16237 ;; Remove the `gnus-killed-list' from the list of variables
16238 ;; to be saved, if required.
16239 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16240 ;; Peel off the "dummy" group.
16241 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16243 ;; Insert the variables into the file.
16245 (when (and (boundp (setq variable (pop variables)))
16246 (symbol-value variable))
16247 (insert "(setq " (symbol-name variable) " '")
16248 (prin1 (symbol-value variable) (current-buffer))
16251 (defun gnus-gnus-to-newsrc-format ()
16252 ;; Generate and save the .newsrc file.
16254 (set-buffer (create-file-buffer gnus-current-startup-file))
16255 (let ((newsrc (cdr gnus-newsrc-alist))
16256 (standard-output (current-buffer))
16257 info ranges range method)
16258 (setq buffer-file-name gnus-current-startup-file)
16259 (buffer-disable-undo (current-buffer))
16262 (if gnus-newsrc-options (insert gnus-newsrc-options))
16263 ;; Write subscribed and unsubscribed.
16264 (while (setq info (pop newsrc))
16265 ;; Don't write foreign groups to .newsrc.
16266 (when (or (null (setq method (gnus-info-method info)))
16267 (equal method "native")
16268 (gnus-server-equal method gnus-select-method))
16269 (insert (gnus-info-group info)
16270 (if (> (gnus-info-level info) gnus-level-subscribed)
16272 (when (setq ranges (gnus-info-read info))
16274 (if (not (listp (cdr ranges)))
16275 (if (= (car ranges) (cdr ranges))
16276 (princ (car ranges))
16277 (princ (car ranges))
16279 (princ (cdr ranges)))
16280 (while (setq range (pop ranges))
16281 (if (or (atom range) (= (car range) (cdr range)))
16282 (princ (or (and (atom range) range) (car range)))
16283 (princ (car range))
16285 (princ (cdr range)))
16286 (if ranges (insert ",")))))
16288 (make-local-variable 'version-control)
16289 (setq version-control 'never)
16290 ;; It has been reported that sometime the modtime on the .newsrc
16291 ;; file seems to be off. We really do want to overwrite it, so
16292 ;; we clear the modtime here before saving. It's a bit odd,
16294 ;; sometimes the modtime clear isn't sufficient. most brute force:
16295 ;; delete the silly thing entirely first. but this fails to provide
16296 ;; such niceties as .newsrc~ creation.
16297 (if gnus-modtime-botch
16298 (delete-file gnus-startup-file)
16299 (clear-visited-file-modtime))
16300 (run-hooks 'gnus-save-standard-newsrc-hook)
16302 (kill-buffer (current-buffer)))))
16306 ;;; Slave functions.
16309 (defun gnus-slave-save-newsrc ()
16311 (set-buffer gnus-dribble-buffer)
16313 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16314 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16316 (defun gnus-master-read-slave-newsrc ()
16319 (file-name-directory gnus-current-startup-file)
16323 (file-name-nondirectory gnus-current-startup-file)
16327 (if (not slave-files)
16328 () ; There are no slave files to read.
16329 (gnus-message 7 "Reading slave newsrcs...")
16331 (set-buffer (get-buffer-create " *gnus slave*"))
16332 (buffer-disable-undo (current-buffer))
16334 (sort (mapcar (lambda (file)
16335 (list (nth 5 (file-attributes file)) file))
16338 (or (< (caar f1) (caar f2))
16339 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16342 (setq file (nth 1 (car slave-files)))
16343 (insert-file-contents file)
16344 (if (condition-case ()
16346 (eval-buffer (current-buffer))
16349 (gnus-message 3 "Possible error in %s" file)
16353 (or gnus-slave ; Slaves shouldn't delete these files.
16357 (setq slave-files (cdr slave-files))))
16358 (gnus-message 7 "Reading slave newsrcs...done"))))
16362 ;;; Group description.
16365 (defun gnus-read-all-descriptions-files ()
16366 (let ((methods (cons gnus-select-method
16368 (when gnus-message-archive-method
16370 gnus-secondary-select-methods))))
16372 (gnus-read-descriptions-file (car methods))
16373 (setq methods (cdr methods)))
16376 (defun gnus-read-descriptions-file (&optional method)
16377 (let ((method (or method gnus-select-method)))
16378 (when (stringp method)
16379 (setq method (gnus-server-to-method method)))
16380 ;; We create the hashtable whether we manage to read the desc file
16381 ;; to avoid trying to re-read after a failed read.
16382 (or gnus-description-hashtb
16383 (setq gnus-description-hashtb
16384 (gnus-make-hashtable (length gnus-active-hashtb))))
16385 ;; Mark this method's desc file as read.
16386 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16387 gnus-description-hashtb)
16389 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16391 ((not (gnus-check-server method))
16392 (gnus-message 1 "Couldn't open server")
16394 ((not (gnus-request-list-newsgroups method))
16395 (gnus-message 1 "Couldn't read newsgroups descriptions")
16401 (set-buffer nntp-server-buffer)
16402 (goto-char (point-min))
16403 (if (or (search-forward "\n.\n" nil t)
16404 (goto-char (point-max)))
16406 (beginning-of-line)
16407 (narrow-to-region (point-min) (point))))
16408 (goto-char (point-min))
16409 (while (not (eobp))
16410 ;; If we get an error, we set group to 0, which is not a
16414 (let ((obarray gnus-description-hashtb))
16415 ;; Group is set to a symbol interned in this
16417 (read nntp-server-buffer))
16419 (skip-chars-forward " \t")
16420 ;; ... which leads to this line being effectively ignored.
16421 (and (symbolp group)
16422 (set group (buffer-substring
16423 (point) (progn (end-of-line) (point)))))
16424 (forward-line 1))))
16425 (gnus-message 5 "Reading descriptions file...done")
16428 (defun gnus-group-get-description (group)
16429 "Get the description of a group by sending XGTITLE to the server."
16430 (when (gnus-request-group-description group)
16432 (set-buffer nntp-server-buffer)
16433 (goto-char (point-min))
16434 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16435 (match-string 1)))))
16442 (defvar gnus-shutdown-alist nil)
16444 (defun gnus-add-shutdown (function &rest symbols)
16445 "Run FUNCTION whenever one of SYMBOLS is shut down."
16446 (push (cons function symbols) gnus-shutdown-alist))
16448 (defun gnus-shutdown (symbol)
16449 "Shut down everything that waits for SYMBOL."
16450 (let ((alist gnus-shutdown-alist)
16452 (while (setq entry (pop alist))
16453 (when (memq symbol (cdr entry))
16454 (funcall (car entry))))))
16458 ;;; Buffering of read articles.
16461 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16462 (defvar gnus-backlog-articles nil)
16463 (defvar gnus-backlog-hashtb nil)
16465 (defun gnus-backlog-buffer ()
16466 "Return the backlog buffer."
16467 (or (get-buffer gnus-backlog-buffer)
16469 (set-buffer (get-buffer-create gnus-backlog-buffer))
16470 (buffer-disable-undo (current-buffer))
16471 (setq buffer-read-only t)
16472 (gnus-add-current-to-buffer-list)
16473 (get-buffer gnus-backlog-buffer))))
16475 (defun gnus-backlog-setup ()
16476 "Initialize backlog variables."
16477 (unless gnus-backlog-hashtb
16478 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16480 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16482 (defun gnus-backlog-shutdown ()
16483 "Clear all backlog variables and buffers."
16484 (when (get-buffer gnus-backlog-buffer)
16485 (kill-buffer gnus-backlog-buffer))
16486 (setq gnus-backlog-hashtb nil
16487 gnus-backlog-articles nil))
16489 (defun gnus-backlog-enter-article (group number buffer)
16490 (gnus-backlog-setup)
16491 (let ((ident (intern (concat group ":" (int-to-string number))
16492 gnus-backlog-hashtb))
16494 (if (memq ident gnus-backlog-articles)
16495 () ; It's already kept.
16496 ;; Remove the oldest article, if necessary.
16497 (and (numberp gnus-keep-backlog)
16498 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16499 (gnus-backlog-remove-oldest-article))
16500 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16501 ;; Insert the new article.
16503 (set-buffer (gnus-backlog-buffer))
16504 (let (buffer-read-only)
16505 (goto-char (point-max))
16506 (or (bolp) (insert "\n"))
16508 (insert-buffer-substring buffer)
16509 ;; Tag the beginning of the article with the ident.
16510 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16512 (defun gnus-backlog-remove-oldest-article ()
16514 (set-buffer (gnus-backlog-buffer))
16515 (goto-char (point-min))
16516 (if (zerop (buffer-size))
16517 () ; The buffer is empty.
16518 (let ((ident (get-text-property (point) 'gnus-backlog))
16520 ;; Remove the ident from the list of articles.
16522 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16523 ;; Delete the article itself.
16525 (point) (next-single-property-change
16526 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16528 (defun gnus-backlog-request-article (group number buffer)
16529 (when (numberp number)
16530 (gnus-backlog-setup)
16531 (let ((ident (intern (concat group ":" (int-to-string number))
16532 gnus-backlog-hashtb))
16534 (when (memq ident gnus-backlog-articles)
16535 ;; It was in the backlog.
16537 (set-buffer (gnus-backlog-buffer))
16538 (if (not (setq beg (text-property-any
16539 (point-min) (point-max) 'gnus-backlog
16541 ;; It wasn't in the backlog after all.
16543 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16544 ;; Find the end (i. e., the beginning of the next article).
16546 (next-single-property-change
16547 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16548 (let ((buffer-read-only nil))
16550 (insert-buffer-substring gnus-backlog-buffer beg end)
16553 ;; Allow redefinition of Gnus functions.
16555 (gnus-ems-redefine)
16559 ;;; gnus.el ends here