(Fcall_interactively): For `N' and `n',
[emacs.git] / lisp / gnus.el
blob1804f0b0cc1ae4eeb02265e16206f41de63ae3f8
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>
6 ;; Keywords: news
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)
13 ;; any later version.
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.
25 ;;; Commentary:
27 ;;; Code:
29 (eval '(run-hooks 'gnus-load-hook))
31 (require 'mail-utils)
32 (require 'timezone)
33 (require 'nnheader)
34 (require 'nnmail)
35 (require 'backquote)
36 (require 'nnoo)
38 (eval-when-compile (require 'cl))
40 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/")
41 "*Directory variable from which all other Gnus file variables are derived.")
43 ;; Site dependent variables. These variables should be defined in
44 ;; paths.el.
46 (defvar gnus-default-nntp-server nil
47 "Specify a default NNTP server.
48 This variable should be defined in paths.el, and should never be set
49 by the user.
50 If you want to change servers, you should use `gnus-select-method'.
51 See the documentation to that variable.")
53 (defvar gnus-backup-default-subscribed-newsgroups
54 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
55 "Default default new newsgroups the first time Gnus is run.
56 Should be set in paths.el, and shouldn't be touched by the user.")
58 (defvar gnus-local-domain nil
59 "Local domain name without a host name.
60 The DOMAINNAME environment variable is used instead if it is defined.
61 If the `system-name' function returns the full Internet name, there is
62 no need to set this variable.")
64 (defvar gnus-local-organization nil
65 "String with a description of what organization (if any) the user belongs to.
66 The ORGANIZATION environment variable is used instead if it is defined.
67 If this variable contains a function, this function will be called
68 with the current newsgroup name as the argument. The function should
69 return a string.
71 In any case, if the string (either in the variable, in the environment
72 variable, or returned by the function) is a file name, the contents of
73 this file will be used as the organization.")
75 ;; Customization variables
77 ;; Don't touch this variable.
78 (defvar gnus-nntp-service "nntp"
79 "*NNTP service name (\"nntp\" or 119).
80 This is an obsolete variable, which is scarcely used. If you use an
81 nntp server for your newsgroup and want to change the port number
82 used to 899, you would say something along these lines:
84 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
86 (defvar gnus-nntpserver-file "/etc/nntpserver"
87 "*A file with only the name of the nntp server in it.")
89 ;; This function is used to check both the environment variable
90 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
91 ;; an nntp server name default.
92 (defun gnus-getenv-nntpserver ()
93 (or (getenv "NNTPSERVER")
94 (and (file-readable-p gnus-nntpserver-file)
95 (save-excursion
96 (set-buffer (get-buffer-create " *gnus nntp*"))
97 (buffer-disable-undo (current-buffer))
98 (insert-file-contents gnus-nntpserver-file)
99 (let ((name (buffer-string)))
100 (prog1
101 (if (string-match "^[ \t\n]*$" name)
103 name)
104 (kill-buffer (current-buffer))))))))
106 (defvar gnus-select-method
107 (nconc
108 (list 'nntp (or (condition-case ()
109 (gnus-getenv-nntpserver)
110 (error nil))
111 (if (and gnus-default-nntp-server
112 (not (string= gnus-default-nntp-server "")))
113 gnus-default-nntp-server)
114 (system-name)))
115 (if (or (null gnus-nntp-service)
116 (equal gnus-nntp-service "nntp"))
118 (list gnus-nntp-service)))
119 "*Default method for selecting a newsgroup.
120 This variable should be a list, where the first element is how the
121 news is to be fetched, the second is the address.
123 For instance, if you want to get your news via NNTP from
124 \"flab.flab.edu\", you could say:
126 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
128 If you want to use your local spool, say:
130 (setq gnus-select-method (list 'nnspool (system-name)))
132 If you use this variable, you must set `gnus-nntp-server' to nil.
134 There is a lot more to know about select methods and virtual servers -
135 see the manual for details.")
137 (defvar gnus-message-archive-method
138 `(nnfolder
139 "archive"
140 (nnfolder-directory ,(nnheader-concat message-directory "archive"))
141 (nnfolder-active-file
142 ,(nnheader-concat message-directory "archive/active"))
143 (nnfolder-get-new-mail nil)
144 (nnfolder-inhibit-expiry t))
145 "*Method used for archiving messages you've sent.
146 This should be a mail method.
148 It's probably not a very effective to change this variable once you've
149 run Gnus once. After doing that, you must edit this server from the
150 server buffer.")
152 (defvar gnus-message-archive-group nil
153 "*Name of the group in which to save the messages you've written.
154 This can either be a string, a list of strings; or an alist
155 of regexps/functions/forms to be evaluated to return a string (or a list
156 of strings). The functions are called with the name of the current
157 group (or nil) as a parameter.
159 Normally the group names returned by this variable should be
160 unprefixed -- which implictly means \"store on the archive server\".
161 However, you may wish to store the message on some other server. In
162 that case, just return a fully prefixed name of the group --
163 \"nnml+private:mail.misc\", for instance.")
165 (defvar gnus-refer-article-method nil
166 "*Preferred method for fetching an article by Message-ID.
167 If you are reading news from the local spool (with nnspool), fetching
168 articles by Message-ID is painfully slow. By setting this method to an
169 nntp method, you might get acceptable results.
171 The value of this variable must be a valid select method as discussed
172 in the documentation of `gnus-select-method'.")
174 (defvar gnus-secondary-select-methods nil
175 "*A list of secondary methods that will be used for reading news.
176 This is a list where each element is a complete select method (see
177 `gnus-select-method').
179 If, for instance, you want to read your mail with the nnml backend,
180 you could set this variable:
182 (setq gnus-secondary-select-methods '((nnml \"\")))")
184 (defvar gnus-secondary-servers nil
185 "*List of NNTP servers that the user can choose between interactively.
186 To make Gnus query you for a server, you have to give `gnus' a
187 non-numeric prefix - `C-u M-x gnus', in short.")
189 (defvar gnus-nntp-server nil
190 "*The name of the host running the NNTP server.
191 This variable is semi-obsolete. Use the `gnus-select-method'
192 variable instead.")
194 (defvar gnus-startup-file "~/.newsrc"
195 "*Your `.newsrc' file.
196 `.newsrc-SERVER' will be used instead if that exists.")
198 (defvar gnus-init-file "~/.gnus"
199 "*Your Gnus elisp startup file.
200 If a file with the .el or .elc suffixes exist, it will be read
201 instead.")
203 (defvar gnus-group-faq-directory
204 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
205 "/ftp@sunsite.auc.dk:/pub/usenet/"
206 "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/"
207 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
208 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
209 "/ftp@rtfm.mit.edu:/pub/usenet/"
210 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
211 "/ftp@ftp.sunet.se:/pub/usenet/"
212 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
213 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
214 "/ftp@ftp.hk.super.net:/mirror/faqs/")
215 "*Directory where the group FAQs are stored.
216 This will most commonly be on a remote machine, and the file will be
217 fetched by ange-ftp.
219 This variable can also be a list of directories. In that case, the
220 first element in the list will be used by default. The others can
221 be used when being prompted for a site.
223 Note that Gnus uses an aol machine as the default directory. If this
224 feels fundamentally unclean, just think of it as a way to finally get
225 something of value back from them.
227 If the default site is too slow, try one of these:
229 North America: mirrors.aol.com /pub/rtfm/usenet
230 ftp.seas.gwu.edu /pub/rtfm
231 rtfm.mit.edu /pub/usenet
232 Europe: ftp.uni-paderborn.de /pub/FAQ
233 src.doc.ic.ac.uk /usenet/news-FAQS
234 ftp.sunet.se /pub/usenet
235 sunsite.auc.dk /pub/usenet
236 Asia: nctuccca.edu.tw /USENET/FAQ
237 hwarang.postech.ac.kr /pub/usenet
238 ftp.hk.super.net /mirror/faqs")
240 (defvar gnus-group-archive-directory
241 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
242 "*The address of the (ding) archives.")
244 (defvar gnus-group-recent-archive-directory
245 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
246 "*The address of the most recent (ding) articles.")
248 (defvar gnus-default-subscribed-newsgroups nil
249 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
250 It should be a list of strings.
251 If it is `t', Gnus will not do anything special the first time it is
252 started; it'll just use the normal newsgroups subscription methods.")
254 (defvar gnus-use-cross-reference t
255 "*Non-nil means that cross referenced articles will be marked as read.
256 If nil, ignore cross references. If t, mark articles as read in
257 subscribed newsgroups. If neither t nor nil, mark as read in all
258 newsgroups.")
260 (defvar gnus-single-article-buffer t
261 "*If non-nil, display all articles in the same buffer.
262 If nil, each group will get its own article buffer.")
264 (defvar gnus-use-dribble-file t
265 "*Non-nil means that Gnus will use a dribble file to store user updates.
266 If Emacs should crash without saving the .newsrc files, complete
267 information can be restored from the dribble file.")
269 (defvar gnus-dribble-directory nil
270 "*The directory where dribble files will be saved.
271 If this variable is nil, the directory where the .newsrc files are
272 saved will be used.")
274 (defvar gnus-asynchronous nil
275 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
277 (defvar gnus-kill-summary-on-exit t
278 "*If non-nil, kill the summary buffer when you exit from it.
279 If nil, the summary will become a \"*Dead Summary*\" buffer, and
280 it will be killed sometime later.")
282 (defvar gnus-large-newsgroup 200
283 "*The number of articles which indicates a large newsgroup.
284 If the number of articles in a newsgroup is greater than this value,
285 confirmation is required for selecting the newsgroup.")
287 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
288 (defvar gnus-no-groups-message "No news is horrible news"
289 "*Message displayed by Gnus when no groups are available.")
291 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
292 "*Non-nil means that the default name of a file to save articles in is the group name.
293 If it's nil, the directory form of the group name is used instead.
295 If this variable is a list, and the list contains the element
296 `not-score', long file names will not be used for score files; if it
297 contains the element `not-save', long file names will not be used for
298 saving; and if it contains the element `not-kill', long file names
299 will not be used for kill files.
301 Note that the default for this variable varies according to what system
302 type you're using. On `usg-unix-v' and `xenix' this variable defaults
303 to nil while on all other systems it defaults to t.")
305 (defvar gnus-article-save-directory gnus-directory
306 "*Name of the directory articles will be saved in (default \"~/News\").")
308 (defvar gnus-kill-files-directory gnus-directory
309 "*Name of the directory where kill files will be stored (default \"~/News\").")
311 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
312 "*A function to save articles in your favorite format.
313 The function must be interactively callable (in other words, it must
314 be an Emacs command).
316 Gnus provides the following functions:
318 * gnus-summary-save-in-rmail (Rmail format)
319 * gnus-summary-save-in-mail (Unix mail format)
320 * gnus-summary-save-in-folder (MH folder)
321 * gnus-summary-save-in-file (article format).
322 * gnus-summary-save-in-vm (use VM's folder format).")
324 (defvar gnus-prompt-before-saving 'always
325 "*This variable says how much prompting is to be done when saving articles.
326 If it is nil, no prompting will be done, and the articles will be
327 saved to the default files. If this variable is `always', each and
328 every article that is saved will be preceded by a prompt, even when
329 saving large batches of articles. If this variable is neither nil not
330 `always', there the user will be prompted once for a file name for
331 each invocation of the saving commands.")
333 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
334 "*A function generating a file name to save articles in Rmail format.
335 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
337 (defvar gnus-mail-save-name (function gnus-plain-save-name)
338 "*A function generating a file name to save articles in Unix mail format.
339 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
341 (defvar gnus-folder-save-name (function gnus-folder-save-name)
342 "*A function generating a file name to save articles in MH folder.
343 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
345 (defvar gnus-file-save-name (function gnus-numeric-save-name)
346 "*A function generating a file name to save articles in article format.
347 The function is called with NEWSGROUP, HEADERS, and optional
348 LAST-FILE.")
350 (defvar gnus-split-methods
351 '((gnus-article-archive-name))
352 "*Variable used to suggest where articles are to be saved.
353 For instance, if you would like to save articles related to Gnus in
354 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
355 you could set this variable to something like:
357 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
358 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
360 This variable is an alist where the where the key is the match and the
361 value is a list of possible files to save in if the match is non-nil.
363 If the match is a string, it is used as a regexp match on the
364 article. If the match is a symbol, that symbol will be funcalled
365 from the buffer of the article to be saved with the newsgroup as the
366 parameter. If it is a list, it will be evaled in the same buffer.
368 If this form or function returns a string, this string will be used as
369 a possible file name; and if it returns a non-nil list, that list will
370 be used as possible file names.")
372 (defvar gnus-move-split-methods nil
373 "*Variable used to suggest where articles are to be moved to.
374 It uses the same syntax as the `gnus-split-methods' variable.")
376 (defvar gnus-save-score nil
377 "*If non-nil, save group scoring info.")
379 (defvar gnus-use-adaptive-scoring nil
380 "*If non-nil, use some adaptive scoring scheme.")
382 (defvar gnus-use-cache 'passive
383 "*If nil, Gnus will ignore the article cache.
384 If `passive', it will allow entering (and reading) articles
385 explicitly entered into the cache. If anything else, use the
386 cache to the full extent of the law.")
388 (defvar gnus-use-trees nil
389 "*If non-nil, display a thread tree buffer.")
391 (defvar gnus-use-grouplens nil
392 "*If non-nil, use GroupLens ratings.")
394 (defvar gnus-keep-backlog nil
395 "*If non-nil, Gnus will keep read articles for later re-retrieval.
396 If it is a number N, then Gnus will only keep the last N articles
397 read. If it is neither nil nor a number, Gnus will keep all read
398 articles. This is not a good idea.")
400 (defvar gnus-use-nocem nil
401 "*If non-nil, Gnus will read NoCeM cancel messages.")
403 (defvar gnus-use-demon nil
404 "If non-nil, Gnus might use some demons.")
406 (defvar gnus-use-scoring t
407 "*If non-nil, enable scoring.")
409 (defvar gnus-use-picons nil
410 "*If non-nil, display picons.")
412 (defvar gnus-fetch-old-headers nil
413 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
414 If an unread article in the group refers to an older, already read (or
415 just marked as read) article, the old article will not normally be
416 displayed in the Summary buffer. If this variable is non-nil, Gnus
417 will attempt to grab the headers to the old articles, and thereby
418 build complete threads. If it has the value `some', only enough
419 headers to connect otherwise loose threads will be displayed.
420 This variable can also be a number. In that case, no more than that
421 number of old headers will be fetched.
423 The server has to support NOV for any of this to work.")
425 ;see gnus-cus.el
426 ;(defvar gnus-visual t
427 ; "*If non-nil, will do various highlighting.
428 ;If nil, no mouse highlights (or any other highlights) will be
429 ;performed. This might speed up Gnus some when generating large group
430 ;and summary buffers.")
432 (defvar gnus-novice-user t
433 "*Non-nil means that you are a usenet novice.
434 If non-nil, verbose messages may be displayed and confirmations may be
435 required.")
437 (defvar gnus-expert-user nil
438 "*Non-nil means that you will never be asked for confirmation about anything.
439 And that means *anything*.")
441 (defvar gnus-verbose 7
442 "*Integer that says how verbose Gnus should be.
443 The higher the number, the more messages Gnus will flash to say what
444 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
445 display most important messages; and at ten, Gnus will keep on
446 jabbering all the time.")
448 (defvar gnus-keep-same-level nil
449 "*Non-nil means that the next newsgroup after the current will be on the same level.
450 When you type, for instance, `n' after reading the last article in the
451 current newsgroup, you will go to the next newsgroup. If this variable
452 is nil, the next newsgroup will be the next from the group
453 buffer.
454 If this variable is non-nil, Gnus will either put you in the
455 next newsgroup with the same level, or, if no such newsgroup is
456 available, the next newsgroup with the lowest possible level higher
457 than the current level.
458 If this variable is `best', Gnus will make the next newsgroup the one
459 with the best level.")
461 (defvar gnus-summary-make-false-root 'adopt
462 "*nil means that Gnus won't gather loose threads.
463 If the root of a thread has expired or been read in a previous
464 session, the information necessary to build a complete thread has been
465 lost. Instead of having many small sub-threads from this original thread
466 scattered all over the summary buffer, Gnus can gather them.
468 If non-nil, Gnus will try to gather all loose sub-threads from an
469 original thread into one large thread.
471 If this variable is non-nil, it should be one of `none', `adopt',
472 `dummy' or `empty'.
474 If this variable is `none', Gnus will not make a false root, but just
475 present the sub-threads after another.
476 If this variable is `dummy', Gnus will create a dummy root that will
477 have all the sub-threads as children.
478 If this variable is `adopt', Gnus will make one of the \"children\"
479 the parent and mark all the step-children as such.
480 If this variable is `empty', the \"children\" are printed with empty
481 subject fields. (Or rather, they will be printed with a string
482 given by the `gnus-summary-same-subject' variable.)")
484 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
485 "*A regexp to match subjects to be excluded from loose thread gathering.
486 As loose thread gathering is done on subjects only, that means that
487 there can be many false gatherings performed. By rooting out certain
488 common subjects, gathering might become saner.")
490 (defvar gnus-summary-gather-subject-limit nil
491 "*Maximum length of subject comparisons when gathering loose threads.
492 Use nil to compare full subjects. Setting this variable to a low
493 number will help gather threads that have been corrupted by
494 newsreaders chopping off subject lines, but it might also mean that
495 unrelated articles that have subject that happen to begin with the
496 same few characters will be incorrectly gathered.
498 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
499 comparing subjects.")
501 (defvar gnus-simplify-ignored-prefixes nil
502 "*Regexp, matches for which are removed from subject lines when simplifying.")
504 (defvar gnus-build-sparse-threads nil
505 "*If non-nil, fill in the gaps in threads.
506 If `some', only fill in the gaps that are needed to tie loose threads
507 together. If `more', fill in all leaf nodes that Gnus can find. If
508 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
510 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
511 "Function used for gathering loose threads.
512 There are two pre-defined functions: `gnus-gather-threads-by-subject',
513 which only takes Subjects into consideration; and
514 `gnus-gather-threads-by-references', which compared the References
515 headers of the articles to find matches.")
517 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
518 (defvar gnus-summary-same-subject ""
519 "*String indicating that the current article has the same subject as the previous.
520 This variable will only be used if the value of
521 `gnus-summary-make-false-root' is `empty'.")
523 (defvar gnus-summary-goto-unread t
524 "*If non-nil, marking commands will go to the next unread article.
525 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
526 whether it is read or not.")
528 (defvar gnus-group-goto-unread t
529 "*If non-nil, movement commands will go to the next unread and subscribed group.")
531 (defvar gnus-goto-next-group-when-activating t
532 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
534 (defvar gnus-check-new-newsgroups t
535 "*Non-nil means that Gnus will add new newsgroups at startup.
536 If this variable is `ask-server', Gnus will ask the server for new
537 groups since the last time it checked. This means that the killed list
538 is no longer necessary, so you could set `gnus-save-killed-list' to
539 nil.
541 A variant is to have this variable be a list of select methods. Gnus
542 will then use the `ask-server' method on all these select methods to
543 query for new groups from all those servers.
546 (setq gnus-check-new-newsgroups
547 '((nntp \"some.server\") (nntp \"other.server\")))
549 If this variable is nil, then you have to tell Gnus explicitly to
550 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
552 (defvar gnus-check-bogus-newsgroups nil
553 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
554 If this variable is nil, then you have to tell Gnus explicitly to
555 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
557 (defvar gnus-read-active-file t
558 "*Non-nil means that Gnus will read the entire active file at startup.
559 If this variable is nil, Gnus will only know about the groups in your
560 `.newsrc' file.
562 If this variable is `some', Gnus will try to only read the relevant
563 parts of the active file from the server. Not all servers support
564 this, and it might be quite slow with other servers, but this should
565 generally be faster than both the t and nil value.
567 If you set this variable to nil or `some', you probably still want to
568 be told about new newsgroups that arrive. To do that, set
569 `gnus-check-new-newsgroups' to `ask-server'. This may not work
570 properly with all servers.")
572 (defvar gnus-level-subscribed 5
573 "*Groups with levels less than or equal to this variable are subscribed.")
575 (defvar gnus-level-unsubscribed 7
576 "*Groups with levels less than or equal to this variable are unsubscribed.
577 Groups with levels less than `gnus-level-subscribed', which should be
578 less than this variable, are subscribed.")
580 (defvar gnus-level-zombie 8
581 "*Groups with this level are zombie groups.")
583 (defvar gnus-level-killed 9
584 "*Groups with this level are killed.")
586 (defvar gnus-level-default-subscribed 3
587 "*New subscribed groups will be subscribed at this level.")
589 (defvar gnus-level-default-unsubscribed 6
590 "*New unsubscribed groups will be unsubscribed at this level.")
592 (defvar gnus-activate-level (1+ gnus-level-subscribed)
593 "*Groups higher than this level won't be activated on startup.
594 Setting this variable to something log might save lots of time when
595 you have many groups that you aren't interested in.")
597 (defvar gnus-activate-foreign-newsgroups 4
598 "*If nil, Gnus will not check foreign newsgroups at startup.
599 If it is non-nil, it should be a number between one and nine. Foreign
600 newsgroups that have a level lower or equal to this number will be
601 activated on startup. For instance, if you want to active all
602 subscribed newsgroups, but not the rest, you'd set this variable to
603 `gnus-level-subscribed'.
605 If you subscribe to lots of newsgroups from different servers, startup
606 might take a while. By setting this variable to nil, you'll save time,
607 but you won't be told how many unread articles there are in the
608 groups.")
610 (defvar gnus-save-newsrc-file t
611 "*Non-nil means that Gnus will save the `.newsrc' file.
612 Gnus always saves its own startup file, which is called
613 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
614 be readily understood by other newsreaders. If you don't plan on
615 using other newsreaders, set this variable to nil to save some time on
616 exit.")
618 (defvar gnus-save-killed-list t
619 "*If non-nil, save the list of killed groups to the startup file.
620 If you set this variable to nil, you'll save both time (when starting
621 and quitting) and space (both memory and disk), but it will also mean
622 that Gnus has no record of which groups are new and which are old, so
623 the automatic new newsgroups subscription methods become meaningless.
625 You should always set `gnus-check-new-newsgroups' to `ask-server' or
626 nil if you set this variable to nil.")
628 (defvar gnus-interactive-catchup t
629 "*If non-nil, require your confirmation when catching up a group.")
631 (defvar gnus-interactive-exit t
632 "*If non-nil, require your confirmation when exiting Gnus.")
634 (defvar gnus-kill-killed t
635 "*If non-nil, Gnus will apply kill files to already killed articles.
636 If it is nil, Gnus will never apply kill files to articles that have
637 already been through the scoring process, which might very well save lots
638 of time.")
640 (defvar gnus-extract-address-components 'gnus-extract-address-components
641 "*Function for extracting address components from a From header.
642 Two pre-defined function exist: `gnus-extract-address-components',
643 which is the default, quite fast, and too simplistic solution, and
644 `mail-extract-address-components', which works much better, but is
645 slower.")
647 (defvar gnus-summary-default-score 0
648 "*Default article score level.
649 If this variable is nil, scoring will be disabled.")
651 (defvar gnus-summary-zcore-fuzz 0
652 "*Fuzziness factor for the zcore in the summary buffer.
653 Articles with scores closer than this to `gnus-summary-default-score'
654 will not be marked.")
656 (defvar gnus-simplify-subject-fuzzy-regexp nil
657 "*Strings to be removed when doing fuzzy matches.
658 This can either be a regular expression or list of regular expressions
659 that will be removed from subject strings if fuzzy subject
660 simplification is selected.")
662 (defvar gnus-permanently-visible-groups nil
663 "*Regexp to match groups that should always be listed in the group buffer.
664 This means that they will still be listed when there are no unread
665 articles in the groups.")
667 (defvar gnus-list-groups-with-ticked-articles t
668 "*If non-nil, list groups that have only ticked articles.
669 If nil, only list groups that have unread articles.")
671 (defvar gnus-group-default-list-level gnus-level-subscribed
672 "*Default listing level.
673 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
675 (defvar gnus-group-use-permanent-levels nil
676 "*If non-nil, once you set a level, Gnus will use this level.")
678 (defvar gnus-group-list-inactive-groups t
679 "*If non-nil, inactive groups will be listed.")
681 (defvar gnus-show-mime nil
682 "*If non-nil, do mime processing of articles.
683 The articles will simply be fed to the function given by
684 `gnus-show-mime-method'.")
686 (defvar gnus-strict-mime t
687 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
689 (defvar gnus-show-mime-method 'metamail-buffer
690 "*Function to process a MIME message.
691 The function is called from the article buffer.")
693 (defvar gnus-decode-encoded-word-method (lambda ())
694 "*Function to decode a MIME encoded-words.
695 The function is called from the article buffer.")
697 (defvar gnus-show-threads t
698 "*If non-nil, display threads in summary mode.")
700 (defvar gnus-thread-hide-subtree nil
701 "*If non-nil, hide all threads initially.
702 If threads are hidden, you have to run the command
703 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
704 to expose hidden threads.")
706 (defvar gnus-thread-hide-killed t
707 "*If non-nil, hide killed threads automatically.")
709 (defvar gnus-thread-ignore-subject nil
710 "*If non-nil, ignore subjects and do all threading based on the Reference header.
711 If nil, which is the default, articles that have different subjects
712 from their parents will start separate threads.")
714 (defvar gnus-thread-operation-ignore-subject t
715 "*If non-nil, subjects will be ignored when doing thread commands.
716 This affects commands like `gnus-summary-kill-thread' and
717 `gnus-summary-lower-thread'.
719 If this variable is nil, articles in the same thread with different
720 subjects will not be included in the operation in question. If this
721 variable is `fuzzy', only articles that have subjects that are fuzzily
722 equal will be included.")
724 (defvar gnus-thread-indent-level 4
725 "*Number that says how much each sub-thread should be indented.")
727 (defvar gnus-ignored-newsgroups
728 (purecopy (mapconcat 'identity
729 '("^to\\." ; not "real" groups
730 "^[0-9. \t]+ " ; all digits in name
731 "[][\"#'()]" ; bogus characters
733 "\\|"))
734 "*A regexp to match uninteresting newsgroups in the active file.
735 Any lines in the active file matching this regular expression are
736 removed from the newsgroup list before anything else is done to it,
737 thus making them effectively non-existent.")
739 (defvar gnus-ignored-headers
740 "^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:"
741 "*All headers that match this regexp will be hidden.
742 This variable can also be a list of regexps of headers to be ignored.
743 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
745 (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-"
746 "*All headers that do not match this regexp will be hidden.
747 This variable can also be a list of regexp of headers to remain visible.
748 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
750 (defvar gnus-sorted-header-list
751 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
752 "^Cc:" "^Date:" "^Organization:")
753 "*This variable is a list of regular expressions.
754 If it is non-nil, headers that match the regular expressions will
755 be placed first in the article buffer in the sequence specified by
756 this list.")
758 (defvar gnus-boring-article-headers
759 '(empty followup-to reply-to)
760 "*Headers that are only to be displayed if they have interesting data.
761 Possible values in this list are `empty', `newsgroups', `followup-to',
762 `reply-to', and `date'.")
764 (defvar gnus-show-all-headers nil
765 "*If non-nil, don't hide any headers.")
767 (defvar gnus-save-all-headers t
768 "*If non-nil, don't remove any headers before saving.")
770 (defvar gnus-saved-headers gnus-visible-headers
771 "*Headers to keep if `gnus-save-all-headers' is nil.
772 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
773 If that variable is nil, however, all headers that match this regexp
774 will be kept while the rest will be deleted before saving.")
776 (defvar gnus-inhibit-startup-message nil
777 "*If non-nil, the startup message will not be displayed.")
779 (defvar gnus-signature-separator "^-- *$"
780 "Regexp matching signature separator.")
782 (defvar gnus-signature-limit nil
783 "Provide a limit to what is considered a signature.
784 If it is a number, no signature may not be longer (in characters) than
785 that number. If it is a function, the function will be called without
786 any parameters, and if it returns nil, there is no signature in the
787 buffer. If it is a string, it will be used as a regexp. If it
788 matches, the text in question is not a signature.")
790 (defvar gnus-auto-extend-newsgroup t
791 "*If non-nil, extend newsgroup forward and backward when requested.")
793 (defvar gnus-auto-select-first t
794 "*If nil, don't select the first unread article when entering a group.
795 If this variable is `best', select the highest-scored unread article
796 in the group. If neither nil nor `best', select the first unread
797 article.
799 If you want to prevent automatic selection of the first unread article
800 in some newsgroups, set the variable to nil in
801 `gnus-select-group-hook'.")
803 (defvar gnus-auto-select-next t
804 "*If non-nil, offer to go to the next group from the end of the previous.
805 If the value is t and the next newsgroup is empty, Gnus will exit
806 summary mode and go back to group mode. If the value is neither nil
807 nor t, Gnus will select the following unread newsgroup. In
808 particular, if the value is the symbol `quietly', the next unread
809 newsgroup will be selected without any confirmation, and if it is
810 `almost-quietly', the next group will be selected without any
811 confirmation if you are located on the last article in the group.
812 Finally, if this variable is `slightly-quietly', the `Z n' command
813 will go to the next group without confirmation.")
815 (defvar gnus-auto-select-same nil
816 "*If non-nil, select the next article with the same subject.")
818 (defvar gnus-summary-check-current nil
819 "*If non-nil, consider the current article when moving.
820 The \"unread\" movement commands will stay on the same line if the
821 current article is unread.")
823 (defvar gnus-auto-center-summary t
824 "*If non-nil, always center the current summary buffer.
825 In particular, if `vertical' do only vertical recentering. If non-nil
826 and non-`vertical', do both horizontal and vertical recentering.")
828 (defvar gnus-break-pages t
829 "*If non-nil, do page breaking on articles.
830 The page delimiter is specified by the `gnus-page-delimiter'
831 variable.")
833 (defvar gnus-page-delimiter "^\^L"
834 "*Regexp describing what to use as article page delimiters.
835 The default value is \"^\^L\", which is a form linefeed at the
836 beginning of a line.")
838 (defvar gnus-use-full-window t
839 "*If non-nil, use the entire Emacs screen.")
841 (defvar gnus-window-configuration nil
842 "Obsolete variable. See `gnus-buffer-configuration'.")
844 (defvar gnus-window-min-width 2
845 "*Minimum width of Gnus buffers.")
847 (defvar gnus-window-min-height 1
848 "*Minimum height of Gnus buffers.")
850 (defvar gnus-buffer-configuration
851 '((group
852 (vertical 1.0
853 (group 1.0 point)
854 (if gnus-carpal '(group-carpal 4))))
855 (summary
856 (vertical 1.0
857 (summary 1.0 point)
858 (if gnus-carpal '(summary-carpal 4))))
859 (article
860 (cond
861 (gnus-use-picons
862 '(frame 1.0
863 (vertical 1.0
864 (summary 0.25 point)
865 (if gnus-carpal '(summary-carpal 4))
866 (article 1.0))
867 (vertical ((height . 5) (width . 15)
868 (user-position . t)
869 (left . -1) (top . 1))
870 (picons 1.0))))
871 (gnus-use-trees
872 '(vertical 1.0
873 (summary 0.25 point)
874 (tree 0.25)
875 (article 1.0)))
877 '(vertical 1.0
878 (summary 0.25 point)
879 (if gnus-carpal '(summary-carpal 4))
880 (article 1.0)))))
881 (server
882 (vertical 1.0
883 (server 1.0 point)
884 (if gnus-carpal '(server-carpal 2))))
885 (browse
886 (vertical 1.0
887 (browse 1.0 point)
888 (if gnus-carpal '(browse-carpal 2))))
889 (message
890 (vertical 1.0
891 (message 1.0 point)))
892 (pick
893 (vertical 1.0
894 (article 1.0 point)))
895 (info
896 (vertical 1.0
897 (info 1.0 point)))
898 (summary-faq
899 (vertical 1.0
900 (summary 0.25)
901 (faq 1.0 point)))
902 (edit-group
903 (vertical 1.0
904 (group 0.5)
905 (edit-group 1.0 point)))
906 (edit-server
907 (vertical 1.0
908 (server 0.5)
909 (edit-server 1.0 point)))
910 (edit-score
911 (vertical 1.0
912 (summary 0.25)
913 (edit-score 1.0 point)))
914 (post
915 (vertical 1.0
916 (post 1.0 point)))
917 (reply
918 (vertical 1.0
919 (article-copy 0.5)
920 (message 1.0 point)))
921 (forward
922 (vertical 1.0
923 (message 1.0 point)))
924 (reply-yank
925 (vertical 1.0
926 (message 1.0 point)))
927 (mail-bounce
928 (vertical 1.0
929 (article 0.5)
930 (message 1.0 point)))
931 (draft
932 (vertical 1.0
933 (draft 1.0 point)))
934 (pipe
935 (vertical 1.0
936 (summary 0.25 point)
937 (if gnus-carpal '(summary-carpal 4))
938 ("*Shell Command Output*" 1.0)))
939 (bug
940 (vertical 1.0
941 ("*Gnus Help Bug*" 0.5)
942 ("*Gnus Bug*" 1.0 point)))
943 (compose-bounce
944 (vertical 1.0
945 (article 0.5)
946 (message 1.0 point))))
947 "Window configuration for all possible Gnus buffers.
948 This variable is a list of lists. Each of these lists has a NAME and
949 a RULE. The NAMEs are commonsense names like `group', which names a
950 rule used when displaying the group buffer; `summary', which names a
951 rule for what happens when you enter a group and do not display an
952 article buffer; and so on. See the value of this variable for a
953 complete list of NAMEs.
955 Each RULE is a list of vectors. The first element in this vector is
956 the name of the buffer to be displayed; the second element is the
957 percentage of the screen this buffer is to occupy (a number in the
958 0.0-0.99 range); the optional third element is `point', which should
959 be present to denote which buffer point is to go to after making this
960 buffer configuration.")
962 (defvar gnus-window-to-buffer
963 '((group . gnus-group-buffer)
964 (summary . gnus-summary-buffer)
965 (article . gnus-article-buffer)
966 (server . gnus-server-buffer)
967 (browse . "*Gnus Browse Server*")
968 (edit-group . gnus-group-edit-buffer)
969 (edit-server . gnus-server-edit-buffer)
970 (group-carpal . gnus-carpal-group-buffer)
971 (summary-carpal . gnus-carpal-summary-buffer)
972 (server-carpal . gnus-carpal-server-buffer)
973 (browse-carpal . gnus-carpal-browse-buffer)
974 (edit-score . gnus-score-edit-buffer)
975 (message . gnus-message-buffer)
976 (mail . gnus-message-buffer)
977 (post-news . gnus-message-buffer)
978 (faq . gnus-faq-buffer)
979 (picons . "*Picons*")
980 (tree . gnus-tree-buffer)
981 (info . gnus-info-buffer)
982 (article-copy . gnus-article-copy)
983 (draft . gnus-draft-buffer))
984 "Mapping from short symbols to buffer names or buffer variables.")
986 (defvar gnus-carpal nil
987 "*If non-nil, display clickable icons.")
989 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
990 "*Function called with a group name when new group is detected.
991 A few pre-made functions are supplied: `gnus-subscribe-randomly'
992 inserts new groups at the beginning of the list of groups;
993 `gnus-subscribe-alphabetically' inserts new groups in strict
994 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
995 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
996 for your decision; `gnus-subscribe-killed' kills all new groups;
997 `gnus-subscribe-zombies' will make all new groups into zombies.")
999 ;; Suggested by a bug report by Hallvard B Furuseth.
1000 ;; <h.b.furuseth@usit.uio.no>.
1001 (defvar gnus-subscribe-options-newsgroup-method
1002 (function gnus-subscribe-alphabetically)
1003 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
1004 If, for instance, you want to subscribe to all newsgroups in the
1005 \"no\" and \"alt\" hierarchies, you'd put the following in your
1006 .newsrc file:
1008 options -n no.all alt.all
1010 Gnus will the subscribe all new newsgroups in these hierarchies with
1011 the subscription method in this variable.")
1013 (defvar gnus-subscribe-hierarchical-interactive nil
1014 "*If non-nil, Gnus will offer to subscribe hierarchically.
1015 When a new hierarchy appears, Gnus will ask the user:
1017 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1019 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1020 subscribe to all newsgroups in the hierarchy and `s' will skip this
1021 hierarchy in its entirety.")
1023 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1024 "*Function used for sorting the group buffer.
1025 This function will be called with group info entries as the arguments
1026 for the groups to be sorted. Pre-made functions include
1027 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1028 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1029 `gnus-group-sort-by-rank'.
1031 This variable can also be a list of sorting functions. In that case,
1032 the most significant sort function should be the last function in the
1033 list.")
1035 ;; Mark variables suggested by Thomas Michanek
1036 ;; <Thomas.Michanek@telelogic.se>.
1037 (defvar gnus-unread-mark ?
1038 "*Mark used for unread articles.")
1039 (defvar gnus-ticked-mark ?!
1040 "*Mark used for ticked articles.")
1041 (defvar gnus-dormant-mark ??
1042 "*Mark used for dormant articles.")
1043 (defvar gnus-del-mark ?r
1044 "*Mark used for del'd articles.")
1045 (defvar gnus-read-mark ?R
1046 "*Mark used for read articles.")
1047 (defvar gnus-expirable-mark ?E
1048 "*Mark used for expirable articles.")
1049 (defvar gnus-killed-mark ?K
1050 "*Mark used for killed articles.")
1051 (defvar gnus-souped-mark ?F
1052 "*Mark used for killed articles.")
1053 (defvar gnus-kill-file-mark ?X
1054 "*Mark used for articles killed by kill files.")
1055 (defvar gnus-low-score-mark ?Y
1056 "*Mark used for articles with a low score.")
1057 (defvar gnus-catchup-mark ?C
1058 "*Mark used for articles that are caught up.")
1059 (defvar gnus-replied-mark ?A
1060 "*Mark used for articles that have been replied to.")
1061 (defvar gnus-cached-mark ?*
1062 "*Mark used for articles that are in the cache.")
1063 (defvar gnus-saved-mark ?S
1064 "*Mark used for articles that have been saved to.")
1065 (defvar gnus-process-mark ?#
1066 "*Process mark.")
1067 (defvar gnus-ancient-mark ?O
1068 "*Mark used for ancient articles.")
1069 (defvar gnus-sparse-mark ?Q
1070 "*Mark used for sparsely reffed articles.")
1071 (defvar gnus-canceled-mark ?G
1072 "*Mark used for canceled articles.")
1073 (defvar gnus-score-over-mark ?+
1074 "*Score mark used for articles with high scores.")
1075 (defvar gnus-score-below-mark ?-
1076 "*Score mark used for articles with low scores.")
1077 (defvar gnus-empty-thread-mark ?
1078 "*There is no thread under the article.")
1079 (defvar gnus-not-empty-thread-mark ?=
1080 "*There is a thread under the article.")
1082 (defvar gnus-view-pseudo-asynchronously nil
1083 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1085 (defvar gnus-view-pseudos nil
1086 "*If `automatic', pseudo-articles will be viewed automatically.
1087 If `not-confirm', pseudos will be viewed automatically, and the user
1088 will not be asked to confirm the command.")
1090 (defvar gnus-view-pseudos-separately t
1091 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1092 If nil, all files that use the same viewing command will be given as a
1093 list of parameters to that command.")
1095 (defvar gnus-insert-pseudo-articles t
1096 "*If non-nil, insert pseudo-articles when decoding articles.")
1098 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1099 "*Format of group lines.
1100 It works along the same lines as a normal formatting string,
1101 with some simple extensions.
1103 %M Only marked articles (character, \"*\" or \" \")
1104 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1105 %L Level of subscribedness (integer)
1106 %N Number of unread articles (integer)
1107 %I Number of dormant articles (integer)
1108 %i Number of ticked and dormant (integer)
1109 %T Number of ticked articles (integer)
1110 %R Number of read articles (integer)
1111 %t Total number of articles (integer)
1112 %y Number of unread, unticked articles (integer)
1113 %G Group name (string)
1114 %g Qualified group name (string)
1115 %D Group description (string)
1116 %s Select method (string)
1117 %o Moderated group (char, \"m\")
1118 %p Process mark (char)
1119 %O Moderated group (string, \"(m)\" or \"\")
1120 %P Topic indentation (string)
1121 %l Whether there are GroupLens predictions for this group (string)
1122 %n Select from where (string)
1123 %z A string that look like `<%s:%n>' if a foreign select method is used
1124 %u User defined specifier. The next character in the format string should
1125 be a letter. Gnus will call the function gnus-user-format-function-X,
1126 where X is the letter following %u. The function will be passed the
1127 current header as argument. The function should return a string, which
1128 will be inserted into the buffer just like information from any other
1129 group specifier.
1131 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1132 the mouse point move inside the area. There can only be one such area.
1134 Note that this format specification is not always respected. For
1135 reasons of efficiency, when listing killed groups, this specification
1136 is ignored altogether. If the spec is changed considerably, your
1137 output may end up looking strange when listing both alive and killed
1138 groups.
1140 If you use %o or %O, reading the active file will be slower and quite
1141 a bit of extra memory will be used. %D will also worsen performance.
1142 Also note that if you change the format specification to include any
1143 of these specs, you must probably re-start Gnus to see them go into
1144 effect.")
1146 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1147 "*The format specification of the lines in the summary buffer.
1149 It works along the same lines as a normal formatting string,
1150 with some simple extensions.
1152 %N Article number, left padded with spaces (string)
1153 %S Subject (string)
1154 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1155 %n Name of the poster (string)
1156 %a Extracted name of the poster (string)
1157 %A Extracted address of the poster (string)
1158 %F Contents of the From: header (string)
1159 %x Contents of the Xref: header (string)
1160 %D Date of the article (string)
1161 %d Date of the article (string) in DD-MMM format
1162 %M Message-id of the article (string)
1163 %r References of the article (string)
1164 %c Number of characters in the article (integer)
1165 %L Number of lines in the article (integer)
1166 %I Indentation based on thread level (a string of spaces)
1167 %T A string with two possible values: 80 spaces if the article
1168 is on thread level two or larger and 0 spaces on level one
1169 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1170 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1171 %[ Opening bracket (character, \"[\" or \"<\")
1172 %] Closing bracket (character, \"]\" or \">\")
1173 %> Spaces of length thread-level (string)
1174 %< Spaces of length (- 20 thread-level) (string)
1175 %i Article score (number)
1176 %z Article zcore (character)
1177 %t Number of articles under the current thread (number).
1178 %e Whether the thread is empty or not (character).
1179 %l GroupLens score (string).
1180 %u User defined specifier. The next character in the format string should
1181 be a letter. Gnus will call the function gnus-user-format-function-X,
1182 where X is the letter following %u. The function will be passed the
1183 current header as argument. The function should return a string, which
1184 will be inserted into the summary just like information from any other
1185 summary specifier.
1187 Text between %( and %) will be highlighted with `gnus-mouse-face'
1188 when the mouse point is placed inside the area. There can only be one
1189 such area.
1191 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1192 with care. For reasons of efficiency, Gnus will compute what column
1193 these characters will end up in, and \"hard-code\" that. This means that
1194 it is illegal to have these specs after a variable-length spec. Well,
1195 you might not be arrested, but your summary buffer will look strange,
1196 which is bad enough.
1198 The smart choice is to have these specs as for to the left as
1199 possible.
1201 This restriction may disappear in later versions of Gnus.")
1203 (defvar gnus-summary-dummy-line-format
1204 "* %(: :%) %S\n"
1205 "*The format specification for the dummy roots in the summary buffer.
1206 It works along the same lines as a normal formatting string,
1207 with some simple extensions.
1209 %S The subject")
1211 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1212 "*The format specification for the summary mode line.
1213 It works along the same lines as a normal formatting string,
1214 with some simple extensions:
1216 %G Group name
1217 %p Unprefixed group name
1218 %A Current article number
1219 %V Gnus version
1220 %U Number of unread articles in the group
1221 %e Number of unselected articles in the group
1222 %Z A string with unread/unselected article counts
1223 %g Shortish group name
1224 %S Subject of the current article
1225 %u User-defined spec
1226 %s Current score file name
1227 %d Number of dormant articles
1228 %r Number of articles that have been marked as read in this session
1229 %E Number of articles expunged by the score files")
1231 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1232 "*The format specification for the article mode line.
1233 See `gnus-summary-mode-line-format' for a closer description.")
1235 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1236 "*The format specification for the group mode line.
1237 It works along the same lines as a normal formatting string,
1238 with some simple extensions:
1240 %S The native news server.
1241 %M The native select method.
1242 %: \":\" if %S isn't \"\".")
1244 (defvar gnus-valid-select-methods
1245 '(("nntp" post address prompt-address)
1246 ("nnspool" post address)
1247 ("nnvirtual" post-mail virtual prompt-address)
1248 ("nnmbox" mail respool address)
1249 ("nnml" mail respool address)
1250 ("nnmh" mail respool address)
1251 ("nndir" post-mail prompt-address address)
1252 ("nneething" none address prompt-address)
1253 ("nndoc" none address prompt-address)
1254 ("nnbabyl" mail address respool)
1255 ("nnkiboze" post virtual)
1256 ("nnsoup" post-mail address)
1257 ("nndraft" post-mail)
1258 ("nnfolder" mail respool address))
1259 "An alist of valid select methods.
1260 The first element of each list lists should be a string with the name
1261 of the select method. The other elements may be be the category of
1262 this method (ie. `post', `mail', `none' or whatever) or other
1263 properties that this method has (like being respoolable).
1264 If you implement a new select method, all you should have to change is
1265 this variable. I think.")
1267 (defvar gnus-updated-mode-lines '(group article summary tree)
1268 "*List of buffers that should update their mode lines.
1269 The list may contain the symbols `group', `article' and `summary'. If
1270 the corresponding symbol is present, Gnus will keep that mode line
1271 updated with information that may be pertinent.
1272 If this variable is nil, screen refresh may be quicker.")
1274 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1275 (defvar gnus-mode-non-string-length nil
1276 "*Max length of mode-line non-string contents.
1277 If this is nil, Gnus will take space as is needed, leaving the rest
1278 of the modeline intact.")
1280 ;see gnus-cus.el
1281 ;(defvar gnus-mouse-face 'highlight
1282 ; "*Face used for mouse highlighting in Gnus.
1283 ;No mouse highlights will be done if `gnus-visual' is nil.")
1285 (defvar gnus-summary-mark-below 0
1286 "*Mark all articles with a score below this variable as read.
1287 This variable is local to each summary buffer and usually set by the
1288 score file.")
1290 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1291 "*List of functions used for sorting articles in the summary buffer.
1292 This variable is only used when not using a threaded display.")
1294 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1295 "*List of functions used for sorting threads in the summary buffer.
1296 By default, threads are sorted by article number.
1298 Each function takes two threads and return non-nil if the first thread
1299 should be sorted before the other. If you use more than one function,
1300 the primary sort function should be the last. You should probably
1301 always include `gnus-thread-sort-by-number' in the list of sorting
1302 functions -- preferably first.
1304 Ready-mady functions include `gnus-thread-sort-by-number',
1305 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1306 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1307 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1309 (defvar gnus-thread-score-function '+
1310 "*Function used for calculating the total score of a thread.
1312 The function is called with the scores of the article and each
1313 subthread and should then return the score of the thread.
1315 Some functions you can use are `+', `max', or `min'.")
1317 (defvar gnus-summary-expunge-below nil
1318 "All articles that have a score less than this variable will be expunged.")
1320 (defvar gnus-thread-expunge-below nil
1321 "All threads that have a total score less than this variable will be expunged.
1322 See `gnus-thread-score-function' for en explanation of what a
1323 \"thread score\" is.")
1325 (defvar gnus-auto-subscribed-groups
1326 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1327 "*All new groups that match this regexp will be subscribed automatically.
1328 Note that this variable only deals with new groups. It has no effect
1329 whatsoever on old groups.
1331 New groups that match this regexp will not be handled by
1332 `gnus-subscribe-newsgroup-method'. Instead, they will
1333 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1335 (defvar gnus-options-subscribe nil
1336 "*All new groups matching this regexp will be subscribed unconditionally.
1337 Note that this variable deals only with new newsgroups. This variable
1338 does not affect old newsgroups.
1340 New groups that match this regexp will not be handled by
1341 `gnus-subscribe-newsgroup-method'. Instead, they will
1342 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1344 (defvar gnus-options-not-subscribe nil
1345 "*All new groups matching this regexp will be ignored.
1346 Note that this variable deals only with new newsgroups. This variable
1347 does not affect old (already subscribed) newsgroups.")
1349 (defvar gnus-auto-expirable-newsgroups nil
1350 "*Groups in which to automatically mark read articles as expirable.
1351 If non-nil, this should be a regexp that should match all groups in
1352 which to perform auto-expiry. This only makes sense for mail groups.")
1354 (defvar gnus-total-expirable-newsgroups nil
1355 "*Groups in which to perform expiry of all read articles.
1356 Use with extreme caution. All groups that match this regexp will be
1357 expiring - which means that all read articles will be deleted after
1358 (say) one week. (This only goes for mail groups and the like, of
1359 course.)")
1361 (defvar gnus-group-uncollapsed-levels 1
1362 "Number of group name elements to leave alone when making a short group name.")
1364 (defvar gnus-hidden-properties '(invisible t intangible t)
1365 "Property list to use for hiding text.")
1367 (defvar gnus-modtime-botch nil
1368 "*Non-nil means .newsrc should be deleted prior to save.
1369 Its use is due to the bogus appearance that .newsrc was modified on
1370 disc.")
1372 ;; Hooks.
1374 (defvar gnus-group-mode-hook nil
1375 "*A hook for Gnus group mode.")
1377 (defvar gnus-summary-mode-hook nil
1378 "*A hook for Gnus summary mode.
1379 This hook is run before any variables are set in the summary buffer.")
1381 (defvar gnus-article-mode-hook nil
1382 "*A hook for Gnus article mode.")
1384 (defvar gnus-summary-prepare-exit-hook nil
1385 "*A hook called when preparing to exit from the summary buffer.
1386 It calls `gnus-summary-expire-articles' by default.")
1387 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1389 (defvar gnus-summary-exit-hook nil
1390 "*A hook called on exit from the summary buffer.")
1392 (defvar gnus-group-catchup-group-hook nil
1393 "*A hook run when catching up a group from the group buffer.")
1395 (defvar gnus-group-update-group-hook nil
1396 "*A hook called when updating group lines.")
1398 (defvar gnus-open-server-hook nil
1399 "*A hook called just before opening connection to the news server.")
1401 (defvar gnus-load-hook nil
1402 "*A hook run while Gnus is loaded.")
1404 (defvar gnus-startup-hook nil
1405 "*A hook called at startup.
1406 This hook is called after Gnus is connected to the NNTP server.")
1408 (defvar gnus-get-new-news-hook nil
1409 "*A hook run just before Gnus checks for new news.")
1411 (defvar gnus-after-getting-new-news-hook nil
1412 "*A hook run after Gnus checks for new news.")
1414 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1415 "*A function that is called to generate the group buffer.
1416 The function is called with three arguments: The first is a number;
1417 all group with a level less or equal to that number should be listed,
1418 if the second is non-nil, empty groups should also be displayed. If
1419 the third is non-nil, it is a number. No groups with a level lower
1420 than this number should be displayed.
1422 The only current function implemented is `gnus-group-prepare-flat'.")
1424 (defvar gnus-group-prepare-hook nil
1425 "*A hook called after the group buffer has been generated.
1426 If you want to modify the group buffer, you can use this hook.")
1428 (defvar gnus-summary-prepare-hook nil
1429 "*A hook called after the summary buffer has been generated.
1430 If you want to modify the summary buffer, you can use this hook.")
1432 (defvar gnus-summary-generate-hook nil
1433 "*A hook run just before generating the summary buffer.
1434 This hook is commonly used to customize threading variables and the
1435 like.")
1437 (defvar gnus-article-prepare-hook nil
1438 "*A hook called after an article has been prepared in the article buffer.
1439 If you want to run a special decoding program like nkf, use this hook.")
1441 ;(defvar gnus-article-display-hook nil
1442 ; "*A hook called after the article is displayed in the article buffer.
1443 ;The hook is designed to change the contents of the article
1444 ;buffer. Typical functions that this hook may contain are
1445 ;`gnus-article-hide-headers' (hide selected headers),
1446 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1447 ;`gnus-article-hide-signature' (hide signature) and
1448 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1449 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1450 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1451 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1453 (defvar gnus-article-x-face-too-ugly nil
1454 "Regexp matching posters whose face shouldn't be shown automatically.")
1456 (defvar gnus-select-group-hook nil
1457 "*A hook called when a newsgroup is selected.
1459 If you'd like to simplify subjects like the
1460 `gnus-summary-next-same-subject' command does, you can use the
1461 following hook:
1463 (setq gnus-select-group-hook
1464 (list
1465 (lambda ()
1466 (mapcar (lambda (header)
1467 (mail-header-set-subject
1468 header
1469 (gnus-simplify-subject
1470 (mail-header-subject header) 're-only)))
1471 gnus-newsgroup-headers))))")
1473 (defvar gnus-select-article-hook nil
1474 "*A hook called when an article is selected.")
1476 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1477 "*A hook called to apply kill files to a group.
1478 This hook is intended to apply a kill file to the selected newsgroup.
1479 The function `gnus-apply-kill-file' is called by default.
1481 Since a general kill file is too heavy to use only for a few
1482 newsgroups, I recommend you to use a lighter hook function. For
1483 example, if you'd like to apply a kill file to articles which contains
1484 a string `rmgroup' in subject in newsgroup `control', you can use the
1485 following hook:
1487 (setq gnus-apply-kill-hook
1488 (list
1489 (lambda ()
1490 (cond ((string-match \"control\" gnus-newsgroup-name)
1491 (gnus-kill \"Subject\" \"rmgroup\")
1492 (gnus-expunge \"X\"))))))")
1494 (defvar gnus-visual-mark-article-hook
1495 (list 'gnus-highlight-selected-summary)
1496 "*Hook run after selecting an article in the summary buffer.
1497 It is meant to be used for highlighting the article in some way. It
1498 is not run if `gnus-visual' is nil.")
1500 (defvar gnus-parse-headers-hook nil
1501 "*A hook called before parsing the headers.")
1502 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1504 (defvar gnus-exit-group-hook nil
1505 "*A hook called when exiting (not quitting) summary mode.")
1507 (defvar gnus-suspend-gnus-hook nil
1508 "*A hook called when suspending (not exiting) Gnus.")
1510 (defvar gnus-exit-gnus-hook nil
1511 "*A hook called when exiting Gnus.")
1513 (defvar gnus-after-exiting-gnus-hook nil
1514 "*A hook called after exiting Gnus.")
1516 (defvar gnus-save-newsrc-hook nil
1517 "*A hook called before saving any of the newsrc files.")
1519 (defvar gnus-save-quick-newsrc-hook nil
1520 "*A hook called just before saving the quick newsrc file.
1521 Can be used to turn version control on or off.")
1523 (defvar gnus-save-standard-newsrc-hook nil
1524 "*A hook called just before saving the standard newsrc file.
1525 Can be used to turn version control on or off.")
1527 (defvar gnus-summary-update-hook
1528 (list 'gnus-summary-highlight-line)
1529 "*A hook called when a summary line is changed.
1530 The hook will not be called if `gnus-visual' is nil.
1532 The default function `gnus-summary-highlight-line' will
1533 highlight the line according to the `gnus-summary-highlight'
1534 variable.")
1536 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1537 "*A hook called when a group line is changed.
1538 The hook will not be called if `gnus-visual' is nil.
1540 The default function `gnus-group-highlight-line' will
1541 highlight the line according to the `gnus-group-highlight'
1542 variable.")
1544 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1545 "*A hook called when an article is selected for the first time.
1546 The hook is intended to mark an article as read (or unread)
1547 automatically when it is selected.")
1549 (defvar gnus-group-change-level-function nil
1550 "Function run when a group level is changed.
1551 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1553 ;; Remove any hilit infestation.
1554 (add-hook 'gnus-startup-hook
1555 (lambda ()
1556 (remove-hook 'gnus-summary-prepare-hook
1557 'hilit-rehighlight-buffer-quietly)
1558 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1559 (setq gnus-mark-article-hook
1560 '(gnus-summary-mark-read-and-unread-as-read))
1561 (remove-hook 'gnus-article-prepare-hook
1562 'hilit-rehighlight-buffer-quietly)))
1565 ;; Internal variables
1567 (defvar gnus-tree-buffer "*Tree*"
1568 "Buffer where Gnus thread trees are displayed.")
1570 ;; Dummy variable.
1571 (defvar gnus-use-generic-from nil)
1573 (defvar gnus-thread-indent-array nil)
1574 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1576 (defvar gnus-newsrc-file-version nil)
1578 (defvar gnus-method-history nil)
1579 ;; Variable holding the user answers to all method prompts.
1581 (defvar gnus-group-history nil)
1582 ;; Variable holding the user answers to all group prompts.
1584 (defvar gnus-server-alist nil
1585 "List of available servers.")
1587 (defvar gnus-group-indentation-function nil)
1589 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1591 (defvar gnus-goto-missing-group-function nil)
1593 (defvar gnus-override-subscribe-method nil)
1595 (defvar gnus-group-goto-next-group-function nil
1596 "Function to override finding the next group after listing groups.")
1598 (defconst gnus-article-mark-lists
1599 '((marked . tick) (replied . reply)
1600 (expirable . expire) (killed . killed)
1601 (bookmarks . bookmark) (dormant . dormant)
1602 (scored . score) (saved . save)
1603 (cached . cache)
1606 ;; Avoid highlighting in kill files.
1607 (defvar gnus-summary-inhibit-highlight nil)
1608 (defvar gnus-newsgroup-selected-overlay nil)
1610 (defvar gnus-inhibit-hiding nil)
1611 (defvar gnus-group-indentation "")
1612 (defvar gnus-inhibit-limiting nil)
1613 (defvar gnus-created-frames nil)
1615 (defvar gnus-article-mode-map nil)
1616 (defvar gnus-dribble-buffer nil)
1617 (defvar gnus-headers-retrieved-by nil)
1618 (defvar gnus-article-reply nil)
1619 (defvar gnus-override-method nil)
1620 (defvar gnus-article-check-size nil)
1622 (defvar gnus-current-score-file nil)
1623 (defvar gnus-newsgroup-adaptive-score-file nil)
1624 (defvar gnus-scores-exclude-files nil)
1626 (defvar gnus-opened-servers nil)
1628 (defvar gnus-current-move-group nil)
1629 (defvar gnus-current-copy-group nil)
1630 (defvar gnus-current-crosspost-group nil)
1632 (defvar gnus-newsgroup-dependencies nil)
1633 (defvar gnus-newsgroup-async nil)
1634 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1636 (defvar gnus-newsgroup-adaptive nil)
1638 (defvar gnus-summary-display-table nil)
1639 (defvar gnus-summary-display-article-function nil)
1641 (defvar gnus-summary-highlight-line-function nil
1642 "Function called after highlighting a summary line.")
1644 (defvar gnus-group-line-format-alist
1645 `((?M gnus-tmp-marked-mark ?c)
1646 (?S gnus-tmp-subscribed ?c)
1647 (?L gnus-tmp-level ?d)
1648 (?N (cond ((eq number t) "*" )
1649 ((numberp number)
1650 (int-to-string
1651 (+ number
1652 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1653 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1654 (t number)) ?s)
1655 (?R gnus-tmp-number-of-read ?s)
1656 (?t gnus-tmp-number-total ?d)
1657 (?y gnus-tmp-number-of-unread ?s)
1658 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1659 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1660 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1661 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1662 (?g gnus-tmp-group ?s)
1663 (?G gnus-tmp-qualified-group ?s)
1664 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1665 (?D gnus-tmp-newsgroup-description ?s)
1666 (?o gnus-tmp-moderated ?c)
1667 (?O gnus-tmp-moderated-string ?s)
1668 (?p gnus-tmp-process-marked ?c)
1669 (?s gnus-tmp-news-server ?s)
1670 (?n gnus-tmp-news-method ?s)
1671 (?P gnus-group-indentation ?s)
1672 (?l gnus-tmp-grouplens ?s)
1673 (?z gnus-tmp-news-method-string ?s)
1674 (?u gnus-tmp-user-defined ?s)))
1676 (defvar gnus-summary-line-format-alist
1677 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1678 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1679 (?s gnus-tmp-subject-or-nil ?s)
1680 (?n gnus-tmp-name ?s)
1681 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1683 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1684 gnus-tmp-from) ?s)
1685 (?F gnus-tmp-from ?s)
1686 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1687 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1688 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1689 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1690 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1691 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1692 (?L gnus-tmp-lines ?d)
1693 (?I gnus-tmp-indentation ?s)
1694 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1695 (?R gnus-tmp-replied ?c)
1696 (?\[ gnus-tmp-opening-bracket ?c)
1697 (?\] gnus-tmp-closing-bracket ?c)
1698 (?\> (make-string gnus-tmp-level ? ) ?s)
1699 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1700 (?i gnus-tmp-score ?d)
1701 (?z gnus-tmp-score-char ?c)
1702 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1703 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1704 (?U gnus-tmp-unread ?c)
1705 (?t (gnus-summary-number-of-articles-in-thread
1706 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1708 (?e (gnus-summary-number-of-articles-in-thread
1709 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1711 (?u gnus-tmp-user-defined ?s))
1712 "An alist of format specifications that can appear in summary lines,
1713 and what variables they correspond with, along with the type of the
1714 variable (string, integer, character, etc).")
1716 (defvar gnus-summary-dummy-line-format-alist
1717 `((?S gnus-tmp-subject ?s)
1718 (?N gnus-tmp-number ?d)
1719 (?u gnus-tmp-user-defined ?s)))
1721 (defvar gnus-summary-mode-line-format-alist
1722 `((?G gnus-tmp-group-name ?s)
1723 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1724 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1725 (?A gnus-tmp-article-number ?d)
1726 (?Z gnus-tmp-unread-and-unselected ?s)
1727 (?V gnus-version ?s)
1728 (?U gnus-tmp-unread-and-unticked ?d)
1729 (?S gnus-tmp-subject ?s)
1730 (?e gnus-tmp-unselected ?d)
1731 (?u gnus-tmp-user-defined ?s)
1732 (?d (length gnus-newsgroup-dormant) ?d)
1733 (?t (length gnus-newsgroup-marked) ?d)
1734 (?r (length gnus-newsgroup-reads) ?d)
1735 (?E gnus-newsgroup-expunged-tally ?d)
1736 (?s (gnus-current-score-file-nondirectory) ?s)))
1738 (defvar gnus-article-mode-line-format-alist
1739 gnus-summary-mode-line-format-alist)
1741 (defvar gnus-group-mode-line-format-alist
1742 `((?S gnus-tmp-news-server ?s)
1743 (?M gnus-tmp-news-method ?s)
1744 (?u gnus-tmp-user-defined ?s)
1745 (?: gnus-tmp-colon ?s)))
1747 (defvar gnus-have-read-active-file nil)
1749 (defconst gnus-maintainer
1750 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1751 "The mail address of the Gnus maintainers.")
1753 (defconst gnus-version-number "5.3"
1754 "Version number for this version of Gnus.")
1756 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1757 "Version string for this version of Gnus.")
1759 (defvar gnus-info-nodes
1760 '((gnus-group-mode "(gnus)The Group Buffer")
1761 (gnus-summary-mode "(gnus)The Summary Buffer")
1762 (gnus-article-mode "(gnus)The Article Buffer")
1763 (gnus-server-mode "(gnus)The Server Buffer")
1764 (gnus-browse-mode "(gnus)Browse Foreign Server")
1765 (gnus-tree-mode "(gnus)Tree Display")
1767 "Alist of major modes and related Info nodes.")
1769 (defvar gnus-group-buffer "*Group*")
1770 (defvar gnus-summary-buffer "*Summary*")
1771 (defvar gnus-article-buffer "*Article*")
1772 (defvar gnus-server-buffer "*Server*")
1774 (defvar gnus-work-buffer " *gnus work*")
1776 (defvar gnus-original-article-buffer " *Original Article*")
1777 (defvar gnus-original-article nil)
1779 (defvar gnus-buffer-list nil
1780 "Gnus buffers that should be killed on exit.")
1782 (defvar gnus-slave nil
1783 "Whether this Gnus is a slave or not.")
1785 (defvar gnus-variable-list
1786 '(gnus-newsrc-options gnus-newsrc-options-n
1787 gnus-newsrc-last-checked-date
1788 gnus-newsrc-alist gnus-server-alist
1789 gnus-killed-list gnus-zombie-list
1790 gnus-topic-topology gnus-topic-alist
1791 gnus-format-specs)
1792 "Gnus variables saved in the quick startup file.")
1794 (defvar gnus-newsrc-options nil
1795 "Options line in the .newsrc file.")
1797 (defvar gnus-newsrc-options-n nil
1798 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1800 (defvar gnus-newsrc-last-checked-date nil
1801 "Date Gnus last asked server for new newsgroups.")
1803 (defvar gnus-topic-topology nil
1804 "The complete topic hierarchy.")
1806 (defvar gnus-topic-alist nil
1807 "The complete topic-group alist.")
1809 (defvar gnus-newsrc-alist nil
1810 "Assoc list of read articles.
1811 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1813 (defvar gnus-newsrc-hashtb nil
1814 "Hashtable of gnus-newsrc-alist.")
1816 (defvar gnus-killed-list nil
1817 "List of killed newsgroups.")
1819 (defvar gnus-killed-hashtb nil
1820 "Hash table equivalent of gnus-killed-list.")
1822 (defvar gnus-zombie-list nil
1823 "List of almost dead newsgroups.")
1825 (defvar gnus-description-hashtb nil
1826 "Descriptions of newsgroups.")
1828 (defvar gnus-list-of-killed-groups nil
1829 "List of newsgroups that have recently been killed by the user.")
1831 (defvar gnus-active-hashtb nil
1832 "Hashtable of active articles.")
1834 (defvar gnus-moderated-list nil
1835 "List of moderated newsgroups.")
1837 (defvar gnus-group-marked nil)
1839 (defvar gnus-current-startup-file nil
1840 "Startup file for the current host.")
1842 (defvar gnus-last-search-regexp nil
1843 "Default regexp for article search command.")
1845 (defvar gnus-last-shell-command nil
1846 "Default shell command on article.")
1848 (defvar gnus-current-select-method nil
1849 "The current method for selecting a newsgroup.")
1851 (defvar gnus-group-list-mode nil)
1853 (defvar gnus-article-internal-prepare-hook nil)
1855 (defvar gnus-newsgroup-name nil)
1856 (defvar gnus-newsgroup-begin nil)
1857 (defvar gnus-newsgroup-end nil)
1858 (defvar gnus-newsgroup-last-rmail nil)
1859 (defvar gnus-newsgroup-last-mail nil)
1860 (defvar gnus-newsgroup-last-folder nil)
1861 (defvar gnus-newsgroup-last-file nil)
1862 (defvar gnus-newsgroup-auto-expire nil)
1863 (defvar gnus-newsgroup-active nil)
1865 (defvar gnus-newsgroup-data nil)
1866 (defvar gnus-newsgroup-data-reverse nil)
1867 (defvar gnus-newsgroup-limit nil)
1868 (defvar gnus-newsgroup-limits nil)
1870 (defvar gnus-newsgroup-unreads nil
1871 "List of unread articles in the current newsgroup.")
1873 (defvar gnus-newsgroup-unselected nil
1874 "List of unselected unread articles in the current newsgroup.")
1876 (defvar gnus-newsgroup-reads nil
1877 "Alist of read articles and article marks in the current newsgroup.")
1879 (defvar gnus-newsgroup-expunged-tally nil)
1881 (defvar gnus-newsgroup-marked nil
1882 "List of ticked articles in the current newsgroup (a subset of unread art).")
1884 (defvar gnus-newsgroup-killed nil
1885 "List of ranges of articles that have been through the scoring process.")
1887 (defvar gnus-newsgroup-cached nil
1888 "List of articles that come from the article cache.")
1890 (defvar gnus-newsgroup-saved nil
1891 "List of articles that have been saved.")
1893 (defvar gnus-newsgroup-kill-headers nil)
1895 (defvar gnus-newsgroup-replied nil
1896 "List of articles that have been replied to in the current newsgroup.")
1898 (defvar gnus-newsgroup-expirable nil
1899 "List of articles in the current newsgroup that can be expired.")
1901 (defvar gnus-newsgroup-processable nil
1902 "List of articles in the current newsgroup that can be processed.")
1904 (defvar gnus-newsgroup-bookmarks nil
1905 "List of articles in the current newsgroup that have bookmarks.")
1907 (defvar gnus-newsgroup-dormant nil
1908 "List of dormant articles in the current newsgroup.")
1910 (defvar gnus-newsgroup-scored nil
1911 "List of scored articles in the current newsgroup.")
1913 (defvar gnus-newsgroup-headers nil
1914 "List of article headers in the current newsgroup.")
1916 (defvar gnus-newsgroup-threads nil)
1918 (defvar gnus-newsgroup-prepared nil
1919 "Whether the current group has been prepared properly.")
1921 (defvar gnus-newsgroup-ancient nil
1922 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1924 (defvar gnus-newsgroup-sparse nil)
1926 (defvar gnus-current-article nil)
1927 (defvar gnus-article-current nil)
1928 (defvar gnus-current-headers nil)
1929 (defvar gnus-have-all-headers nil)
1930 (defvar gnus-last-article nil)
1931 (defvar gnus-newsgroup-history nil)
1932 (defvar gnus-current-kill-article nil)
1934 ;; Save window configuration.
1935 (defvar gnus-prev-winconf nil)
1937 (defvar gnus-summary-mark-positions nil)
1938 (defvar gnus-group-mark-positions nil)
1940 (defvar gnus-reffed-article-number nil)
1942 ;;; Let the byte-compiler know that we know about this variable.
1943 (defvar rmail-default-rmail-file)
1945 (defvar gnus-cache-removable-articles nil)
1947 (defvar gnus-dead-summary nil)
1949 (defconst gnus-summary-local-variables
1950 '(gnus-newsgroup-name
1951 gnus-newsgroup-begin gnus-newsgroup-end
1952 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1953 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1954 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1955 gnus-newsgroup-unselected gnus-newsgroup-marked
1956 gnus-newsgroup-reads gnus-newsgroup-saved
1957 gnus-newsgroup-replied gnus-newsgroup-expirable
1958 gnus-newsgroup-processable gnus-newsgroup-killed
1959 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1960 gnus-newsgroup-headers gnus-newsgroup-threads
1961 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1962 gnus-current-article gnus-current-headers gnus-have-all-headers
1963 gnus-last-article gnus-article-internal-prepare-hook
1964 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1965 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1966 gnus-newsgroup-async gnus-thread-expunge-below
1967 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1968 (gnus-summary-mark-below . global)
1969 gnus-newsgroup-active gnus-scores-exclude-files
1970 gnus-newsgroup-history gnus-newsgroup-ancient
1971 gnus-newsgroup-sparse
1972 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1973 gnus-newsgroup-adaptive-score-file
1974 (gnus-newsgroup-expunged-tally . 0)
1975 gnus-cache-removable-articles gnus-newsgroup-cached
1976 gnus-newsgroup-data gnus-newsgroup-data-reverse
1977 gnus-newsgroup-limit gnus-newsgroup-limits)
1978 "Variables that are buffer-local to the summary buffers.")
1980 (defconst gnus-bug-message
1981 "Sending a bug report to the Gnus Towers.
1982 ========================================
1984 The buffer below is a mail buffer. When you press `C-c C-c', it will
1985 be sent to the Gnus Bug Exterminators.
1987 At the bottom of the buffer you'll see lots of variable settings.
1988 Please do not delete those. They will tell the Bug People what your
1989 environment is, so that it will be easier to locate the bugs.
1991 If you have found a bug that makes Emacs go \"beep\", set
1992 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1993 and include the backtrace in your bug report.
1995 Please describe the bug in annoying, painstaking detail.
1997 Thank you for your help in stamping out bugs.
2000 ;;; End of variables.
2002 ;; Define some autoload functions Gnus might use.
2003 (eval-and-compile
2005 ;; This little mapcar goes through the list below and marks the
2006 ;; symbols in question as autoloaded functions.
2007 (mapcar
2008 (lambda (package)
2009 (let ((interactive (nth 1 (memq ':interactive package))))
2010 (mapcar
2011 (lambda (function)
2012 (let (keymap)
2013 (when (consp function)
2014 (setq keymap (car (memq 'keymap function)))
2015 (setq function (car function)))
2016 (autoload function (car package) nil interactive keymap)))
2017 (if (eq (nth 1 package) ':interactive)
2018 (cdddr package)
2019 (cdr package)))))
2020 '(("metamail" metamail-buffer)
2021 ("info" Info-goto-node)
2022 ("hexl" hexl-hex-string-to-integer)
2023 ("pp" pp pp-to-string pp-eval-expression)
2024 ("mail-extr" mail-extract-address-components)
2025 ("nnmail" nnmail-split-fancy nnmail-article-group)
2026 ("nnvirtual" nnvirtual-catchup-group)
2027 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2028 timezone-make-sortable-date timezone-make-time-string)
2029 ("rmailout" rmail-output)
2030 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2031 rmail-show-message)
2032 ("gnus-soup" :interactive t
2033 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2034 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2035 ("nnsoup" nnsoup-pack-replies)
2036 ("score-mode" :interactive t gnus-score-mode)
2037 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2038 gnus-Folder-save-name gnus-folder-save-name)
2039 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2040 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2041 gnus-server-make-menu-bar gnus-article-make-menu-bar
2042 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2043 gnus-summary-highlight-line gnus-carpal-setup-buffer
2044 gnus-group-highlight-line
2045 gnus-article-add-button gnus-insert-next-page-button
2046 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2047 ("gnus-vis" :interactive t
2048 gnus-article-push-button gnus-article-press-button
2049 gnus-article-highlight gnus-article-highlight-some
2050 gnus-article-highlight-headers gnus-article-highlight-signature
2051 gnus-article-add-buttons gnus-article-add-buttons-to-head
2052 gnus-article-next-button gnus-article-prev-button)
2053 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2054 gnus-demon-add-disconnection gnus-demon-add-handler
2055 gnus-demon-remove-handler)
2056 ("gnus-demon" :interactive t
2057 gnus-demon-init gnus-demon-cancel)
2058 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2059 gnus-tree-open gnus-tree-close)
2060 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2061 gnus-nocem-unwanted-article-p)
2062 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2063 ("gnus-srvr" gnus-browse-foreign-server)
2064 ("gnus-cite" :interactive t
2065 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2066 gnus-article-hide-citation gnus-article-fill-cited-article
2067 gnus-article-hide-citation-in-followups)
2068 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2069 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2070 gnus-execute gnus-expunge)
2071 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2072 gnus-cache-possibly-remove-articles gnus-cache-request-article
2073 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2074 gnus-cache-enter-remove-article gnus-cached-article-p
2075 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2076 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2077 gnus-cache-remove-article)
2078 ("gnus-score" :interactive t
2079 gnus-summary-increase-score gnus-summary-lower-score
2080 gnus-score-flush-cache gnus-score-close
2081 gnus-score-raise-same-subject-and-select
2082 gnus-score-raise-same-subject gnus-score-default
2083 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2084 gnus-score-lower-same-subject gnus-score-lower-thread
2085 gnus-possibly-score-headers gnus-summary-raise-score
2086 gnus-summary-set-score gnus-summary-current-score)
2087 ("gnus-score"
2088 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2089 gnus-current-score-file-nondirectory gnus-score-adaptive
2090 gnus-score-find-trace gnus-score-file-name)
2091 ("gnus-edit" :interactive t gnus-score-customize)
2092 ("gnus-topic" :interactive t gnus-topic-mode)
2093 ("gnus-topic" gnus-topic-remove-group)
2094 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2095 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2096 ("gnus-uu" :interactive t
2097 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2098 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2099 gnus-uu-mark-by-regexp gnus-uu-mark-all
2100 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2101 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2102 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2103 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2104 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2105 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2106 gnus-uu-decode-binhex-view)
2107 ("gnus-msg" (gnus-summary-send-map keymap)
2108 gnus-mail-yank-original gnus-mail-send-and-exit
2109 gnus-article-mail gnus-new-mail gnus-mail-reply)
2110 ("gnus-msg" :interactive t
2111 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2112 gnus-summary-followup gnus-summary-followup-with-original
2113 gnus-summary-cancel-article gnus-summary-supersede-article
2114 gnus-post-news gnus-inews-news
2115 gnus-summary-reply gnus-summary-reply-with-original
2116 gnus-summary-mail-forward gnus-summary-mail-other-window
2117 gnus-bug)
2118 ("gnus-picon" :interactive t gnus-article-display-picons
2119 gnus-group-display-picons gnus-picons-article-display-x-face
2120 gnus-picons-display-x-face)
2121 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2122 gnus-grouplens-mode)
2123 ("smiley" :interactive t gnus-smiley-display)
2124 ("gnus-vm" gnus-vm-mail-setup)
2125 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2126 gnus-summary-save-article-vm))))
2130 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2131 ;; If you want the cursor to go somewhere else, set these two
2132 ;; functions in some startup hook to whatever you want.
2133 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2134 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2136 ;;; Various macros and substs.
2138 (defun gnus-header-from (header)
2139 (mail-header-from header))
2141 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2142 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2143 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2144 (w (make-symbol "w"))
2145 (buf (make-symbol "buf")))
2146 `(let* ((,tempvar (selected-window))
2147 (,buf ,buffer)
2148 (,w (get-buffer-window ,buf 'visible)))
2149 (unwind-protect
2150 (progn
2151 (if ,w
2152 (select-window ,w)
2153 (pop-to-buffer ,buf))
2154 ,@forms)
2155 (select-window ,tempvar)))))
2157 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2158 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2159 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2161 (defmacro gnus-gethash (string hashtable)
2162 "Get hash value of STRING in HASHTABLE."
2163 `(symbol-value (intern-soft ,string ,hashtable)))
2165 (defmacro gnus-sethash (string value hashtable)
2166 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2167 `(set (intern ,string ,hashtable) ,value))
2169 (defmacro gnus-intern-safe (string hashtable)
2170 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2171 `(let ((symbol (intern ,string ,hashtable)))
2172 (or (boundp symbol)
2173 (set symbol nil))
2174 symbol))
2176 (defmacro gnus-group-unread (group)
2177 "Get the currently computed number of unread articles in GROUP."
2178 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2180 (defmacro gnus-group-entry (group)
2181 "Get the newsrc entry for GROUP."
2182 `(gnus-gethash ,group gnus-newsrc-hashtb))
2184 (defmacro gnus-active (group)
2185 "Get active info on GROUP."
2186 `(gnus-gethash ,group gnus-active-hashtb))
2188 (defmacro gnus-set-active (group active)
2189 "Set GROUP's active info."
2190 `(gnus-sethash ,group ,active gnus-active-hashtb))
2192 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2193 ;; function `substring' might cut on a middle of multi-octet
2194 ;; character.
2195 (defun gnus-truncate-string (str width)
2196 (substring str 0 width))
2198 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2199 ;; to limit the length of a string. This function is necessary since
2200 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2201 (defsubst gnus-limit-string (str width)
2202 (if (> (length str) width)
2203 (substring str 0 width)
2204 str))
2206 (defsubst gnus-simplify-subject-re (subject)
2207 "Remove \"Re:\" from subject lines."
2208 (if (string-match "^[Rr][Ee]: *" subject)
2209 (substring subject (match-end 0))
2210 subject))
2212 (defsubst gnus-functionp (form)
2213 "Return non-nil if FORM is funcallable."
2214 (or (and (symbolp form) (fboundp form))
2215 (and (listp form) (eq (car form) 'lambda))))
2217 (defsubst gnus-goto-char (point)
2218 (and point (goto-char point)))
2220 (defmacro gnus-buffer-exists-p (buffer)
2221 `(let ((buffer ,buffer))
2222 (and buffer
2223 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2224 buffer))))
2226 (defmacro gnus-kill-buffer (buffer)
2227 `(let ((buf ,buffer))
2228 (if (gnus-buffer-exists-p buf)
2229 (kill-buffer buf))))
2231 (defsubst gnus-point-at-bol ()
2232 "Return point at the beginning of the line."
2233 (let ((p (point)))
2234 (beginning-of-line)
2235 (prog1
2236 (point)
2237 (goto-char p))))
2239 (defsubst gnus-point-at-eol ()
2240 "Return point at the end of the line."
2241 (let ((p (point)))
2242 (end-of-line)
2243 (prog1
2244 (point)
2245 (goto-char p))))
2247 (defun gnus-alive-p ()
2248 "Say whether Gnus is running or not."
2249 (and gnus-group-buffer
2250 (get-buffer gnus-group-buffer)))
2252 (defun gnus-delete-first (elt list)
2253 "Delete by side effect the first occurrence of ELT as a member of LIST."
2254 (if (equal (car list) elt)
2255 (cdr list)
2256 (let ((total list))
2257 (while (and (cdr list)
2258 (not (equal (cadr list) elt)))
2259 (setq list (cdr list)))
2260 (when (cdr list)
2261 (setcdr list (cddr list)))
2262 total)))
2264 ;; Delete the current line (and the next N lines.);
2265 (defmacro gnus-delete-line (&optional n)
2266 `(delete-region (progn (beginning-of-line) (point))
2267 (progn (forward-line ,(or n 1)) (point))))
2269 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2270 (defvar gnus-init-inhibit nil)
2271 (defun gnus-read-init-file (&optional inhibit-next)
2272 (if gnus-init-inhibit
2273 (setq gnus-init-inhibit nil)
2274 (setq gnus-init-inhibit inhibit-next)
2275 (and gnus-init-file
2276 (or (and (file-exists-p gnus-init-file)
2277 ;; Don't try to load a directory.
2278 (not (file-directory-p gnus-init-file)))
2279 (file-exists-p (concat gnus-init-file ".el"))
2280 (file-exists-p (concat gnus-init-file ".elc")))
2281 (condition-case var
2282 (load gnus-init-file nil t)
2283 (error
2284 (error "Error in %s: %s" gnus-init-file var))))))
2286 ;; Info access macros.
2288 (defmacro gnus-info-group (info)
2289 `(nth 0 ,info))
2290 (defmacro gnus-info-rank (info)
2291 `(nth 1 ,info))
2292 (defmacro gnus-info-read (info)
2293 `(nth 2 ,info))
2294 (defmacro gnus-info-marks (info)
2295 `(nth 3 ,info))
2296 (defmacro gnus-info-method (info)
2297 `(nth 4 ,info))
2298 (defmacro gnus-info-params (info)
2299 `(nth 5 ,info))
2301 (defmacro gnus-info-level (info)
2302 `(let ((rank (gnus-info-rank ,info)))
2303 (if (consp rank)
2304 (car rank)
2305 rank)))
2306 (defmacro gnus-info-score (info)
2307 `(let ((rank (gnus-info-rank ,info)))
2308 (or (and (consp rank) (cdr rank)) 0)))
2310 (defmacro gnus-info-set-group (info group)
2311 `(setcar ,info ,group))
2312 (defmacro gnus-info-set-rank (info rank)
2313 `(setcar (nthcdr 1 ,info) ,rank))
2314 (defmacro gnus-info-set-read (info read)
2315 `(setcar (nthcdr 2 ,info) ,read))
2316 (defmacro gnus-info-set-marks (info marks)
2317 `(setcar (nthcdr 3 ,info) ,marks))
2318 (defmacro gnus-info-set-method (info method)
2319 `(setcar (nthcdr 4 ,info) ,method))
2320 (defmacro gnus-info-set-params (info params)
2321 `(setcar (nthcdr 5 ,info) ,params))
2323 (defmacro gnus-info-set-level (info level)
2324 `(let ((rank (cdr ,info)))
2325 (if (consp (car rank))
2326 (setcar (car rank) ,level)
2327 (setcar rank ,level))))
2328 (defmacro gnus-info-set-score (info score)
2329 `(let ((rank (cdr ,info)))
2330 (if (consp (car rank))
2331 (setcdr (car rank) ,score)
2332 (setcar rank (cons (car rank) ,score)))))
2334 (defmacro gnus-get-info (group)
2335 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2337 (defun gnus-byte-code (func)
2338 "Return a form that can be `eval'ed based on FUNC."
2339 (let ((fval (symbol-function func)))
2340 (if (byte-code-function-p fval)
2341 (let ((flist (append fval nil)))
2342 (setcar flist 'byte-code)
2343 flist)
2344 (cons 'progn (cddr fval)))))
2346 ;; Find out whether the gnus-visual TYPE is wanted.
2347 (defun gnus-visual-p (&optional type class)
2348 (and gnus-visual ; Has to be non-nil, at least.
2349 (if (not type) ; We don't care about type.
2350 gnus-visual
2351 (if (listp gnus-visual) ; It's a list, so we check it.
2352 (or (memq type gnus-visual)
2353 (memq class gnus-visual))
2354 t))))
2356 ;;; Load the compatability functions.
2358 (require 'gnus-cus)
2359 (require 'gnus-ems)
2363 ;;; Shutdown
2366 (defvar gnus-shutdown-alist nil)
2368 (defun gnus-add-shutdown (function &rest symbols)
2369 "Run FUNCTION whenever one of SYMBOLS is shut down."
2370 (push (cons function symbols) gnus-shutdown-alist))
2372 (defun gnus-shutdown (symbol)
2373 "Shut down everything that waits for SYMBOL."
2374 (let ((alist gnus-shutdown-alist)
2375 entry)
2376 (while (setq entry (pop alist))
2377 (when (memq symbol (cdr entry))
2378 (funcall (car entry))))))
2382 ;; Format specs. The chunks below are the machine-generated forms
2383 ;; that are to be evaled as the result of the default format strings.
2384 ;; We write them in here to get them byte-compiled. That way the
2385 ;; default actions will be quite fast, while still retaining the full
2386 ;; flexibility of the user-defined format specs.
2388 ;; First we have lots of dummy defvars to let the compiler know these
2389 ;; are really dynamic variables.
2391 (defvar gnus-tmp-unread)
2392 (defvar gnus-tmp-replied)
2393 (defvar gnus-tmp-score-char)
2394 (defvar gnus-tmp-indentation)
2395 (defvar gnus-tmp-opening-bracket)
2396 (defvar gnus-tmp-lines)
2397 (defvar gnus-tmp-name)
2398 (defvar gnus-tmp-closing-bracket)
2399 (defvar gnus-tmp-subject-or-nil)
2400 (defvar gnus-tmp-subject)
2401 (defvar gnus-tmp-marked)
2402 (defvar gnus-tmp-marked-mark)
2403 (defvar gnus-tmp-subscribed)
2404 (defvar gnus-tmp-process-marked)
2405 (defvar gnus-tmp-number-of-unread)
2406 (defvar gnus-tmp-group-name)
2407 (defvar gnus-tmp-group)
2408 (defvar gnus-tmp-article-number)
2409 (defvar gnus-tmp-unread-and-unselected)
2410 (defvar gnus-tmp-news-method)
2411 (defvar gnus-tmp-news-server)
2412 (defvar gnus-tmp-article-number)
2413 (defvar gnus-mouse-face)
2414 (defvar gnus-mouse-face-prop)
2416 (defun gnus-summary-line-format-spec ()
2417 (insert gnus-tmp-unread gnus-tmp-replied
2418 gnus-tmp-score-char gnus-tmp-indentation)
2419 (gnus-put-text-property
2420 (point)
2421 (progn
2422 (insert
2423 gnus-tmp-opening-bracket
2424 (format "%4d: %-20s"
2425 gnus-tmp-lines
2426 (if (> (length gnus-tmp-name) 20)
2427 (substring gnus-tmp-name 0 20)
2428 gnus-tmp-name))
2429 gnus-tmp-closing-bracket)
2430 (point))
2431 gnus-mouse-face-prop gnus-mouse-face)
2432 (insert " " gnus-tmp-subject-or-nil "\n"))
2434 (defvar gnus-summary-line-format-spec
2435 (gnus-byte-code 'gnus-summary-line-format-spec))
2437 (defun gnus-summary-dummy-line-format-spec ()
2438 (insert "* ")
2439 (gnus-put-text-property
2440 (point)
2441 (progn
2442 (insert ": :")
2443 (point))
2444 gnus-mouse-face-prop gnus-mouse-face)
2445 (insert " " gnus-tmp-subject "\n"))
2447 (defvar gnus-summary-dummy-line-format-spec
2448 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2450 (defun gnus-group-line-format-spec ()
2451 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2452 gnus-tmp-process-marked
2453 gnus-group-indentation
2454 (format "%5s: " gnus-tmp-number-of-unread))
2455 (gnus-put-text-property
2456 (point)
2457 (progn
2458 (insert gnus-tmp-group "\n")
2459 (1- (point)))
2460 gnus-mouse-face-prop gnus-mouse-face))
2461 (defvar gnus-group-line-format-spec
2462 (gnus-byte-code 'gnus-group-line-format-spec))
2464 (defvar gnus-format-specs
2465 `((version . ,emacs-version)
2466 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2467 (summary-dummy ,gnus-summary-dummy-line-format
2468 ,gnus-summary-dummy-line-format-spec)
2469 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2471 (defvar gnus-article-mode-line-format-spec nil)
2472 (defvar gnus-summary-mode-line-format-spec nil)
2473 (defvar gnus-group-mode-line-format-spec nil)
2475 ;;; Phew. All that gruft is over, fortunately.
2479 ;;; Gnus Utility Functions
2482 (defun gnus-extract-address-components (from)
2483 (let (name address)
2484 ;; First find the address - the thing with the @ in it. This may
2485 ;; not be accurate in mail addresses, but does the trick most of
2486 ;; the time in news messages.
2487 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2488 (setq address (substring from (match-beginning 0) (match-end 0))))
2489 ;; Then we check whether the "name <address>" format is used.
2490 (and address
2491 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2492 ;; Linear white space is not required.
2493 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2494 (and (setq name (substring from 0 (match-beginning 0)))
2495 ;; Strip any quotes from the name.
2496 (string-match "\".*\"" name)
2497 (setq name (substring name 1 (1- (match-end 0))))))
2498 ;; If not, then "address (name)" is used.
2499 (or name
2500 (and (string-match "(.+)" from)
2501 (setq name (substring from (1+ (match-beginning 0))
2502 (1- (match-end 0)))))
2503 (and (string-match "()" from)
2504 (setq name address))
2505 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2506 ;; XOVER might not support folded From headers.
2507 (and (string-match "(.*" from)
2508 (setq name (substring from (1+ (match-beginning 0))
2509 (match-end 0)))))
2510 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2511 (list (or name from) (or address from))))
2513 (defun gnus-fetch-field (field)
2514 "Return the value of the header FIELD of current article."
2515 (save-excursion
2516 (save-restriction
2517 (let ((case-fold-search t)
2518 (inhibit-point-motion-hooks t))
2519 (nnheader-narrow-to-headers)
2520 (message-fetch-field field)))))
2522 (defun gnus-goto-colon ()
2523 (beginning-of-line)
2524 (search-forward ":" (gnus-point-at-eol) t))
2526 ;;;###autoload
2527 (defun gnus-update-format (var)
2528 "Update the format specification near point."
2529 (interactive
2530 (list
2531 (save-excursion
2532 (eval-defun nil)
2533 ;; Find the end of the current word.
2534 (re-search-forward "[ \t\n]" nil t)
2535 ;; Search backward.
2536 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2537 (match-string 1)))))
2538 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2539 (match-string 1 var))))
2540 (entry (assq type gnus-format-specs))
2541 value spec)
2542 (when entry
2543 (setq gnus-format-specs (delq entry gnus-format-specs)))
2544 (set
2545 (intern (format "%s-spec" var))
2546 (gnus-parse-format (setq value (symbol-value (intern var)))
2547 (symbol-value (intern (format "%s-alist" var)))
2548 (not (string-match "mode" var))))
2549 (setq spec (symbol-value (intern (format "%s-spec" var))))
2550 (push (list type value spec) gnus-format-specs)
2552 (pop-to-buffer "*Gnus Format*")
2553 (erase-buffer)
2554 (lisp-interaction-mode)
2555 (insert (pp-to-string spec))))
2557 (defun gnus-update-format-specifications (&optional force)
2558 "Update all (necessary) format specifications."
2559 ;; Make the indentation array.
2560 (gnus-make-thread-indent-array)
2562 ;; See whether all the stored info needs to be flushed.
2563 (when (or force
2564 (not (equal emacs-version
2565 (cdr (assq 'version gnus-format-specs)))))
2566 (setq gnus-format-specs nil))
2568 ;; Go through all the formats and see whether they need updating.
2569 (let ((types '(summary summary-dummy group
2570 summary-mode group-mode article-mode))
2571 new-format entry type val)
2572 (while (setq type (pop types))
2573 ;; Jump to the proper buffer to find out the value of
2574 ;; the variable, if possible. (It may be buffer-local.)
2575 (save-excursion
2576 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2577 val)
2578 (when (and (boundp buffer)
2579 (setq val (symbol-value buffer))
2580 (get-buffer val)
2581 (buffer-name (get-buffer val)))
2582 (set-buffer (get-buffer val)))
2583 (setq new-format (symbol-value
2584 (intern (format "gnus-%s-line-format" type))))))
2585 (setq entry (cdr (assq type gnus-format-specs)))
2586 (if (and entry
2587 (equal (car entry) new-format))
2588 ;; Use the old format.
2589 (set (intern (format "gnus-%s-line-format-spec" type))
2590 (cadr entry))
2591 ;; This is a new format.
2592 (setq val
2593 (if (not (stringp new-format))
2594 ;; This is a function call or something.
2595 new-format
2596 ;; This is a "real" format.
2597 (gnus-parse-format
2598 new-format
2599 (symbol-value
2600 (intern (format "gnus-%s-line-format-alist"
2601 (if (eq type 'article-mode)
2602 'summary-mode type))))
2603 (not (string-match "mode$" (symbol-name type))))))
2604 ;; Enter the new format spec into the list.
2605 (if entry
2606 (progn
2607 (setcar (cdr entry) val)
2608 (setcar entry new-format))
2609 (push (list type new-format val) gnus-format-specs))
2610 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2612 (unless (assq 'version gnus-format-specs)
2613 (push (cons 'version emacs-version) gnus-format-specs))
2615 (gnus-update-group-mark-positions)
2616 (gnus-update-summary-mark-positions))
2618 (defun gnus-update-summary-mark-positions ()
2619 "Compute where the summary marks are to go."
2620 (save-excursion
2621 (when (and gnus-summary-buffer
2622 (get-buffer gnus-summary-buffer)
2623 (buffer-name (get-buffer gnus-summary-buffer)))
2624 (set-buffer gnus-summary-buffer))
2625 (let ((gnus-replied-mark 129)
2626 (gnus-score-below-mark 130)
2627 (gnus-score-over-mark 130)
2628 (thread nil)
2629 (gnus-visual nil)
2630 (spec gnus-summary-line-format-spec)
2631 pos)
2632 (save-excursion
2633 (gnus-set-work-buffer)
2634 (let ((gnus-summary-line-format-spec spec))
2635 (gnus-summary-insert-line
2636 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2637 (goto-char (point-min))
2638 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2639 (- (point) 2)))))
2640 (goto-char (point-min))
2641 (push (cons 'replied (and (search-forward "\201" nil t)
2642 (- (point) 2)))
2643 pos)
2644 (goto-char (point-min))
2645 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2646 pos)))
2647 (setq gnus-summary-mark-positions pos))))
2649 (defun gnus-update-group-mark-positions ()
2650 (save-excursion
2651 (let ((gnus-process-mark 128)
2652 (gnus-group-marked '("dummy.group"))
2653 (gnus-active-hashtb (make-vector 10 0)))
2654 (gnus-set-active "dummy.group" '(0 . 0))
2655 (gnus-set-work-buffer)
2656 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2657 (goto-char (point-min))
2658 (setq gnus-group-mark-positions
2659 (list (cons 'process (and (search-forward "\200" nil t)
2660 (- (point) 2))))))))
2662 (defvar gnus-mouse-face-0 'highlight)
2663 (defvar gnus-mouse-face-1 'highlight)
2664 (defvar gnus-mouse-face-2 'highlight)
2665 (defvar gnus-mouse-face-3 'highlight)
2666 (defvar gnus-mouse-face-4 'highlight)
2668 (defun gnus-mouse-face-function (form type)
2669 `(gnus-put-text-property
2670 (point) (progn ,@form (point))
2671 gnus-mouse-face-prop
2672 ,(if (equal type 0)
2673 'gnus-mouse-face
2674 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2676 (defvar gnus-face-0 'bold)
2677 (defvar gnus-face-1 'italic)
2678 (defvar gnus-face-2 'bold-italic)
2679 (defvar gnus-face-3 'bold)
2680 (defvar gnus-face-4 'bold)
2682 (defun gnus-face-face-function (form type)
2683 `(gnus-put-text-property
2684 (point) (progn ,@form (point))
2685 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2687 (defun gnus-max-width-function (el max-width)
2688 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2689 (if (symbolp el)
2690 `(if (> (length ,el) ,max-width)
2691 (substring ,el 0 ,max-width)
2692 ,el)
2693 `(let ((val (eval ,el)))
2694 (if (numberp val)
2695 (setq val (int-to-string val)))
2696 (if (> (length val) ,max-width)
2697 (substring val 0 ,max-width)
2698 val))))
2700 (defun gnus-parse-format (format spec-alist &optional insert)
2701 ;; This function parses the FORMAT string with the help of the
2702 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2703 ;; string. If the FORMAT string contains the specifiers %( and %)
2704 ;; the text between them will have the mouse-face text property.
2705 (if (string-match
2706 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2707 format)
2708 (gnus-parse-complex-format format spec-alist)
2709 ;; This is a simple format.
2710 (gnus-parse-simple-format format spec-alist insert)))
2712 (defun gnus-parse-complex-format (format spec-alist)
2713 (save-excursion
2714 (gnus-set-work-buffer)
2715 (insert format)
2716 (goto-char (point-min))
2717 (while (re-search-forward "\"" nil t)
2718 (replace-match "\\\"" nil t))
2719 (goto-char (point-min))
2720 (insert "(\"")
2721 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2722 (let ((number (if (match-beginning 1)
2723 (match-string 1) "0"))
2724 (delim (aref (match-string 2) 0)))
2725 (if (or (= delim ?\() (= delim ?\{))
2726 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2727 " " number " \""))
2728 (replace-match "\")\""))))
2729 (goto-char (point-max))
2730 (insert "\")")
2731 (goto-char (point-min))
2732 (let ((form (read (current-buffer))))
2733 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2735 (defun gnus-complex-form-to-spec (form spec-alist)
2736 (delq nil
2737 (mapcar
2738 (lambda (sform)
2739 (if (stringp sform)
2740 (gnus-parse-simple-format sform spec-alist t)
2741 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2742 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2743 (nth 1 sform))))
2744 form)))
2746 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2747 ;; This function parses the FORMAT string with the help of the
2748 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2749 ;; string.
2750 (let ((max-width 0)
2751 spec flist fstring newspec elem beg result dontinsert)
2752 (save-excursion
2753 (gnus-set-work-buffer)
2754 (insert format)
2755 (goto-char (point-min))
2756 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2757 nil t)
2758 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2759 (setq newspec "%"
2760 beg (1+ (match-beginning 0)))
2761 ;; First check if there are any specs that look anything like
2762 ;; "%12,12A", ie. with a "max width specification". These have
2763 ;; to be treated specially.
2764 (if (setq beg (match-beginning 1))
2765 (setq max-width
2766 (string-to-int
2767 (buffer-substring
2768 (1+ (match-beginning 1)) (match-end 1))))
2769 (setq max-width 0)
2770 (setq beg (match-beginning 2)))
2771 ;; Find the specification from `spec-alist'.
2772 (unless (setq elem (cdr (assq spec spec-alist)))
2773 (setq elem '("*" ?s)))
2774 ;; Treat user defined format specifiers specially.
2775 (when (eq (car elem) 'gnus-tmp-user-defined)
2776 (setq elem
2777 (list
2778 (list (intern (concat "gnus-user-format-function-"
2779 (match-string 3)))
2780 'gnus-tmp-header) ?s))
2781 (delete-region (match-beginning 3) (match-end 3)))
2782 (if (not (zerop max-width))
2783 (let ((el (car elem)))
2784 (cond ((= (cadr elem) ?c)
2785 (setq el (list 'char-to-string el)))
2786 ((= (cadr elem) ?d)
2787 (setq el (list 'int-to-string el))))
2788 (setq flist (cons (gnus-max-width-function el max-width)
2789 flist))
2790 (setq newspec ?s))
2791 (progn
2792 (setq flist (cons (car elem) flist))
2793 (setq newspec (cadr elem)))))
2794 ;; Remove the old specification (and possibly a ",12" string).
2795 (delete-region beg (match-end 2))
2796 ;; Insert the new specification.
2797 (goto-char beg)
2798 (insert newspec))
2799 (setq fstring (buffer-substring 1 (point-max))))
2800 ;; Do some postprocessing to increase efficiency.
2801 (setq
2802 result
2803 (cond
2804 ;; Emptyness.
2805 ((string= fstring "")
2806 nil)
2807 ;; Not a format string.
2808 ((not (string-match "%" fstring))
2809 (list fstring))
2810 ;; A format string with just a single string spec.
2811 ((string= fstring "%s")
2812 (list (car flist)))
2813 ;; A single character.
2814 ((string= fstring "%c")
2815 (list (car flist)))
2816 ;; A single number.
2817 ((string= fstring "%d")
2818 (setq dontinsert)
2819 (if insert
2820 (list `(princ ,(car flist)))
2821 (list `(int-to-string ,(car flist)))))
2822 ;; Just lots of chars and strings.
2823 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2824 (nreverse flist))
2825 ;; A single string spec at the beginning of the spec.
2826 ((string-match "\\`%[sc][^%]+\\'" fstring)
2827 (list (car flist) (substring fstring 2)))
2828 ;; A single string spec in the middle of the spec.
2829 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2830 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2831 ;; A single string spec in the end of the spec.
2832 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2833 (list (match-string 1 fstring) (car flist)))
2834 ;; A more complex spec.
2836 (list (cons 'format (cons fstring (nreverse flist)))))))
2838 (if insert
2839 (when result
2840 (if dontinsert
2841 result
2842 (cons 'insert result)))
2843 (cond ((stringp result)
2844 result)
2845 ((consp result)
2846 (cons 'concat result))
2847 (t "")))))
2849 (defun gnus-eval-format (format &optional alist props)
2850 "Eval the format variable FORMAT, using ALIST.
2851 If PROPS, insert the result."
2852 (let ((form (gnus-parse-format format alist props)))
2853 (if props
2854 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2855 (eval form))))
2857 (defun gnus-remove-text-with-property (prop)
2858 "Delete all text in the current buffer with text property PROP."
2859 (save-excursion
2860 (goto-char (point-min))
2861 (while (not (eobp))
2862 (while (get-text-property (point) prop)
2863 (delete-char 1))
2864 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2866 (defun gnus-set-work-buffer ()
2867 (if (get-buffer gnus-work-buffer)
2868 (progn
2869 (set-buffer gnus-work-buffer)
2870 (erase-buffer))
2871 (set-buffer (get-buffer-create gnus-work-buffer))
2872 (kill-all-local-variables)
2873 (buffer-disable-undo (current-buffer))
2874 (gnus-add-current-to-buffer-list)))
2876 ;; Article file names when saving.
2878 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2879 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2880 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2881 Otherwise, it is like ~/News/news/group/num."
2882 (let ((default
2883 (expand-file-name
2884 (concat (if (gnus-use-long-file-name 'not-save)
2885 (gnus-capitalize-newsgroup newsgroup)
2886 (gnus-newsgroup-directory-form newsgroup))
2887 "/" (int-to-string (mail-header-number headers)))
2888 gnus-article-save-directory)))
2889 (if (and last-file
2890 (string-equal (file-name-directory default)
2891 (file-name-directory last-file))
2892 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2893 default
2894 (or last-file default))))
2896 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2897 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2898 If variable `gnus-use-long-file-name' is non-nil, it is
2899 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2900 (let ((default
2901 (expand-file-name
2902 (concat (if (gnus-use-long-file-name 'not-save)
2903 newsgroup
2904 (gnus-newsgroup-directory-form newsgroup))
2905 "/" (int-to-string (mail-header-number headers)))
2906 gnus-article-save-directory)))
2907 (if (and last-file
2908 (string-equal (file-name-directory default)
2909 (file-name-directory last-file))
2910 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2911 default
2912 (or last-file default))))
2914 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2915 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2916 If variable `gnus-use-long-file-name' is non-nil, it is
2917 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2918 (or last-file
2919 (expand-file-name
2920 (if (gnus-use-long-file-name 'not-save)
2921 (gnus-capitalize-newsgroup newsgroup)
2922 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2923 gnus-article-save-directory)))
2925 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2926 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2927 If variable `gnus-use-long-file-name' is non-nil, it is
2928 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2929 (or last-file
2930 (expand-file-name
2931 (if (gnus-use-long-file-name 'not-save)
2932 newsgroup
2933 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2934 gnus-article-save-directory)))
2936 ;; For subscribing new newsgroup
2938 (defun gnus-subscribe-hierarchical-interactive (groups)
2939 (let ((groups (sort groups 'string<))
2940 prefixes prefix start ans group starts)
2941 (while groups
2942 (setq prefixes (list "^"))
2943 (while (and groups prefixes)
2944 (while (not (string-match (car prefixes) (car groups)))
2945 (setq prefixes (cdr prefixes)))
2946 (setq prefix (car prefixes))
2947 (setq start (1- (length prefix)))
2948 (if (and (string-match "[^\\.]\\." (car groups) start)
2949 (cdr groups)
2950 (setq prefix
2951 (concat "^" (substring (car groups) 0 (match-end 0))))
2952 (string-match prefix (cadr groups)))
2953 (progn
2954 (setq prefixes (cons prefix prefixes))
2955 (message "Descend hierarchy %s? ([y]nsq): "
2956 (substring prefix 1 (1- (length prefix))))
2957 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2958 (ding)
2959 (message "Descend hierarchy %s? ([y]nsq): "
2960 (substring prefix 1 (1- (length prefix)))))
2961 (cond ((= ans ?n)
2962 (while (and groups
2963 (string-match prefix
2964 (setq group (car groups))))
2965 (setq gnus-killed-list
2966 (cons group gnus-killed-list))
2967 (gnus-sethash group group gnus-killed-hashtb)
2968 (setq groups (cdr groups)))
2969 (setq starts (cdr starts)))
2970 ((= ans ?s)
2971 (while (and groups
2972 (string-match prefix
2973 (setq group (car groups))))
2974 (gnus-sethash group group gnus-killed-hashtb)
2975 (gnus-subscribe-alphabetically (car groups))
2976 (setq groups (cdr groups)))
2977 (setq starts (cdr starts)))
2978 ((= ans ?q)
2979 (while groups
2980 (setq group (car groups))
2981 (setq gnus-killed-list (cons group gnus-killed-list))
2982 (gnus-sethash group group gnus-killed-hashtb)
2983 (setq groups (cdr groups))))
2984 (t nil)))
2985 (message "Subscribe %s? ([n]yq)" (car groups))
2986 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2987 (ding)
2988 (message "Subscribe %s? ([n]yq)" (car groups)))
2989 (setq group (car groups))
2990 (cond ((= ans ?y)
2991 (gnus-subscribe-alphabetically (car groups))
2992 (gnus-sethash group group gnus-killed-hashtb))
2993 ((= ans ?q)
2994 (while groups
2995 (setq group (car groups))
2996 (setq gnus-killed-list (cons group gnus-killed-list))
2997 (gnus-sethash group group gnus-killed-hashtb)
2998 (setq groups (cdr groups))))
3000 (setq gnus-killed-list (cons group gnus-killed-list))
3001 (gnus-sethash group group gnus-killed-hashtb)))
3002 (setq groups (cdr groups)))))))
3004 (defun gnus-subscribe-randomly (newsgroup)
3005 "Subscribe new NEWSGROUP by making it the first newsgroup."
3006 (gnus-subscribe-newsgroup newsgroup))
3008 (defun gnus-subscribe-alphabetically (newgroup)
3009 "Subscribe new NEWSGROUP and insert it in alphabetical order."
3010 (let ((groups (cdr gnus-newsrc-alist))
3011 before)
3012 (while (and (not before) groups)
3013 (if (string< newgroup (caar groups))
3014 (setq before (caar groups))
3015 (setq groups (cdr groups))))
3016 (gnus-subscribe-newsgroup newgroup before)))
3018 (defun gnus-subscribe-hierarchically (newgroup)
3019 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
3020 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
3021 (save-excursion
3022 (set-buffer (find-file-noselect gnus-current-startup-file))
3023 (let ((groupkey newgroup)
3024 before)
3025 (while (and (not before) groupkey)
3026 (goto-char (point-min))
3027 (let ((groupkey-re
3028 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3029 (while (and (re-search-forward groupkey-re nil t)
3030 (progn
3031 (setq before (match-string 1))
3032 (string< before newgroup)))))
3033 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3034 (setq groupkey
3035 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3036 (substring groupkey (match-beginning 1) (match-end 1)))))
3037 (gnus-subscribe-newsgroup newgroup before))
3038 (kill-buffer (current-buffer))))
3040 (defun gnus-subscribe-interactively (group)
3041 "Subscribe the new GROUP interactively.
3042 It is inserted in hierarchical newsgroup order if subscribed. If not,
3043 it is killed."
3044 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3045 (gnus-subscribe-hierarchically group)
3046 (push group gnus-killed-list)))
3048 (defun gnus-subscribe-zombies (group)
3049 "Make the new GROUP into a zombie group."
3050 (push group gnus-zombie-list))
3052 (defun gnus-subscribe-killed (group)
3053 "Make the new GROUP a killed group."
3054 (push group gnus-killed-list))
3056 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3057 "Subscribe new NEWSGROUP.
3058 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3059 the first newsgroup."
3060 ;; We subscribe the group by changing its level to `subscribed'.
3061 (gnus-group-change-level
3062 newsgroup gnus-level-default-subscribed
3063 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3064 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3066 ;; For directories
3068 (defun gnus-newsgroup-directory-form (newsgroup)
3069 "Make hierarchical directory name from NEWSGROUP name."
3070 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3071 (len (length newsgroup))
3072 idx)
3073 ;; If this is a foreign group, we don't want to translate the
3074 ;; entire name.
3075 (if (setq idx (string-match ":" newsgroup))
3076 (aset newsgroup idx ?/)
3077 (setq idx 0))
3078 ;; Replace all occurrences of `.' with `/'.
3079 (while (< idx len)
3080 (if (= (aref newsgroup idx) ?.)
3081 (aset newsgroup idx ?/))
3082 (setq idx (1+ idx)))
3083 newsgroup))
3085 (defun gnus-newsgroup-savable-name (group)
3086 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3087 ;; with dots.
3088 (nnheader-replace-chars-in-string group ?/ ?.))
3090 (defun gnus-make-directory (dir)
3091 "Make DIRECTORY recursively."
3092 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3093 ;; of the many mysteries of the universe.
3094 (let* ((dir (expand-file-name dir default-directory))
3095 dirs err)
3096 (if (string-match "/$" dir)
3097 (setq dir (substring dir 0 (match-beginning 0))))
3098 ;; First go down the path until we find a directory that exists.
3099 (while (not (file-exists-p dir))
3100 (setq dirs (cons dir dirs))
3101 (string-match "/[^/]+$" dir)
3102 (setq dir (substring dir 0 (match-beginning 0))))
3103 ;; Then create all the subdirs.
3104 (while (and dirs (not err))
3105 (condition-case ()
3106 (make-directory (car dirs))
3107 (error (setq err t)))
3108 (setq dirs (cdr dirs)))
3109 ;; We return whether we were successful or not.
3110 (not dirs)))
3112 (defun gnus-capitalize-newsgroup (newsgroup)
3113 "Capitalize NEWSGROUP name."
3114 (and (not (zerop (length newsgroup)))
3115 (concat (char-to-string (upcase (aref newsgroup 0)))
3116 (substring newsgroup 1))))
3118 ;; Various... things.
3120 (defun gnus-simplify-subject (subject &optional re-only)
3121 "Remove `Re:' and words in parentheses.
3122 If RE-ONLY is non-nil, strip leading `Re:'s only."
3123 (let ((case-fold-search t)) ;Ignore case.
3124 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3125 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3126 (setq subject (substring subject (match-end 0))))
3127 ;; Remove uninteresting prefixes.
3128 (if (and (not re-only)
3129 gnus-simplify-ignored-prefixes
3130 (string-match gnus-simplify-ignored-prefixes subject))
3131 (setq subject (substring subject (match-end 0))))
3132 ;; Remove words in parentheses from end.
3133 (unless re-only
3134 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3135 (setq subject (substring subject 0 (match-beginning 0)))))
3136 ;; Return subject string.
3137 subject))
3139 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3140 ;; all whitespace.
3141 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3142 (defun gnus-simplify-buffer-fuzzy ()
3143 (let ((case-fold-search t))
3144 (goto-char (point-min))
3145 (while (search-forward "\t" nil t)
3146 (replace-match " " t t))
3147 (goto-char (point-min))
3148 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3149 (goto-char (match-beginning 0))
3150 (while (or
3151 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3152 (looking-at "^[[].*: .*[]]$"))
3153 (goto-char (point-min))
3154 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3155 nil t)
3156 (replace-match "" t t))
3157 (goto-char (point-min))
3158 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3159 (goto-char (match-end 0))
3160 (delete-char -1)
3161 (delete-region
3162 (progn (goto-char (match-beginning 0)))
3163 (re-search-forward ":"))))
3164 (goto-char (point-min))
3165 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3166 (replace-match "" t t))
3167 (goto-char (point-min))
3168 (while (re-search-forward " +" nil t)
3169 (replace-match " " t t))
3170 (goto-char (point-min))
3171 (while (re-search-forward " $" nil t)
3172 (replace-match "" t t))
3173 (goto-char (point-min))
3174 (while (re-search-forward "^ +" nil t)
3175 (replace-match "" t t))
3176 (goto-char (point-min))
3177 (when gnus-simplify-subject-fuzzy-regexp
3178 (if (listp gnus-simplify-subject-fuzzy-regexp)
3179 (let ((list gnus-simplify-subject-fuzzy-regexp))
3180 (while list
3181 (goto-char (point-min))
3182 (while (re-search-forward (car list) nil t)
3183 (replace-match "" t t))
3184 (setq list (cdr list))))
3185 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3186 (replace-match "" t t))))))
3188 (defun gnus-simplify-subject-fuzzy (subject)
3189 "Siplify a subject string fuzzily."
3190 (save-excursion
3191 (gnus-set-work-buffer)
3192 (let ((case-fold-search t))
3193 (insert subject)
3194 (inline (gnus-simplify-buffer-fuzzy))
3195 (buffer-string))))
3197 ;; Add the current buffer to the list of buffers to be killed on exit.
3198 (defun gnus-add-current-to-buffer-list ()
3199 (or (memq (current-buffer) gnus-buffer-list)
3200 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3202 (defun gnus-string> (s1 s2)
3203 (not (or (string< s1 s2)
3204 (string= s1 s2))))
3206 (defun gnus-read-active-file-p ()
3207 "Say whether the active file has been read from `gnus-select-method'."
3208 (memq gnus-select-method gnus-have-read-active-file))
3210 ;;; General various misc type functions.
3212 (defun gnus-clear-system ()
3213 "Clear all variables and buffers."
3214 ;; Clear Gnus variables.
3215 (let ((variables gnus-variable-list))
3216 (while variables
3217 (set (car variables) nil)
3218 (setq variables (cdr variables))))
3219 ;; Clear other internal variables.
3220 (setq gnus-list-of-killed-groups nil
3221 gnus-have-read-active-file nil
3222 gnus-newsrc-alist nil
3223 gnus-newsrc-hashtb nil
3224 gnus-killed-list nil
3225 gnus-zombie-list nil
3226 gnus-killed-hashtb nil
3227 gnus-active-hashtb nil
3228 gnus-moderated-list nil
3229 gnus-description-hashtb nil
3230 gnus-current-headers nil
3231 gnus-thread-indent-array nil
3232 gnus-newsgroup-headers nil
3233 gnus-newsgroup-name nil
3234 gnus-server-alist nil
3235 gnus-group-list-mode nil
3236 gnus-opened-servers nil
3237 gnus-group-mark-positions nil
3238 gnus-newsgroup-data nil
3239 gnus-newsgroup-unreads nil
3240 nnoo-state-alist nil
3241 gnus-current-select-method nil)
3242 (gnus-shutdown 'gnus)
3243 ;; Kill the startup file.
3244 (and gnus-current-startup-file
3245 (get-file-buffer gnus-current-startup-file)
3246 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3247 ;; Clear the dribble buffer.
3248 (gnus-dribble-clear)
3249 ;; Kill global KILL file buffer.
3250 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3251 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3252 (gnus-kill-buffer nntp-server-buffer)
3253 ;; Kill Gnus buffers.
3254 (while gnus-buffer-list
3255 (gnus-kill-buffer (pop gnus-buffer-list)))
3256 ;; Remove Gnus frames.
3257 (gnus-kill-gnus-frames))
3259 (defun gnus-kill-gnus-frames ()
3260 "Kill all frames Gnus has created."
3261 (while gnus-created-frames
3262 (when (frame-live-p (car gnus-created-frames))
3263 ;; We slap a condition-case around this `delete-frame' to ensure
3264 ;; against errors if we try do delete the single frame that's left.
3265 (condition-case ()
3266 (delete-frame (car gnus-created-frames))
3267 (error nil)))
3268 (pop gnus-created-frames)))
3270 (defun gnus-windows-old-to-new (setting)
3271 ;; First we take care of the really, really old Gnus 3 actions.
3272 (when (symbolp setting)
3273 (setq setting
3274 ;; Take care of ooold GNUS 3.x values.
3275 (cond ((eq setting 'SelectArticle) 'article)
3276 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3277 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3278 (t setting))))
3279 (if (or (listp setting)
3280 (not (and gnus-window-configuration
3281 (memq setting '(group summary article)))))
3282 setting
3283 (let* ((setting (if (eq setting 'group)
3284 (if (assq 'newsgroup gnus-window-configuration)
3285 'newsgroup
3286 'newsgroups) setting))
3287 (elem (cadr (assq setting gnus-window-configuration)))
3288 (total (apply '+ elem))
3289 (types '(group summary article))
3290 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3291 (i 0)
3292 perc
3293 out)
3294 (while (< i 3)
3295 (or (not (numberp (nth i elem)))
3296 (zerop (nth i elem))
3297 (progn
3298 (setq perc (if (= i 2)
3300 (/ (float (nth 0 elem)) total)))
3301 (setq out (cons (if (eq pbuf (nth i types))
3302 (list (nth i types) perc 'point)
3303 (list (nth i types) perc))
3304 out))))
3305 (setq i (1+ i)))
3306 `(vertical 1.0 ,@(nreverse out)))))
3308 ;;;###autoload
3309 (defun gnus-add-configuration (conf)
3310 "Add the window configuration CONF to `gnus-buffer-configuration'."
3311 (setq gnus-buffer-configuration
3312 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3313 gnus-buffer-configuration))))
3315 (defvar gnus-frame-list nil)
3317 (defun gnus-configure-frame (split &optional window)
3318 "Split WINDOW according to SPLIT."
3319 (unless window
3320 (setq window (get-buffer-window (current-buffer))))
3321 (select-window window)
3322 ;; This might be an old-stylee buffer config.
3323 (when (vectorp split)
3324 (setq split (append split nil)))
3325 (when (or (consp (car split))
3326 (vectorp (car split)))
3327 (push 1.0 split)
3328 (push 'vertical split))
3329 ;; The SPLIT might be something that is to be evaled to
3330 ;; return a new SPLIT.
3331 (while (and (not (assq (car split) gnus-window-to-buffer))
3332 (gnus-functionp (car split)))
3333 (setq split (eval split)))
3334 (let* ((type (car split))
3335 (subs (cddr split))
3336 (len (if (eq type 'horizontal) (window-width) (window-height)))
3337 (total 0)
3338 (window-min-width (or gnus-window-min-width window-min-width))
3339 (window-min-height (or gnus-window-min-height window-min-height))
3340 s result new-win rest comp-subs size sub)
3341 (cond
3342 ;; Nothing to do here.
3343 ((null split))
3344 ;; Don't switch buffers.
3345 ((null type)
3346 (and (memq 'point split) window))
3347 ;; This is a buffer to be selected.
3348 ((not (memq type '(frame horizontal vertical)))
3349 (let ((buffer (cond ((stringp type) type)
3350 (t (cdr (assq type gnus-window-to-buffer)))))
3351 buf)
3352 (unless buffer
3353 (error "Illegal buffer type: %s" type))
3354 (unless (setq buf (get-buffer (if (symbolp buffer)
3355 (symbol-value buffer) buffer)))
3356 (setq buf (get-buffer-create (if (symbolp buffer)
3357 (symbol-value buffer) buffer))))
3358 (switch-to-buffer buf)
3359 ;; We return the window if it has the `point' spec.
3360 (and (memq 'point split) window)))
3361 ;; This is a frame split.
3362 ((eq type 'frame)
3363 (unless gnus-frame-list
3364 (setq gnus-frame-list (list (window-frame
3365 (get-buffer-window (current-buffer))))))
3366 (let ((i 0)
3367 params frame fresult)
3368 (while (< i (length subs))
3369 ;; Frame parameter is gotten from the sub-split.
3370 (setq params (cadr (elt subs i)))
3371 ;; It should be a list.
3372 (unless (listp params)
3373 (setq params nil))
3374 ;; Create a new frame?
3375 (unless (setq frame (elt gnus-frame-list i))
3376 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3377 (push frame gnus-created-frames))
3378 ;; Is the old frame still alive?
3379 (unless (frame-live-p frame)
3380 (setcar (nthcdr i gnus-frame-list)
3381 (setq frame (make-frame params))))
3382 ;; Select the frame in question and do more splits there.
3383 (select-frame frame)
3384 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3385 (incf i))
3386 ;; Select the frame that has the selected buffer.
3387 (when fresult
3388 (select-frame (window-frame fresult)))))
3389 ;; This is a normal split.
3391 (when (> (length subs) 0)
3392 ;; First we have to compute the sizes of all new windows.
3393 (while subs
3394 (setq sub (append (pop subs) nil))
3395 (while (and (not (assq (car sub) gnus-window-to-buffer))
3396 (gnus-functionp (car sub)))
3397 (setq sub (eval sub)))
3398 (when sub
3399 (push sub comp-subs)
3400 (setq size (cadar comp-subs))
3401 (cond ((equal size 1.0)
3402 (setq rest (car comp-subs))
3403 (setq s 0))
3404 ((floatp size)
3405 (setq s (floor (* size len))))
3406 ((integerp size)
3407 (setq s size))
3409 (error "Illegal size: %s" size)))
3410 ;; Try to make sure that we are inside the safe limits.
3411 (cond ((zerop s))
3412 ((eq type 'horizontal)
3413 (setq s (max s window-min-width)))
3414 ((eq type 'vertical)
3415 (setq s (max s window-min-height))))
3416 (setcar (cdar comp-subs) s)
3417 (incf total s)))
3418 ;; Take care of the "1.0" spec.
3419 (if rest
3420 (setcar (cdr rest) (- len total))
3421 (error "No 1.0 specs in %s" split))
3422 ;; The we do the actual splitting in a nice recursive
3423 ;; fashion.
3424 (setq comp-subs (nreverse comp-subs))
3425 (while comp-subs
3426 (if (null (cdr comp-subs))
3427 (setq new-win window)
3428 (setq new-win
3429 (split-window window (cadar comp-subs)
3430 (eq type 'horizontal))))
3431 (setq result (or (gnus-configure-frame
3432 (car comp-subs) window) result))
3433 (select-window new-win)
3434 (setq window new-win)
3435 (setq comp-subs (cdr comp-subs))))
3436 ;; Return the proper window, if any.
3437 (when result
3438 (select-window result))))))
3440 (defvar gnus-frame-split-p nil)
3442 (defun gnus-configure-windows (setting &optional force)
3443 (setq setting (gnus-windows-old-to-new setting))
3444 (let ((split (if (symbolp setting)
3445 (cadr (assq setting gnus-buffer-configuration))
3446 setting))
3447 all-visible)
3449 (setq gnus-frame-split-p nil)
3451 (unless split
3452 (error "No such setting: %s" setting))
3454 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3455 (not force))
3456 ;; All the windows mentioned are already visible, so we just
3457 ;; put point in the assigned buffer, and do not touch the
3458 ;; winconf.
3459 (select-window all-visible)
3461 ;; Either remove all windows or just remove all Gnus windows.
3462 (let ((frame (selected-frame)))
3463 (unwind-protect
3464 (if gnus-use-full-window
3465 ;; We want to remove all other windows.
3466 (if (not gnus-frame-split-p)
3467 ;; This is not a `frame' split, so we ignore the
3468 ;; other frames.
3469 (delete-other-windows)
3470 ;; This is a `frame' split, so we delete all windows
3471 ;; on all frames.
3472 (mapcar
3473 (lambda (frame)
3474 (unless (eq (cdr (assq 'minibuffer
3475 (frame-parameters frame)))
3476 'only)
3477 (select-frame frame)
3478 (delete-other-windows)))
3479 (frame-list)))
3480 ;; Just remove some windows.
3481 (gnus-remove-some-windows)
3482 (switch-to-buffer nntp-server-buffer))
3483 (select-frame frame)))
3485 (switch-to-buffer nntp-server-buffer)
3486 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3488 (defun gnus-all-windows-visible-p (split)
3489 "Say whether all buffers in SPLIT are currently visible.
3490 In particular, the value returned will be the window that
3491 should have point."
3492 (let ((stack (list split))
3493 (all-visible t)
3494 type buffer win buf)
3495 (while (and (setq split (pop stack))
3496 all-visible)
3497 ;; Be backwards compatible.
3498 (when (vectorp split)
3499 (setq split (append split nil)))
3500 (when (or (consp (car split))
3501 (vectorp (car split)))
3502 (push 1.0 split)
3503 (push 'vertical split))
3504 ;; The SPLIT might be something that is to be evaled to
3505 ;; return a new SPLIT.
3506 (while (and (not (assq (car split) gnus-window-to-buffer))
3507 (gnus-functionp (car split)))
3508 (setq split (eval split)))
3510 (setq type (elt split 0))
3511 (cond
3512 ;; Nothing here.
3513 ((null split) t)
3514 ;; A buffer.
3515 ((not (memq type '(horizontal vertical frame)))
3516 (setq buffer (cond ((stringp type) type)
3517 (t (cdr (assq type gnus-window-to-buffer)))))
3518 (unless buffer
3519 (error "Illegal buffer type: %s" type))
3520 (when (setq buf (get-buffer (if (symbolp buffer)
3521 (symbol-value buffer)
3522 buffer)))
3523 (setq win (get-buffer-window buf t)))
3524 (if win
3525 (when (memq 'point split)
3526 (setq all-visible win))
3527 (setq all-visible nil)))
3529 (when (eq type 'frame)
3530 (setq gnus-frame-split-p t))
3531 (setq stack (append (cddr split) stack)))))
3532 (unless (eq all-visible t)
3533 all-visible)))
3535 (defun gnus-window-top-edge (&optional window)
3536 (nth 1 (window-edges window)))
3538 (defun gnus-remove-some-windows ()
3539 (let ((buffers gnus-window-to-buffer)
3540 buf bufs lowest-buf lowest)
3541 (save-excursion
3542 ;; Remove windows on all known Gnus buffers.
3543 (while buffers
3544 (setq buf (cdar buffers))
3545 (if (symbolp buf)
3546 (setq buf (and (boundp buf) (symbol-value buf))))
3547 (and buf
3548 (get-buffer-window buf)
3549 (progn
3550 (setq bufs (cons buf bufs))
3551 (pop-to-buffer buf)
3552 (if (or (not lowest)
3553 (< (gnus-window-top-edge) lowest))
3554 (progn
3555 (setq lowest (gnus-window-top-edge))
3556 (setq lowest-buf buf)))))
3557 (setq buffers (cdr buffers)))
3558 ;; Remove windows on *all* summary buffers.
3559 (walk-windows
3560 (lambda (win)
3561 (let ((buf (window-buffer win)))
3562 (if (string-match "^\\*Summary" (buffer-name buf))
3563 (progn
3564 (setq bufs (cons buf bufs))
3565 (pop-to-buffer buf)
3566 (if (or (not lowest)
3567 (< (gnus-window-top-edge) lowest))
3568 (progn
3569 (setq lowest-buf buf)
3570 (setq lowest (gnus-window-top-edge)))))))))
3571 (and lowest-buf
3572 (progn
3573 (pop-to-buffer lowest-buf)
3574 (switch-to-buffer nntp-server-buffer)))
3575 (while bufs
3576 (and (not (eq (car bufs) lowest-buf))
3577 (delete-windows-on (car bufs)))
3578 (setq bufs (cdr bufs))))))
3580 (defun gnus-version (&optional arg)
3581 "Version number of this version of Gnus.
3582 If ARG, insert string at point."
3583 (interactive "P")
3584 (let ((methods gnus-valid-select-methods)
3585 (mess gnus-version)
3586 meth)
3587 ;; Go through all the legal select methods and add their version
3588 ;; numbers to the total version string. Only the backends that are
3589 ;; currently in use will have their message numbers taken into
3590 ;; consideration.
3591 (while methods
3592 (setq meth (intern (concat (caar methods) "-version")))
3593 (and (boundp meth)
3594 (stringp (symbol-value meth))
3595 (setq mess (concat mess "; " (symbol-value meth))))
3596 (setq methods (cdr methods)))
3597 (if arg
3598 (insert (message mess))
3599 (message mess))))
3601 (defun gnus-info-find-node ()
3602 "Find Info documentation of Gnus."
3603 (interactive)
3604 ;; Enlarge info window if needed.
3605 (let ((mode major-mode)
3606 gnus-info-buffer)
3607 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3608 (setq gnus-info-buffer (current-buffer))
3609 (gnus-configure-windows 'info)))
3611 (defun gnus-days-between (date1 date2)
3612 ;; Return the number of days between date1 and date2.
3613 (- (gnus-day-number date1) (gnus-day-number date2)))
3615 (defun gnus-day-number (date)
3616 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3617 (timezone-parse-date date))))
3618 (timezone-absolute-from-gregorian
3619 (nth 1 dat) (nth 2 dat) (car dat))))
3621 (defun gnus-encode-date (date)
3622 "Convert DATE to internal time."
3623 (let* ((parse (timezone-parse-date date))
3624 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3625 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3626 (encode-time (caddr time) (cadr time) (car time)
3627 (caddr date) (cadr date) (car date) (nth 4 date))))
3629 (defun gnus-time-minus (t1 t2)
3630 "Subtract two internal times."
3631 (let ((borrow (< (cadr t1) (cadr t2))))
3632 (list (- (car t1) (car t2) (if borrow 1 0))
3633 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3635 (defun gnus-file-newer-than (file date)
3636 (let ((fdate (nth 5 (file-attributes file))))
3637 (or (> (car fdate) (car date))
3638 (and (= (car fdate) (car date))
3639 (> (nth 1 fdate) (nth 1 date))))))
3641 (defmacro gnus-local-set-keys (&rest plist)
3642 "Set the keys in PLIST in the current keymap."
3643 `(gnus-define-keys-1 (current-local-map) ',plist))
3645 (defmacro gnus-define-keys (keymap &rest plist)
3646 "Define all keys in PLIST in KEYMAP."
3647 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3649 (put 'gnus-define-keys 'lisp-indent-function 1)
3650 (put 'gnus-define-keys 'lisp-indent-hook 1)
3651 (put 'gnus-define-keymap 'lisp-indent-function 1)
3652 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3654 (defmacro gnus-define-keymap (keymap &rest plist)
3655 "Define all keys in PLIST in KEYMAP."
3656 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3658 (defun gnus-define-keys-1 (keymap plist)
3659 (when (null keymap)
3660 (error "Can't set keys in a null keymap"))
3661 (cond ((symbolp keymap)
3662 (setq keymap (symbol-value keymap)))
3663 ((keymapp keymap))
3664 ((listp keymap)
3665 (set (car keymap) nil)
3666 (define-prefix-command (car keymap))
3667 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3668 (setq keymap (symbol-value (car keymap)))))
3669 (let (key)
3670 (while plist
3671 (when (symbolp (setq key (pop plist)))
3672 (setq key (symbol-value key)))
3673 (define-key keymap key (pop plist)))))
3675 (defun gnus-group-read-only-p (&optional group)
3676 "Check whether GROUP supports editing or not.
3677 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3678 that that variable is buffer-local to the summary buffers."
3679 (let ((group (or group gnus-newsgroup-name)))
3680 (not (gnus-check-backend-function 'request-replace-article group))))
3682 (defun gnus-group-total-expirable-p (group)
3683 "Check whether GROUP is total-expirable or not."
3684 (let ((params (gnus-info-params (gnus-get-info group))))
3685 (or (memq 'total-expire params)
3686 (cdr (assq 'total-expire params)) ; (total-expire . t)
3687 (and gnus-total-expirable-newsgroups ; Check var.
3688 (string-match gnus-total-expirable-newsgroups group)))))
3690 (defun gnus-group-auto-expirable-p (group)
3691 "Check whether GROUP is total-expirable or not."
3692 (let ((params (gnus-info-params (gnus-get-info group))))
3693 (or (memq 'auto-expire params)
3694 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3695 (and gnus-auto-expirable-newsgroups ; Check var.
3696 (string-match gnus-auto-expirable-newsgroups group)))))
3698 (defun gnus-virtual-group-p (group)
3699 "Say whether GROUP is virtual or not."
3700 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3701 gnus-valid-select-methods)))
3703 (defun gnus-news-group-p (group &optional article)
3704 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3705 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3706 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3707 (eq (gnus-request-type group article) 'news))))
3709 (defsubst gnus-simplify-subject-fully (subject)
3710 "Simplify a subject string according to the user's wishes."
3711 (cond
3712 ((null gnus-summary-gather-subject-limit)
3713 (gnus-simplify-subject-re subject))
3714 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3715 (gnus-simplify-subject-fuzzy subject))
3716 ((numberp gnus-summary-gather-subject-limit)
3717 (gnus-limit-string (gnus-simplify-subject-re subject)
3718 gnus-summary-gather-subject-limit))
3720 subject)))
3722 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3723 "Check whether two subjects are equal. If optional argument
3724 simple-first is t, first argument is already simplified."
3725 (cond
3726 ((null simple-first)
3727 (equal (gnus-simplify-subject-fully s1)
3728 (gnus-simplify-subject-fully s2)))
3730 (equal s1
3731 (gnus-simplify-subject-fully s2)))))
3733 ;; Returns a list of writable groups.
3734 (defun gnus-writable-groups ()
3735 (let ((alist gnus-newsrc-alist)
3736 groups group)
3737 (while (setq group (car (pop alist)))
3738 (unless (gnus-group-read-only-p group)
3739 (push group groups)))
3740 (nreverse groups)))
3742 (defun gnus-completing-read (default prompt &rest args)
3743 ;; Like `completing-read', except that DEFAULT is the default argument.
3744 (let* ((prompt (if default
3745 (concat prompt " (default " default ") ")
3746 (concat prompt " ")))
3747 (answer (apply 'completing-read prompt args)))
3748 (if (or (null answer) (zerop (length answer)))
3749 default
3750 answer)))
3752 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3753 ;; the echo area.
3754 (defun gnus-y-or-n-p (prompt)
3755 (prog1
3756 (y-or-n-p prompt)
3757 (message "")))
3759 (defun gnus-yes-or-no-p (prompt)
3760 (prog1
3761 (yes-or-no-p prompt)
3762 (message "")))
3764 ;; Check whether to use long file names.
3765 (defun gnus-use-long-file-name (symbol)
3766 ;; The variable has to be set...
3767 (and gnus-use-long-file-name
3768 ;; If it isn't a list, then we return t.
3769 (or (not (listp gnus-use-long-file-name))
3770 ;; If it is a list, and the list contains `symbol', we
3771 ;; return nil.
3772 (not (memq symbol gnus-use-long-file-name)))))
3774 ;; I suspect there's a better way, but I haven't taken the time to do
3775 ;; it yet. -erik selberg@cs.washington.edu
3776 (defun gnus-dd-mmm (messy-date)
3777 "Return a string like DD-MMM from a big messy string"
3778 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3779 (error nil))))
3780 (if (not datevec)
3781 "??-???"
3782 (format "%2s-%s"
3783 (condition-case ()
3784 ;; Make sure leading zeroes are stripped.
3785 (number-to-string (string-to-number (aref datevec 2)))
3786 (error "??"))
3787 (capitalize
3788 (or (car
3789 (nth (1- (string-to-number (aref datevec 1)))
3790 timezone-months-assoc))
3791 "???"))))))
3793 (defun gnus-mode-string-quote (string)
3794 "Quote all \"%\" in STRING."
3795 (save-excursion
3796 (gnus-set-work-buffer)
3797 (insert string)
3798 (goto-char (point-min))
3799 (while (search-forward "%" nil t)
3800 (insert "%"))
3801 (buffer-string)))
3803 ;; Make a hash table (default and minimum size is 255).
3804 ;; Optional argument HASHSIZE specifies the table size.
3805 (defun gnus-make-hashtable (&optional hashsize)
3806 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3808 ;; Make a number that is suitable for hashing; bigger than MIN and one
3809 ;; less than 2^x.
3810 (defun gnus-create-hash-size (min)
3811 (let ((i 1))
3812 (while (< i min)
3813 (setq i (* 2 i)))
3814 (1- i)))
3816 ;; Show message if message has a lower level than `gnus-verbose'.
3817 ;; Guideline for numbers:
3818 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3819 ;; for things that take a long time, 7 - not very important messages
3820 ;; on stuff, 9 - messages inside loops.
3821 (defun gnus-message (level &rest args)
3822 (if (<= level gnus-verbose)
3823 (apply 'message args)
3824 ;; We have to do this format thingy here even if the result isn't
3825 ;; shown - the return value has to be the same as the return value
3826 ;; from `message'.
3827 (apply 'format args)))
3829 (defun gnus-error (level &rest args)
3830 "Beep an error if LEVEL is equal to or less than `gnus-verbose'."
3831 (when (<= (floor level) gnus-verbose)
3832 (apply 'message args)
3833 (ding)
3834 (let (duration)
3835 (when (and (floatp level)
3836 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3837 (sit-for duration))))
3838 nil)
3840 ;; Generate a unique new group name.
3841 (defun gnus-generate-new-group-name (leaf)
3842 (let ((name leaf)
3843 (num 0))
3844 (while (gnus-gethash name gnus-newsrc-hashtb)
3845 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3846 name))
3848 (defsubst gnus-hide-text (b e props)
3849 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3850 (gnus-add-text-properties b e props)
3851 (when (memq 'intangible props)
3852 (gnus-put-text-property (max (1- b) (point-min))
3853 b 'intangible (cddr (memq 'intangible props)))))
3855 (defsubst gnus-unhide-text (b e)
3856 "Remove hidden text properties from region between B and E."
3857 (remove-text-properties b e gnus-hidden-properties)
3858 (when (memq 'intangible gnus-hidden-properties)
3859 (gnus-put-text-property (max (1- b) (point-min))
3860 b 'intangible nil)))
3862 (defun gnus-hide-text-type (b e type)
3863 "Hide text of TYPE between B and E."
3864 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3866 (defun gnus-parent-headers (headers &optional generation)
3867 "Return the headers of the GENERATIONeth parent of HEADERS."
3868 (unless generation
3869 (setq generation 1))
3870 (let (references parent)
3871 (while (and headers (not (zerop generation)))
3872 (setq references (mail-header-references headers))
3873 (when (and references
3874 (setq parent (gnus-parent-id references))
3875 (setq headers (car (gnus-id-to-thread parent))))
3876 (decf generation)))
3877 headers))
3879 (defun gnus-parent-id (references)
3880 "Return the last Message-ID in REFERENCES."
3881 (when (and references
3882 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3883 (substring references (match-beginning 1) (match-end 1))))
3885 (defun gnus-split-references (references)
3886 "Return a list of Message-IDs in REFERENCES."
3887 (let ((beg 0)
3888 ids)
3889 (while (string-match "<[^>]+>" references beg)
3890 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3891 ids))
3892 (nreverse ids)))
3894 (defun gnus-buffer-live-p (buffer)
3895 "Say whether BUFFER is alive or not."
3896 (and buffer
3897 (get-buffer buffer)
3898 (buffer-name (get-buffer buffer))))
3900 (defun gnus-ephemeral-group-p (group)
3901 "Say whether GROUP is ephemeral or not."
3902 (gnus-group-get-parameter group 'quit-config))
3904 (defun gnus-group-quit-config (group)
3905 "Return the quit-config of GROUP."
3906 (gnus-group-get-parameter group 'quit-config))
3908 (defun gnus-simplify-mode-line ()
3909 "Make mode lines a bit simpler."
3910 (setq mode-line-modified "-- ")
3911 (when (listp mode-line-format)
3912 (make-local-variable 'mode-line-format)
3913 (setq mode-line-format (copy-sequence mode-line-format))
3914 (when (equal (nth 3 mode-line-format) " ")
3915 (setcar (nthcdr 3 mode-line-format) " "))))
3917 ;;; List and range functions
3919 (defun gnus-last-element (list)
3920 "Return last element of LIST."
3921 (while (cdr list)
3922 (setq list (cdr list)))
3923 (car list))
3925 (defun gnus-copy-sequence (list)
3926 "Do a complete, total copy of a list."
3927 (if (and (consp list) (not (consp (cdr list))))
3928 (cons (car list) (cdr list))
3929 (mapcar (lambda (elem) (if (consp elem)
3930 (if (consp (cdr elem))
3931 (gnus-copy-sequence elem)
3932 (cons (car elem) (cdr elem)))
3933 elem))
3934 list)))
3936 (defun gnus-set-difference (list1 list2)
3937 "Return a list of elements of LIST1 that do not appear in LIST2."
3938 (let ((list1 (copy-sequence list1)))
3939 (while list2
3940 (setq list1 (delq (car list2) list1))
3941 (setq list2 (cdr list2)))
3942 list1))
3944 (defun gnus-sorted-complement (list1 list2)
3945 "Return a list of elements of LIST1 that do not appear in LIST2.
3946 Both lists have to be sorted over <."
3947 (let (out)
3948 (if (or (null list1) (null list2))
3949 (or list1 list2)
3950 (while (and list1 list2)
3951 (cond ((= (car list1) (car list2))
3952 (setq list1 (cdr list1)
3953 list2 (cdr list2)))
3954 ((< (car list1) (car list2))
3955 (setq out (cons (car list1) out))
3956 (setq list1 (cdr list1)))
3958 (setq out (cons (car list2) out))
3959 (setq list2 (cdr list2)))))
3960 (nconc (nreverse out) (or list1 list2)))))
3962 (defun gnus-intersection (list1 list2)
3963 (let ((result nil))
3964 (while list2
3965 (if (memq (car list2) list1)
3966 (setq result (cons (car list2) result)))
3967 (setq list2 (cdr list2)))
3968 result))
3970 (defun gnus-sorted-intersection (list1 list2)
3971 ;; LIST1 and LIST2 have to be sorted over <.
3972 (let (out)
3973 (while (and list1 list2)
3974 (cond ((= (car list1) (car list2))
3975 (setq out (cons (car list1) out)
3976 list1 (cdr list1)
3977 list2 (cdr list2)))
3978 ((< (car list1) (car list2))
3979 (setq list1 (cdr list1)))
3981 (setq list2 (cdr list2)))))
3982 (nreverse out)))
3984 (defun gnus-set-sorted-intersection (list1 list2)
3985 ;; LIST1 and LIST2 have to be sorted over <.
3986 ;; This function modifies LIST1.
3987 (let* ((top (cons nil list1))
3988 (prev top))
3989 (while (and list1 list2)
3990 (cond ((= (car list1) (car list2))
3991 (setq prev list1
3992 list1 (cdr list1)
3993 list2 (cdr list2)))
3994 ((< (car list1) (car list2))
3995 (setcdr prev (cdr list1))
3996 (setq list1 (cdr list1)))
3998 (setq list2 (cdr list2)))))
3999 (setcdr prev nil)
4000 (cdr top)))
4002 (defun gnus-compress-sequence (numbers &optional always-list)
4003 "Convert list of numbers to a list of ranges or a single range.
4004 If ALWAYS-LIST is non-nil, this function will always release a list of
4005 ranges."
4006 (let* ((first (car numbers))
4007 (last (car numbers))
4008 result)
4009 (if (null numbers)
4011 (if (not (listp (cdr numbers)))
4012 numbers
4013 (while numbers
4014 (cond ((= last (car numbers)) nil) ;Omit duplicated number
4015 ((= (1+ last) (car numbers)) ;Still in sequence
4016 (setq last (car numbers)))
4017 (t ;End of one sequence
4018 (setq result
4019 (cons (if (= first last) first
4020 (cons first last)) result))
4021 (setq first (car numbers))
4022 (setq last (car numbers))))
4023 (setq numbers (cdr numbers)))
4024 (if (and (not always-list) (null result))
4025 (if (= first last) (list first) (cons first last))
4026 (nreverse (cons (if (= first last) first (cons first last))
4027 result)))))))
4029 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
4030 (defun gnus-uncompress-range (ranges)
4031 "Expand a list of ranges into a list of numbers.
4032 RANGES is either a single range on the form `(num . num)' or a list of
4033 these ranges."
4034 (let (first last result)
4035 (cond
4036 ((null ranges)
4037 nil)
4038 ((not (listp (cdr ranges)))
4039 (setq first (car ranges))
4040 (setq last (cdr ranges))
4041 (while (<= first last)
4042 (setq result (cons first result))
4043 (setq first (1+ first)))
4044 (nreverse result))
4046 (while ranges
4047 (if (atom (car ranges))
4048 (if (numberp (car ranges))
4049 (setq result (cons (car ranges) result)))
4050 (setq first (caar ranges))
4051 (setq last (cdar ranges))
4052 (while (<= first last)
4053 (setq result (cons first result))
4054 (setq first (1+ first))))
4055 (setq ranges (cdr ranges)))
4056 (nreverse result)))))
4058 (defun gnus-add-to-range (ranges list)
4059 "Return a list of ranges that has all articles from both RANGES and LIST.
4060 Note: LIST has to be sorted over `<'."
4061 (if (not ranges)
4062 (gnus-compress-sequence list t)
4063 (setq list (copy-sequence list))
4064 (or (listp (cdr ranges))
4065 (setq ranges (list ranges)))
4066 (let ((out ranges)
4067 ilist lowest highest temp)
4068 (while (and ranges list)
4069 (setq ilist list)
4070 (setq lowest (or (and (atom (car ranges)) (car ranges))
4071 (caar ranges)))
4072 (while (and list (cdr list) (< (cadr list) lowest))
4073 (setq list (cdr list)))
4074 (if (< (car ilist) lowest)
4075 (progn
4076 (setq temp list)
4077 (setq list (cdr list))
4078 (setcdr temp nil)
4079 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4080 (setq highest (or (and (atom (car ranges)) (car ranges))
4081 (cdar ranges)))
4082 (while (and list (<= (car list) highest))
4083 (setq list (cdr list)))
4084 (setq ranges (cdr ranges)))
4085 (if list
4086 (setq out (nconc (gnus-compress-sequence list t) out)))
4087 (setq out (sort out (lambda (r1 r2)
4088 (< (or (and (atom r1) r1) (car r1))
4089 (or (and (atom r2) r2) (car r2))))))
4090 (setq ranges out)
4091 (while ranges
4092 (if (atom (car ranges))
4093 (if (cdr ranges)
4094 (if (atom (cadr ranges))
4095 (if (= (1+ (car ranges)) (cadr ranges))
4096 (progn
4097 (setcar ranges (cons (car ranges)
4098 (cadr ranges)))
4099 (setcdr ranges (cddr ranges))))
4100 (if (= (1+ (car ranges)) (caadr ranges))
4101 (progn
4102 (setcar (cadr ranges) (car ranges))
4103 (setcar ranges (cadr ranges))
4104 (setcdr ranges (cddr ranges))))))
4105 (if (cdr ranges)
4106 (if (atom (cadr ranges))
4107 (if (= (1+ (cdar ranges)) (cadr ranges))
4108 (progn
4109 (setcdr (car ranges) (cadr ranges))
4110 (setcdr ranges (cddr ranges))))
4111 (if (= (1+ (cdar ranges)) (caadr ranges))
4112 (progn
4113 (setcdr (car ranges) (cdadr ranges))
4114 (setcdr ranges (cddr ranges)))))))
4115 (setq ranges (cdr ranges)))
4116 out)))
4118 (defun gnus-remove-from-range (ranges list)
4119 "Return a list of ranges that has all articles from LIST removed from RANGES.
4120 Note: LIST has to be sorted over `<'."
4121 ;; !!! This function shouldn't look like this, but I've got a headache.
4122 (gnus-compress-sequence
4123 (gnus-sorted-complement
4124 (gnus-uncompress-range ranges) list)))
4126 (defun gnus-member-of-range (number ranges)
4127 (if (not (listp (cdr ranges)))
4128 (and (>= number (car ranges))
4129 (<= number (cdr ranges)))
4130 (let ((not-stop t))
4131 (while (and ranges
4132 (if (numberp (car ranges))
4133 (>= number (car ranges))
4134 (>= number (caar ranges)))
4135 not-stop)
4136 (if (if (numberp (car ranges))
4137 (= number (car ranges))
4138 (and (>= number (caar ranges))
4139 (<= number (cdar ranges))))
4140 (setq not-stop nil))
4141 (setq ranges (cdr ranges)))
4142 (not not-stop))))
4144 (defun gnus-range-length (range)
4145 "Return the length RANGE would have if uncompressed."
4146 (length (gnus-uncompress-range range)))
4148 (defun gnus-sublist-p (list sublist)
4149 "Test whether all elements in SUBLIST are members of LIST."
4150 (let ((sublistp t))
4151 (while sublist
4152 (unless (memq (pop sublist) list)
4153 (setq sublistp nil
4154 sublist nil)))
4155 sublistp))
4159 ;;; Gnus group mode
4162 (defvar gnus-group-mode-map nil)
4163 (put 'gnus-group-mode 'mode-class 'special)
4165 (unless gnus-group-mode-map
4166 (setq gnus-group-mode-map (make-keymap))
4167 (suppress-keymap gnus-group-mode-map)
4169 (gnus-define-keys gnus-group-mode-map
4170 " " gnus-group-read-group
4171 "=" gnus-group-select-group
4172 "\r" gnus-group-select-group
4173 "\M-\r" gnus-group-quick-select-group
4174 "j" gnus-group-jump-to-group
4175 "n" gnus-group-next-unread-group
4176 "p" gnus-group-prev-unread-group
4177 "\177" gnus-group-prev-unread-group
4178 [delete] gnus-group-prev-unread-group
4179 "N" gnus-group-next-group
4180 "P" gnus-group-prev-group
4181 "\M-n" gnus-group-next-unread-group-same-level
4182 "\M-p" gnus-group-prev-unread-group-same-level
4183 "," gnus-group-best-unread-group
4184 "." gnus-group-first-unread-group
4185 "u" gnus-group-unsubscribe-current-group
4186 "U" gnus-group-unsubscribe-group
4187 "c" gnus-group-catchup-current
4188 "C" gnus-group-catchup-current-all
4189 "l" gnus-group-list-groups
4190 "L" gnus-group-list-all-groups
4191 "m" gnus-group-mail
4192 "g" gnus-group-get-new-news
4193 "\M-g" gnus-group-get-new-news-this-group
4194 "R" gnus-group-restart
4195 "r" gnus-group-read-init-file
4196 "B" gnus-group-browse-foreign-server
4197 "b" gnus-group-check-bogus-groups
4198 "F" gnus-find-new-newsgroups
4199 "\C-c\C-d" gnus-group-describe-group
4200 "\M-d" gnus-group-describe-all-groups
4201 "\C-c\C-a" gnus-group-apropos
4202 "\C-c\M-\C-a" gnus-group-description-apropos
4203 "a" gnus-group-post-news
4204 "\ek" gnus-group-edit-local-kill
4205 "\eK" gnus-group-edit-global-kill
4206 "\C-k" gnus-group-kill-group
4207 "\C-y" gnus-group-yank-group
4208 "\C-w" gnus-group-kill-region
4209 "\C-x\C-t" gnus-group-transpose-groups
4210 "\C-c\C-l" gnus-group-list-killed
4211 "\C-c\C-x" gnus-group-expire-articles
4212 "\C-c\M-\C-x" gnus-group-expire-all-groups
4213 "V" gnus-version
4214 "s" gnus-group-save-newsrc
4215 "z" gnus-group-suspend
4216 ; "Z" gnus-group-clear-dribble
4217 "q" gnus-group-exit
4218 "Q" gnus-group-quit
4219 "?" gnus-group-describe-briefly
4220 "\C-c\C-i" gnus-info-find-node
4221 "\M-e" gnus-group-edit-group-method
4222 "^" gnus-group-enter-server-mode
4223 gnus-mouse-2 gnus-mouse-pick-group
4224 "<" beginning-of-buffer
4225 ">" end-of-buffer
4226 "\C-c\C-b" gnus-bug
4227 "\C-c\C-s" gnus-group-sort-groups
4228 "t" gnus-topic-mode
4229 "\C-c\M-g" gnus-activate-all-groups
4230 "\M-&" gnus-group-universal-argument
4231 "#" gnus-group-mark-group
4232 "\M-#" gnus-group-unmark-group)
4234 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4235 "m" gnus-group-mark-group
4236 "u" gnus-group-unmark-group
4237 "w" gnus-group-mark-region
4238 "m" gnus-group-mark-buffer
4239 "r" gnus-group-mark-regexp
4240 "U" gnus-group-unmark-all-groups)
4242 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4243 "d" gnus-group-make-directory-group
4244 "h" gnus-group-make-help-group
4245 "a" gnus-group-make-archive-group
4246 "k" gnus-group-make-kiboze-group
4247 "m" gnus-group-make-group
4248 "E" gnus-group-edit-group
4249 "e" gnus-group-edit-group-method
4250 "p" gnus-group-edit-group-parameters
4251 "v" gnus-group-add-to-virtual
4252 "V" gnus-group-make-empty-virtual
4253 "D" gnus-group-enter-directory
4254 "f" gnus-group-make-doc-group
4255 "r" gnus-group-rename-group
4256 "\177" gnus-group-delete-group
4257 [delete] gnus-group-delete-group)
4259 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4260 "b" gnus-group-brew-soup
4261 "w" gnus-soup-save-areas
4262 "s" gnus-soup-send-replies
4263 "p" gnus-soup-pack-packet
4264 "r" nnsoup-pack-replies)
4266 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4267 "s" gnus-group-sort-groups
4268 "a" gnus-group-sort-groups-by-alphabet
4269 "u" gnus-group-sort-groups-by-unread
4270 "l" gnus-group-sort-groups-by-level
4271 "v" gnus-group-sort-groups-by-score
4272 "r" gnus-group-sort-groups-by-rank
4273 "m" gnus-group-sort-groups-by-method)
4275 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4276 "k" gnus-group-list-killed
4277 "z" gnus-group-list-zombies
4278 "s" gnus-group-list-groups
4279 "u" gnus-group-list-all-groups
4280 "A" gnus-group-list-active
4281 "a" gnus-group-apropos
4282 "d" gnus-group-description-apropos
4283 "m" gnus-group-list-matching
4284 "M" gnus-group-list-all-matching
4285 "l" gnus-group-list-level)
4287 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4288 "f" gnus-score-flush-cache)
4290 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4291 "f" gnus-group-fetch-faq)
4293 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4294 "l" gnus-group-set-current-level
4295 "t" gnus-group-unsubscribe-current-group
4296 "s" gnus-group-unsubscribe-group
4297 "k" gnus-group-kill-group
4298 "y" gnus-group-yank-group
4299 "w" gnus-group-kill-region
4300 "\C-k" gnus-group-kill-level
4301 "z" gnus-group-kill-all-zombies))
4303 (defun gnus-group-mode ()
4304 "Major mode for reading news.
4306 All normal editing commands are switched off.
4307 \\<gnus-group-mode-map>
4308 The group buffer lists (some of) the groups available. For instance,
4309 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4310 lists all zombie groups.
4312 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4313 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4315 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4317 The following commands are available:
4319 \\{gnus-group-mode-map}"
4320 (interactive)
4321 (when (and menu-bar-mode
4322 (gnus-visual-p 'group-menu 'menu))
4323 (gnus-group-make-menu-bar))
4324 (kill-all-local-variables)
4325 (gnus-simplify-mode-line)
4326 (setq major-mode 'gnus-group-mode)
4327 (setq mode-name "Group")
4328 (gnus-group-set-mode-line)
4329 (setq mode-line-process nil)
4330 (use-local-map gnus-group-mode-map)
4331 (buffer-disable-undo (current-buffer))
4332 (setq truncate-lines t)
4333 (setq buffer-read-only t)
4334 (gnus-make-local-hook 'post-command-hook)
4335 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4336 (run-hooks 'gnus-group-mode-hook))
4338 (defun gnus-clear-inboxes-moved ()
4339 (setq nnmail-moved-inboxes nil))
4341 (defun gnus-mouse-pick-group (e)
4342 "Enter the group under the mouse pointer."
4343 (interactive "e")
4344 (mouse-set-point e)
4345 (gnus-group-read-group nil))
4347 ;; Look at LEVEL and find out what the level is really supposed to be.
4348 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4349 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4350 (defun gnus-group-default-level (&optional level number-or-nil)
4351 (cond
4352 (gnus-group-use-permanent-levels
4353 (or (setq gnus-group-use-permanent-levels
4354 (or level (if (numberp gnus-group-use-permanent-levels)
4355 gnus-group-use-permanent-levels
4356 (or gnus-group-default-list-level
4357 gnus-level-subscribed))))
4358 gnus-group-default-list-level gnus-level-subscribed))
4359 (number-or-nil
4360 level)
4362 (or level gnus-group-default-list-level gnus-level-subscribed))))
4364 ;;;###autoload
4365 (defun gnus-slave-no-server (&optional arg)
4366 "Read network news as a slave, without connecting to local server"
4367 (interactive "P")
4368 (gnus-no-server arg t))
4370 ;;;###autoload
4371 (defun gnus-no-server (&optional arg slave)
4372 "Read network news.
4373 If ARG is a positive number, Gnus will use that as the
4374 startup level. If ARG is nil, Gnus will be started at level 2.
4375 If ARG is non-nil and not a positive number, Gnus will
4376 prompt the user for the name of an NNTP server to use.
4377 As opposed to `gnus', this command will not connect to the local server."
4378 (interactive "P")
4379 (let ((val (or arg (1- gnus-level-default-subscribed))))
4380 (gnus val t slave)
4381 (make-local-variable 'gnus-group-use-permanent-levels)
4382 (setq gnus-group-use-permanent-levels val)))
4384 ;;;###autoload
4385 (defun gnus-slave (&optional arg)
4386 "Read news as a slave."
4387 (interactive "P")
4388 (gnus arg nil 'slave))
4390 ;;;###autoload
4391 (defun gnus-other-frame (&optional arg)
4392 "Pop up a frame to read news."
4393 (interactive "P")
4394 (if (get-buffer gnus-group-buffer)
4395 (let ((pop-up-frames t))
4396 (gnus arg))
4397 (select-frame (make-frame))
4398 (gnus arg)))
4400 ;;;###autoload
4401 (defun gnus (&optional arg dont-connect slave)
4402 "Read network news.
4403 If ARG is non-nil and a positive number, Gnus will use that as the
4404 startup level. If ARG is non-nil and not a positive number, Gnus will
4405 prompt the user for the name of an NNTP server to use."
4406 (interactive "P")
4408 (if (get-buffer gnus-group-buffer)
4409 (progn
4410 (switch-to-buffer gnus-group-buffer)
4411 (gnus-group-get-new-news))
4413 (gnus-clear-system)
4414 (nnheader-init-server-buffer)
4415 (gnus-read-init-file)
4416 (setq gnus-slave slave)
4418 (gnus-group-setup-buffer)
4419 (let ((buffer-read-only nil))
4420 (erase-buffer)
4421 (if (not gnus-inhibit-startup-message)
4422 (progn
4423 (gnus-group-startup-message)
4424 (sit-for 0))))
4426 (let ((level (and (numberp arg) (> arg 0) arg))
4427 did-connect)
4428 (unwind-protect
4429 (progn
4430 (or dont-connect
4431 (setq did-connect
4432 (gnus-start-news-server (and arg (not level))))))
4433 (if (and (not dont-connect)
4434 (not did-connect))
4435 (gnus-group-quit)
4436 (run-hooks 'gnus-startup-hook)
4437 ;; NNTP server is successfully open.
4439 ;; Find the current startup file name.
4440 (setq gnus-current-startup-file
4441 (gnus-make-newsrc-file gnus-startup-file))
4443 ;; Read the dribble file.
4444 (when (or gnus-slave gnus-use-dribble-file)
4445 (gnus-dribble-read-file))
4447 ;; Allow using GroupLens predictions.
4448 (when gnus-use-grouplens
4449 (bbb-login)
4450 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4452 (gnus-summary-make-display-table)
4453 ;; Do the actual startup.
4454 (gnus-setup-news nil level dont-connect)
4455 ;; Generate the group buffer.
4456 (gnus-group-list-groups level)
4457 (gnus-group-first-unread-group)
4458 (gnus-configure-windows 'group)
4459 (gnus-group-set-mode-line))))))
4461 (defun gnus-unload ()
4462 "Unload all Gnus features."
4463 (interactive)
4464 (or (boundp 'load-history)
4465 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4466 (let ((history load-history)
4467 feature)
4468 (while history
4469 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4470 (setq feature (cdr (assq 'provide (car history))))
4471 (unload-feature feature 'force))
4472 (setq history (cdr history)))))
4474 (defun gnus-compile ()
4475 "Byte-compile the user-defined format specs."
4476 (interactive)
4477 (let ((entries gnus-format-specs)
4478 entry gnus-tmp-func)
4479 (save-excursion
4480 (gnus-message 7 "Compiling format specs...")
4482 (while entries
4483 (setq entry (pop entries))
4484 (if (eq (car entry) 'version)
4485 (setq gnus-format-specs (delq entry gnus-format-specs))
4486 (when (and (listp (caddr entry))
4487 (not (eq 'byte-code (caaddr entry))))
4488 (fset 'gnus-tmp-func
4489 `(lambda () ,(caddr entry)))
4490 (byte-compile 'gnus-tmp-func)
4491 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4493 (push (cons 'version emacs-version) gnus-format-specs)
4495 (gnus-message 7 "Compiling user specs...done"))))
4497 (defun gnus-indent-rigidly (start end arg)
4498 "Indent rigidly using only spaces and no tabs."
4499 (save-excursion
4500 (save-restriction
4501 (narrow-to-region start end)
4502 (indent-rigidly start end arg)
4503 (goto-char (point-min))
4504 (while (search-forward "\t" nil t)
4505 (replace-match " " t t)))))
4507 (defun gnus-group-startup-message (&optional x y)
4508 "Insert startup message in current buffer."
4509 ;; Insert the message.
4510 (erase-buffer)
4511 (insert
4512 (format " %s
4513 _ ___ _ _
4514 _ ___ __ ___ __ _ ___
4515 __ _ ___ __ ___
4516 _ ___ _
4517 _ _ __ _
4518 ___ __ _
4519 __ _
4520 _ _ _
4521 _ _ _
4522 _ _ _
4523 __ ___
4524 _ _ _ _
4532 ""))
4533 ;; And then hack it.
4534 (gnus-indent-rigidly (point-min) (point-max)
4535 (/ (max (- (window-width) (or x 46)) 0) 2))
4536 (goto-char (point-min))
4537 (forward-line 1)
4538 (let* ((pheight (count-lines (point-min) (point-max)))
4539 (wheight (window-height))
4540 (rest (- wheight pheight)))
4541 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4542 ;; Fontify some.
4543 (goto-char (point-min))
4544 (and (search-forward "Praxis" nil t)
4545 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4546 (goto-char (point-min))
4547 (let* ((mode-string (gnus-group-set-mode-line)))
4548 (setq mode-line-buffer-identification
4549 (list (concat gnus-version (substring (car mode-string) 4))))
4550 (set-buffer-modified-p t)))
4552 (defun gnus-group-setup-buffer ()
4553 (or (get-buffer gnus-group-buffer)
4554 (progn
4555 (switch-to-buffer gnus-group-buffer)
4556 (gnus-add-current-to-buffer-list)
4557 (gnus-group-mode)
4558 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4560 (defun gnus-group-list-groups (&optional level unread lowest)
4561 "List newsgroups with level LEVEL or lower that have unread articles.
4562 Default is all subscribed groups.
4563 If argument UNREAD is non-nil, groups with no unread articles are also
4564 listed."
4565 (interactive (list (if current-prefix-arg
4566 (prefix-numeric-value current-prefix-arg)
4568 (gnus-group-default-level nil t)
4569 gnus-group-default-list-level
4570 gnus-level-subscribed))))
4571 (or level
4572 (setq level (car gnus-group-list-mode)
4573 unread (cdr gnus-group-list-mode)))
4574 (setq level (gnus-group-default-level level))
4575 (gnus-group-setup-buffer) ;May call from out of group buffer
4576 (gnus-update-format-specifications)
4577 (let ((case-fold-search nil)
4578 (props (text-properties-at (gnus-point-at-bol)))
4579 (group (gnus-group-group-name)))
4580 (set-buffer gnus-group-buffer)
4581 (funcall gnus-group-prepare-function level unread lowest)
4582 (if (zerop (buffer-size))
4583 (gnus-message 5 gnus-no-groups-message)
4584 (goto-char (point-max))
4585 (when (or (not gnus-group-goto-next-group-function)
4586 (not (funcall gnus-group-goto-next-group-function
4587 group props)))
4588 (if (not group)
4589 ;; Go to the first group with unread articles.
4590 (gnus-group-search-forward t)
4591 ;; Find the right group to put point on. If the current group
4592 ;; has disappeared in the new listing, try to find the next
4593 ;; one. If no next one can be found, just leave point at the
4594 ;; first newsgroup in the buffer.
4595 (if (not (gnus-goto-char
4596 (text-property-any
4597 (point-min) (point-max)
4598 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4599 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4600 (while (and newsrc
4601 (not (gnus-goto-char
4602 (text-property-any
4603 (point-min) (point-max) 'gnus-group
4604 (gnus-intern-safe
4605 (caar newsrc) gnus-active-hashtb)))))
4606 (setq newsrc (cdr newsrc)))
4607 (or newsrc (progn (goto-char (point-max))
4608 (forward-line -1)))))))
4609 ;; Adjust cursor point.
4610 (gnus-group-position-point))))
4612 (defun gnus-group-list-level (level &optional all)
4613 "List groups on LEVEL.
4614 If ALL (the prefix), also list groups that have no unread articles."
4615 (interactive "nList groups on level: \nP")
4616 (gnus-group-list-groups level all level))
4618 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4619 "List all newsgroups with unread articles of level LEVEL or lower.
4620 If ALL is non-nil, list groups that have no unread articles.
4621 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4622 If REGEXP, only list groups matching REGEXP."
4623 (set-buffer gnus-group-buffer)
4624 (let ((buffer-read-only nil)
4625 (newsrc (cdr gnus-newsrc-alist))
4626 (lowest (or lowest 1))
4627 info clevel unread group params)
4628 (erase-buffer)
4629 (if (< lowest gnus-level-zombie)
4630 ;; List living groups.
4631 (while newsrc
4632 (setq info (car newsrc)
4633 group (gnus-info-group info)
4634 params (gnus-info-params info)
4635 newsrc (cdr newsrc)
4636 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4637 (and unread ; This group might be bogus
4638 (or (not regexp)
4639 (string-match regexp group))
4640 (<= (setq clevel (gnus-info-level info)) level)
4641 (>= clevel lowest)
4642 (or all ; We list all groups?
4643 (if (eq unread t) ; Unactivated?
4644 gnus-group-list-inactive-groups ; We list unactivated
4645 (> unread 0)) ; We list groups with unread articles
4646 (and gnus-list-groups-with-ticked-articles
4647 (cdr (assq 'tick (gnus-info-marks info))))
4648 ; And groups with tickeds
4649 ;; Check for permanent visibility.
4650 (and gnus-permanently-visible-groups
4651 (string-match gnus-permanently-visible-groups
4652 group))
4653 (memq 'visible params)
4654 (cdr (assq 'visible params)))
4655 (gnus-group-insert-group-line
4656 group (gnus-info-level info)
4657 (gnus-info-marks info) unread (gnus-info-method info)))))
4659 ;; List dead groups.
4660 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4661 (gnus-group-prepare-flat-list-dead
4662 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4663 gnus-level-zombie ?Z
4664 regexp))
4665 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4666 (gnus-group-prepare-flat-list-dead
4667 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4668 gnus-level-killed ?K regexp))
4670 (gnus-group-set-mode-line)
4671 (setq gnus-group-list-mode (cons level all))
4672 (run-hooks 'gnus-group-prepare-hook)))
4674 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4675 ;; List zombies and killed lists somewhat faster, which was
4676 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4677 ;; this by ignoring the group format specification altogether.
4678 (let (group)
4679 (if regexp
4680 ;; This loop is used when listing groups that match some
4681 ;; regexp.
4682 (while groups
4683 (setq group (pop groups))
4684 (when (string-match regexp group)
4685 (gnus-add-text-properties
4686 (point) (prog1 (1+ (point))
4687 (insert " " mark " *: " group "\n"))
4688 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4689 'gnus-unread t
4690 'gnus-level level))))
4691 ;; This loop is used when listing all groups.
4692 (while groups
4693 (gnus-add-text-properties
4694 (point) (prog1 (1+ (point))
4695 (insert " " mark " *: "
4696 (setq group (pop groups)) "\n"))
4697 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4698 'gnus-unread t
4699 'gnus-level level))))))
4701 (defmacro gnus-group-real-name (group)
4702 "Find the real name of a foreign newsgroup."
4703 `(let ((gname ,group))
4704 (if (string-match ":[^:]+$" gname)
4705 (substring gname (1+ (match-beginning 0)))
4706 gname)))
4708 (defsubst gnus-server-add-address (method)
4709 (let ((method-name (symbol-name (car method))))
4710 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4711 (not (assq (intern (concat method-name "-address")) method)))
4712 (append method (list (list (intern (concat method-name "-address"))
4713 (nth 1 method))))
4714 method)))
4716 (defsubst gnus-server-get-method (group method)
4717 ;; Input either a server name, and extended server name, or a
4718 ;; select method, and return a select method.
4719 (cond ((stringp method)
4720 (gnus-server-to-method method))
4721 ((equal method gnus-select-method)
4722 gnus-select-method)
4723 ((and (stringp (car method)) group)
4724 (gnus-server-extend-method group method))
4725 ((and method (not group)
4726 (equal (cadr method) ""))
4727 method)
4729 (gnus-server-add-address method))))
4731 (defun gnus-server-to-method (server)
4732 "Map virtual server names to select methods."
4733 (or
4734 ;; Is this a method, perhaps?
4735 (and server (listp server) server)
4736 ;; Perhaps this is the native server?
4737 (and (equal server "native") gnus-select-method)
4738 ;; It should be in the server alist.
4739 (cdr (assoc server gnus-server-alist))
4740 ;; If not, we look through all the opened server
4741 ;; to see whether we can find it there.
4742 (let ((opened gnus-opened-servers))
4743 (while (and opened
4744 (not (equal server (format "%s:%s" (caaar opened)
4745 (cadaar opened)))))
4746 (pop opened))
4747 (caar opened))))
4749 (defmacro gnus-method-equal (ss1 ss2)
4750 "Say whether two servers are equal."
4751 `(let ((s1 ,ss1)
4752 (s2 ,ss2))
4753 (or (equal s1 s2)
4754 (and (= (length s1) (length s2))
4755 (progn
4756 (while (and s1 (member (car s1) s2))
4757 (setq s1 (cdr s1)))
4758 (null s1))))))
4760 (defun gnus-server-equal (m1 m2)
4761 "Say whether two methods are equal."
4762 (let ((m1 (cond ((null m1) gnus-select-method)
4763 ((stringp m1) (gnus-server-to-method m1))
4764 (t m1)))
4765 (m2 (cond ((null m2) gnus-select-method)
4766 ((stringp m2) (gnus-server-to-method m2))
4767 (t m2))))
4768 (gnus-method-equal m1 m2)))
4770 (defun gnus-servers-using-backend (backend)
4771 "Return a list of known servers using BACKEND."
4772 (let ((opened gnus-opened-servers)
4773 out)
4774 (while opened
4775 (when (eq backend (caaar opened))
4776 (push (caar opened) out))
4777 (pop opened))
4778 out))
4780 (defun gnus-archive-server-wanted-p ()
4781 "Say whether the user wants to use the archive server."
4782 (cond
4783 ((or (not gnus-message-archive-method)
4784 (not gnus-message-archive-group))
4785 nil)
4786 ((and gnus-message-archive-method gnus-message-archive-group)
4789 (let ((active (cadr (assq 'nnfolder-active-file
4790 gnus-message-archive-method))))
4791 (and active
4792 (file-exists-p active))))))
4794 (defun gnus-group-prefixed-name (group method)
4795 "Return the whole name from GROUP and METHOD."
4796 (and (stringp method) (setq method (gnus-server-to-method method)))
4797 (concat (format "%s" (car method))
4798 (if (and
4799 (or (assoc (format "%s" (car method))
4800 (gnus-methods-using 'address))
4801 (gnus-server-equal method gnus-message-archive-method))
4802 (nth 1 method)
4803 (not (string= (nth 1 method) "")))
4804 (concat "+" (nth 1 method)))
4805 ":" group))
4807 (defun gnus-group-real-prefix (group)
4808 "Return the prefix of the current group name."
4809 (if (string-match "^[^:]+:" group)
4810 (substring group 0 (match-end 0))
4811 ""))
4813 (defun gnus-group-method (group)
4814 "Return the server or method used for selecting GROUP."
4815 (let ((prefix (gnus-group-real-prefix group)))
4816 (if (equal prefix "")
4817 gnus-select-method
4818 (let ((servers gnus-opened-servers)
4819 (server "")
4820 backend possible found)
4821 (if (string-match "^[^\\+]+\\+" prefix)
4822 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4823 server (substring prefix (match-end 0) (1- (length prefix))))
4824 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4825 (while servers
4826 (when (eq (caaar servers) backend)
4827 (setq possible (caar servers))
4828 (when (equal (cadaar servers) server)
4829 (setq found (caar servers))))
4830 (pop servers))
4831 (or (car (rassoc found gnus-server-alist))
4832 found
4833 (car (rassoc possible gnus-server-alist))
4834 possible
4835 (list backend server))))))
4837 (defsubst gnus-secondary-method-p (method)
4838 "Return whether METHOD is a secondary select method."
4839 (let ((methods gnus-secondary-select-methods)
4840 (gmethod (gnus-server-get-method nil method)))
4841 (while (and methods
4842 (not (equal (gnus-server-get-method nil (car methods))
4843 gmethod)))
4844 (setq methods (cdr methods)))
4845 methods))
4847 (defun gnus-group-foreign-p (group)
4848 "Say whether a group is foreign or not."
4849 (and (not (gnus-group-native-p group))
4850 (not (gnus-group-secondary-p group))))
4852 (defun gnus-group-native-p (group)
4853 "Say whether the group is native or not."
4854 (not (string-match ":" group)))
4856 (defun gnus-group-secondary-p (group)
4857 "Say whether the group is secondary or not."
4858 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4860 (defun gnus-group-get-parameter (group &optional symbol)
4861 "Returns the group parameters for GROUP.
4862 If SYMBOL, return the value of that symbol in the group parameters."
4863 (let ((params (gnus-info-params (gnus-get-info group))))
4864 (if symbol
4865 (gnus-group-parameter-value params symbol)
4866 params)))
4868 (defun gnus-group-parameter-value (params symbol)
4869 "Return the value of SYMBOL in group PARAMS."
4870 (or (car (memq symbol params)) ; It's either a simple symbol
4871 (cdr (assq symbol params)))) ; or a cons.
4873 (defun gnus-group-add-parameter (group param)
4874 "Add parameter PARAM to GROUP."
4875 (let ((info (gnus-get-info group)))
4876 (if (not info)
4877 () ; This is a dead group. We just ignore it.
4878 ;; Cons the new param to the old one and update.
4879 (gnus-group-set-info (cons param (gnus-info-params info))
4880 group 'params))))
4882 (defun gnus-group-set-parameter (group name value)
4883 "Set parameter NAME to VALUE in GROUP."
4884 (let ((info (gnus-get-info group)))
4885 (if (not info)
4886 () ; This is a dead group. We just ignore it.
4887 (let ((old-params (gnus-info-params info))
4888 (new-params (list (cons name value))))
4889 (while old-params
4890 (if (or (not (listp (car old-params)))
4891 (not (eq (caar old-params) name)))
4892 (setq new-params (append new-params (list (car old-params)))))
4893 (setq old-params (cdr old-params)))
4894 (gnus-group-set-info new-params group 'params)))))
4896 (defun gnus-group-add-score (group &optional score)
4897 "Add SCORE to the GROUP score.
4898 If SCORE is nil, add 1 to the score of GROUP."
4899 (let ((info (gnus-get-info group)))
4900 (when info
4901 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4903 (defun gnus-summary-bubble-group ()
4904 "Increase the score of the current group.
4905 This is a handy function to add to `gnus-summary-exit-hook' to
4906 increase the score of each group you read."
4907 (gnus-group-add-score gnus-newsgroup-name))
4909 (defun gnus-group-set-info (info &optional method-only-group part)
4910 (let* ((entry (gnus-gethash
4911 (or method-only-group (gnus-info-group info))
4912 gnus-newsrc-hashtb))
4913 (part-info info)
4914 (info (if method-only-group (nth 2 entry) info))
4915 method)
4916 (when method-only-group
4917 (unless entry
4918 (error "Trying to change non-existent group %s" method-only-group))
4919 ;; We have received parts of the actual group info - either the
4920 ;; select method or the group parameters. We first check
4921 ;; whether we have to extend the info, and if so, do that.
4922 (let ((len (length info))
4923 (total (if (eq part 'method) 5 6)))
4924 (when (< len total)
4925 (setcdr (nthcdr (1- len) info)
4926 (make-list (- total len) nil)))
4927 ;; Then we enter the new info.
4928 (setcar (nthcdr (1- total) info) part-info)))
4929 (unless entry
4930 ;; This is a new group, so we just create it.
4931 (save-excursion
4932 (set-buffer gnus-group-buffer)
4933 (setq method (gnus-info-method info))
4934 (when (gnus-server-equal method "native")
4935 (setq method nil))
4936 (save-excursion
4937 (set-buffer gnus-group-buffer)
4938 (if method
4939 ;; It's a foreign group...
4940 (gnus-group-make-group
4941 (gnus-group-real-name (gnus-info-group info))
4942 (if (stringp method) method
4943 (prin1-to-string (car method)))
4944 (and (consp method)
4945 (nth 1 (gnus-info-method info))))
4946 ;; It's a native group.
4947 (gnus-group-make-group (gnus-info-group info))))
4948 (gnus-message 6 "Note: New group created")
4949 (setq entry
4950 (gnus-gethash (gnus-group-prefixed-name
4951 (gnus-group-real-name (gnus-info-group info))
4952 (or (gnus-info-method info) gnus-select-method))
4953 gnus-newsrc-hashtb))))
4954 ;; Whether it was a new group or not, we now have the entry, so we
4955 ;; can do the update.
4956 (if entry
4957 (progn
4958 (setcar (nthcdr 2 entry) info)
4959 (when (and (not (eq (car entry) t))
4960 (gnus-active (gnus-info-group info)))
4961 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4962 (error "No such group: %s" (gnus-info-group info)))))
4964 (defun gnus-group-set-method-info (group select-method)
4965 (gnus-group-set-info select-method group 'method))
4967 (defun gnus-group-set-params-info (group params)
4968 (gnus-group-set-info params group 'params))
4970 (defun gnus-group-update-group-line ()
4971 "Update the current line in the group buffer."
4972 (let* ((buffer-read-only nil)
4973 (group (gnus-group-group-name))
4974 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4975 gnus-group-indentation)
4976 (when group
4977 (and entry
4978 (not (gnus-ephemeral-group-p group))
4979 (gnus-dribble-enter
4980 (concat "(gnus-group-set-info '"
4981 (prin1-to-string (nth 2 entry)) ")")))
4982 (setq gnus-group-indentation (gnus-group-group-indentation))
4983 (gnus-delete-line)
4984 (gnus-group-insert-group-line-info group)
4985 (forward-line -1)
4986 (gnus-group-position-point))))
4988 (defun gnus-group-insert-group-line-info (group)
4989 "Insert GROUP on the current line."
4990 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4991 active info)
4992 (if entry
4993 (progn
4994 ;; (Un)subscribed group.
4995 (setq info (nth 2 entry))
4996 (gnus-group-insert-group-line
4997 group (gnus-info-level info) (gnus-info-marks info)
4998 (or (car entry) t) (gnus-info-method info)))
4999 ;; This group is dead.
5000 (gnus-group-insert-group-line
5001 group
5002 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
5004 (if (setq active (gnus-active group))
5005 (- (1+ (cdr active)) (car active)) 0)
5006 nil))))
5008 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
5009 gnus-tmp-marked number
5010 gnus-tmp-method)
5011 "Insert a group line in the group buffer."
5012 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
5013 (gnus-tmp-number-total
5014 (if gnus-tmp-active
5015 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
5017 (gnus-tmp-number-of-unread
5018 (if (numberp number) (int-to-string (max 0 number))
5019 "*"))
5020 (gnus-tmp-number-of-read
5021 (if (numberp number)
5022 (int-to-string (max 0 (- gnus-tmp-number-total number)))
5023 "*"))
5024 (gnus-tmp-subscribed
5025 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
5026 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
5027 ((= gnus-tmp-level gnus-level-zombie) ?Z)
5028 (t ?K)))
5029 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
5030 (gnus-tmp-newsgroup-description
5031 (if gnus-description-hashtb
5032 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
5033 ""))
5034 (gnus-tmp-moderated
5035 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
5036 (gnus-tmp-moderated-string
5037 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
5038 (gnus-tmp-method
5039 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
5040 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
5041 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
5042 (gnus-tmp-news-method-string
5043 (if gnus-tmp-method
5044 (format "(%s:%s)" (car gnus-tmp-method)
5045 (cadr gnus-tmp-method)) ""))
5046 (gnus-tmp-marked-mark
5047 (if (and (numberp number)
5048 (zerop number)
5049 (cdr (assq 'tick gnus-tmp-marked)))
5050 ?* ? ))
5051 (gnus-tmp-process-marked
5052 (if (member gnus-tmp-group gnus-group-marked)
5053 gnus-process-mark ? ))
5054 (gnus-tmp-grouplens
5055 (or (and gnus-use-grouplens
5056 (bbb-grouplens-group-p gnus-tmp-group))
5057 ""))
5058 (buffer-read-only nil)
5059 header gnus-tmp-header) ; passed as parameter to user-funcs.
5060 (beginning-of-line)
5061 (gnus-add-text-properties
5062 (point)
5063 (prog1 (1+ (point))
5064 ;; Insert the text.
5065 (eval gnus-group-line-format-spec))
5066 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5067 gnus-unread ,(if (numberp number)
5068 (string-to-int gnus-tmp-number-of-unread)
5070 gnus-marked ,gnus-tmp-marked-mark
5071 gnus-indentation ,gnus-group-indentation
5072 gnus-level ,gnus-tmp-level))
5073 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5074 (forward-line -1)
5075 (run-hooks 'gnus-group-update-hook)
5076 (forward-line))
5077 ;; Allow XEmacs to remove front-sticky text properties.
5078 (gnus-group-remove-excess-properties)))
5080 (defun gnus-group-update-group (group &optional visible-only)
5081 "Update all lines where GROUP appear.
5082 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5083 already."
5084 (save-excursion
5085 (set-buffer gnus-group-buffer)
5086 ;; The buffer may be narrowed.
5087 (save-restriction
5088 (widen)
5089 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5090 (loc (point-min))
5091 found buffer-read-only)
5092 ;; Enter the current status into the dribble buffer.
5093 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5094 (if (and entry (not (gnus-ephemeral-group-p group)))
5095 (gnus-dribble-enter
5096 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5097 ")"))))
5098 ;; Find all group instances. If topics are in use, each group
5099 ;; may be listed in more than once.
5100 (while (setq loc (text-property-any
5101 loc (point-max) 'gnus-group ident))
5102 (setq found t)
5103 (goto-char loc)
5104 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5105 (gnus-delete-line)
5106 (gnus-group-insert-group-line-info group)
5107 (save-excursion
5108 (forward-line -1)
5109 (run-hooks 'gnus-group-update-group-hook)))
5110 (setq loc (1+ loc)))
5111 (unless (or found visible-only)
5112 ;; No such line in the buffer, find out where it's supposed to
5113 ;; go, and insert it there (or at the end of the buffer).
5114 (if gnus-goto-missing-group-function
5115 (funcall gnus-goto-missing-group-function group)
5116 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5117 (while (and entry (car entry)
5118 (not
5119 (gnus-goto-char
5120 (text-property-any
5121 (point-min) (point-max)
5122 'gnus-group (gnus-intern-safe
5123 (caar entry) gnus-active-hashtb)))))
5124 (setq entry (cdr entry)))
5125 (or entry (goto-char (point-max)))))
5126 ;; Finally insert the line.
5127 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5128 (gnus-group-insert-group-line-info group)
5129 (save-excursion
5130 (forward-line -1)
5131 (run-hooks 'gnus-group-update-group-hook))))
5132 (gnus-group-set-mode-line)))))
5134 (defun gnus-group-set-mode-line ()
5135 "Update the mode line in the group buffer."
5136 (when (memq 'group gnus-updated-mode-lines)
5137 ;; Yes, we want to keep this mode line updated.
5138 (save-excursion
5139 (set-buffer gnus-group-buffer)
5140 (let* ((gformat (or gnus-group-mode-line-format-spec
5141 (setq gnus-group-mode-line-format-spec
5142 (gnus-parse-format
5143 gnus-group-mode-line-format
5144 gnus-group-mode-line-format-alist))))
5145 (gnus-tmp-news-server (cadr gnus-select-method))
5146 (gnus-tmp-news-method (car gnus-select-method))
5147 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5148 (max-len 60)
5149 gnus-tmp-header ;Dummy binding for user-defined formats
5150 ;; Get the resulting string.
5151 (modified
5152 (and gnus-dribble-buffer
5153 (buffer-name gnus-dribble-buffer)
5154 (buffer-modified-p gnus-dribble-buffer)
5155 (save-excursion
5156 (set-buffer gnus-dribble-buffer)
5157 (not (zerop (buffer-size))))))
5158 (mode-string (eval gformat)))
5159 ;; Say whether the dribble buffer has been modified.
5160 (setq mode-line-modified
5161 (if modified "---*- " "----- "))
5162 ;; If the line is too long, we chop it off.
5163 (when (> (length mode-string) max-len)
5164 (setq mode-string (substring mode-string 0 (- max-len 4))))
5165 (prog1
5166 (setq mode-line-buffer-identification
5167 (gnus-mode-line-buffer-identification
5168 (list mode-string)))
5169 (set-buffer-modified-p modified))))))
5171 (defun gnus-group-group-name ()
5172 "Get the name of the newsgroup on the current line."
5173 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5174 (and group (symbol-name group))))
5176 (defun gnus-group-group-level ()
5177 "Get the level of the newsgroup on the current line."
5178 (get-text-property (gnus-point-at-bol) 'gnus-level))
5180 (defun gnus-group-group-indentation ()
5181 "Get the indentation of the newsgroup on the current line."
5182 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5183 (and gnus-group-indentation-function
5184 (funcall gnus-group-indentation-function))
5185 ""))
5187 (defun gnus-group-group-unread ()
5188 "Get the number of unread articles of the newsgroup on the current line."
5189 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5191 (defun gnus-group-search-forward (&optional backward all level first-too)
5192 "Find the next newsgroup with unread articles.
5193 If BACKWARD is non-nil, find the previous newsgroup instead.
5194 If ALL is non-nil, just find any newsgroup.
5195 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5196 group exists.
5197 If FIRST-TOO, the current line is also eligible as a target."
5198 (let ((way (if backward -1 1))
5199 (low gnus-level-killed)
5200 (beg (point))
5201 pos found lev)
5202 (if (and backward (progn (beginning-of-line)) (bobp))
5204 (or first-too (forward-line way))
5205 (while (and
5206 (not (eobp))
5207 (not (setq
5208 found
5209 (and (or all
5210 (and
5211 (let ((unread
5212 (get-text-property (point) 'gnus-unread)))
5213 (and (numberp unread) (> unread 0)))
5214 (setq lev (get-text-property (point)
5215 'gnus-level))
5216 (<= lev gnus-level-subscribed)))
5217 (or (not level)
5218 (and (setq lev (get-text-property (point)
5219 'gnus-level))
5220 (or (= lev level)
5221 (and (< lev low)
5222 (< level lev)
5223 (progn
5224 (setq low lev)
5225 (setq pos (point))
5226 nil))))))))
5227 (zerop (forward-line way)))))
5228 (if found
5229 (progn (gnus-group-position-point) t)
5230 (goto-char (or pos beg))
5231 (and pos t))))
5233 ;;; Gnus group mode commands
5235 ;; Group marking.
5237 (defun gnus-group-mark-group (n &optional unmark no-advance)
5238 "Mark the current group."
5239 (interactive "p")
5240 (let ((buffer-read-only nil)
5241 group)
5242 (while (and (> n 0)
5243 (not (eobp)))
5244 (when (setq group (gnus-group-group-name))
5245 ;; Update the mark.
5246 (beginning-of-line)
5247 (forward-char
5248 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5249 (delete-char 1)
5250 (if unmark
5251 (progn
5252 (insert " ")
5253 (setq gnus-group-marked (delete group gnus-group-marked)))
5254 (insert "#")
5255 (setq gnus-group-marked
5256 (cons group (delete group gnus-group-marked)))))
5257 (or no-advance (gnus-group-next-group 1))
5258 (decf n))
5259 (gnus-summary-position-point)
5262 (defun gnus-group-unmark-group (n)
5263 "Remove the mark from the current group."
5264 (interactive "p")
5265 (gnus-group-mark-group n 'unmark)
5266 (gnus-group-position-point))
5268 (defun gnus-group-unmark-all-groups ()
5269 "Unmark all groups."
5270 (interactive)
5271 (let ((groups gnus-group-marked))
5272 (save-excursion
5273 (while groups
5274 (gnus-group-remove-mark (pop groups)))))
5275 (gnus-group-position-point))
5277 (defun gnus-group-mark-region (unmark beg end)
5278 "Mark all groups between point and mark.
5279 If UNMARK, remove the mark instead."
5280 (interactive "P\nr")
5281 (let ((num (count-lines beg end)))
5282 (save-excursion
5283 (goto-char beg)
5284 (- num (gnus-group-mark-group num unmark)))))
5286 (defun gnus-group-mark-buffer (&optional unmark)
5287 "Mark all groups in the buffer.
5288 If UNMARK, remove the mark instead."
5289 (interactive "P")
5290 (gnus-group-mark-region unmark (point-min) (point-max)))
5292 (defun gnus-group-mark-regexp (regexp)
5293 "Mark all groups that match some regexp."
5294 (interactive "sMark (regexp): ")
5295 (let ((alist (cdr gnus-newsrc-alist))
5296 group)
5297 (while alist
5298 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5299 (gnus-group-set-mark group))))
5300 (gnus-group-position-point))
5302 (defun gnus-group-remove-mark (group)
5303 "Remove the process mark from GROUP and move point there.
5304 Return nil if the group isn't displayed."
5305 (if (gnus-group-goto-group group)
5306 (save-excursion
5307 (gnus-group-mark-group 1 'unmark t)
5309 (setq gnus-group-marked
5310 (delete group gnus-group-marked))
5311 nil))
5313 (defun gnus-group-set-mark (group)
5314 "Set the process mark on GROUP."
5315 (if (gnus-group-goto-group group)
5316 (save-excursion
5317 (gnus-group-mark-group 1 nil t))
5318 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5320 (defun gnus-group-universal-argument (arg &optional groups func)
5321 "Perform any command on all groups accoring to the process/prefix convention."
5322 (interactive "P")
5323 (let ((groups (or groups (gnus-group-process-prefix arg)))
5324 group func)
5325 (if (eq (setq func (or func
5326 (key-binding
5327 (read-key-sequence
5328 (substitute-command-keys
5329 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5330 'undefined)
5331 (gnus-error 1 "Undefined key")
5332 (while groups
5333 (gnus-group-remove-mark (setq group (pop groups)))
5334 (command-execute func))))
5335 (gnus-group-position-point))
5337 (defun gnus-group-process-prefix (n)
5338 "Return a list of groups to work on.
5339 Take into consideration N (the prefix) and the list of marked groups."
5340 (cond
5342 (setq n (prefix-numeric-value n))
5343 ;; There is a prefix, so we return a list of the N next
5344 ;; groups.
5345 (let ((way (if (< n 0) -1 1))
5346 (n (abs n))
5347 group groups)
5348 (save-excursion
5349 (while (and (> n 0)
5350 (setq group (gnus-group-group-name)))
5351 (setq groups (cons group groups))
5352 (setq n (1- n))
5353 (gnus-group-next-group way)))
5354 (nreverse groups)))
5355 ((and (boundp 'transient-mark-mode)
5356 transient-mark-mode
5357 (boundp 'mark-active)
5358 mark-active)
5359 ;; Work on the region between point and mark.
5360 (let ((max (max (point) (mark)))
5361 groups)
5362 (save-excursion
5363 (goto-char (min (point) (mark)))
5364 (while
5365 (and
5366 (push (gnus-group-group-name) groups)
5367 (zerop (gnus-group-next-group 1))
5368 (< (point) max)))
5369 (nreverse groups))))
5370 (gnus-group-marked
5371 ;; No prefix, but a list of marked articles.
5372 (reverse gnus-group-marked))
5374 ;; Neither marked articles or a prefix, so we return the
5375 ;; current group.
5376 (let ((group (gnus-group-group-name)))
5377 (and group (list group))))))
5379 ;; Selecting groups.
5381 (defun gnus-group-read-group (&optional all no-article group)
5382 "Read news in this newsgroup.
5383 If the prefix argument ALL is non-nil, already read articles become
5384 readable. IF ALL is a number, fetch this number of articles. If the
5385 optional argument NO-ARTICLE is non-nil, no article will be
5386 auto-selected upon group entry. If GROUP is non-nil, fetch that
5387 group."
5388 (interactive "P")
5389 (let ((group (or group (gnus-group-group-name)))
5390 number active marked entry)
5391 (or group (error "No group on current line"))
5392 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5393 group gnus-newsrc-hashtb)))))
5394 ;; This group might be a dead group. In that case we have to get
5395 ;; the number of unread articles from `gnus-active-hashtb'.
5396 (setq number
5397 (cond ((numberp all) all)
5398 (entry (car entry))
5399 ((setq active (gnus-active group))
5400 (- (1+ (cdr active)) (car active)))))
5401 (gnus-summary-read-group
5402 group (or all (and (numberp number)
5403 (zerop (+ number (gnus-range-length
5404 (cdr (assq 'tick marked)))
5405 (gnus-range-length
5406 (cdr (assq 'dormant marked)))))))
5407 no-article)))
5409 (defun gnus-group-select-group (&optional all)
5410 "Select this newsgroup.
5411 No article is selected automatically.
5412 If ALL is non-nil, already read articles become readable.
5413 If ALL is a number, fetch this number of articles."
5414 (interactive "P")
5415 (gnus-group-read-group all t))
5417 (defun gnus-group-quick-select-group (&optional all)
5418 "Select the current group \"quickly\".
5419 This means that no highlighting or scoring will be performed."
5420 (interactive "P")
5421 (let (gnus-visual
5422 gnus-score-find-score-files-function
5423 gnus-apply-kill-hook
5424 gnus-summary-expunge-below)
5425 (gnus-group-read-group all t)))
5427 (defun gnus-group-visible-select-group (&optional all)
5428 "Select the current group without hiding any articles."
5429 (interactive "P")
5430 (let ((gnus-inhibit-limiting t))
5431 (gnus-group-read-group all t)))
5433 ;;;###autoload
5434 (defun gnus-fetch-group (group)
5435 "Start Gnus if necessary and enter GROUP.
5436 Returns whether the fetching was successful or not."
5437 (interactive "sGroup name: ")
5438 (or (get-buffer gnus-group-buffer)
5439 (gnus))
5440 (gnus-group-read-group nil nil group))
5442 ;; Enter a group that is not in the group buffer. Non-nil is returned
5443 ;; if selection was successful.
5444 (defun gnus-group-read-ephemeral-group
5445 (group method &optional activate quit-config)
5446 (let ((group (if (gnus-group-foreign-p group) group
5447 (gnus-group-prefixed-name group method))))
5448 (gnus-sethash
5449 group
5450 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5451 ((quit-config . ,(if quit-config quit-config
5452 (cons (current-buffer) 'summary))))))
5453 gnus-newsrc-hashtb)
5454 (set-buffer gnus-group-buffer)
5455 (or (gnus-check-server method)
5456 (error "Unable to contact server: %s" (gnus-status-message method)))
5457 (if activate (or (gnus-request-group group)
5458 (error "Couldn't request group")))
5459 (condition-case ()
5460 (gnus-group-read-group t t group)
5461 (error nil)
5462 (quit nil))))
5464 (defun gnus-group-jump-to-group (group)
5465 "Jump to newsgroup GROUP."
5466 (interactive
5467 (list (completing-read
5468 "Group: " gnus-active-hashtb nil
5469 (gnus-read-active-file-p)
5471 'gnus-group-history)))
5473 (when (equal group "")
5474 (error "Empty group name"))
5476 (when (string-match "[\000-\032]" group)
5477 (error "Control characters in group: %s" group))
5479 (let ((b (text-property-any
5480 (point-min) (point-max)
5481 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5482 (unless (gnus-ephemeral-group-p group)
5483 (if b
5484 ;; Either go to the line in the group buffer...
5485 (goto-char b)
5486 ;; ... or insert the line.
5488 (gnus-active group)
5489 (gnus-activate-group group)
5490 (error "%s error: %s" group (gnus-status-message group)))
5492 (gnus-group-update-group group)
5493 (goto-char (text-property-any
5494 (point-min) (point-max)
5495 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5496 ;; Adjust cursor point.
5497 (gnus-group-position-point)))
5499 (defun gnus-group-goto-group (group)
5500 "Goto to newsgroup GROUP."
5501 (when group
5502 (let ((b (text-property-any (point-min) (point-max)
5503 'gnus-group (gnus-intern-safe
5504 group gnus-active-hashtb))))
5505 (and b (goto-char b)))))
5507 (defun gnus-group-next-group (n)
5508 "Go to next N'th newsgroup.
5509 If N is negative, search backward instead.
5510 Returns the difference between N and the number of skips actually
5511 done."
5512 (interactive "p")
5513 (gnus-group-next-unread-group n t))
5515 (defun gnus-group-next-unread-group (n &optional all level)
5516 "Go to next N'th unread newsgroup.
5517 If N is negative, search backward instead.
5518 If ALL is non-nil, choose any newsgroup, unread or not.
5519 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5520 such group can be found, the next group with a level higher than
5521 LEVEL.
5522 Returns the difference between N and the number of skips actually
5523 made."
5524 (interactive "p")
5525 (let ((backward (< n 0))
5526 (n (abs n)))
5527 (while (and (> n 0)
5528 (gnus-group-search-forward
5529 backward (or (not gnus-group-goto-unread) all) level))
5530 (setq n (1- n)))
5531 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5532 (if level " on this level or higher" "")))
5535 (defun gnus-group-prev-group (n)
5536 "Go to previous N'th newsgroup.
5537 Returns the difference between N and the number of skips actually
5538 done."
5539 (interactive "p")
5540 (gnus-group-next-unread-group (- n) t))
5542 (defun gnus-group-prev-unread-group (n)
5543 "Go to previous N'th unread newsgroup.
5544 Returns the difference between N and the number of skips actually
5545 done."
5546 (interactive "p")
5547 (gnus-group-next-unread-group (- n)))
5549 (defun gnus-group-next-unread-group-same-level (n)
5550 "Go to next N'th unread newsgroup on the same level.
5551 If N is negative, search backward instead.
5552 Returns the difference between N and the number of skips actually
5553 done."
5554 (interactive "p")
5555 (gnus-group-next-unread-group n t (gnus-group-group-level))
5556 (gnus-group-position-point))
5558 (defun gnus-group-prev-unread-group-same-level (n)
5559 "Go to next N'th unread newsgroup on the same level.
5560 Returns the difference between N and the number of skips actually
5561 done."
5562 (interactive "p")
5563 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5564 (gnus-group-position-point))
5566 (defun gnus-group-best-unread-group (&optional exclude-group)
5567 "Go to the group with the highest level.
5568 If EXCLUDE-GROUP, do not go to that group."
5569 (interactive)
5570 (goto-char (point-min))
5571 (let ((best 100000)
5572 unread best-point)
5573 (while (not (eobp))
5574 (setq unread (get-text-property (point) 'gnus-unread))
5575 (if (and (numberp unread) (> unread 0))
5576 (progn
5577 (if (and (get-text-property (point) 'gnus-level)
5578 (< (get-text-property (point) 'gnus-level) best)
5579 (or (not exclude-group)
5580 (not (equal exclude-group (gnus-group-group-name)))))
5581 (progn
5582 (setq best (get-text-property (point) 'gnus-level))
5583 (setq best-point (point))))))
5584 (forward-line 1))
5585 (if best-point (goto-char best-point))
5586 (gnus-summary-position-point)
5587 (and best-point (gnus-group-group-name))))
5589 (defun gnus-group-first-unread-group ()
5590 "Go to the first group with unread articles."
5591 (interactive)
5592 (prog1
5593 (let ((opoint (point))
5594 unread)
5595 (goto-char (point-min))
5596 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5597 (and (numberp unread) ; Not a topic.
5598 (not (zerop unread))) ; Has unread articles.
5599 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5600 (point) ; Success.
5601 (goto-char opoint)
5602 nil)) ; Not success.
5603 (gnus-group-position-point)))
5605 (defun gnus-group-enter-server-mode ()
5606 "Jump to the server buffer."
5607 (interactive)
5608 (gnus-enter-server-buffer))
5610 (defun gnus-group-make-group (name &optional method address)
5611 "Add a new newsgroup.
5612 The user will be prompted for a NAME, for a select METHOD, and an
5613 ADDRESS."
5614 (interactive
5615 (cons
5616 (read-string "Group name: ")
5617 (let ((method
5618 (completing-read
5619 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5620 nil t nil 'gnus-method-history)))
5621 (cond ((assoc method gnus-valid-select-methods)
5622 (list method
5623 (if (memq 'prompt-address
5624 (assoc method gnus-valid-select-methods))
5625 (read-string "Address: ")
5626 "")))
5627 ((assoc method gnus-server-alist)
5628 (list method))
5630 (list method ""))))))
5632 (let* ((meth (and method (if address (list (intern method) address)
5633 method)))
5634 (nname (if method (gnus-group-prefixed-name name meth) name))
5635 backend info)
5636 (when (gnus-gethash nname gnus-newsrc-hashtb)
5637 (error "Group %s already exists" nname))
5638 ;; Subscribe to the new group.
5639 (gnus-group-change-level
5640 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5641 gnus-level-default-subscribed gnus-level-killed
5642 (and (gnus-group-group-name)
5643 (gnus-gethash (gnus-group-group-name)
5644 gnus-newsrc-hashtb))
5646 ;; Make it active.
5647 (gnus-set-active nname (cons 1 0))
5648 (or (gnus-ephemeral-group-p name)
5649 (gnus-dribble-enter
5650 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5651 ;; Insert the line.
5652 (gnus-group-insert-group-line-info nname)
5653 (forward-line -1)
5654 (gnus-group-position-point)
5656 ;; Load the backend and try to make the backend create
5657 ;; the group as well.
5658 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5659 nil meth))))
5660 gnus-valid-select-methods)
5661 (require backend))
5662 (gnus-check-server meth)
5663 (and (gnus-check-backend-function 'request-create-group nname)
5664 (gnus-request-create-group nname))
5667 (defun gnus-group-delete-group (group &optional force)
5668 "Delete the current group. Only meaningful with mail groups.
5669 If FORCE (the prefix) is non-nil, all the articles in the group will
5670 be deleted. This is \"deleted\" as in \"removed forever from the face
5671 of the Earth\". There is no undo. The user will be prompted before
5672 doing the deletion."
5673 (interactive
5674 (list (gnus-group-group-name)
5675 current-prefix-arg))
5676 (or group (error "No group to rename"))
5677 (or (gnus-check-backend-function 'request-delete-group group)
5678 (error "This backend does not support group deletion"))
5679 (prog1
5680 (if (not (gnus-yes-or-no-p
5681 (format
5682 "Do you really want to delete %s%s? "
5683 group (if force " and all its contents" ""))))
5684 () ; Whew!
5685 (gnus-message 6 "Deleting group %s..." group)
5686 (if (not (gnus-request-delete-group group force))
5687 (gnus-error 3 "Couldn't delete group %s" group)
5688 (gnus-message 6 "Deleting group %s...done" group)
5689 (gnus-group-goto-group group)
5690 (gnus-group-kill-group 1 t)
5691 (gnus-sethash group nil gnus-active-hashtb)
5693 (gnus-group-position-point)))
5695 (defun gnus-group-rename-group (group new-name)
5696 (interactive
5697 (list
5698 (gnus-group-group-name)
5699 (progn
5700 (or (gnus-check-backend-function
5701 'request-rename-group (gnus-group-group-name))
5702 (error "This backend does not support renaming groups"))
5703 (read-string "New group name: "))))
5705 (or (gnus-check-backend-function 'request-rename-group group)
5706 (error "This backend does not support renaming groups"))
5708 (or group (error "No group to rename"))
5709 (and (string-match "^[ \t]*$" new-name)
5710 (error "Not a valid group name"))
5712 ;; We find the proper prefixed name.
5713 (setq new-name
5714 (gnus-group-prefixed-name
5715 (gnus-group-real-name new-name)
5716 (gnus-info-method (gnus-get-info group))))
5718 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5719 (prog1
5720 (if (not (gnus-request-rename-group group new-name))
5721 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5722 ;; We rename the group internally by killing it...
5723 (gnus-group-goto-group group)
5724 (gnus-group-kill-group)
5725 ;; ... changing its name ...
5726 (setcar (cdar gnus-list-of-killed-groups) new-name)
5727 ;; ... and then yanking it. Magic!
5728 (gnus-group-yank-group)
5729 (gnus-set-active new-name (gnus-active group))
5730 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5731 new-name)
5732 (gnus-group-position-point)))
5734 (defun gnus-group-edit-group (group &optional part)
5735 "Edit the group on the current line."
5736 (interactive (list (gnus-group-group-name)))
5737 (let* ((part (or part 'info))
5738 (done-func `(lambda ()
5739 "Exit editing mode and update the information."
5740 (interactive)
5741 (gnus-group-edit-group-done ',part ,group)))
5742 (winconf (current-window-configuration))
5743 info)
5744 (or group (error "No group on current line"))
5745 (or (setq info (gnus-get-info group))
5746 (error "Killed group; can't be edited"))
5747 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5748 (gnus-configure-windows 'edit-group)
5749 (gnus-add-current-to-buffer-list)
5750 (emacs-lisp-mode)
5751 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5752 (use-local-map (copy-keymap emacs-lisp-mode-map))
5753 (local-set-key "\C-c\C-c" done-func)
5754 (make-local-variable 'gnus-prev-winconf)
5755 (setq gnus-prev-winconf winconf)
5756 (erase-buffer)
5757 (insert
5758 (cond
5759 ((eq part 'method)
5760 ";; Type `C-c C-c' after editing the select method.\n\n")
5761 ((eq part 'params)
5762 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5763 ((eq part 'info)
5764 ";; Type `C-c C-c' after editing the group info.\n\n")))
5765 (insert
5766 (pp-to-string
5767 (cond ((eq part 'method)
5768 (or (gnus-info-method info) "native"))
5769 ((eq part 'params)
5770 (gnus-info-params info))
5771 (t info)))
5772 "\n")))
5774 (defun gnus-group-edit-group-method (group)
5775 "Edit the select method of GROUP."
5776 (interactive (list (gnus-group-group-name)))
5777 (gnus-group-edit-group group 'method))
5779 (defun gnus-group-edit-group-parameters (group)
5780 "Edit the group parameters of GROUP."
5781 (interactive (list (gnus-group-group-name)))
5782 (gnus-group-edit-group group 'params))
5784 (defun gnus-group-edit-group-done (part group)
5785 "Get info from buffer, update variables and jump to the group buffer."
5786 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5787 (goto-char (point-min))
5788 (let* ((form (read (current-buffer)))
5789 (winconf gnus-prev-winconf)
5790 (method (cond ((eq part 'info) (nth 4 form))
5791 ((eq part 'method) form)
5792 (t nil)))
5793 (info (cond ((eq part 'info) form)
5794 ((eq part 'method) (gnus-get-info group))
5795 (t nil)))
5796 (new-group (if info
5797 (if (or (not method)
5798 (gnus-server-equal
5799 gnus-select-method method))
5800 (gnus-group-real-name (car info))
5801 (gnus-group-prefixed-name
5802 (gnus-group-real-name (car info)) method))
5803 nil)))
5804 (when (and new-group
5805 (not (equal new-group group)))
5806 (when (gnus-group-goto-group group)
5807 (gnus-group-kill-group 1))
5808 (gnus-activate-group new-group))
5809 ;; Set the info.
5810 (if (and info new-group)
5811 (progn
5812 (setq info (gnus-copy-sequence info))
5813 (setcar info new-group)
5814 (unless (gnus-server-equal method "native")
5815 (unless (nthcdr 3 info)
5816 (nconc info (list nil nil)))
5817 (unless (nthcdr 4 info)
5818 (nconc info (list nil)))
5819 (gnus-info-set-method info method))
5820 (gnus-group-set-info info))
5821 (gnus-group-set-info form (or new-group group) part))
5822 (kill-buffer (current-buffer))
5823 (and winconf (set-window-configuration winconf))
5824 (set-buffer gnus-group-buffer)
5825 (gnus-group-update-group (or new-group group))
5826 (gnus-group-position-point)))
5828 (defun gnus-group-make-help-group ()
5829 "Create the Gnus documentation group."
5830 (interactive)
5831 (let ((path load-path)
5832 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5833 file dir)
5834 (and (gnus-gethash name gnus-newsrc-hashtb)
5835 (error "Documentation group already exists"))
5836 (while path
5837 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5838 file nil)
5839 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5840 (file-exists-p
5841 (setq file (concat (file-name-directory
5842 (directory-file-name dir))
5843 "etc/gnus-tut.txt"))))
5844 (setq path nil)))
5845 (if (not file)
5846 (gnus-message 1 "Couldn't find doc group")
5847 (gnus-group-make-group
5848 (gnus-group-real-name name)
5849 (list 'nndoc "gnus-help"
5850 (list 'nndoc-address file)
5851 (list 'nndoc-article-type 'mbox)))))
5852 (gnus-group-position-point))
5854 (defun gnus-group-make-doc-group (file type)
5855 "Create a group that uses a single file as the source."
5856 (interactive
5857 (list (read-file-name "File name: ")
5858 (and current-prefix-arg 'ask)))
5859 (when (eq type 'ask)
5860 (let ((err "")
5861 char found)
5862 (while (not found)
5863 (message
5864 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5865 err)
5866 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5867 ((= char ?b) 'babyl)
5868 ((= char ?d) 'digest)
5869 ((= char ?f) 'forward)
5870 ((= char ?a) 'mmfd)
5871 (t (setq err (format "%c unknown. " char))
5872 nil))))
5873 (setq type found)))
5874 (let* ((file (expand-file-name file))
5875 (name (gnus-generate-new-group-name
5876 (gnus-group-prefixed-name
5877 (file-name-nondirectory file) '(nndoc "")))))
5878 (gnus-group-make-group
5879 (gnus-group-real-name name)
5880 (list 'nndoc (file-name-nondirectory file)
5881 (list 'nndoc-address file)
5882 (list 'nndoc-article-type (or type 'guess))))))
5884 (defun gnus-group-make-archive-group (&optional all)
5885 "Create the (ding) Gnus archive group of the most recent articles.
5886 Given a prefix, create a full group."
5887 (interactive "P")
5888 (let ((group (gnus-group-prefixed-name
5889 (if all "ding.archives" "ding.recent") '(nndir ""))))
5890 (and (gnus-gethash group gnus-newsrc-hashtb)
5891 (error "Archive group already exists"))
5892 (gnus-group-make-group
5893 (gnus-group-real-name group)
5894 (list 'nndir (if all "hpc" "edu")
5895 (list 'nndir-directory
5896 (if all gnus-group-archive-directory
5897 gnus-group-recent-archive-directory))))))
5899 (defun gnus-group-make-directory-group (dir)
5900 "Create an nndir group.
5901 The user will be prompted for a directory. The contents of this
5902 directory will be used as a newsgroup. The directory should contain
5903 mail messages or news articles in files that have numeric names."
5904 (interactive
5905 (list (read-file-name "Create group from directory: ")))
5906 (or (file-exists-p dir) (error "No such directory"))
5907 (or (file-directory-p dir) (error "Not a directory"))
5908 (let ((ext "")
5909 (i 0)
5910 group)
5911 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5912 (setq group
5913 (gnus-group-prefixed-name
5914 (concat (file-name-as-directory (directory-file-name dir))
5915 ext)
5916 '(nndir "")))
5917 (setq ext (format "<%d>" (setq i (1+ i)))))
5918 (gnus-group-make-group
5919 (gnus-group-real-name group)
5920 (list 'nndir group (list 'nndir-directory dir)))))
5922 (defun gnus-group-make-kiboze-group (group address scores)
5923 "Create an nnkiboze group.
5924 The user will be prompted for a name, a regexp to match groups, and
5925 score file entries for articles to include in the group."
5926 (interactive
5927 (list
5928 (read-string "nnkiboze group name: ")
5929 (read-string "Source groups (regexp): ")
5930 (let ((headers (mapcar (lambda (group) (list group))
5931 '("subject" "from" "number" "date" "message-id"
5932 "references" "chars" "lines" "xref"
5933 "followup" "all" "body" "head")))
5934 scores header regexp regexps)
5935 (while (not (equal "" (setq header (completing-read
5936 "Match on header: " headers nil t))))
5937 (setq regexps nil)
5938 (while (not (equal "" (setq regexp (read-string
5939 (format "Match on %s (string): "
5940 header)))))
5941 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5942 (setq scores (cons (cons header regexps) scores)))
5943 scores)))
5944 (gnus-group-make-group group "nnkiboze" address)
5945 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5946 (let (emacs-lisp-mode-hook)
5947 (pp scores (current-buffer)))))
5949 (defun gnus-group-add-to-virtual (n vgroup)
5950 "Add the current group to a virtual group."
5951 (interactive
5952 (list current-prefix-arg
5953 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5954 "nnvirtual:")))
5955 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5956 (error "%s is not an nnvirtual group" vgroup))
5957 (let* ((groups (gnus-group-process-prefix n))
5958 (method (gnus-info-method (gnus-get-info vgroup))))
5959 (setcar (cdr method)
5960 (concat
5961 (nth 1 method) "\\|"
5962 (mapconcat
5963 (lambda (s)
5964 (gnus-group-remove-mark s)
5965 (concat "\\(^" (regexp-quote s) "$\\)"))
5966 groups "\\|"))))
5967 (gnus-group-position-point))
5969 (defun gnus-group-make-empty-virtual (group)
5970 "Create a new, fresh, empty virtual group."
5971 (interactive "sCreate new, empty virtual group: ")
5972 (let* ((method (list 'nnvirtual "^$"))
5973 (pgroup (gnus-group-prefixed-name group method)))
5974 ;; Check whether it exists already.
5975 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5976 (error "Group %s already exists." pgroup))
5977 ;; Subscribe the new group after the group on the current line.
5978 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5979 (gnus-group-update-group pgroup)
5980 (forward-line -1)
5981 (gnus-group-position-point)))
5983 (defun gnus-group-enter-directory (dir)
5984 "Enter an ephemeral nneething group."
5985 (interactive "DDirectory to read: ")
5986 (let* ((method (list 'nneething dir '(nneething-read-only t)))
5987 (leaf (gnus-group-prefixed-name
5988 (file-name-nondirectory (directory-file-name dir))
5989 method))
5990 (name (gnus-generate-new-group-name leaf)))
5991 (unless (gnus-group-read-ephemeral-group
5992 name method t
5993 (cons (current-buffer)
5994 (if (eq major-mode 'gnus-summary-mode)
5995 'summary 'group)))
5996 (error "Couldn't enter %s" dir))))
5998 ;; Group sorting commands
5999 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
6001 (defun gnus-group-sort-groups (func &optional reverse)
6002 "Sort the group buffer according to FUNC.
6003 If REVERSE, reverse the sorting order."
6004 (interactive (list gnus-group-sort-function
6005 current-prefix-arg))
6006 (let ((func (cond
6007 ((not (listp func)) func)
6008 ((null func) func)
6009 ((= 1 (length func)) (car func))
6010 (t `(lambda (t1 t2)
6011 ,(gnus-make-sort-function
6012 (reverse func)))))))
6013 ;; We peel off the dummy group from the alist.
6014 (when func
6015 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
6016 (pop gnus-newsrc-alist))
6017 ;; Do the sorting.
6018 (setq gnus-newsrc-alist
6019 (sort gnus-newsrc-alist func))
6020 (when reverse
6021 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
6022 ;; Regenerate the hash table.
6023 (gnus-make-hashtable-from-newsrc-alist)
6024 (gnus-group-list-groups))))
6026 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
6027 "Sort the group buffer alphabetically by group name.
6028 If REVERSE, sort in reverse order."
6029 (interactive "P")
6030 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
6032 (defun gnus-group-sort-groups-by-unread (&optional reverse)
6033 "Sort the group buffer by number of unread articles.
6034 If REVERSE, sort in reverse order."
6035 (interactive "P")
6036 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
6038 (defun gnus-group-sort-groups-by-level (&optional reverse)
6039 "Sort the group buffer by group level.
6040 If REVERSE, sort in reverse order."
6041 (interactive "P")
6042 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
6044 (defun gnus-group-sort-groups-by-score (&optional reverse)
6045 "Sort the group buffer by group score.
6046 If REVERSE, sort in reverse order."
6047 (interactive "P")
6048 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
6050 (defun gnus-group-sort-groups-by-rank (&optional reverse)
6051 "Sort the group buffer by group rank.
6052 If REVERSE, sort in reverse order."
6053 (interactive "P")
6054 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
6056 (defun gnus-group-sort-groups-by-method (&optional reverse)
6057 "Sort the group buffer alphabetically by backend name.
6058 If REVERSE, sort in reverse order."
6059 (interactive "P")
6060 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6062 (defun gnus-group-sort-by-alphabet (info1 info2)
6063 "Sort alphabetically."
6064 (string< (gnus-info-group info1) (gnus-info-group info2)))
6066 (defun gnus-group-sort-by-unread (info1 info2)
6067 "Sort by number of unread articles."
6068 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6069 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6070 (< (or (and (numberp n1) n1) 0)
6071 (or (and (numberp n2) n2) 0))))
6073 (defun gnus-group-sort-by-level (info1 info2)
6074 "Sort by level."
6075 (< (gnus-info-level info1) (gnus-info-level info2)))
6077 (defun gnus-group-sort-by-method (info1 info2)
6078 "Sort alphabetically by backend name."
6079 (string< (symbol-name (car (gnus-find-method-for-group
6080 (gnus-info-group info1) info1)))
6081 (symbol-name (car (gnus-find-method-for-group
6082 (gnus-info-group info2) info2)))))
6084 (defun gnus-group-sort-by-score (info1 info2)
6085 "Sort by group score."
6086 (< (gnus-info-score info1) (gnus-info-score info2)))
6088 (defun gnus-group-sort-by-rank (info1 info2)
6089 "Sort by level and score."
6090 (let ((level1 (gnus-info-level info1))
6091 (level2 (gnus-info-level info2)))
6092 (or (< level1 level2)
6093 (and (= level1 level2)
6094 (> (gnus-info-score info1) (gnus-info-score info2))))))
6096 ;; Group catching up.
6098 (defun gnus-group-clear-data (n)
6099 "Clear all marks and read ranges from the current group."
6100 (interactive "P")
6101 (let ((groups (gnus-group-process-prefix n))
6102 group info)
6103 (while (setq group (pop groups))
6104 (setq info (gnus-get-info group))
6105 (gnus-info-set-read info nil)
6106 (when (gnus-info-marks info)
6107 (gnus-info-set-marks info nil))
6108 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6109 (when (gnus-group-goto-group group)
6110 (gnus-group-remove-mark group)
6111 (gnus-group-update-group-line)))))
6113 (defun gnus-group-catchup-current (&optional n all)
6114 "Mark all articles not marked as unread in current newsgroup as read.
6115 If prefix argument N is numeric, the ARG next newsgroups will be
6116 caught up. If ALL is non-nil, marked articles will also be marked as
6117 read. Cross references (Xref: header) of articles are ignored.
6118 The difference between N and actual number of newsgroups that were
6119 caught up is returned."
6120 (interactive "P")
6121 (unless (gnus-group-group-name)
6122 (error "No group on the current line"))
6123 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6124 gnus-expert-user
6125 (gnus-y-or-n-p
6126 (if all
6127 "Do you really want to mark all articles as read? "
6128 "Mark all unread articles as read? "))))
6130 (let ((groups (gnus-group-process-prefix n))
6131 (ret 0))
6132 (while groups
6133 ;; Virtual groups have to be given special treatment.
6134 (let ((method (gnus-find-method-for-group (car groups))))
6135 (if (eq 'nnvirtual (car method))
6136 (nnvirtual-catchup-group
6137 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6138 (gnus-group-remove-mark (car groups))
6139 (if (>= (gnus-group-group-level) gnus-level-zombie)
6140 (gnus-message 2 "Dead groups can't be caught up")
6141 (if (prog1
6142 (gnus-group-goto-group (car groups))
6143 (gnus-group-catchup (car groups) all))
6144 (gnus-group-update-group-line)
6145 (setq ret (1+ ret))))
6146 (setq groups (cdr groups)))
6147 (gnus-group-next-unread-group 1)
6148 ret)))
6150 (defun gnus-group-catchup-current-all (&optional n)
6151 "Mark all articles in current newsgroup as read.
6152 Cross references (Xref: header) of articles are ignored."
6153 (interactive "P")
6154 (gnus-group-catchup-current n 'all))
6156 (defun gnus-group-catchup (group &optional all)
6157 "Mark all articles in GROUP as read.
6158 If ALL is non-nil, all articles are marked as read.
6159 The return value is the number of articles that were marked as read,
6160 or nil if no action could be taken."
6161 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6162 (num (car entry)))
6163 ;; Do the updating only if the newsgroup isn't killed.
6164 (if (not (numberp (car entry)))
6165 (gnus-message 1 "Can't catch up; non-active group")
6166 ;; Do auto-expirable marks if that's required.
6167 (when (gnus-group-auto-expirable-p group)
6168 (gnus-add-marked-articles
6169 group 'expire (gnus-list-of-unread-articles group))
6170 (when all
6171 (let ((marks (nth 3 (nth 2 entry))))
6172 (gnus-add-marked-articles
6173 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6174 (gnus-add-marked-articles
6175 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6176 (when entry
6177 (gnus-update-read-articles group nil)
6178 ;; Also nix out the lists of marks and dormants.
6179 (when all
6180 (gnus-add-marked-articles group 'tick nil nil 'force)
6181 (gnus-add-marked-articles group 'dormant nil nil 'force))
6182 (run-hooks 'gnus-group-catchup-group-hook)
6183 num))))
6185 (defun gnus-group-expire-articles (&optional n)
6186 "Expire all expirable articles in the current newsgroup."
6187 (interactive "P")
6188 (let ((groups (gnus-group-process-prefix n))
6189 group)
6190 (unless groups
6191 (error "No groups to expire"))
6192 (while (setq group (pop groups))
6193 (gnus-group-remove-mark group)
6194 (when (gnus-check-backend-function 'request-expire-articles group)
6195 (gnus-message 6 "Expiring articles in %s..." group)
6196 (let* ((info (gnus-get-info group))
6197 (expirable (if (gnus-group-total-expirable-p group)
6198 (cons nil (gnus-list-of-read-articles group))
6199 (assq 'expire (gnus-info-marks info))))
6200 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6201 (when expirable
6202 (setcdr
6203 expirable
6204 (gnus-compress-sequence
6205 (if expiry-wait
6206 ;; We set the expiry variables to the groupp
6207 ;; parameter.
6208 (let ((nnmail-expiry-wait-function nil)
6209 (nnmail-expiry-wait expiry-wait))
6210 (gnus-request-expire-articles
6211 (gnus-uncompress-sequence (cdr expirable)) group))
6212 ;; Just expire using the normal expiry values.
6213 (gnus-request-expire-articles
6214 (gnus-uncompress-sequence (cdr expirable)) group))))
6215 (gnus-close-group group))
6216 (gnus-message 6 "Expiring articles in %s...done" group)))
6217 (gnus-group-position-point))))
6219 (defun gnus-group-expire-all-groups ()
6220 "Expire all expirable articles in all newsgroups."
6221 (interactive)
6222 (save-excursion
6223 (gnus-message 5 "Expiring...")
6224 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6225 (cdr gnus-newsrc-alist))))
6226 (gnus-group-expire-articles nil)))
6227 (gnus-group-position-point)
6228 (gnus-message 5 "Expiring...done"))
6230 (defun gnus-group-set-current-level (n level)
6231 "Set the level of the next N groups to LEVEL."
6232 (interactive
6233 (list
6234 current-prefix-arg
6235 (string-to-int
6236 (let ((s (read-string
6237 (format "Level (default %s): "
6238 (or (gnus-group-group-level)
6239 gnus-level-default-subscribed)))))
6240 (if (string-match "^\\s-*$" s)
6241 (int-to-string (or (gnus-group-group-level)
6242 gnus-level-default-subscribed))
6243 s)))))
6244 (or (and (>= level 1) (<= level gnus-level-killed))
6245 (error "Illegal level: %d" level))
6246 (let ((groups (gnus-group-process-prefix n))
6247 group)
6248 (while (setq group (pop groups))
6249 (gnus-group-remove-mark group)
6250 (gnus-message 6 "Changed level of %s from %d to %d"
6251 group (or (gnus-group-group-level) gnus-level-killed)
6252 level)
6253 (gnus-group-change-level
6254 group level (or (gnus-group-group-level) gnus-level-killed))
6255 (gnus-group-update-group-line)))
6256 (gnus-group-position-point))
6258 (defun gnus-group-unsubscribe-current-group (&optional n)
6259 "Toggle subscription of the current group.
6260 If given numerical prefix, toggle the N next groups."
6261 (interactive "P")
6262 (let ((groups (gnus-group-process-prefix n))
6263 group)
6264 (while groups
6265 (setq group (car groups)
6266 groups (cdr groups))
6267 (gnus-group-remove-mark group)
6268 (gnus-group-unsubscribe-group
6269 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6270 gnus-level-default-unsubscribed
6271 gnus-level-default-subscribed) t)
6272 (gnus-group-update-group-line))
6273 (gnus-group-next-group 1)))
6275 (defun gnus-group-unsubscribe-group (group &optional level silent)
6276 "Toggle subscription to GROUP.
6277 Killed newsgroups are subscribed. If SILENT, don't try to update the
6278 group line."
6279 (interactive
6280 (list (completing-read
6281 "Group: " gnus-active-hashtb nil
6282 (gnus-read-active-file-p)
6283 nil
6284 'gnus-group-history)))
6285 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6286 (cond
6287 ((string-match "^[ \t]$" group)
6288 (error "Empty group name"))
6289 (newsrc
6290 ;; Toggle subscription flag.
6291 (gnus-group-change-level
6292 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6293 gnus-level-subscribed)
6294 (1+ gnus-level-subscribed)
6295 gnus-level-default-subscribed)))
6296 (unless silent
6297 (gnus-group-update-group group)))
6298 ((and (stringp group)
6299 (or (not (gnus-read-active-file-p))
6300 (gnus-active group)))
6301 ;; Add new newsgroup.
6302 (gnus-group-change-level
6303 group
6304 (if level level gnus-level-default-subscribed)
6305 (or (and (member group gnus-zombie-list)
6306 gnus-level-zombie)
6307 gnus-level-killed)
6308 (and (gnus-group-group-name)
6309 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6310 (unless silent
6311 (gnus-group-update-group group)))
6312 (t (error "No such newsgroup: %s" group)))
6313 (gnus-group-position-point)))
6315 (defun gnus-group-transpose-groups (n)
6316 "Move the current newsgroup up N places.
6317 If given a negative prefix, move down instead. The difference between
6318 N and the number of steps taken is returned."
6319 (interactive "p")
6320 (or (gnus-group-group-name)
6321 (error "No group on current line"))
6322 (gnus-group-kill-group 1)
6323 (prog1
6324 (forward-line (- n))
6325 (gnus-group-yank-group)
6326 (gnus-group-position-point)))
6328 (defun gnus-group-kill-all-zombies ()
6329 "Kill all zombie newsgroups."
6330 (interactive)
6331 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6332 (setq gnus-zombie-list nil)
6333 (gnus-group-list-groups))
6335 (defun gnus-group-kill-region (begin end)
6336 "Kill newsgroups in current region (excluding current point).
6337 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6338 (interactive "r")
6339 (let ((lines
6340 ;; Count lines.
6341 (save-excursion
6342 (count-lines
6343 (progn
6344 (goto-char begin)
6345 (beginning-of-line)
6346 (point))
6347 (progn
6348 (goto-char end)
6349 (beginning-of-line)
6350 (point))))))
6351 (goto-char begin)
6352 (beginning-of-line) ;Important when LINES < 1
6353 (gnus-group-kill-group lines)))
6355 (defun gnus-group-kill-group (&optional n discard)
6356 "Kill the next N groups.
6357 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6358 However, only groups that were alive can be yanked; already killed
6359 groups or zombie groups can't be yanked.
6360 The return value is the name of the group that was killed, or a list
6361 of groups killed."
6362 (interactive "P")
6363 (let ((buffer-read-only nil)
6364 (groups (gnus-group-process-prefix n))
6365 group entry level out)
6366 (if (< (length groups) 10)
6367 ;; This is faster when there are few groups.
6368 (while groups
6369 (push (setq group (pop groups)) out)
6370 (gnus-group-remove-mark group)
6371 (setq level (gnus-group-group-level))
6372 (gnus-delete-line)
6373 (when (and (not discard)
6374 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6375 (push (cons (car entry) (nth 2 entry))
6376 gnus-list-of-killed-groups))
6377 (gnus-group-change-level
6378 (if entry entry group) gnus-level-killed (if entry nil level)))
6379 ;; If there are lots and lots of groups to be killed, we use
6380 ;; this thing instead.
6381 (let (entry)
6382 (setq groups (nreverse groups))
6383 (while groups
6384 (gnus-group-remove-mark (setq group (pop groups)))
6385 (gnus-delete-line)
6386 (push group gnus-killed-list)
6387 (setq gnus-newsrc-alist
6388 (delq (assoc group gnus-newsrc-alist)
6389 gnus-newsrc-alist))
6390 (when gnus-group-change-level-function
6391 (funcall gnus-group-change-level-function group 9 3))
6392 (cond
6393 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6394 (push (cons (car entry) (nth 2 entry))
6395 gnus-list-of-killed-groups)
6396 (setcdr (cdr entry) (cdddr entry)))
6397 ((member group gnus-zombie-list)
6398 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6399 (gnus-make-hashtable-from-newsrc-alist)))
6401 (gnus-group-position-point)
6402 (if (< (length out) 2) (car out) (nreverse out))))
6404 (defun gnus-group-yank-group (&optional arg)
6405 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6406 inserting it before the current newsgroup. The numeric ARG specifies
6407 how many newsgroups are to be yanked. The name of the newsgroup yanked
6408 is returned, or (if several groups are yanked) a list of yanked groups
6409 is returned."
6410 (interactive "p")
6411 (setq arg (or arg 1))
6412 (let (info group prev out)
6413 (while (>= (decf arg) 0)
6414 (if (not (setq info (pop gnus-list-of-killed-groups)))
6415 (error "No more newsgroups to yank"))
6416 (push (setq group (nth 1 info)) out)
6417 ;; Find which newsgroup to insert this one before - search
6418 ;; backward until something suitable is found. If there are no
6419 ;; other newsgroups in this buffer, just make this newsgroup the
6420 ;; first newsgroup.
6421 (setq prev (gnus-group-group-name))
6422 (gnus-group-change-level
6423 info (gnus-info-level (cdr info)) gnus-level-killed
6424 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6426 (gnus-group-insert-group-line-info group))
6427 (forward-line -1)
6428 (gnus-group-position-point)
6429 (if (< (length out) 2) (car out) (nreverse out))))
6431 (defun gnus-group-kill-level (level)
6432 "Kill all groups that is on a certain LEVEL."
6433 (interactive "nKill all groups on level: ")
6434 (cond
6435 ((= level gnus-level-zombie)
6436 (setq gnus-killed-list
6437 (nconc gnus-zombie-list gnus-killed-list))
6438 (setq gnus-zombie-list nil))
6439 ((and (< level gnus-level-zombie)
6440 (> level 0)
6441 (or gnus-expert-user
6442 (gnus-yes-or-no-p
6443 (format
6444 "Do you really want to kill all groups on level %d? "
6445 level))))
6446 (let* ((prev gnus-newsrc-alist)
6447 (alist (cdr prev)))
6448 (while alist
6449 (if (= (gnus-info-level (car alist)) level)
6450 (progn
6451 (push (gnus-info-group (car alist)) gnus-killed-list)
6452 (setcdr prev (cdr alist)))
6453 (setq prev alist))
6454 (setq alist (cdr alist)))
6455 (gnus-make-hashtable-from-newsrc-alist)
6456 (gnus-group-list-groups)))
6458 (error "Can't kill; illegal level: %d" level))))
6460 (defun gnus-group-list-all-groups (&optional arg)
6461 "List all newsgroups with level ARG or lower.
6462 Default is gnus-level-unsubscribed, which lists all subscribed and most
6463 unsubscribed groups."
6464 (interactive "P")
6465 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6467 ;; Redefine this to list ALL killed groups if prefix arg used.
6468 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6469 (defun gnus-group-list-killed (&optional arg)
6470 "List all killed newsgroups in the group buffer.
6471 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6472 entail asking the server for the groups."
6473 (interactive "P")
6474 ;; Find all possible killed newsgroups if arg.
6475 (when arg
6476 (gnus-get-killed-groups))
6477 (if (not gnus-killed-list)
6478 (gnus-message 6 "No killed groups")
6479 (let (gnus-group-list-mode)
6480 (funcall gnus-group-prepare-function
6481 gnus-level-killed t gnus-level-killed))
6482 (goto-char (point-min)))
6483 (gnus-group-position-point))
6485 (defun gnus-group-list-zombies ()
6486 "List all zombie newsgroups in the group buffer."
6487 (interactive)
6488 (if (not gnus-zombie-list)
6489 (gnus-message 6 "No zombie groups")
6490 (let (gnus-group-list-mode)
6491 (funcall gnus-group-prepare-function
6492 gnus-level-zombie t gnus-level-zombie))
6493 (goto-char (point-min)))
6494 (gnus-group-position-point))
6496 (defun gnus-group-list-active ()
6497 "List all groups that are available from the server(s)."
6498 (interactive)
6499 ;; First we make sure that we have really read the active file.
6500 (unless (gnus-read-active-file-p)
6501 (let ((gnus-read-active-file t))
6502 (gnus-read-active-file)))
6503 ;; Find all groups and sort them.
6504 (let ((groups
6505 (sort
6506 (let (list)
6507 (mapatoms
6508 (lambda (sym)
6509 (and (boundp sym)
6510 (symbol-value sym)
6511 (setq list (cons (symbol-name sym) list))))
6512 gnus-active-hashtb)
6513 list)
6514 'string<))
6515 (buffer-read-only nil))
6516 (erase-buffer)
6517 (while groups
6518 (gnus-group-insert-group-line-info (pop groups)))
6519 (goto-char (point-min))))
6521 (defun gnus-activate-all-groups (level)
6522 "Activate absolutely all groups."
6523 (interactive (list 7))
6524 (let ((gnus-activate-level level)
6525 (gnus-activate-foreign-newsgroups level))
6526 (gnus-group-get-new-news)))
6528 (defun gnus-group-get-new-news (&optional arg)
6529 "Get newly arrived articles.
6530 If ARG is a number, it specifies which levels you are interested in
6531 re-scanning. If ARG is non-nil and not a number, this will force
6532 \"hard\" re-reading of the active files from all servers."
6533 (interactive "P")
6534 (run-hooks 'gnus-get-new-news-hook)
6535 ;; We might read in new NoCeM messages here.
6536 (when (and gnus-use-nocem
6537 (null arg))
6538 (gnus-nocem-scan-groups))
6539 ;; If ARG is not a number, then we read the active file.
6540 (when (and arg (not (numberp arg)))
6541 (let ((gnus-read-active-file t))
6542 (gnus-read-active-file))
6543 (setq arg nil))
6545 (setq arg (gnus-group-default-level arg t))
6546 (if (and gnus-read-active-file (not arg))
6547 (progn
6548 (gnus-read-active-file)
6549 (gnus-get-unread-articles arg))
6550 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6551 (gnus-get-unread-articles arg)))
6552 (run-hooks 'gnus-after-getting-new-news-hook)
6553 (gnus-group-list-groups))
6555 (defun gnus-group-get-new-news-this-group (&optional n)
6556 "Check for newly arrived news in the current group (and the N-1 next groups).
6557 The difference between N and the number of newsgroup checked is returned.
6558 If N is negative, this group and the N-1 previous groups will be checked."
6559 (interactive "P")
6560 (let* ((groups (gnus-group-process-prefix n))
6561 (ret (if (numberp n) (- n (length groups)) 0))
6562 (beg (unless n (point)))
6563 group)
6564 (while (setq group (pop groups))
6565 (gnus-group-remove-mark group)
6566 (if (gnus-activate-group group 'scan)
6567 (progn
6568 (gnus-get-unread-articles-in-group
6569 (gnus-get-info group) (gnus-active group) t)
6570 (unless (gnus-virtual-group-p group)
6571 (gnus-close-group group))
6572 (gnus-group-update-group group))
6573 (if (eq (gnus-server-status (gnus-find-method-for-group group))
6574 'denied)
6575 (gnus-error "Server denied access")
6576 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
6577 (when beg (goto-char beg))
6578 (when gnus-goto-next-group-when-activating
6579 (gnus-group-next-unread-group 1 t))
6580 (gnus-summary-position-point)
6581 ret))
6583 (defun gnus-group-fetch-faq (group &optional faq-dir)
6584 "Fetch the FAQ for the current group."
6585 (interactive
6586 (list
6587 (and (gnus-group-group-name)
6588 (gnus-group-real-name (gnus-group-group-name)))
6589 (cond (current-prefix-arg
6590 (completing-read
6591 "Faq dir: " (and (listp gnus-group-faq-directory)
6592 (mapcar (lambda (file) (list file))
6593 gnus-group-faq-directory)))))))
6594 (or faq-dir
6595 (setq faq-dir (if (listp gnus-group-faq-directory)
6596 (car gnus-group-faq-directory)
6597 gnus-group-faq-directory)))
6598 (or group (error "No group name given"))
6599 (let ((file (concat (file-name-as-directory faq-dir)
6600 (gnus-group-real-name group))))
6601 (if (not (file-exists-p file))
6602 (error "No such file: %s" file)
6603 (find-file file))))
6605 (defun gnus-group-describe-group (force &optional group)
6606 "Display a description of the current newsgroup."
6607 (interactive (list current-prefix-arg (gnus-group-group-name)))
6608 (let* ((method (gnus-find-method-for-group group))
6609 (mname (gnus-group-prefixed-name "" method))
6610 desc)
6611 (when (and force
6612 gnus-description-hashtb)
6613 (gnus-sethash mname nil gnus-description-hashtb))
6614 (or group (error "No group name given"))
6615 (and (or (and gnus-description-hashtb
6616 ;; We check whether this group's method has been
6617 ;; queried for a description file.
6618 (gnus-gethash mname gnus-description-hashtb))
6619 (setq desc (gnus-group-get-description group))
6620 (gnus-read-descriptions-file method))
6621 (gnus-message 1
6622 (or desc (gnus-gethash group gnus-description-hashtb)
6623 "No description available")))))
6625 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6626 (defun gnus-group-describe-all-groups (&optional force)
6627 "Pop up a buffer with descriptions of all newsgroups."
6628 (interactive "P")
6629 (and force (setq gnus-description-hashtb nil))
6630 (if (not (or gnus-description-hashtb
6631 (gnus-read-all-descriptions-files)))
6632 (error "Couldn't request descriptions file"))
6633 (let ((buffer-read-only nil)
6635 (erase-buffer)
6636 (mapatoms
6637 (lambda (group)
6638 (setq b (point))
6639 (insert (format " *: %-20s %s\n" (symbol-name group)
6640 (symbol-value group)))
6641 (gnus-add-text-properties
6642 b (1+ b) (list 'gnus-group group
6643 'gnus-unread t 'gnus-marked nil
6644 'gnus-level (1+ gnus-level-subscribed))))
6645 gnus-description-hashtb)
6646 (goto-char (point-min))
6647 (gnus-group-position-point)))
6649 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6650 (defun gnus-group-apropos (regexp &optional search-description)
6651 "List all newsgroups that have names that match a regexp."
6652 (interactive "sGnus apropos (regexp): ")
6653 (let ((prev "")
6654 (obuf (current-buffer))
6655 groups des)
6656 ;; Go through all newsgroups that are known to Gnus.
6657 (mapatoms
6658 (lambda (group)
6659 (and (symbol-name group)
6660 (string-match regexp (symbol-name group))
6661 (setq groups (cons (symbol-name group) groups))))
6662 gnus-active-hashtb)
6663 ;; Also go through all descriptions that are known to Gnus.
6664 (when search-description
6665 (mapatoms
6666 (lambda (group)
6667 (and (string-match regexp (symbol-value group))
6668 (gnus-active (symbol-name group))
6669 (setq groups (cons (symbol-name group) groups))))
6670 gnus-description-hashtb))
6671 (if (not groups)
6672 (gnus-message 3 "No groups matched \"%s\"." regexp)
6673 ;; Print out all the groups.
6674 (save-excursion
6675 (pop-to-buffer "*Gnus Help*")
6676 (buffer-disable-undo (current-buffer))
6677 (erase-buffer)
6678 (setq groups (sort groups 'string<))
6679 (while groups
6680 ;; Groups may be entered twice into the list of groups.
6681 (if (not (string= (car groups) prev))
6682 (progn
6683 (insert (setq prev (car groups)) "\n")
6684 (if (and gnus-description-hashtb
6685 (setq des (gnus-gethash (car groups)
6686 gnus-description-hashtb)))
6687 (insert " " des "\n"))))
6688 (setq groups (cdr groups)))
6689 (goto-char (point-min))))
6690 (pop-to-buffer obuf)))
6692 (defun gnus-group-description-apropos (regexp)
6693 "List all newsgroups that have names or descriptions that match a regexp."
6694 (interactive "sGnus description apropos (regexp): ")
6695 (if (not (or gnus-description-hashtb
6696 (gnus-read-all-descriptions-files)))
6697 (error "Couldn't request descriptions file"))
6698 (gnus-group-apropos regexp t))
6700 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6701 (defun gnus-group-list-matching (level regexp &optional all lowest)
6702 "List all groups with unread articles that match REGEXP.
6703 If the prefix LEVEL is non-nil, it should be a number that says which
6704 level to cut off listing groups.
6705 If ALL, also list groups with no unread articles.
6706 If LOWEST, don't list groups with level lower than LOWEST.
6708 This command may read the active file."
6709 (interactive "P\nsList newsgroups matching: ")
6710 ;; First make sure active file has been read.
6711 (when (and level
6712 (> (prefix-numeric-value level) gnus-level-killed))
6713 (gnus-get-killed-groups))
6714 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6715 all (or lowest 1) regexp)
6716 (goto-char (point-min))
6717 (gnus-group-position-point))
6719 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6720 "List all groups that match REGEXP.
6721 If the prefix LEVEL is non-nil, it should be a number that says which
6722 level to cut off listing groups.
6723 If LOWEST, don't list groups with level lower than LOWEST."
6724 (interactive "P\nsList newsgroups matching: ")
6725 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6727 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6728 (defun gnus-group-save-newsrc (&optional force)
6729 "Save the Gnus startup files.
6730 If FORCE, force saving whether it is necessary or not."
6731 (interactive "P")
6732 (gnus-save-newsrc-file force))
6734 (defun gnus-group-restart (&optional arg)
6735 "Force Gnus to read the .newsrc file."
6736 (interactive "P")
6737 (when (gnus-yes-or-no-p
6738 (format "Are you sure you want to read %s? "
6739 gnus-current-startup-file))
6740 (gnus-save-newsrc-file)
6741 (gnus-setup-news 'force)
6742 (gnus-group-list-groups arg)))
6744 (defun gnus-group-read-init-file ()
6745 "Read the Gnus elisp init file."
6746 (interactive)
6747 (gnus-read-init-file))
6749 (defun gnus-group-check-bogus-groups (&optional silent)
6750 "Check bogus newsgroups.
6751 If given a prefix, don't ask for confirmation before removing a bogus
6752 group."
6753 (interactive "P")
6754 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6755 (gnus-group-list-groups))
6757 (defun gnus-group-edit-global-kill (&optional article group)
6758 "Edit the global kill file.
6759 If GROUP, edit that local kill file instead."
6760 (interactive "P")
6761 (setq gnus-current-kill-article article)
6762 (gnus-kill-file-edit-file group)
6763 (gnus-message
6765 (substitute-command-keys
6766 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6767 (if group "local" "global")))))
6769 (defun gnus-group-edit-local-kill (article group)
6770 "Edit a local kill file."
6771 (interactive (list nil (gnus-group-group-name)))
6772 (gnus-group-edit-global-kill article group))
6774 (defun gnus-group-force-update ()
6775 "Update `.newsrc' file."
6776 (interactive)
6777 (gnus-save-newsrc-file))
6779 (defun gnus-group-suspend ()
6780 "Suspend the current Gnus session.
6781 In fact, cleanup buffers except for group mode buffer.
6782 The hook gnus-suspend-gnus-hook is called before actually suspending."
6783 (interactive)
6784 (run-hooks 'gnus-suspend-gnus-hook)
6785 ;; Kill Gnus buffers except for group mode buffer.
6786 (let* ((group-buf (get-buffer gnus-group-buffer))
6787 ;; Do this on a separate list in case the user does a ^G before we finish
6788 (gnus-buffer-list
6789 (delete group-buf (delete gnus-dribble-buffer
6790 (append gnus-buffer-list nil)))))
6791 (while gnus-buffer-list
6792 (gnus-kill-buffer (pop gnus-buffer-list)))
6793 (gnus-kill-gnus-frames)
6794 (when group-buf
6795 (setq gnus-buffer-list (list group-buf))
6796 (bury-buffer group-buf)
6797 (delete-windows-on group-buf t))))
6799 (defun gnus-group-clear-dribble ()
6800 "Clear all information from the dribble buffer."
6801 (interactive)
6802 (gnus-dribble-clear)
6803 (gnus-message 7 "Cleared dribble buffer"))
6805 (defun gnus-group-exit ()
6806 "Quit reading news after updating .newsrc.eld and .newsrc.
6807 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6808 (interactive)
6809 (when
6810 (or noninteractive ;For gnus-batch-kill
6811 (not gnus-interactive-exit) ;Without confirmation
6812 gnus-expert-user
6813 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6814 (run-hooks 'gnus-exit-gnus-hook)
6815 ;; Offer to save data from non-quitted summary buffers.
6816 (gnus-offer-save-summaries)
6817 ;; Save the newsrc file(s).
6818 (gnus-save-newsrc-file)
6819 ;; Kill-em-all.
6820 (gnus-close-backends)
6821 ;; Reset everything.
6822 (gnus-clear-system)
6823 ;; Allow the user to do things after cleaning up.
6824 (run-hooks 'gnus-after-exiting-gnus-hook)))
6826 (defun gnus-close-backends ()
6827 ;; Send a close request to all backends that support such a request.
6828 (let ((methods gnus-valid-select-methods)
6829 func)
6830 (while methods
6831 (if (fboundp (setq func (intern (concat (caar methods)
6832 "-request-close"))))
6833 (funcall func))
6834 (setq methods (cdr methods)))))
6836 (defun gnus-group-quit ()
6837 "Quit reading news without updating .newsrc.eld or .newsrc.
6838 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6839 (interactive)
6840 (when (or noninteractive ;For gnus-batch-kill
6841 (zerop (buffer-size))
6842 (not (gnus-server-opened gnus-select-method))
6843 gnus-expert-user
6844 (not gnus-current-startup-file)
6845 (gnus-yes-or-no-p
6846 (format "Quit reading news without saving %s? "
6847 (file-name-nondirectory gnus-current-startup-file))))
6848 (run-hooks 'gnus-exit-gnus-hook)
6849 (if gnus-use-full-window
6850 (delete-other-windows)
6851 (gnus-remove-some-windows))
6852 (gnus-dribble-save)
6853 (gnus-close-backends)
6854 (gnus-clear-system)
6855 ;; Allow the user to do things after cleaning up.
6856 (run-hooks 'gnus-after-exiting-gnus-hook)))
6858 (defun gnus-offer-save-summaries ()
6859 "Offer to save all active summary buffers."
6860 (save-excursion
6861 (let ((buflist (buffer-list))
6862 buffers bufname)
6863 ;; Go through all buffers and find all summaries.
6864 (while buflist
6865 (and (setq bufname (buffer-name (car buflist)))
6866 (string-match "Summary" bufname)
6867 (save-excursion
6868 (set-buffer bufname)
6869 ;; We check that this is, indeed, a summary buffer.
6870 (and (eq major-mode 'gnus-summary-mode)
6871 ;; Also make sure this isn't bogus.
6872 gnus-newsgroup-prepared))
6873 (push bufname buffers))
6874 (setq buflist (cdr buflist)))
6875 ;; Go through all these summary buffers and offer to save them.
6876 (when buffers
6877 (map-y-or-n-p
6878 "Update summary buffer %s? "
6879 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6880 buffers)))))
6882 (defun gnus-group-describe-briefly ()
6883 "Give a one line description of the group mode commands."
6884 (interactive)
6885 (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")))
6887 (defun gnus-group-browse-foreign-server (method)
6888 "Browse a foreign news server.
6889 If called interactively, this function will ask for a select method
6890 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6891 If not, METHOD should be a list where the first element is the method
6892 and the second element is the address."
6893 (interactive
6894 (list (let ((how (completing-read
6895 "Which backend: "
6896 (append gnus-valid-select-methods gnus-server-alist)
6897 nil t (cons "nntp" 0) 'gnus-method-history)))
6898 ;; We either got a backend name or a virtual server name.
6899 ;; If the first, we also need an address.
6900 (if (assoc how gnus-valid-select-methods)
6901 (list (intern how)
6902 ;; Suggested by mapjph@bath.ac.uk.
6903 (completing-read
6904 "Address: "
6905 (mapcar (lambda (server) (list server))
6906 gnus-secondary-servers)))
6907 ;; We got a server name, so we find the method.
6908 (gnus-server-to-method how)))))
6909 (gnus-browse-foreign-server method))
6913 ;;; Gnus summary mode
6916 (defvar gnus-summary-mode-map nil)
6918 (put 'gnus-summary-mode 'mode-class 'special)
6920 (unless gnus-summary-mode-map
6921 (setq gnus-summary-mode-map (make-keymap))
6922 (suppress-keymap gnus-summary-mode-map)
6924 ;; Non-orthogonal keys
6926 (gnus-define-keys gnus-summary-mode-map
6927 " " gnus-summary-next-page
6928 "\177" gnus-summary-prev-page
6929 [delete] gnus-summary-prev-page
6930 "\r" gnus-summary-scroll-up
6931 "n" gnus-summary-next-unread-article
6932 "p" gnus-summary-prev-unread-article
6933 "N" gnus-summary-next-article
6934 "P" gnus-summary-prev-article
6935 "\M-\C-n" gnus-summary-next-same-subject
6936 "\M-\C-p" gnus-summary-prev-same-subject
6937 "\M-n" gnus-summary-next-unread-subject
6938 "\M-p" gnus-summary-prev-unread-subject
6939 "." gnus-summary-first-unread-article
6940 "," gnus-summary-best-unread-article
6941 "\M-s" gnus-summary-search-article-forward
6942 "\M-r" gnus-summary-search-article-backward
6943 "<" gnus-summary-beginning-of-article
6944 ">" gnus-summary-end-of-article
6945 "j" gnus-summary-goto-article
6946 "^" gnus-summary-refer-parent-article
6947 "\M-^" gnus-summary-refer-article
6948 "u" gnus-summary-tick-article-forward
6949 "!" gnus-summary-tick-article-forward
6950 "U" gnus-summary-tick-article-backward
6951 "d" gnus-summary-mark-as-read-forward
6952 "D" gnus-summary-mark-as-read-backward
6953 "E" gnus-summary-mark-as-expirable
6954 "\M-u" gnus-summary-clear-mark-forward
6955 "\M-U" gnus-summary-clear-mark-backward
6956 "k" gnus-summary-kill-same-subject-and-select
6957 "\C-k" gnus-summary-kill-same-subject
6958 "\M-\C-k" gnus-summary-kill-thread
6959 "\M-\C-l" gnus-summary-lower-thread
6960 "e" gnus-summary-edit-article
6961 "#" gnus-summary-mark-as-processable
6962 "\M-#" gnus-summary-unmark-as-processable
6963 "\M-\C-t" gnus-summary-toggle-threads
6964 "\M-\C-s" gnus-summary-show-thread
6965 "\M-\C-h" gnus-summary-hide-thread
6966 "\M-\C-f" gnus-summary-next-thread
6967 "\M-\C-b" gnus-summary-prev-thread
6968 "\M-\C-u" gnus-summary-up-thread
6969 "\M-\C-d" gnus-summary-down-thread
6970 "&" gnus-summary-execute-command
6971 "c" gnus-summary-catchup-and-exit
6972 "\C-w" gnus-summary-mark-region-as-read
6973 "\C-t" gnus-summary-toggle-truncation
6974 "?" gnus-summary-mark-as-dormant
6975 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6976 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6977 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6978 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6979 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6980 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6981 "=" gnus-summary-expand-window
6982 "\C-x\C-s" gnus-summary-reselect-current-group
6983 "\M-g" gnus-summary-rescan-group
6984 "w" gnus-summary-stop-page-breaking
6985 "\C-c\C-r" gnus-summary-caesar-message
6986 "\M-t" gnus-summary-toggle-mime
6987 "f" gnus-summary-followup
6988 "F" gnus-summary-followup-with-original
6989 "C" gnus-summary-cancel-article
6990 "r" gnus-summary-reply
6991 "R" gnus-summary-reply-with-original
6992 "\C-c\C-f" gnus-summary-mail-forward
6993 "o" gnus-summary-save-article
6994 "\C-o" gnus-summary-save-article-mail
6995 "|" gnus-summary-pipe-output
6996 "\M-k" gnus-summary-edit-local-kill
6997 "\M-K" gnus-summary-edit-global-kill
6998 "V" gnus-version
6999 "\C-c\C-d" gnus-summary-describe-group
7000 "q" gnus-summary-exit
7001 "Q" gnus-summary-exit-no-update
7002 "\C-c\C-i" gnus-info-find-node
7003 gnus-mouse-2 gnus-mouse-pick-article
7004 "m" gnus-summary-mail-other-window
7005 "a" gnus-summary-post-news
7006 "x" gnus-summary-limit-to-unread
7007 "s" gnus-summary-isearch-article
7008 "t" gnus-article-hide-headers
7009 "g" gnus-summary-show-article
7010 "l" gnus-summary-goto-last-article
7011 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
7012 "\C-d" gnus-summary-enter-digest-group
7013 "\C-c\C-b" gnus-bug
7014 "*" gnus-cache-enter-article
7015 "\M-*" gnus-cache-remove-article
7016 "\M-&" gnus-summary-universal-argument
7017 "\C-l" gnus-recenter
7018 "I" gnus-summary-increase-score
7019 "L" gnus-summary-lower-score
7021 "V" gnus-summary-score-map
7022 "X" gnus-uu-extract-map
7023 "S" gnus-summary-send-map)
7025 ;; Sort of orthogonal keymap
7026 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
7027 "t" gnus-summary-tick-article-forward
7028 "!" gnus-summary-tick-article-forward
7029 "d" gnus-summary-mark-as-read-forward
7030 "r" gnus-summary-mark-as-read-forward
7031 "c" gnus-summary-clear-mark-forward
7032 " " gnus-summary-clear-mark-forward
7033 "e" gnus-summary-mark-as-expirable
7034 "x" gnus-summary-mark-as-expirable
7035 "?" gnus-summary-mark-as-dormant
7036 "b" gnus-summary-set-bookmark
7037 "B" gnus-summary-remove-bookmark
7038 "#" gnus-summary-mark-as-processable
7039 "\M-#" gnus-summary-unmark-as-processable
7040 "S" gnus-summary-limit-include-expunged
7041 "C" gnus-summary-catchup
7042 "H" gnus-summary-catchup-to-here
7043 "\C-c" gnus-summary-catchup-all
7044 "k" gnus-summary-kill-same-subject-and-select
7045 "K" gnus-summary-kill-same-subject
7046 "P" gnus-uu-mark-map)
7048 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
7049 "c" gnus-summary-clear-above
7050 "u" gnus-summary-tick-above
7051 "m" gnus-summary-mark-above
7052 "k" gnus-summary-kill-below)
7054 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
7055 "/" gnus-summary-limit-to-subject
7056 "n" gnus-summary-limit-to-articles
7057 "w" gnus-summary-pop-limit
7058 "s" gnus-summary-limit-to-subject
7059 "a" gnus-summary-limit-to-author
7060 "u" gnus-summary-limit-to-unread
7061 "m" gnus-summary-limit-to-marks
7062 "v" gnus-summary-limit-to-score
7063 "D" gnus-summary-limit-include-dormant
7064 "d" gnus-summary-limit-exclude-dormant
7065 ;; "t" gnus-summary-limit-exclude-thread
7066 "E" gnus-summary-limit-include-expunged
7067 "c" gnus-summary-limit-exclude-childless-dormant
7068 "C" gnus-summary-limit-mark-excluded-as-read)
7070 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7071 "n" gnus-summary-next-unread-article
7072 "p" gnus-summary-prev-unread-article
7073 "N" gnus-summary-next-article
7074 "P" gnus-summary-prev-article
7075 "\C-n" gnus-summary-next-same-subject
7076 "\C-p" gnus-summary-prev-same-subject
7077 "\M-n" gnus-summary-next-unread-subject
7078 "\M-p" gnus-summary-prev-unread-subject
7079 "f" gnus-summary-first-unread-article
7080 "b" gnus-summary-best-unread-article
7081 "j" gnus-summary-goto-article
7082 "g" gnus-summary-goto-subject
7083 "l" gnus-summary-goto-last-article
7084 "p" gnus-summary-pop-article)
7086 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7087 "k" gnus-summary-kill-thread
7088 "l" gnus-summary-lower-thread
7089 "i" gnus-summary-raise-thread
7090 "T" gnus-summary-toggle-threads
7091 "t" gnus-summary-rethread-current
7092 "^" gnus-summary-reparent-thread
7093 "s" gnus-summary-show-thread
7094 "S" gnus-summary-show-all-threads
7095 "h" gnus-summary-hide-thread
7096 "H" gnus-summary-hide-all-threads
7097 "n" gnus-summary-next-thread
7098 "p" gnus-summary-prev-thread
7099 "u" gnus-summary-up-thread
7100 "o" gnus-summary-top-thread
7101 "d" gnus-summary-down-thread
7102 "#" gnus-uu-mark-thread
7103 "\M-#" gnus-uu-unmark-thread)
7105 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7106 "c" gnus-summary-catchup-and-exit
7107 "C" gnus-summary-catchup-all-and-exit
7108 "E" gnus-summary-exit-no-update
7109 "Q" gnus-summary-exit
7110 "Z" gnus-summary-exit
7111 "n" gnus-summary-catchup-and-goto-next-group
7112 "R" gnus-summary-reselect-current-group
7113 "G" gnus-summary-rescan-group
7114 "N" gnus-summary-next-group
7115 "P" gnus-summary-prev-group)
7117 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7118 " " gnus-summary-next-page
7119 "n" gnus-summary-next-page
7120 "\177" gnus-summary-prev-page
7121 [delete] gnus-summary-prev-page
7122 "p" gnus-summary-prev-page
7123 "\r" gnus-summary-scroll-up
7124 "<" gnus-summary-beginning-of-article
7125 ">" gnus-summary-end-of-article
7126 "b" gnus-summary-beginning-of-article
7127 "e" gnus-summary-end-of-article
7128 "^" gnus-summary-refer-parent-article
7129 "r" gnus-summary-refer-parent-article
7130 "R" gnus-summary-refer-references
7131 "g" gnus-summary-show-article
7132 "s" gnus-summary-isearch-article)
7134 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7135 "b" gnus-article-add-buttons
7136 "B" gnus-article-add-buttons-to-head
7137 "o" gnus-article-treat-overstrike
7138 ;; "w" gnus-article-word-wrap
7139 "w" gnus-article-fill-cited-article
7140 "c" gnus-article-remove-cr
7141 "L" gnus-article-remove-trailing-blank-lines
7142 "q" gnus-article-de-quoted-unreadable
7143 "f" gnus-article-display-x-face
7144 "l" gnus-summary-stop-page-breaking
7145 "r" gnus-summary-caesar-message
7146 "t" gnus-article-hide-headers
7147 "v" gnus-summary-verbose-headers
7148 "m" gnus-summary-toggle-mime)
7150 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7151 "a" gnus-article-hide
7152 "h" gnus-article-hide-headers
7153 "b" gnus-article-hide-boring-headers
7154 "s" gnus-article-hide-signature
7155 "c" gnus-article-hide-citation
7156 "p" gnus-article-hide-pgp
7157 "\C-c" gnus-article-hide-citation-maybe)
7159 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7160 "a" gnus-article-highlight
7161 "h" gnus-article-highlight-headers
7162 "c" gnus-article-highlight-citation
7163 "s" gnus-article-highlight-signature)
7165 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7166 "z" gnus-article-date-ut
7167 "u" gnus-article-date-ut
7168 "l" gnus-article-date-local
7169 "e" gnus-article-date-lapsed
7170 "o" gnus-article-date-original)
7172 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7173 "v" gnus-version
7174 "f" gnus-summary-fetch-faq
7175 "d" gnus-summary-describe-group
7176 "h" gnus-summary-describe-briefly
7177 "i" gnus-info-find-node)
7179 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7180 "e" gnus-summary-expire-articles
7181 "\M-\C-e" gnus-summary-expire-articles-now
7182 "\177" gnus-summary-delete-article
7183 [delete] gnus-summary-delete-article
7184 "m" gnus-summary-move-article
7185 "r" gnus-summary-respool-article
7186 "w" gnus-summary-edit-article
7187 "c" gnus-summary-copy-article
7188 "B" gnus-summary-crosspost-article
7189 "q" gnus-summary-respool-query
7190 "i" gnus-summary-import-article)
7192 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7193 "o" gnus-summary-save-article
7194 "m" gnus-summary-save-article-mail
7195 "r" gnus-summary-save-article-rmail
7196 "f" gnus-summary-save-article-file
7197 "b" gnus-summary-save-article-body-file
7198 "h" gnus-summary-save-article-folder
7199 "v" gnus-summary-save-article-vm
7200 "p" gnus-summary-pipe-output
7201 "s" gnus-soup-add-article)
7206 (defun gnus-summary-mode (&optional group)
7207 "Major mode for reading articles.
7209 All normal editing commands are switched off.
7210 \\<gnus-summary-mode-map>
7211 Each line in this buffer represents one article. To read an
7212 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7213 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7214 respectively.
7216 You can also post articles and send mail from this buffer. To
7217 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7218 of an article, type `\\[gnus-summary-reply]'.
7220 There are approx. one gazillion commands you can execute in this
7221 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7223 The following commands are available:
7225 \\{gnus-summary-mode-map}"
7226 (interactive)
7227 (when (and menu-bar-mode
7228 (gnus-visual-p 'summary-menu 'menu))
7229 (gnus-summary-make-menu-bar))
7230 (kill-all-local-variables)
7231 (gnus-summary-make-local-variables)
7232 (gnus-make-thread-indent-array)
7233 (gnus-simplify-mode-line)
7234 (setq major-mode 'gnus-summary-mode)
7235 (setq mode-name "Summary")
7236 (make-local-variable 'minor-mode-alist)
7237 (use-local-map gnus-summary-mode-map)
7238 (buffer-disable-undo (current-buffer))
7239 (setq buffer-read-only t) ;Disable modification
7240 (setq truncate-lines t)
7241 (setq selective-display t)
7242 (setq selective-display-ellipses t) ;Display `...'
7243 (setq buffer-display-table gnus-summary-display-table)
7244 (setq gnus-newsgroup-name group)
7245 (make-local-variable 'gnus-summary-line-format)
7246 (make-local-variable 'gnus-summary-line-format-spec)
7247 (make-local-variable 'gnus-summary-mark-positions)
7248 (gnus-make-local-hook 'post-command-hook)
7249 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
7250 (run-hooks 'gnus-summary-mode-hook))
7252 (defun gnus-summary-make-local-variables ()
7253 "Make all the local summary buffer variables."
7254 (let ((locals gnus-summary-local-variables)
7255 global local)
7256 (while (setq local (pop locals))
7257 (if (consp local)
7258 (progn
7259 (if (eq (cdr local) 'global)
7260 ;; Copy the global value of the variable.
7261 (setq global (symbol-value (car local)))
7262 ;; Use the value from the list.
7263 (setq global (eval (cdr local))))
7264 (make-local-variable (car local))
7265 (set (car local) global))
7266 ;; Simple nil-valued local variable.
7267 (make-local-variable local)
7268 (set local nil)))))
7270 (defun gnus-summary-make-display-table ()
7271 ;; Change the display table. Odd characters have a tendency to mess
7272 ;; up nicely formatted displays - we make all possible glyphs
7273 ;; display only a single character.
7275 ;; We start from the standard display table, if any.
7276 (setq gnus-summary-display-table
7277 (or (copy-sequence standard-display-table)
7278 (make-display-table)))
7279 ;; Nix out all the control chars...
7280 (let ((i 32))
7281 (while (>= (setq i (1- i)) 0)
7282 (aset gnus-summary-display-table i [??])))
7283 ;; ... but not newline and cr, of course. (cr is necessary for the
7284 ;; selective display).
7285 (aset gnus-summary-display-table ?\n nil)
7286 (aset gnus-summary-display-table ?\r nil)
7287 ;; We nix out any glyphs over 126 that are not set already.
7288 (let ((i 256))
7289 (while (>= (setq i (1- i)) 127)
7290 ;; Only modify if the entry is nil.
7291 (or (aref gnus-summary-display-table i)
7292 (aset gnus-summary-display-table i [??])))))
7294 (defun gnus-summary-clear-local-variables ()
7295 (let ((locals gnus-summary-local-variables))
7296 (while locals
7297 (if (consp (car locals))
7298 (and (vectorp (caar locals))
7299 (set (caar locals) nil))
7300 (and (vectorp (car locals))
7301 (set (car locals) nil)))
7302 (setq locals (cdr locals)))))
7304 ;; Summary data functions.
7306 (defmacro gnus-data-number (data)
7307 `(car ,data))
7309 (defmacro gnus-data-set-number (data number)
7310 `(setcar ,data ,number))
7312 (defmacro gnus-data-mark (data)
7313 `(nth 1 ,data))
7315 (defmacro gnus-data-set-mark (data mark)
7316 `(setcar (nthcdr 1 ,data) ,mark))
7318 (defmacro gnus-data-pos (data)
7319 `(nth 2 ,data))
7321 (defmacro gnus-data-set-pos (data pos)
7322 `(setcar (nthcdr 2 ,data) ,pos))
7324 (defmacro gnus-data-header (data)
7325 `(nth 3 ,data))
7327 (defmacro gnus-data-level (data)
7328 `(nth 4 ,data))
7330 (defmacro gnus-data-unread-p (data)
7331 `(= (nth 1 ,data) gnus-unread-mark))
7333 (defmacro gnus-data-pseudo-p (data)
7334 `(consp (nth 3 ,data)))
7336 (defmacro gnus-data-find (number)
7337 `(assq ,number gnus-newsgroup-data))
7339 (defmacro gnus-data-find-list (number &optional data)
7340 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7341 (memq (assq ,number bdata)
7342 bdata)))
7344 (defmacro gnus-data-make (number mark pos header level)
7345 `(list ,number ,mark ,pos ,header ,level))
7347 (defun gnus-data-enter (after-article number mark pos header level offset)
7348 (let ((data (gnus-data-find-list after-article)))
7349 (or data (error "No such article: %d" after-article))
7350 (setcdr data (cons (gnus-data-make number mark pos header level)
7351 (cdr data)))
7352 (setq gnus-newsgroup-data-reverse nil)
7353 (gnus-data-update-list (cddr data) offset)))
7355 (defun gnus-data-enter-list (after-article list &optional offset)
7356 (when list
7357 (let ((data (and after-article (gnus-data-find-list after-article)))
7358 (ilist list))
7359 (or data (not after-article) (error "No such article: %d" after-article))
7360 ;; Find the last element in the list to be spliced into the main
7361 ;; list.
7362 (while (cdr list)
7363 (setq list (cdr list)))
7364 (if (not data)
7365 (progn
7366 (setcdr list gnus-newsgroup-data)
7367 (setq gnus-newsgroup-data ilist)
7368 (and offset (gnus-data-update-list (cdr list) offset)))
7369 (setcdr list (cdr data))
7370 (setcdr data ilist)
7371 (and offset (gnus-data-update-list (cdr data) offset)))
7372 (setq gnus-newsgroup-data-reverse nil))))
7374 (defun gnus-data-remove (article &optional offset)
7375 (let ((data gnus-newsgroup-data))
7376 (if (= (gnus-data-number (car data)) article)
7377 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7378 gnus-newsgroup-data-reverse nil)
7379 (while (cdr data)
7380 (and (= (gnus-data-number (cadr data)) article)
7381 (progn
7382 (setcdr data (cddr data))
7383 (and offset (gnus-data-update-list (cdr data) offset))
7384 (setq data nil
7385 gnus-newsgroup-data-reverse nil)))
7386 (setq data (cdr data))))))
7388 (defmacro gnus-data-list (backward)
7389 `(if ,backward
7390 (or gnus-newsgroup-data-reverse
7391 (setq gnus-newsgroup-data-reverse
7392 (reverse gnus-newsgroup-data)))
7393 gnus-newsgroup-data))
7395 (defun gnus-data-update-list (data offset)
7396 "Add OFFSET to the POS of all data entries in DATA."
7397 (while data
7398 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7399 (setq data (cdr data))))
7401 (defun gnus-data-compute-positions ()
7402 "Compute the positions of all articles."
7403 (let ((data gnus-newsgroup-data)
7404 pos)
7405 (while data
7406 (when (setq pos (text-property-any
7407 (point-min) (point-max)
7408 'gnus-number (gnus-data-number (car data))))
7409 (gnus-data-set-pos (car data) (+ pos 3)))
7410 (setq data (cdr data)))))
7412 (defun gnus-summary-article-pseudo-p (article)
7413 "Say whether this article is a pseudo article or not."
7414 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7416 (defun gnus-article-parent-p (number)
7417 "Say whether this article is a parent or not."
7418 (let ((data (gnus-data-find-list number)))
7419 (and (cdr data) ; There has to be an article after...
7420 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7421 (gnus-data-level (nth 1 data))))))
7423 (defun gnus-article-children (number)
7424 "Return a list of all children to NUMBER."
7425 (let* ((data (gnus-data-find-list number))
7426 (level (gnus-data-level (car data)))
7427 children)
7428 (setq data (cdr data))
7429 (while (and data
7430 (= (gnus-data-level (car data)) (1+ level)))
7431 (push (gnus-data-number (car data)) children)
7432 (setq data (cdr data)))
7433 children))
7435 (defmacro gnus-summary-skip-intangible ()
7436 "If the current article is intangible, then jump to a different article."
7437 '(let ((to (get-text-property (point) 'gnus-intangible)))
7438 (and to (gnus-summary-goto-subject to))))
7440 (defmacro gnus-summary-article-intangible-p ()
7441 "Say whether this article is intangible or not."
7442 '(get-text-property (point) 'gnus-intangible))
7444 ;; Some summary mode macros.
7446 (defmacro gnus-summary-article-number ()
7447 "The article number of the article on the current line.
7448 If there isn's an article number here, then we return the current
7449 article number."
7450 '(progn
7451 (gnus-summary-skip-intangible)
7452 (or (get-text-property (point) 'gnus-number)
7453 (gnus-summary-last-subject))))
7455 (defmacro gnus-summary-article-header (&optional number)
7456 `(gnus-data-header (gnus-data-find
7457 ,(or number '(gnus-summary-article-number)))))
7459 (defmacro gnus-summary-thread-level (&optional number)
7460 `(if (and (eq gnus-summary-make-false-root 'dummy)
7461 (get-text-property (point) 'gnus-intangible))
7463 (gnus-data-level (gnus-data-find
7464 ,(or number '(gnus-summary-article-number))))))
7466 (defmacro gnus-summary-article-mark (&optional number)
7467 `(gnus-data-mark (gnus-data-find
7468 ,(or number '(gnus-summary-article-number)))))
7470 (defmacro gnus-summary-article-pos (&optional number)
7471 `(gnus-data-pos (gnus-data-find
7472 ,(or number '(gnus-summary-article-number)))))
7474 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7475 (defmacro gnus-summary-article-subject (&optional number)
7476 "Return current subject string or nil if nothing."
7477 `(let ((headers
7478 ,(if number
7479 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7480 '(gnus-data-header (assq (gnus-summary-article-number)
7481 gnus-newsgroup-data)))))
7482 (and headers
7483 (vectorp headers)
7484 (mail-header-subject headers))))
7486 (defmacro gnus-summary-article-score (&optional number)
7487 "Return current article score."
7488 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7489 gnus-newsgroup-scored))
7490 gnus-summary-default-score 0))
7492 (defun gnus-summary-article-children (&optional number)
7493 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7494 (level (gnus-data-level (car data)))
7495 l children)
7496 (while (and (setq data (cdr data))
7497 (> (setq l (gnus-data-level (car data))) level))
7498 (and (= (1+ level) l)
7499 (setq children (cons (gnus-data-number (car data))
7500 children))))
7501 (nreverse children)))
7503 (defun gnus-summary-article-parent (&optional number)
7504 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7505 (gnus-data-list t)))
7506 (level (gnus-data-level (car data))))
7507 (if (zerop level)
7508 () ; This is a root.
7509 ;; We search until we find an article with a level less than
7510 ;; this one. That function has to be the parent.
7511 (while (and (setq data (cdr data))
7512 (not (< (gnus-data-level (car data)) level))))
7513 (and data (gnus-data-number (car data))))))
7515 (defun gnus-unread-mark-p (mark)
7516 "Say whether MARK is the unread mark."
7517 (= mark gnus-unread-mark))
7519 (defun gnus-read-mark-p (mark)
7520 "Say whether MARK is one of the marks that mark as read.
7521 This is all marks except unread, ticked, dormant, and expirable."
7522 (not (or (= mark gnus-unread-mark)
7523 (= mark gnus-ticked-mark)
7524 (= mark gnus-dormant-mark)
7525 (= mark gnus-expirable-mark))))
7527 ;; Saving hidden threads.
7529 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7530 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7531 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7533 (defmacro gnus-save-hidden-threads (&rest forms)
7534 "Save hidden threads, eval FORMS, and restore the hidden threads."
7535 (let ((config (make-symbol "config")))
7536 `(let ((,config (gnus-hidden-threads-configuration)))
7537 (unwind-protect
7538 (progn
7539 ,@forms)
7540 (gnus-restore-hidden-threads-configuration ,config)))))
7542 (defun gnus-hidden-threads-configuration ()
7543 "Return the current hidden threads configuration."
7544 (save-excursion
7545 (let (config)
7546 (goto-char (point-min))
7547 (while (search-forward "\r" nil t)
7548 (push (1- (point)) config))
7549 config)))
7551 (defun gnus-restore-hidden-threads-configuration (config)
7552 "Restore hidden threads configuration from CONFIG."
7553 (let (point buffer-read-only)
7554 (while (setq point (pop config))
7555 (when (and (< point (point-max))
7556 (goto-char point)
7557 (= (following-char) ?\n))
7558 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7560 ;; Various summary mode internalish functions.
7562 (defun gnus-mouse-pick-article (e)
7563 (interactive "e")
7564 (mouse-set-point e)
7565 (gnus-summary-next-page nil t))
7567 (defun gnus-summary-setup-buffer (group)
7568 "Initialize summary buffer."
7569 (let ((buffer (concat "*Summary " group "*")))
7570 (if (get-buffer buffer)
7571 (progn
7572 (set-buffer buffer)
7573 (setq gnus-summary-buffer (current-buffer))
7574 (not gnus-newsgroup-prepared))
7575 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7576 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7577 (gnus-add-current-to-buffer-list)
7578 (gnus-summary-mode group)
7579 (when gnus-carpal
7580 (gnus-carpal-setup-buffer 'summary))
7581 (unless gnus-single-article-buffer
7582 (make-local-variable 'gnus-article-buffer)
7583 (make-local-variable 'gnus-article-current)
7584 (make-local-variable 'gnus-original-article-buffer))
7585 (setq gnus-newsgroup-name group)
7586 t)))
7588 (defun gnus-set-global-variables ()
7589 ;; Set the global equivalents of the summary buffer-local variables
7590 ;; to the latest values they had. These reflect the summary buffer
7591 ;; that was in action when the last article was fetched.
7592 (when (eq major-mode 'gnus-summary-mode)
7593 (setq gnus-summary-buffer (current-buffer))
7594 (let ((name gnus-newsgroup-name)
7595 (marked gnus-newsgroup-marked)
7596 (unread gnus-newsgroup-unreads)
7597 (headers gnus-current-headers)
7598 (data gnus-newsgroup-data)
7599 (summary gnus-summary-buffer)
7600 (article-buffer gnus-article-buffer)
7601 (original gnus-original-article-buffer)
7602 (gac gnus-article-current)
7603 (score-file gnus-current-score-file))
7604 (save-excursion
7605 (set-buffer gnus-group-buffer)
7606 (setq gnus-newsgroup-name name)
7607 (setq gnus-newsgroup-marked marked)
7608 (setq gnus-newsgroup-unreads unread)
7609 (setq gnus-current-headers headers)
7610 (setq gnus-newsgroup-data data)
7611 (setq gnus-article-current gac)
7612 (setq gnus-summary-buffer summary)
7613 (setq gnus-article-buffer article-buffer)
7614 (setq gnus-original-article-buffer original)
7615 (setq gnus-current-score-file score-file)))))
7617 (defun gnus-summary-last-article-p (&optional article)
7618 "Return whether ARTICLE is the last article in the buffer."
7619 (if (not (setq article (or article (gnus-summary-article-number))))
7620 t ; All non-existant numbers are the last article. :-)
7621 (not (cdr (gnus-data-find-list article)))))
7623 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7624 "Insert a dummy root in the summary buffer."
7625 (beginning-of-line)
7626 (gnus-add-text-properties
7627 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7628 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7630 (defun gnus-make-thread-indent-array ()
7631 (let ((n 200))
7632 (unless (and gnus-thread-indent-array
7633 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7634 (setq gnus-thread-indent-array (make-vector 201 "")
7635 gnus-thread-indent-array-level gnus-thread-indent-level)
7636 (while (>= n 0)
7637 (aset gnus-thread-indent-array n
7638 (make-string (* n gnus-thread-indent-level) ? ))
7639 (setq n (1- n))))))
7641 (defun gnus-summary-insert-line
7642 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7643 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7644 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7645 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7646 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7647 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7648 (gnus-tmp-score-char
7649 (if (or (null gnus-summary-default-score)
7650 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7651 gnus-summary-zcore-fuzz)) ?
7652 (if (< gnus-tmp-score gnus-summary-default-score)
7653 gnus-score-below-mark gnus-score-over-mark)))
7654 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7655 ((memq gnus-tmp-current gnus-newsgroup-cached)
7656 gnus-cached-mark)
7657 (gnus-tmp-replied gnus-replied-mark)
7658 ((memq gnus-tmp-current gnus-newsgroup-saved)
7659 gnus-saved-mark)
7660 (t gnus-unread-mark)))
7661 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7662 (gnus-tmp-name
7663 (cond
7664 ((string-match "(.+)" gnus-tmp-from)
7665 (substring gnus-tmp-from
7666 (1+ (match-beginning 0)) (1- (match-end 0))))
7667 ((string-match "<[^>]+> *$" gnus-tmp-from)
7668 (let ((beg (match-beginning 0)))
7669 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7670 (substring gnus-tmp-from (1+ (match-beginning 0))
7671 (1- (match-end 0))))
7672 (substring gnus-tmp-from 0 beg))))
7673 (t gnus-tmp-from)))
7674 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7675 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7676 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7677 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7678 (buffer-read-only nil))
7679 (when (string= gnus-tmp-name "")
7680 (setq gnus-tmp-name gnus-tmp-from))
7681 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7682 (gnus-put-text-property
7683 (point)
7684 (progn (eval gnus-summary-line-format-spec) (point))
7685 'gnus-number gnus-tmp-number)
7686 (when (gnus-visual-p 'summary-highlight 'highlight)
7687 (forward-line -1)
7688 (run-hooks 'gnus-summary-update-hook)
7689 (forward-line 1))))
7691 (defun gnus-summary-update-line (&optional dont-update)
7692 ;; Update summary line after change.
7693 (when (and gnus-summary-default-score
7694 (not gnus-summary-inhibit-highlight))
7695 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7696 (article (gnus-summary-article-number))
7697 (score (gnus-summary-article-score article)))
7698 (unless dont-update
7699 (if (and gnus-summary-mark-below
7700 (< (gnus-summary-article-score)
7701 gnus-summary-mark-below))
7702 ;; This article has a low score, so we mark it as read.
7703 (when (memq article gnus-newsgroup-unreads)
7704 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7705 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7706 ;; This article was previously marked as read on account
7707 ;; of a low score, but now it has risen, so we mark it as
7708 ;; unread.
7709 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7710 (gnus-summary-update-mark
7711 (if (or (null gnus-summary-default-score)
7712 (<= (abs (- score gnus-summary-default-score))
7713 gnus-summary-zcore-fuzz)) ?
7714 (if (< score gnus-summary-default-score)
7715 gnus-score-below-mark gnus-score-over-mark)) 'score))
7716 ;; Do visual highlighting.
7717 (when (gnus-visual-p 'summary-highlight 'highlight)
7718 (run-hooks 'gnus-summary-update-hook)))))
7720 (defvar gnus-tmp-new-adopts nil)
7722 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7723 ;; Sum up all elements (and sub-elements) in a list.
7724 (let* ((number
7725 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7726 (cond
7727 ((and (consp thread) (cdr thread))
7728 (apply
7729 '+ 1 (mapcar
7730 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7731 ((null thread)
7733 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7735 (t 0))))
7736 (when (and level (zerop level) gnus-tmp-new-adopts)
7737 (incf number
7738 (apply '+ (mapcar
7739 'gnus-summary-number-of-articles-in-thread
7740 gnus-tmp-new-adopts))))
7741 (if char
7742 (if (> number 1) gnus-not-empty-thread-mark
7743 gnus-empty-thread-mark)
7744 number)))
7746 (defun gnus-summary-set-local-parameters (group)
7747 "Go through the local params of GROUP and set all variable specs in that list."
7748 (let ((params (gnus-info-params (gnus-get-info group)))
7749 elem)
7750 (while params
7751 (setq elem (car params)
7752 params (cdr params))
7753 (and (consp elem) ; Has to be a cons.
7754 (consp (cdr elem)) ; The cdr has to be a list.
7755 (symbolp (car elem)) ; Has to be a symbol in there.
7756 (not (memq (car elem)
7757 '(quit-config to-address to-list to-group)))
7758 (progn ; So we set it.
7759 (make-local-variable (car elem))
7760 (set (car elem) (eval (nth 1 elem))))))))
7762 (defun gnus-summary-read-group (group &optional show-all no-article
7763 kill-buffer no-display)
7764 "Start reading news in newsgroup GROUP.
7765 If SHOW-ALL is non-nil, already read articles are also listed.
7766 If NO-ARTICLE is non-nil, no article is selected initially.
7767 If NO-DISPLAY, don't generate a summary buffer."
7768 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7769 (let* ((new-group (gnus-summary-setup-buffer group))
7770 (quit-config (gnus-group-quit-config group))
7771 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7772 (cond
7773 ;; This summary buffer exists already, so we just select it.
7774 ((not new-group)
7775 (gnus-set-global-variables)
7776 (when kill-buffer
7777 (gnus-kill-or-deaden-summary kill-buffer))
7778 (gnus-configure-windows 'summary 'force)
7779 (gnus-set-mode-line 'summary)
7780 (gnus-summary-position-point)
7781 (message "")
7783 ;; We couldn't select this group.
7784 ((null did-select)
7785 (when (and (eq major-mode 'gnus-summary-mode)
7786 (not (equal (current-buffer) kill-buffer)))
7787 (kill-buffer (current-buffer))
7788 (if (not quit-config)
7789 (progn
7790 (set-buffer gnus-group-buffer)
7791 (gnus-group-jump-to-group group)
7792 (gnus-group-next-unread-group 1))
7793 (if (not (buffer-name (car quit-config)))
7794 (gnus-configure-windows 'group 'force)
7795 (set-buffer (car quit-config))
7796 (and (eq major-mode 'gnus-summary-mode)
7797 (gnus-set-global-variables))
7798 (gnus-configure-windows (cdr quit-config)))))
7799 (gnus-message 3 "Can't select group")
7800 nil)
7801 ;; The user did a `C-g' while prompting for number of articles,
7802 ;; so we exit this group.
7803 ((eq did-select 'quit)
7804 (and (eq major-mode 'gnus-summary-mode)
7805 (not (equal (current-buffer) kill-buffer))
7806 (kill-buffer (current-buffer)))
7807 (when kill-buffer
7808 (gnus-kill-or-deaden-summary kill-buffer))
7809 (if (not quit-config)
7810 (progn
7811 (set-buffer gnus-group-buffer)
7812 (gnus-group-jump-to-group group)
7813 (gnus-group-next-unread-group 1)
7814 (gnus-configure-windows 'group 'force))
7815 (if (not (buffer-name (car quit-config)))
7816 (gnus-configure-windows 'group 'force)
7817 (set-buffer (car quit-config))
7818 (and (eq major-mode 'gnus-summary-mode)
7819 (gnus-set-global-variables))
7820 (gnus-configure-windows (cdr quit-config))))
7821 ;; Finally signal the quit.
7822 (signal 'quit nil))
7823 ;; The group was successfully selected.
7825 (gnus-set-global-variables)
7826 ;; Save the active value in effect when the group was entered.
7827 (setq gnus-newsgroup-active
7828 (gnus-copy-sequence
7829 (gnus-active gnus-newsgroup-name)))
7830 ;; You can change the summary buffer in some way with this hook.
7831 (run-hooks 'gnus-select-group-hook)
7832 ;; Set any local variables in the group parameters.
7833 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7834 (gnus-update-format-specifications)
7835 ;; Do score processing.
7836 (when gnus-use-scoring
7837 (gnus-possibly-score-headers))
7838 ;; Check whether to fill in the gaps in the threads.
7839 (when gnus-build-sparse-threads
7840 (gnus-build-sparse-threads))
7841 ;; Find the initial limit.
7842 (if gnus-show-threads
7843 (if show-all
7844 (let ((gnus-newsgroup-dormant nil))
7845 (gnus-summary-initial-limit show-all))
7846 (gnus-summary-initial-limit show-all))
7847 (setq gnus-newsgroup-limit
7848 (mapcar
7849 (lambda (header) (mail-header-number header))
7850 gnus-newsgroup-headers)))
7851 ;; Generate the summary buffer.
7852 (unless no-display
7853 (gnus-summary-prepare))
7854 (when gnus-use-trees
7855 (gnus-tree-open group)
7856 (setq gnus-summary-highlight-line-function
7857 'gnus-tree-highlight-article))
7858 ;; If the summary buffer is empty, but there are some low-scored
7859 ;; articles or some excluded dormants, we include these in the
7860 ;; buffer.
7861 (when (and (zerop (buffer-size))
7862 (not no-display))
7863 (cond (gnus-newsgroup-dormant
7864 (gnus-summary-limit-include-dormant))
7865 ((and gnus-newsgroup-scored show-all)
7866 (gnus-summary-limit-include-expunged))))
7867 ;; Function `gnus-apply-kill-file' must be called in this hook.
7868 (run-hooks 'gnus-apply-kill-hook)
7869 (if (and (zerop (buffer-size))
7870 (not no-display))
7871 (progn
7872 ;; This newsgroup is empty.
7873 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7874 (gnus-message 6 "No unread news")
7875 (when kill-buffer
7876 (gnus-kill-or-deaden-summary kill-buffer))
7877 ;; Return nil from this function.
7878 nil)
7879 ;; Hide conversation thread subtrees. We cannot do this in
7880 ;; gnus-summary-prepare-hook since kill processing may not
7881 ;; work with hidden articles.
7882 (and gnus-show-threads
7883 gnus-thread-hide-subtree
7884 (gnus-summary-hide-all-threads))
7885 ;; Show first unread article if requested.
7886 (if (and (not no-article)
7887 (not no-display)
7888 gnus-newsgroup-unreads
7889 gnus-auto-select-first)
7890 (unless (if (eq gnus-auto-select-first 'best)
7891 (gnus-summary-best-unread-article)
7892 (gnus-summary-first-unread-article))
7893 (gnus-configure-windows 'summary))
7894 ;; Don't select any articles, just move point to the first
7895 ;; article in the group.
7896 (goto-char (point-min))
7897 (gnus-summary-position-point)
7898 (gnus-set-mode-line 'summary)
7899 (gnus-configure-windows 'summary 'force))
7900 ;; If we are in async mode, we send some info to the backend.
7901 (when gnus-newsgroup-async
7902 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7903 (when kill-buffer
7904 (gnus-kill-or-deaden-summary kill-buffer))
7905 (when (get-buffer-window gnus-group-buffer t)
7906 ;; Gotta use windows, because recenter does wierd stuff if
7907 ;; the current buffer ain't the displayed window.
7908 (let ((owin (selected-window)))
7909 (select-window (get-buffer-window gnus-group-buffer t))
7910 (when (gnus-group-goto-group group)
7911 (recenter))
7912 (select-window owin))))
7913 ;; Mark this buffer as "prepared".
7914 (setq gnus-newsgroup-prepared t)
7915 t))))
7917 (defun gnus-summary-prepare ()
7918 "Generate the summary buffer."
7919 (let ((buffer-read-only nil))
7920 (erase-buffer)
7921 (setq gnus-newsgroup-data nil
7922 gnus-newsgroup-data-reverse nil)
7923 (run-hooks 'gnus-summary-generate-hook)
7924 ;; Generate the buffer, either with threads or without.
7925 (when gnus-newsgroup-headers
7926 (gnus-summary-prepare-threads
7927 (if gnus-show-threads
7928 (gnus-sort-gathered-threads
7929 (funcall gnus-summary-thread-gathering-function
7930 (gnus-sort-threads
7931 (gnus-cut-threads (gnus-make-threads)))))
7932 ;; Unthreaded display.
7933 (gnus-sort-articles gnus-newsgroup-headers))))
7934 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7935 ;; Call hooks for modifying summary buffer.
7936 (goto-char (point-min))
7937 (run-hooks 'gnus-summary-prepare-hook)))
7939 (defun gnus-gather-threads-by-subject (threads)
7940 "Gather threads by looking at Subject headers."
7941 (if (not gnus-summary-make-false-root)
7942 threads
7943 (let ((hashtb (gnus-make-hashtable 1023))
7944 (prev threads)
7945 (result threads)
7946 subject hthread whole-subject)
7947 (while threads
7948 (setq whole-subject (mail-header-subject (caar threads)))
7949 (setq subject
7950 (cond
7951 ;; Truncate the subject.
7952 ((numberp gnus-summary-gather-subject-limit)
7953 (setq subject (gnus-simplify-subject-re whole-subject))
7954 (if (> (length subject) gnus-summary-gather-subject-limit)
7955 (substring subject 0 gnus-summary-gather-subject-limit)
7956 subject))
7957 ;; Fuzzily simplify it.
7958 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7959 (gnus-simplify-subject-fuzzy whole-subject))
7960 ;; Just remove the leading "Re:".
7962 (gnus-simplify-subject-re whole-subject))))
7964 (if (and gnus-summary-gather-exclude-subject
7965 (string-match gnus-summary-gather-exclude-subject
7966 subject))
7967 () ; We don't want to do anything with this article.
7968 ;; We simplify the subject before looking it up in the
7969 ;; hash table.
7971 (if (setq hthread (gnus-gethash subject hashtb))
7972 (progn
7973 ;; We enter a dummy root into the thread, if we
7974 ;; haven't done that already.
7975 (unless (stringp (caar hthread))
7976 (setcar hthread (list whole-subject (car hthread))))
7977 ;; We add this new gathered thread to this gathered
7978 ;; thread.
7979 (setcdr (car hthread)
7980 (nconc (cdar hthread) (list (car threads))))
7981 ;; Remove it from the list of threads.
7982 (setcdr prev (cdr threads))
7983 (setq threads prev))
7984 ;; Enter this thread into the hash table.
7985 (gnus-sethash subject threads hashtb)))
7986 (setq prev threads)
7987 (setq threads (cdr threads)))
7988 result)))
7990 (defun gnus-gather-threads-by-references (threads)
7991 "Gather threads by looking at References headers."
7992 (let ((idhashtb (gnus-make-hashtable 1023))
7993 (thhashtb (gnus-make-hashtable 1023))
7994 (prev threads)
7995 (result threads)
7996 ids references id gthread gid entered)
7997 (while threads
7998 (when (setq references (mail-header-references (caar threads)))
7999 (setq id (mail-header-id (caar threads)))
8000 (setq ids (gnus-split-references references))
8001 (setq entered nil)
8002 (while ids
8003 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
8004 (progn
8005 (gnus-sethash (car ids) id idhashtb)
8006 (gnus-sethash id threads thhashtb))
8007 (setq gthread (gnus-gethash gid thhashtb))
8008 (unless entered
8009 ;; We enter a dummy root into the thread, if we
8010 ;; haven't done that already.
8011 (unless (stringp (caar gthread))
8012 (setcar gthread (list (mail-header-subject (caar gthread))
8013 (car gthread))))
8014 ;; We add this new gathered thread to this gathered
8015 ;; thread.
8016 (setcdr (car gthread)
8017 (nconc (cdar gthread) (list (car threads)))))
8018 ;; Add it into the thread hash table.
8019 (gnus-sethash id gthread thhashtb)
8020 (setq entered t)
8021 ;; Remove it from the list of threads.
8022 (setcdr prev (cdr threads))
8023 (setq threads prev))
8024 (setq ids (cdr ids))))
8025 (setq prev threads)
8026 (setq threads (cdr threads)))
8027 result))
8029 (defun gnus-sort-gathered-threads (threads)
8030 "Sort subtreads inside each gathered thread by article number."
8031 (let ((result threads))
8032 (while threads
8033 (when (stringp (caar threads))
8034 (setcdr (car threads)
8035 (sort (cdar threads) 'gnus-thread-sort-by-number)))
8036 (setq threads (cdr threads)))
8037 result))
8039 (defun gnus-make-threads ()
8040 "Go through the dependency hashtb and find the roots. Return all threads."
8041 (let (threads)
8042 (mapatoms
8043 (lambda (refs)
8044 (unless (car (symbol-value refs))
8045 ;; These threads do not refer back to any other articles,
8046 ;; so they're roots.
8047 (setq threads (append (cdr (symbol-value refs)) threads))))
8048 gnus-newsgroup-dependencies)
8049 threads))
8051 (defun gnus-build-sparse-threads ()
8052 (let ((headers gnus-newsgroup-headers)
8053 (deps gnus-newsgroup-dependencies)
8054 header references generation relations
8055 cthread subject child end pthread relation)
8056 ;; First we create an alist of generations/relations, where
8057 ;; generations is how much we trust the ralation, and the relation
8058 ;; is parent/child.
8059 (gnus-message 7 "Making sparse threads...")
8060 (save-excursion
8061 (nnheader-set-temp-buffer " *gnus sparse threads*")
8062 (while (setq header (pop headers))
8063 (when (and (setq references (mail-header-references header))
8064 (not (string= references "")))
8065 (insert references)
8066 (setq child (mail-header-id header)
8067 subject (mail-header-subject header))
8068 (setq generation 0)
8069 (while (search-backward ">" nil t)
8070 (setq end (1+ (point)))
8071 (when (search-backward "<" nil t)
8072 (push (list (incf generation)
8073 child (setq child (buffer-substring (point) end))
8074 subject)
8075 relations)))
8076 (push (list (1+ generation) child nil subject) relations)
8077 (erase-buffer)))
8078 (kill-buffer (current-buffer)))
8079 ;; Sort over trustworthiness.
8080 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8081 (while (setq relation (pop relations))
8082 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8083 (unless (car (symbol-value cthread))
8084 ;; Make this article the parent of these threads.
8085 (setcar (symbol-value cthread)
8086 (vector gnus-reffed-article-number
8087 (cadddr relation)
8088 "" ""
8089 (cadr relation)
8090 (or (caddr relation) "") 0 0 "")))
8091 (set cthread (list (vector gnus-reffed-article-number
8092 (cadddr relation)
8093 "" "" (cadr relation)
8094 (or (caddr relation) "") 0 0 ""))))
8095 (push gnus-reffed-article-number gnus-newsgroup-limit)
8096 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8097 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8098 gnus-newsgroup-reads)
8099 (decf gnus-reffed-article-number)
8100 ;; Make this new thread the child of its parent.
8101 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8102 (setcdr (symbol-value pthread)
8103 (nconc (cdr (symbol-value pthread))
8104 (list (symbol-value cthread))))
8105 (set pthread (list nil (symbol-value cthread))))))
8106 (gnus-message 7 "Making sparse threads...done")))
8108 (defun gnus-build-old-threads ()
8109 ;; Look at all the articles that refer back to old articles, and
8110 ;; fetch the headers for the articles that aren't there. This will
8111 ;; build complete threads - if the roots haven't been expired by the
8112 ;; server, that is.
8113 (let (id heads)
8114 (mapatoms
8115 (lambda (refs)
8116 (when (not (car (symbol-value refs)))
8117 (setq heads (cdr (symbol-value refs)))
8118 (while heads
8119 (if (memq (mail-header-number (caar heads))
8120 gnus-newsgroup-dormant)
8121 (setq heads (cdr heads))
8122 (setq id (symbol-name refs))
8123 (while (and (setq id (gnus-build-get-header id))
8124 (not (car (gnus-gethash
8125 id gnus-newsgroup-dependencies)))))
8126 (setq heads nil)))))
8127 gnus-newsgroup-dependencies)))
8129 (defun gnus-build-get-header (id)
8130 ;; Look through the buffer of NOV lines and find the header to
8131 ;; ID. Enter this line into the dependencies hash table, and return
8132 ;; the id of the parent article (if any).
8133 (let ((deps gnus-newsgroup-dependencies)
8134 found header)
8135 (prog1
8136 (save-excursion
8137 (set-buffer nntp-server-buffer)
8138 (goto-char (point-min))
8139 (while (and (not found) (search-forward id nil t))
8140 (beginning-of-line)
8141 (setq found (looking-at
8142 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8143 (regexp-quote id))))
8144 (or found (beginning-of-line 2)))
8145 (when found
8146 (beginning-of-line)
8147 (and
8148 (setq header (gnus-nov-parse-line
8149 (read (current-buffer)) deps))
8150 (gnus-parent-id (mail-header-references header)))))
8151 (when header
8152 (let ((number (mail-header-number header)))
8153 (push number gnus-newsgroup-limit)
8154 (push header gnus-newsgroup-headers)
8155 (if (memq number gnus-newsgroup-unselected)
8156 (progn
8157 (push number gnus-newsgroup-unreads)
8158 (setq gnus-newsgroup-unselected
8159 (delq number gnus-newsgroup-unselected)))
8160 (push number gnus-newsgroup-ancient)))))))
8162 (defun gnus-summary-update-article (article &optional iheader)
8163 "Update ARTICLE in the summary buffer."
8164 (set-buffer gnus-summary-buffer)
8165 (let* ((header (or iheader (gnus-summary-article-header article)))
8166 (id (mail-header-id header))
8167 (data (gnus-data-find article))
8168 (thread (gnus-id-to-thread id))
8169 (references (mail-header-references header))
8170 (parent
8171 (gnus-id-to-thread
8172 (or (gnus-parent-id
8173 (if (and references
8174 (not (equal "" references)))
8175 references))
8176 "none")))
8177 (buffer-read-only nil)
8178 (old (car thread))
8179 (number (mail-header-number header))
8180 pos)
8181 (when thread
8182 ;; !!! Should this be in or not?
8183 (unless iheader
8184 (setcar thread nil))
8185 (when parent
8186 (delq thread parent))
8187 (if (gnus-summary-insert-subject id header iheader)
8188 ;; Set the (possibly) new article number in the data structure.
8189 (gnus-data-set-number data (gnus-id-to-article id))
8190 (setcar thread old)
8191 nil))))
8193 (defun gnus-rebuild-thread (id)
8194 "Rebuild the thread containing ID."
8195 (let ((buffer-read-only nil)
8196 current thread data)
8197 (if (not gnus-show-threads)
8198 (setq thread (list (car (gnus-id-to-thread id))))
8199 ;; Get the thread this article is part of.
8200 (setq thread (gnus-remove-thread id)))
8201 (setq current (save-excursion
8202 (and (zerop (forward-line -1))
8203 (gnus-summary-article-number))))
8204 ;; If this is a gathered thread, we have to go some re-gathering.
8205 (when (stringp (car thread))
8206 (let ((subject (car thread))
8207 roots thr)
8208 (setq thread (cdr thread))
8209 (while thread
8210 (unless (memq (setq thr (gnus-id-to-thread
8211 (gnus-root-id
8212 (mail-header-id (caar thread)))))
8213 roots)
8214 (push thr roots))
8215 (setq thread (cdr thread)))
8216 ;; We now have all (unique) roots.
8217 (if (= (length roots) 1)
8218 ;; All the loose roots are now one solid root.
8219 (setq thread (car roots))
8220 (setq thread (cons subject (gnus-sort-threads roots))))))
8221 (let (threads)
8222 ;; We then insert this thread into the summary buffer.
8223 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8224 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8225 (setq data (nreverse gnus-newsgroup-data))
8226 (setq threads gnus-newsgroup-threads))
8227 ;; We splice the new data into the data structure.
8228 (gnus-data-enter-list current data)
8229 (gnus-data-compute-positions)
8230 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8232 (defun gnus-number-to-header (number)
8233 "Return the header for article NUMBER."
8234 (let ((headers gnus-newsgroup-headers))
8235 (while (and headers
8236 (not (= number (mail-header-number (car headers)))))
8237 (pop headers))
8238 (when headers
8239 (car headers))))
8241 (defun gnus-id-to-thread (id)
8242 "Return the (sub-)thread where ID appears."
8243 (gnus-gethash id gnus-newsgroup-dependencies))
8245 (defun gnus-id-to-article (id)
8246 "Return the article number of ID."
8247 (let ((thread (gnus-id-to-thread id)))
8248 (when (and thread
8249 (car thread))
8250 (mail-header-number (car thread)))))
8252 (defun gnus-id-to-header (id)
8253 "Return the article headers of ID."
8254 (car (gnus-id-to-thread id)))
8256 (defun gnus-article-displayed-root-p (article)
8257 "Say whether ARTICLE is a root(ish) article."
8258 (let ((level (gnus-summary-thread-level article))
8259 (refs (mail-header-references (gnus-summary-article-header article)))
8260 particle)
8261 (cond
8262 ((null level) nil)
8263 ((zerop level) t)
8264 ((null refs) t)
8265 ((null (gnus-parent-id refs)) t)
8266 ((and (= 1 level)
8267 (null (setq particle (gnus-id-to-article
8268 (gnus-parent-id refs))))
8269 (null (gnus-summary-thread-level particle)))))))
8271 (defun gnus-root-id (id)
8272 "Return the id of the root of the thread where ID appears."
8273 (let (last-id prev)
8274 (while (and id (setq prev (car (gnus-gethash
8275 id gnus-newsgroup-dependencies))))
8276 (setq last-id id
8277 id (gnus-parent-id (mail-header-references prev))))
8278 last-id))
8280 (defun gnus-remove-thread (id &optional dont-remove)
8281 "Remove the thread that has ID in it."
8282 (let ((dep gnus-newsgroup-dependencies)
8283 headers thread last-id)
8284 ;; First go up in this thread until we find the root.
8285 (setq last-id (gnus-root-id id))
8286 (setq headers (list (car (gnus-id-to-thread last-id))
8287 (caadr (gnus-id-to-thread last-id))))
8288 ;; We have now found the real root of this thread. It might have
8289 ;; been gathered into some loose thread, so we have to search
8290 ;; through the threads to find the thread we wanted.
8291 (let ((threads gnus-newsgroup-threads)
8292 sub)
8293 (while threads
8294 (setq sub (car threads))
8295 (if (stringp (car sub))
8296 ;; This is a gathered threads, so we look at the roots
8297 ;; below it to find whether this article in in this
8298 ;; gathered root.
8299 (progn
8300 (setq sub (cdr sub))
8301 (while sub
8302 (when (member (caar sub) headers)
8303 (setq thread (car threads)
8304 threads nil
8305 sub nil))
8306 (setq sub (cdr sub))))
8307 ;; It's an ordinary thread, so we check it.
8308 (when (eq (car sub) (car headers))
8309 (setq thread sub
8310 threads nil)))
8311 (setq threads (cdr threads)))
8312 ;; If this article is in no thread, then it's a root.
8313 (if thread
8314 (unless dont-remove
8315 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8316 (setq thread (gnus-gethash last-id dep)))
8317 (when thread
8318 (prog1
8319 thread ; We return this thread.
8320 (unless dont-remove
8321 (if (stringp (car thread))
8322 (progn
8323 ;; If we use dummy roots, then we have to remove the
8324 ;; dummy root as well.
8325 (when (eq gnus-summary-make-false-root 'dummy)
8326 ;; Uhm.
8328 (setq thread (cdr thread))
8329 (while thread
8330 (gnus-remove-thread-1 (car thread))
8331 (setq thread (cdr thread))))
8332 (gnus-remove-thread-1 thread))))))))
8334 (defun gnus-remove-thread-1 (thread)
8335 "Remove the thread THREAD recursively."
8336 (let ((number (mail-header-number (car thread)))
8337 pos)
8338 (when (setq pos (text-property-any
8339 (point-min) (point-max) 'gnus-number number))
8340 (goto-char pos)
8341 (gnus-delete-line)
8342 (gnus-data-remove number))
8343 (setq thread (cdr thread))
8344 (while thread
8345 (gnus-remove-thread-1 (pop thread)))))
8347 (defun gnus-sort-threads (threads)
8348 "Sort THREADS."
8349 (if (not gnus-thread-sort-functions)
8350 threads
8351 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8352 (car gnus-thread-sort-functions)
8353 `(lambda (t1 t2)
8354 ,(gnus-make-sort-function
8355 (reverse gnus-thread-sort-functions))))))
8356 (gnus-message 7 "Sorting threads...")
8357 (prog1
8358 (sort threads func)
8359 (gnus-message 7 "Sorting threads...done")))))
8361 (defun gnus-sort-articles (articles)
8362 "Sort ARTICLES."
8363 (when gnus-article-sort-functions
8364 (let ((func (if (= 1 (length gnus-article-sort-functions))
8365 (car gnus-article-sort-functions)
8366 `(lambda (t1 t2)
8367 ,(gnus-make-sort-function
8368 (reverse gnus-article-sort-functions))))))
8369 (gnus-message 7 "Sorting articles...")
8370 (prog1
8371 (setq gnus-newsgroup-headers (sort articles func))
8372 (gnus-message 7 "Sorting articles...done")))))
8374 (defun gnus-make-sort-function (funs)
8375 "Return a composite sort condition based on the functions in FUNC."
8376 (if (cdr funs)
8377 `(or (,(car funs) t1 t2)
8378 (and (not (,(car funs) t2 t1))
8379 ,(gnus-make-sort-function (cdr funs))))
8380 `(,(car funs) t1 t2)))
8382 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8383 (defmacro gnus-thread-header (thread)
8384 ;; Return header of first article in THREAD.
8385 ;; Note that THREAD must never, ever be anything else than a variable -
8386 ;; using some other form will lead to serious barfage.
8387 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8388 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8389 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8390 (vector thread) 2))
8392 (defsubst gnus-article-sort-by-number (h1 h2)
8393 "Sort articles by article number."
8394 (< (mail-header-number h1)
8395 (mail-header-number h2)))
8397 (defun gnus-thread-sort-by-number (h1 h2)
8398 "Sort threads by root article number."
8399 (gnus-article-sort-by-number
8400 (gnus-thread-header h1) (gnus-thread-header h2)))
8402 (defsubst gnus-article-sort-by-author (h1 h2)
8403 "Sort articles by root author."
8404 (string-lessp
8405 (let ((extract (funcall
8406 gnus-extract-address-components
8407 (mail-header-from h1))))
8408 (or (car extract) (cdr extract)))
8409 (let ((extract (funcall
8410 gnus-extract-address-components
8411 (mail-header-from h2))))
8412 (or (car extract) (cdr extract)))))
8414 (defun gnus-thread-sort-by-author (h1 h2)
8415 "Sort threads by root author."
8416 (gnus-article-sort-by-author
8417 (gnus-thread-header h1) (gnus-thread-header h2)))
8419 (defsubst gnus-article-sort-by-subject (h1 h2)
8420 "Sort articles by root subject."
8421 (string-lessp
8422 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8423 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8425 (defun gnus-thread-sort-by-subject (h1 h2)
8426 "Sort threads by root subject."
8427 (gnus-article-sort-by-subject
8428 (gnus-thread-header h1) (gnus-thread-header h2)))
8430 (defsubst gnus-article-sort-by-date (h1 h2)
8431 "Sort articles by root article date."
8432 (string-lessp
8433 (inline (gnus-sortable-date (mail-header-date h1)))
8434 (inline (gnus-sortable-date (mail-header-date h2)))))
8436 (defun gnus-thread-sort-by-date (h1 h2)
8437 "Sort threads by root article date."
8438 (gnus-article-sort-by-date
8439 (gnus-thread-header h1) (gnus-thread-header h2)))
8441 (defsubst gnus-article-sort-by-score (h1 h2)
8442 "Sort articles by root article score.
8443 Unscored articles will be counted as having a score of zero."
8444 (> (or (cdr (assq (mail-header-number h1)
8445 gnus-newsgroup-scored))
8446 gnus-summary-default-score 0)
8447 (or (cdr (assq (mail-header-number h2)
8448 gnus-newsgroup-scored))
8449 gnus-summary-default-score 0)))
8451 (defun gnus-thread-sort-by-score (h1 h2)
8452 "Sort threads by root article score."
8453 (gnus-article-sort-by-score
8454 (gnus-thread-header h1) (gnus-thread-header h2)))
8456 (defun gnus-thread-sort-by-total-score (h1 h2)
8457 "Sort threads by the sum of all scores in the thread.
8458 Unscored articles will be counted as having a score of zero."
8459 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8461 (defun gnus-thread-total-score (thread)
8462 ;; This function find the total score of THREAD.
8463 (cond ((null thread)
8465 ((consp thread)
8466 (if (stringp (car thread))
8467 (apply gnus-thread-score-function 0
8468 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8469 (gnus-thread-total-score-1 thread)))
8471 (gnus-thread-total-score-1 (list thread)))))
8473 (defun gnus-thread-total-score-1 (root)
8474 ;; This function find the total score of the thread below ROOT.
8475 (setq root (car root))
8476 (apply gnus-thread-score-function
8477 (or (append
8478 (mapcar 'gnus-thread-total-score
8479 (cdr (gnus-gethash (mail-header-id root)
8480 gnus-newsgroup-dependencies)))
8481 (if (> (mail-header-number root) 0)
8482 (list (or (cdr (assq (mail-header-number root)
8483 gnus-newsgroup-scored))
8484 gnus-summary-default-score 0))))
8485 (list gnus-summary-default-score)
8486 '(0))))
8488 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8489 (defvar gnus-tmp-prev-subject nil)
8490 (defvar gnus-tmp-false-parent nil)
8491 (defvar gnus-tmp-root-expunged nil)
8492 (defvar gnus-tmp-dummy-line nil)
8494 (defun gnus-summary-prepare-threads (threads)
8495 "Prepare summary buffer from THREADS and indentation LEVEL.
8496 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8497 or a straight list of headers."
8498 (gnus-message 7 "Generating summary...")
8500 (setq gnus-newsgroup-threads threads)
8501 (beginning-of-line)
8503 (let ((gnus-tmp-level 0)
8504 (default-score (or gnus-summary-default-score 0))
8505 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8506 thread number subject stack state gnus-tmp-gathered beg-match
8507 new-roots gnus-tmp-new-adopts thread-end
8508 gnus-tmp-header gnus-tmp-unread
8509 gnus-tmp-replied gnus-tmp-subject-or-nil
8510 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8511 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8512 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8514 (setq gnus-tmp-prev-subject nil)
8516 (if (vectorp (car threads))
8517 ;; If this is a straight (sic) list of headers, then a
8518 ;; threaded summary display isn't required, so we just create
8519 ;; an unthreaded one.
8520 (gnus-summary-prepare-unthreaded threads)
8522 ;; Do the threaded display.
8524 (while (or threads stack gnus-tmp-new-adopts new-roots)
8526 (if (and (= gnus-tmp-level 0)
8527 (not (setq gnus-tmp-dummy-line nil))
8528 (or (not stack)
8529 (= (caar stack) 0))
8530 (not gnus-tmp-false-parent)
8531 (or gnus-tmp-new-adopts new-roots))
8532 (if gnus-tmp-new-adopts
8533 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8534 thread (list (car gnus-tmp-new-adopts))
8535 gnus-tmp-header (caar thread)
8536 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8537 (if new-roots
8538 (setq thread (list (car new-roots))
8539 gnus-tmp-header (caar thread)
8540 new-roots (cdr new-roots))))
8542 (if threads
8543 ;; If there are some threads, we do them before the
8544 ;; threads on the stack.
8545 (setq thread threads
8546 gnus-tmp-header (caar thread))
8547 ;; There were no current threads, so we pop something off
8548 ;; the stack.
8549 (setq state (car stack)
8550 gnus-tmp-level (car state)
8551 thread (cdr state)
8552 stack (cdr stack)
8553 gnus-tmp-header (caar thread))))
8555 (setq gnus-tmp-false-parent nil)
8556 (setq gnus-tmp-root-expunged nil)
8557 (setq thread-end nil)
8559 (if (stringp gnus-tmp-header)
8560 ;; The header is a dummy root.
8561 (cond
8562 ((eq gnus-summary-make-false-root 'adopt)
8563 ;; We let the first article adopt the rest.
8564 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8565 (cddar thread)))
8566 (setq gnus-tmp-gathered
8567 (nconc (mapcar
8568 (lambda (h) (mail-header-number (car h)))
8569 (cddar thread))
8570 gnus-tmp-gathered))
8571 (setq thread (cons (list (caar thread)
8572 (cadar thread))
8573 (cdr thread)))
8574 (setq gnus-tmp-level -1
8575 gnus-tmp-false-parent t))
8576 ((eq gnus-summary-make-false-root 'empty)
8577 ;; We print adopted articles with empty subject fields.
8578 (setq gnus-tmp-gathered
8579 (nconc (mapcar
8580 (lambda (h) (mail-header-number (car h)))
8581 (cddar thread))
8582 gnus-tmp-gathered))
8583 (setq gnus-tmp-level -1))
8584 ((eq gnus-summary-make-false-root 'dummy)
8585 ;; We remember that we probably want to output a dummy
8586 ;; root.
8587 (setq gnus-tmp-dummy-line gnus-tmp-header)
8588 (setq gnus-tmp-prev-subject gnus-tmp-header))
8590 ;; We do not make a root for the gathered
8591 ;; sub-threads at all.
8592 (setq gnus-tmp-level -1)))
8594 (setq number (mail-header-number gnus-tmp-header)
8595 subject (mail-header-subject gnus-tmp-header))
8597 (cond
8598 ;; If the thread has changed subject, we might want to make
8599 ;; this subthread into a root.
8600 ((and (null gnus-thread-ignore-subject)
8601 (not (zerop gnus-tmp-level))
8602 gnus-tmp-prev-subject
8603 (not (inline
8604 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8605 (setq new-roots (nconc new-roots (list (car thread)))
8606 thread-end t
8607 gnus-tmp-header nil))
8608 ;; If the article lies outside the current limit,
8609 ;; then we do not display it.
8610 ((and (not (memq number gnus-newsgroup-limit))
8611 (not gnus-tmp-dummy-line))
8612 (setq gnus-tmp-gathered
8613 (nconc (mapcar
8614 (lambda (h) (mail-header-number (car h)))
8615 (cdar thread))
8616 gnus-tmp-gathered))
8617 (setq gnus-tmp-new-adopts (if (cdar thread)
8618 (append gnus-tmp-new-adopts
8619 (cdar thread))
8620 gnus-tmp-new-adopts)
8621 thread-end t
8622 gnus-tmp-header nil)
8623 (when (zerop gnus-tmp-level)
8624 (setq gnus-tmp-root-expunged t)))
8625 ;; Perhaps this article is to be marked as read?
8626 ((and gnus-summary-mark-below
8627 (< (or (cdr (assq number gnus-newsgroup-scored))
8628 default-score)
8629 gnus-summary-mark-below)
8630 ;; Don't touch sparse articles.
8631 (not (memq number gnus-newsgroup-sparse))
8632 (not (memq number gnus-newsgroup-ancient)))
8633 (setq gnus-newsgroup-unreads
8634 (delq number gnus-newsgroup-unreads))
8635 (if gnus-newsgroup-auto-expire
8636 (push number gnus-newsgroup-expirable)
8637 (push (cons number gnus-low-score-mark)
8638 gnus-newsgroup-reads))))
8640 (when gnus-tmp-header
8641 ;; We may have an old dummy line to output before this
8642 ;; article.
8643 (when gnus-tmp-dummy-line
8644 (gnus-summary-insert-dummy-line
8645 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8646 (setq gnus-tmp-dummy-line nil))
8648 ;; Compute the mark.
8649 (setq
8650 gnus-tmp-unread
8651 (cond
8652 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8653 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8654 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8655 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8656 (t (or (cdr (assq number gnus-newsgroup-reads))
8657 gnus-ancient-mark))))
8659 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8660 gnus-tmp-header gnus-tmp-level)
8661 gnus-newsgroup-data)
8663 ;; Actually insert the line.
8664 (setq
8665 gnus-tmp-subject-or-nil
8666 (cond
8667 ((and gnus-thread-ignore-subject
8668 gnus-tmp-prev-subject
8669 (not (inline (gnus-subject-equal
8670 gnus-tmp-prev-subject subject))))
8671 subject)
8672 ((zerop gnus-tmp-level)
8673 (if (and (eq gnus-summary-make-false-root 'empty)
8674 (memq number gnus-tmp-gathered)
8675 gnus-tmp-prev-subject
8676 (inline (gnus-subject-equal
8677 gnus-tmp-prev-subject subject)))
8678 gnus-summary-same-subject
8679 subject))
8680 (t gnus-summary-same-subject)))
8681 (if (and (eq gnus-summary-make-false-root 'adopt)
8682 (= gnus-tmp-level 1)
8683 (memq number gnus-tmp-gathered))
8684 (setq gnus-tmp-opening-bracket ?\<
8685 gnus-tmp-closing-bracket ?\>)
8686 (setq gnus-tmp-opening-bracket ?\[
8687 gnus-tmp-closing-bracket ?\]))
8688 (setq
8689 gnus-tmp-indentation
8690 (aref gnus-thread-indent-array gnus-tmp-level)
8691 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8692 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8693 gnus-summary-default-score 0)
8694 gnus-tmp-score-char
8695 (if (or (null gnus-summary-default-score)
8696 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8697 gnus-summary-zcore-fuzz)) ?
8698 (if (< gnus-tmp-score gnus-summary-default-score)
8699 gnus-score-below-mark gnus-score-over-mark))
8700 gnus-tmp-replied
8701 (cond ((memq number gnus-newsgroup-processable)
8702 gnus-process-mark)
8703 ((memq number gnus-newsgroup-cached)
8704 gnus-cached-mark)
8705 ((memq number gnus-newsgroup-replied)
8706 gnus-replied-mark)
8707 ((memq number gnus-newsgroup-saved)
8708 gnus-saved-mark)
8709 (t gnus-unread-mark))
8710 gnus-tmp-from (mail-header-from gnus-tmp-header)
8711 gnus-tmp-name
8712 (cond
8713 ((string-match "(.+)" gnus-tmp-from)
8714 (substring gnus-tmp-from
8715 (1+ (match-beginning 0)) (1- (match-end 0))))
8716 ((string-match "<[^>]+> *$" gnus-tmp-from)
8717 (setq beg-match (match-beginning 0))
8718 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8719 (substring gnus-tmp-from (1+ (match-beginning 0))
8720 (1- (match-end 0))))
8721 (substring gnus-tmp-from 0 beg-match)))
8722 (t gnus-tmp-from)))
8723 (when (string= gnus-tmp-name "")
8724 (setq gnus-tmp-name gnus-tmp-from))
8725 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8726 (gnus-put-text-property
8727 (point)
8728 (progn (eval gnus-summary-line-format-spec) (point))
8729 'gnus-number number)
8730 (when gnus-visual-p
8731 (forward-line -1)
8732 (run-hooks 'gnus-summary-update-hook)
8733 (forward-line 1))
8735 (setq gnus-tmp-prev-subject subject)))
8737 (when (nth 1 thread)
8738 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8739 (incf gnus-tmp-level)
8740 (setq threads (if thread-end nil (cdar thread)))
8741 (unless threads
8742 (setq gnus-tmp-level 0)))))
8743 (gnus-message 7 "Generating summary...done"))
8745 (defun gnus-summary-prepare-unthreaded (headers)
8746 "Generate an unthreaded summary buffer based on HEADERS."
8747 (let (header number mark)
8749 (while headers
8750 ;; We may have to root out some bad articles...
8751 (when (memq (setq number (mail-header-number
8752 (setq header (pop headers))))
8753 gnus-newsgroup-limit)
8754 ;; Mark article as read when it has a low score.
8755 (when (and gnus-summary-mark-below
8756 (< (or (cdr (assq number gnus-newsgroup-scored))
8757 gnus-summary-default-score 0)
8758 gnus-summary-mark-below)
8759 (not (memq number gnus-newsgroup-ancient)))
8760 (setq gnus-newsgroup-unreads
8761 (delq number gnus-newsgroup-unreads))
8762 (if gnus-newsgroup-auto-expire
8763 (push number gnus-newsgroup-expirable)
8764 (push (cons number gnus-low-score-mark)
8765 gnus-newsgroup-reads)))
8767 (setq mark
8768 (cond
8769 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8770 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8771 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8772 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8773 (t (or (cdr (assq number gnus-newsgroup-reads))
8774 gnus-ancient-mark))))
8775 (setq gnus-newsgroup-data
8776 (cons (gnus-data-make number mark (1+ (point)) header 0)
8777 gnus-newsgroup-data))
8778 (gnus-summary-insert-line
8779 header 0 nil mark (memq number gnus-newsgroup-replied)
8780 (memq number gnus-newsgroup-expirable)
8781 (mail-header-subject header) nil
8782 (cdr (assq number gnus-newsgroup-scored))
8783 (memq number gnus-newsgroup-processable))))))
8785 (defun gnus-select-newsgroup (group &optional read-all)
8786 "Select newsgroup GROUP.
8787 If READ-ALL is non-nil, all articles in the group are selected."
8788 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8789 (info (nth 2 entry))
8790 articles fetched-articles cached)
8792 (or (gnus-check-server
8793 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8794 (error "Couldn't open server"))
8796 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8797 (gnus-activate-group group) ; Or we can activate it...
8798 (progn ; Or we bug out.
8799 (when (equal major-mode 'gnus-summary-mode)
8800 (kill-buffer (current-buffer)))
8801 (error "Couldn't request group %s: %s"
8802 group (gnus-status-message group))))
8804 (unless (gnus-request-group group t)
8805 (when (equal major-mode 'gnus-summary-mode)
8806 (kill-buffer (current-buffer)))
8807 (error "Couldn't request group %s: %s"
8808 group (gnus-status-message group)))
8810 (setq gnus-newsgroup-name group)
8811 (setq gnus-newsgroup-unselected nil)
8812 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8814 (and gnus-asynchronous
8815 (gnus-check-backend-function
8816 'request-asynchronous gnus-newsgroup-name)
8817 (setq gnus-newsgroup-async
8818 (gnus-request-asynchronous gnus-newsgroup-name)))
8820 ;; Adjust and set lists of article marks.
8821 (when info
8822 (gnus-adjust-marked-articles info))
8824 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8825 (when (gnus-virtual-group-p group)
8826 (setq cached gnus-newsgroup-cached))
8828 (setq gnus-newsgroup-unreads
8829 (gnus-set-difference
8830 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8831 gnus-newsgroup-dormant))
8833 (setq gnus-newsgroup-processable nil)
8835 (setq articles (gnus-articles-to-read group read-all))
8837 (cond
8838 ((null articles)
8839 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8840 'quit)
8841 ((eq articles 0) nil)
8843 ;; Init the dependencies hash table.
8844 (setq gnus-newsgroup-dependencies
8845 (gnus-make-hashtable (length articles)))
8846 ;; Retrieve the headers and read them in.
8847 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8848 (setq gnus-newsgroup-headers
8849 (if (eq 'nov
8850 (setq gnus-headers-retrieved-by
8851 (gnus-retrieve-headers
8852 articles gnus-newsgroup-name
8853 ;; We might want to fetch old headers, but
8854 ;; not if there is only 1 article.
8855 (and gnus-fetch-old-headers
8856 (or (and
8857 (not (eq gnus-fetch-old-headers 'some))
8858 (not (numberp gnus-fetch-old-headers)))
8859 (> (length articles) 1))))))
8860 (gnus-get-newsgroup-headers-xover articles)
8861 (gnus-get-newsgroup-headers)))
8862 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8864 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8865 (when cached
8866 (setq gnus-newsgroup-cached cached))
8868 ;; Set the initial limit.
8869 (setq gnus-newsgroup-limit (copy-sequence articles))
8870 ;; Remove canceled articles from the list of unread articles.
8871 (setq gnus-newsgroup-unreads
8872 (gnus-set-sorted-intersection
8873 gnus-newsgroup-unreads
8874 (setq fetched-articles
8875 (mapcar (lambda (headers) (mail-header-number headers))
8876 gnus-newsgroup-headers))))
8877 ;; Removed marked articles that do not exist.
8878 (gnus-update-missing-marks
8879 (gnus-sorted-complement fetched-articles articles))
8880 ;; We might want to build some more threads first.
8881 (and gnus-fetch-old-headers
8882 (eq gnus-headers-retrieved-by 'nov)
8883 (gnus-build-old-threads))
8884 ;; Check whether auto-expire is to be done in this group.
8885 (setq gnus-newsgroup-auto-expire
8886 (gnus-group-auto-expirable-p group))
8887 ;; Set up the article buffer now, if necessary.
8888 (unless gnus-single-article-buffer
8889 (gnus-article-setup-buffer))
8890 ;; First and last article in this newsgroup.
8891 (when gnus-newsgroup-headers
8892 (setq gnus-newsgroup-begin
8893 (mail-header-number (car gnus-newsgroup-headers))
8894 gnus-newsgroup-end
8895 (mail-header-number
8896 (gnus-last-element gnus-newsgroup-headers))))
8897 (setq gnus-reffed-article-number -1)
8898 ;; GROUP is successfully selected.
8899 (or gnus-newsgroup-headers t)))))
8901 (defun gnus-articles-to-read (group read-all)
8902 ;; Find out what articles the user wants to read.
8903 (let* ((articles
8904 ;; Select all articles if `read-all' is non-nil, or if there
8905 ;; are no unread articles.
8906 (if (or read-all
8907 (and (zerop (length gnus-newsgroup-marked))
8908 (zerop (length gnus-newsgroup-unreads))))
8909 (gnus-uncompress-range (gnus-active group))
8910 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8911 (copy-sequence gnus-newsgroup-unreads))
8912 '<)))
8913 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8914 (scored (length scored-list))
8915 (number (length articles))
8916 (marked (+ (length gnus-newsgroup-marked)
8917 (length gnus-newsgroup-dormant)))
8918 (select
8919 (cond
8920 ((numberp read-all)
8921 read-all)
8923 (condition-case ()
8924 (cond
8925 ((and (or (<= scored marked) (= scored number))
8926 (numberp gnus-large-newsgroup)
8927 (> number gnus-large-newsgroup))
8928 (let ((input
8929 (read-string
8930 (format
8931 "How many articles from %s (default %d): "
8932 gnus-newsgroup-name number))))
8933 (if (string-match "^[ \t]*$" input) number input)))
8934 ((and (> scored marked) (< scored number)
8935 (> (- scored number) 20))
8936 (let ((input
8937 (read-string
8938 (format "%s %s (%d scored, %d total): "
8939 "How many articles from"
8940 group scored number))))
8941 (if (string-match "^[ \t]*$" input)
8942 number input)))
8943 (t number))
8944 (quit nil))))))
8945 (setq select (if (stringp select) (string-to-number select) select))
8946 (if (or (null select) (zerop select))
8947 select
8948 (if (and (not (zerop scored)) (<= (abs select) scored))
8949 (progn
8950 (setq articles (sort scored-list '<))
8951 (setq number (length articles)))
8952 (setq articles (copy-sequence articles)))
8954 (if (< (abs select) number)
8955 (if (< select 0)
8956 ;; Select the N oldest articles.
8957 (setcdr (nthcdr (1- (abs select)) articles) nil)
8958 ;; Select the N most recent articles.
8959 (setq articles (nthcdr (- number select) articles))))
8960 (setq gnus-newsgroup-unselected
8961 (gnus-sorted-intersection
8962 gnus-newsgroup-unreads
8963 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8964 articles)))
8966 (defun gnus-killed-articles (killed articles)
8967 (let (out)
8968 (while articles
8969 (if (inline (gnus-member-of-range (car articles) killed))
8970 (setq out (cons (car articles) out)))
8971 (setq articles (cdr articles)))
8972 out))
8974 (defun gnus-uncompress-marks (marks)
8975 "Uncompress the mark ranges in MARKS."
8976 (let ((uncompressed '(score bookmark))
8977 out)
8978 (while marks
8979 (if (memq (caar marks) uncompressed)
8980 (push (car marks) out)
8981 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8982 (setq marks (cdr marks)))
8983 out))
8985 (defun gnus-adjust-marked-articles (info)
8986 "Set all article lists and remove all marks that are no longer legal."
8987 (let* ((marked-lists (gnus-info-marks info))
8988 (active (gnus-active (gnus-info-group info)))
8989 (min (car active))
8990 (max (cdr active))
8991 (types gnus-article-mark-lists)
8992 (uncompressed '(score bookmark killed))
8993 marks var articles article mark)
8995 (while marked-lists
8996 (setq marks (pop marked-lists))
8997 (set (setq var (intern (format "gnus-newsgroup-%s"
8998 (car (rassq (setq mark (car marks))
8999 types)))))
9000 (if (memq (car marks) uncompressed) (cdr marks)
9001 (gnus-uncompress-range (cdr marks))))
9003 (setq articles (symbol-value var))
9005 ;; All articles have to be subsets of the active articles.
9006 (cond
9007 ;; Adjust "simple" lists.
9008 ((memq mark '(tick dormant expirable reply save))
9009 (while articles
9010 (when (or (< (setq article (pop articles)) min) (> article max))
9011 (set var (delq article (symbol-value var))))))
9012 ;; Adjust assocs.
9013 ((memq mark uncompressed)
9014 (while articles
9015 (when (or (not (consp (setq article (pop articles))))
9016 (< (car article) min)
9017 (> (car article) max))
9018 (set var (delq article (symbol-value var))))))))))
9020 (defun gnus-update-missing-marks (missing)
9021 "Go through the list of MISSING articles and remove them mark lists."
9022 (when missing
9023 (let ((types gnus-article-mark-lists)
9024 var m)
9025 ;; Go through all types.
9026 (while types
9027 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
9028 (when (symbol-value var)
9029 ;; This list has articles. So we delete all missing articles
9030 ;; from it.
9031 (setq m missing)
9032 (while m
9033 (set var (delq (pop m) (symbol-value var)))))))))
9035 (defun gnus-update-marks ()
9036 "Enter the various lists of marked articles into the newsgroup info list."
9037 (let ((types gnus-article-mark-lists)
9038 (info (gnus-get-info gnus-newsgroup-name))
9039 (uncompressed '(score bookmark killed))
9040 type list newmarked symbol)
9041 (when info
9042 ;; Add all marks lists that are non-nil to the list of marks lists.
9043 (while types
9044 (setq type (pop types))
9045 (when (setq list (symbol-value
9046 (setq symbol
9047 (intern (format "gnus-newsgroup-%s"
9048 (car type))))))
9049 (push (cons (cdr type)
9050 (if (memq (cdr type) uncompressed) list
9051 (gnus-compress-sequence
9052 (set symbol (sort list '<)) t)))
9053 newmarked)))
9055 ;; Enter these new marks into the info of the group.
9056 (if (nthcdr 3 info)
9057 (setcar (nthcdr 3 info) newmarked)
9058 ;; Add the marks lists to the end of the info.
9059 (when newmarked
9060 (setcdr (nthcdr 2 info) (list newmarked))))
9062 ;; Cut off the end of the info if there's nothing else there.
9063 (let ((i 5))
9064 (while (and (> i 2)
9065 (not (nth i info)))
9066 (when (nthcdr (decf i) info)
9067 (setcdr (nthcdr i info) nil)))))))
9069 (defun gnus-add-marked-articles (group type articles &optional info force)
9070 ;; Add ARTICLES of TYPE to the info of GROUP.
9071 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
9072 ;; add, but replace marked articles of TYPE with ARTICLES.
9073 (let ((info (or info (gnus-get-info group)))
9074 (uncompressed '(score bookmark killed))
9075 marked m)
9076 (or (not info)
9077 (and (not (setq marked (nthcdr 3 info)))
9078 (or (null articles)
9079 (setcdr (nthcdr 2 info)
9080 (list (list (cons type (gnus-compress-sequence
9081 articles t)))))))
9082 (and (not (setq m (assq type (car marked))))
9083 (or (null articles)
9084 (setcar marked
9085 (cons (cons type (gnus-compress-sequence articles t) )
9086 (car marked)))))
9087 (if force
9088 (if (null articles)
9089 (setcar (nthcdr 3 info)
9090 (delq (assq type (car marked)) (car marked)))
9091 (setcdr m (gnus-compress-sequence articles t)))
9092 (setcdr m (gnus-compress-sequence
9093 (sort (nconc (gnus-uncompress-range (cdr m))
9094 (copy-sequence articles)) '<) t))))))
9096 (defun gnus-set-mode-line (where)
9097 "This function sets the mode line of the article or summary buffers.
9098 If WHERE is `summary', the summary mode line format will be used."
9099 ;; Is this mode line one we keep updated?
9100 (when (memq where gnus-updated-mode-lines)
9101 (let (mode-string)
9102 (save-excursion
9103 ;; We evaluate this in the summary buffer since these
9104 ;; variables are buffer-local to that buffer.
9105 (set-buffer gnus-summary-buffer)
9106 ;; We bind all these variables that are used in the `eval' form
9107 ;; below.
9108 (let* ((mformat (symbol-value
9109 (intern
9110 (format "gnus-%s-mode-line-format-spec" where))))
9111 (gnus-tmp-group-name gnus-newsgroup-name)
9112 (gnus-tmp-article-number (or gnus-current-article 0))
9113 (gnus-tmp-unread gnus-newsgroup-unreads)
9114 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9115 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9116 (gnus-tmp-unread-and-unselected
9117 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9118 (zerop gnus-tmp-unselected)) "")
9119 ((zerop gnus-tmp-unselected)
9120 (format "{%d more}" gnus-tmp-unread-and-unticked))
9121 (t (format "{%d(+%d) more}"
9122 gnus-tmp-unread-and-unticked
9123 gnus-tmp-unselected))))
9124 (gnus-tmp-subject
9125 (if (and gnus-current-headers
9126 (vectorp gnus-current-headers))
9127 (gnus-mode-string-quote
9128 (mail-header-subject gnus-current-headers)) ""))
9129 max-len
9130 gnus-tmp-header);; passed as argument to any user-format-funcs
9131 (setq mode-string (eval mformat))
9132 (setq max-len (max 4 (if gnus-mode-non-string-length
9133 (- (window-width)
9134 gnus-mode-non-string-length)
9135 (length mode-string))))
9136 ;; We might have to chop a bit of the string off...
9137 (when (> (length mode-string) max-len)
9138 (setq mode-string
9139 (concat (gnus-truncate-string mode-string (- max-len 3))
9140 "...")))
9141 ;; Pad the mode string a bit.
9142 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9143 ;; Update the mode line.
9144 (setq mode-line-buffer-identification
9145 (gnus-mode-line-buffer-identification
9146 (list mode-string)))
9147 (set-buffer-modified-p t))))
9149 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9150 "Go through the HEADERS list and add all Xrefs to a hash table.
9151 The resulting hash table is returned, or nil if no Xrefs were found."
9152 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9153 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9154 (xref-hashtb (make-vector 63 0))
9155 start group entry number xrefs header)
9156 (while headers
9157 (setq header (pop headers))
9158 (when (and (setq xrefs (mail-header-xref header))
9159 (not (memq (setq number (mail-header-number header))
9160 unreads)))
9161 (setq start 0)
9162 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9163 (setq start (match-end 0))
9164 (setq group (if prefix
9165 (concat prefix (substring xrefs (match-beginning 1)
9166 (match-end 1)))
9167 (substring xrefs (match-beginning 1) (match-end 1))))
9168 (setq number
9169 (string-to-int (substring xrefs (match-beginning 2)
9170 (match-end 2))))
9171 (if (setq entry (gnus-gethash group xref-hashtb))
9172 (setcdr entry (cons number (cdr entry)))
9173 (gnus-sethash group (cons number nil) xref-hashtb)))))
9174 (and start xref-hashtb)))
9176 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9177 "Look through all the headers and mark the Xrefs as read."
9178 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9179 name entry info xref-hashtb idlist method nth4)
9180 (save-excursion
9181 (set-buffer gnus-group-buffer)
9182 (when (setq xref-hashtb
9183 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9184 (mapatoms
9185 (lambda (group)
9186 (unless (string= from-newsgroup (setq name (symbol-name group)))
9187 (setq idlist (symbol-value group))
9188 ;; Dead groups are not updated.
9189 (and (prog1
9190 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9191 info (nth 2 entry))
9192 (if (stringp (setq nth4 (gnus-info-method info)))
9193 (setq nth4 (gnus-server-to-method nth4))))
9194 ;; Only do the xrefs if the group has the same
9195 ;; select method as the group we have just read.
9196 (or (gnus-methods-equal-p
9197 nth4 (gnus-find-method-for-group from-newsgroup))
9198 virtual
9199 (equal nth4 (setq method (gnus-find-method-for-group
9200 from-newsgroup)))
9201 (and (equal (car nth4) (car method))
9202 (equal (nth 1 nth4) (nth 1 method))))
9203 gnus-use-cross-reference
9204 (or (not (eq gnus-use-cross-reference t))
9205 virtual
9206 ;; Only do cross-references on subscribed
9207 ;; groups, if that is what is wanted.
9208 (<= (gnus-info-level info) gnus-level-subscribed))
9209 (gnus-group-make-articles-read name idlist))))
9210 xref-hashtb)))))
9212 (defun gnus-group-make-articles-read (group articles)
9213 (let* ((num 0)
9214 (entry (gnus-gethash group gnus-newsrc-hashtb))
9215 (info (nth 2 entry))
9216 (active (gnus-active group))
9217 range)
9218 ;; First peel off all illegal article numbers.
9219 (if active
9220 (let ((ids articles)
9221 id first)
9222 (while ids
9223 (setq id (car ids))
9224 (if (and first (> id (cdr active)))
9225 (progn
9226 ;; We'll end up in this situation in one particular
9227 ;; obscure situation. If you re-scan a group and get
9228 ;; a new article that is cross-posted to a different
9229 ;; group that has not been re-scanned, you might get
9230 ;; crossposted article that has a higher number than
9231 ;; Gnus believes possible. So we re-activate this
9232 ;; group as well. This might mean doing the
9233 ;; crossposting thingy will *increase* the number
9234 ;; of articles in some groups. Tsk, tsk.
9235 (setq active (or (gnus-activate-group group) active))))
9236 (if (or (> id (cdr active))
9237 (< id (car active)))
9238 (setq articles (delq id articles)))
9239 (setq ids (cdr ids)))))
9240 ;; If the read list is nil, we init it.
9241 (and active
9242 (null (gnus-info-read info))
9243 (> (car active) 1)
9244 (gnus-info-set-read info (cons 1 (1- (car active)))))
9245 ;; Then we add the read articles to the range.
9246 (gnus-info-set-read
9247 info
9248 (setq range
9249 (gnus-add-to-range
9250 (gnus-info-read info) (setq articles (sort articles '<)))))
9251 ;; Then we have to re-compute how many unread
9252 ;; articles there are in this group.
9253 (if active
9254 (progn
9255 (cond
9256 ((not range)
9257 (setq num (- (1+ (cdr active)) (car active))))
9258 ((not (listp (cdr range)))
9259 (setq num (- (cdr active) (- (1+ (cdr range))
9260 (car range)))))
9262 (while range
9263 (if (numberp (car range))
9264 (setq num (1+ num))
9265 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9266 (setq range (cdr range)))
9267 (setq num (- (cdr active) num))))
9268 ;; Update the number of unread articles.
9269 (setcar entry num)
9270 ;; Update the group buffer.
9271 (gnus-group-update-group group t)))))
9273 (defun gnus-methods-equal-p (m1 m2)
9274 (let ((m1 (or m1 gnus-select-method))
9275 (m2 (or m2 gnus-select-method)))
9276 (or (equal m1 m2)
9277 (and (eq (car m1) (car m2))
9278 (or (not (memq 'address (assoc (symbol-name (car m1))
9279 gnus-valid-select-methods)))
9280 (equal (nth 1 m1) (nth 1 m2)))))))
9282 (defsubst gnus-header-value ()
9283 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9285 (defvar gnus-newsgroup-none-id 0)
9287 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9288 (let ((cur nntp-server-buffer)
9289 (dependencies
9290 (or dependencies
9291 (save-excursion (set-buffer gnus-summary-buffer)
9292 gnus-newsgroup-dependencies)))
9293 headers id id-dep ref-dep end ref)
9294 (save-excursion
9295 (set-buffer nntp-server-buffer)
9296 (run-hooks 'gnus-parse-headers-hook)
9297 (let ((case-fold-search t)
9298 in-reply-to header p lines)
9299 (goto-char (point-min))
9300 ;; Search to the beginning of the next header. Error messages
9301 ;; do not begin with 2 or 3.
9302 (while (re-search-forward "^[23][0-9]+ " nil t)
9303 (setq id nil
9304 ref nil)
9305 ;; This implementation of this function, with nine
9306 ;; search-forwards instead of the one re-search-forward and
9307 ;; a case (which basically was the old function) is actually
9308 ;; about twice as fast, even though it looks messier. You
9309 ;; can't have everything, I guess. Speed and elegance
9310 ;; doesn't always go hand in hand.
9311 (setq
9312 header
9313 (vector
9314 ;; Number.
9315 (prog1
9316 (read cur)
9317 (end-of-line)
9318 (setq p (point))
9319 (narrow-to-region (point)
9320 (or (and (search-forward "\n.\n" nil t)
9321 (- (point) 2))
9322 (point))))
9323 ;; Subject.
9324 (progn
9325 (goto-char p)
9326 (if (search-forward "\nsubject: " nil t)
9327 (gnus-header-value) "(none)"))
9328 ;; From.
9329 (progn
9330 (goto-char p)
9331 (if (search-forward "\nfrom: " nil t)
9332 (gnus-header-value) "(nobody)"))
9333 ;; Date.
9334 (progn
9335 (goto-char p)
9336 (if (search-forward "\ndate: " nil t)
9337 (gnus-header-value) ""))
9338 ;; Message-ID.
9339 (progn
9340 (goto-char p)
9341 (if (search-forward "\nmessage-id: " nil t)
9342 (setq id (gnus-header-value))
9343 ;; If there was no message-id, we just fake one to make
9344 ;; subsequent routines simpler.
9345 (setq id (concat "none+"
9346 (int-to-string
9347 (setq gnus-newsgroup-none-id
9348 (1+ gnus-newsgroup-none-id)))))))
9349 ;; References.
9350 (progn
9351 (goto-char p)
9352 (if (search-forward "\nreferences: " nil t)
9353 (progn
9354 (setq end (point))
9355 (prog1
9356 (gnus-header-value)
9357 (setq ref
9358 (buffer-substring
9359 (progn
9360 (end-of-line)
9361 (search-backward ">" end t)
9362 (1+ (point)))
9363 (progn
9364 (search-backward "<" end t)
9365 (point))))))
9366 ;; Get the references from the in-reply-to header if there
9367 ;; were no references and the in-reply-to header looks
9368 ;; promising.
9369 (if (and (search-forward "\nin-reply-to: " nil t)
9370 (setq in-reply-to (gnus-header-value))
9371 (string-match "<[^>]+>" in-reply-to))
9372 (setq ref (substring in-reply-to (match-beginning 0)
9373 (match-end 0)))
9374 (setq ref ""))))
9375 ;; Chars.
9377 ;; Lines.
9378 (progn
9379 (goto-char p)
9380 (if (search-forward "\nlines: " nil t)
9381 (if (numberp (setq lines (read cur)))
9382 lines 0)
9384 ;; Xref.
9385 (progn
9386 (goto-char p)
9387 (and (search-forward "\nxref: " nil t)
9388 (gnus-header-value)))))
9389 ;; We do the threading while we read the headers. The
9390 ;; message-id and the last reference are both entered into
9391 ;; the same hash table. Some tippy-toeing around has to be
9392 ;; done in case an article has arrived before the article
9393 ;; which it refers to.
9394 (if (boundp (setq id-dep (intern id dependencies)))
9395 (if (and (car (symbol-value id-dep))
9396 (not force-new))
9397 ;; An article with this Message-ID has already
9398 ;; been seen, so we ignore this one, except we add
9399 ;; any additional Xrefs (in case the two articles
9400 ;; came from different servers).
9401 (progn
9402 (mail-header-set-xref
9403 (car (symbol-value id-dep))
9404 (concat (or (mail-header-xref
9405 (car (symbol-value id-dep))) "")
9406 (or (mail-header-xref header) "")))
9407 (setq header nil))
9408 (setcar (symbol-value id-dep) header))
9409 (set id-dep (list header)))
9410 (when header
9411 (if (boundp (setq ref-dep (intern ref dependencies)))
9412 (setcdr (symbol-value ref-dep)
9413 (nconc (cdr (symbol-value ref-dep))
9414 (list (symbol-value id-dep))))
9415 (set ref-dep (list nil (symbol-value id-dep))))
9416 (setq headers (cons header headers)))
9417 (goto-char (point-max))
9418 (widen))
9419 (nreverse headers)))))
9421 ;; The following macros and functions were written by Felix Lee
9422 ;; <flee@cse.psu.edu>.
9424 (defmacro gnus-nov-read-integer ()
9425 '(prog1
9426 (if (= (following-char) ?\t)
9428 (let ((num (condition-case nil (read buffer) (error nil))))
9429 (if (numberp num) num 0)))
9430 (or (eobp) (forward-char 1))))
9432 (defmacro gnus-nov-skip-field ()
9433 '(search-forward "\t" eol 'move))
9435 (defmacro gnus-nov-field ()
9436 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9438 ;; Goes through the xover lines and returns a list of vectors
9439 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9440 force-new dependencies)
9441 "Parse the news overview data in the server buffer, and return a
9442 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9443 ;; Get the Xref when the users reads the articles since most/some
9444 ;; NNTP servers do not include Xrefs when using XOVER.
9445 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9446 (let ((cur nntp-server-buffer)
9447 (dependencies (or dependencies gnus-newsgroup-dependencies))
9448 number headers header)
9449 (save-excursion
9450 (set-buffer nntp-server-buffer)
9451 ;; Allow the user to mangle the headers before parsing them.
9452 (run-hooks 'gnus-parse-headers-hook)
9453 (goto-char (point-min))
9454 (while (and sequence (not (eobp)))
9455 (setq number (read cur))
9456 (while (and sequence (< (car sequence) number))
9457 (setq sequence (cdr sequence)))
9458 (and sequence
9459 (eq number (car sequence))
9460 (progn
9461 (setq sequence (cdr sequence))
9462 (if (setq header
9463 (inline (gnus-nov-parse-line
9464 number dependencies force-new)))
9465 (setq headers (cons header headers)))))
9466 (forward-line 1))
9467 (setq headers (nreverse headers)))
9468 headers))
9470 ;; This function has to be called with point after the article number
9471 ;; on the beginning of the line.
9472 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9473 (let ((none 0)
9474 (eol (gnus-point-at-eol))
9475 (buffer (current-buffer))
9476 header ref id id-dep ref-dep)
9478 ;; overview: [num subject from date id refs chars lines misc]
9479 (narrow-to-region (point) eol)
9480 (or (eobp) (forward-char))
9482 (condition-case nil
9483 (setq header
9484 (vector
9485 number ; number
9486 (gnus-nov-field) ; subject
9487 (gnus-nov-field) ; from
9488 (gnus-nov-field) ; date
9489 (setq id (or (gnus-nov-field)
9490 (concat "none+"
9491 (int-to-string
9492 (setq none (1+ none)))))) ; id
9493 (progn
9494 (save-excursion
9495 (let ((beg (point)))
9496 (search-forward "\t" eol)
9497 (if (search-backward ">" beg t)
9498 (setq ref
9499 (buffer-substring
9500 (1+ (point))
9501 (search-backward "<" beg t)))
9502 (setq ref nil))))
9503 (gnus-nov-field)) ; refs
9504 (gnus-nov-read-integer) ; chars
9505 (gnus-nov-read-integer) ; lines
9506 (if (= (following-char) ?\n)
9508 (gnus-nov-field)) ; misc
9510 (error (progn
9511 (gnus-error 4 "Strange nov line")
9512 (setq header nil)
9513 (goto-char eol))))
9515 (widen)
9517 ;; We build the thread tree.
9518 (when header
9519 (if (boundp (setq id-dep (intern id dependencies)))
9520 (if (and (car (symbol-value id-dep))
9521 (not force-new))
9522 ;; An article with this Message-ID has already been seen,
9523 ;; so we ignore this one, except we add any additional
9524 ;; Xrefs (in case the two articles came from different
9525 ;; servers.
9526 (progn
9527 (mail-header-set-xref
9528 (car (symbol-value id-dep))
9529 (concat (or (mail-header-xref
9530 (car (symbol-value id-dep))) "")
9531 (or (mail-header-xref header) "")))
9532 (setq header nil))
9533 (setcar (symbol-value id-dep) header))
9534 (set id-dep (list header))))
9535 (when header
9536 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9537 (setcdr (symbol-value ref-dep)
9538 (nconc (cdr (symbol-value ref-dep))
9539 (list (symbol-value id-dep))))
9540 (set ref-dep (list nil (symbol-value id-dep)))))
9541 header))
9543 (defun gnus-article-get-xrefs ()
9544 "Fill in the Xref value in `gnus-current-headers', if necessary.
9545 This is meant to be called in `gnus-article-internal-prepare-hook'."
9546 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9547 gnus-current-headers)))
9548 (or (not gnus-use-cross-reference)
9549 (not headers)
9550 (and (mail-header-xref headers)
9551 (not (string= (mail-header-xref headers) "")))
9552 (let ((case-fold-search t)
9553 xref)
9554 (save-restriction
9555 (nnheader-narrow-to-headers)
9556 (goto-char (point-min))
9557 (if (or (and (eq (downcase (following-char)) ?x)
9558 (looking-at "Xref:"))
9559 (search-forward "\nXref:" nil t))
9560 (progn
9561 (goto-char (1+ (match-end 0)))
9562 (setq xref (buffer-substring (point)
9563 (progn (end-of-line) (point))))
9564 (mail-header-set-xref headers xref))))))))
9566 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9567 "Find article ID and insert the summary line for that article."
9568 (let ((header (if (and old-header use-old-header)
9569 old-header (gnus-read-header id)))
9570 (number (and (numberp id) id))
9571 pos)
9572 (when header
9573 ;; Rebuild the thread that this article is part of and go to the
9574 ;; article we have fetched.
9575 (when (and (not gnus-show-threads)
9576 old-header)
9577 (when (setq pos (text-property-any
9578 (point-min) (point-max) 'gnus-number
9579 (mail-header-number old-header)))
9580 (goto-char pos)
9581 (gnus-delete-line)
9582 (gnus-data-remove (mail-header-number old-header))))
9583 (when old-header
9584 (mail-header-set-number header (mail-header-number old-header)))
9585 (setq gnus-newsgroup-sparse
9586 (delq (setq number (mail-header-number header))
9587 gnus-newsgroup-sparse))
9588 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9589 (gnus-rebuild-thread (mail-header-id header))
9590 (gnus-summary-goto-subject number nil t))
9591 (when (and (numberp number)
9592 (> number 0))
9593 ;; We have to update the boundaries even if we can't fetch the
9594 ;; article if ID is a number -- so that the next `P' or `N'
9595 ;; command will fetch the previous (or next) article even
9596 ;; if the one we tried to fetch this time has been canceled.
9597 (and (> number gnus-newsgroup-end)
9598 (setq gnus-newsgroup-end number))
9599 (and (< number gnus-newsgroup-begin)
9600 (setq gnus-newsgroup-begin number))
9601 (setq gnus-newsgroup-unselected
9602 (delq number gnus-newsgroup-unselected)))
9603 ;; Report back a success?
9604 (and header (mail-header-number header))))
9606 (defun gnus-summary-work-articles (n)
9607 "Return a list of articles to be worked upon. The prefix argument,
9608 the list of process marked articles, and the current article will be
9609 taken into consideration."
9610 (cond
9612 ;; A numerical prefix has been given.
9613 (let ((backward (< n 0))
9614 (n (abs (prefix-numeric-value n)))
9615 articles article)
9616 (save-excursion
9617 (while
9618 (and (> n 0)
9619 (push (setq article (gnus-summary-article-number))
9620 articles)
9621 (if backward
9622 (gnus-summary-find-prev nil article)
9623 (gnus-summary-find-next nil article)))
9624 (decf n)))
9625 (nreverse articles)))
9626 ((and (boundp 'transient-mark-mode)
9627 transient-mark-mode
9628 mark-active)
9629 ;; Work on the region between point and mark.
9630 (let ((max (max (point) (mark)))
9631 articles article)
9632 (save-excursion
9633 (goto-char (min (point) (mark)))
9634 (while
9635 (and
9636 (push (setq article (gnus-summary-article-number)) articles)
9637 (gnus-summary-find-next nil article)
9638 (< (point) max)))
9639 (nreverse articles))))
9640 (gnus-newsgroup-processable
9641 ;; There are process-marked articles present.
9642 (reverse gnus-newsgroup-processable))
9644 ;; Just return the current article.
9645 (list (gnus-summary-article-number)))))
9647 (defun gnus-summary-search-group (&optional backward use-level)
9648 "Search for next unread newsgroup.
9649 If optional argument BACKWARD is non-nil, search backward instead."
9650 (save-excursion
9651 (set-buffer gnus-group-buffer)
9652 (if (gnus-group-search-forward
9653 backward nil (if use-level (gnus-group-group-level) nil))
9654 (gnus-group-group-name))))
9656 (defun gnus-summary-best-group (&optional exclude-group)
9657 "Find the name of the best unread group.
9658 If EXCLUDE-GROUP, do not go to this group."
9659 (save-excursion
9660 (set-buffer gnus-group-buffer)
9661 (save-excursion
9662 (gnus-group-best-unread-group exclude-group))))
9664 (defun gnus-summary-find-next (&optional unread article backward)
9665 (if backward (gnus-summary-find-prev)
9666 (let* ((dummy (gnus-summary-article-intangible-p))
9667 (article (or article (gnus-summary-article-number)))
9668 (arts (gnus-data-find-list article))
9669 result)
9670 (when (and (not dummy)
9671 (or (not gnus-summary-check-current)
9672 (not unread)
9673 (not (gnus-data-unread-p (car arts)))))
9674 (setq arts (cdr arts)))
9675 (when (setq result
9676 (if unread
9677 (progn
9678 (while arts
9679 (when (gnus-data-unread-p (car arts))
9680 (setq result (car arts)
9681 arts nil))
9682 (setq arts (cdr arts)))
9683 result)
9684 (car arts)))
9685 (goto-char (gnus-data-pos result))
9686 (gnus-data-number result)))))
9688 (defun gnus-summary-find-prev (&optional unread article)
9689 (let* ((eobp (eobp))
9690 (article (or article (gnus-summary-article-number)))
9691 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9692 result)
9693 (when (and (not eobp)
9694 (or (not gnus-summary-check-current)
9695 (not unread)
9696 (not (gnus-data-unread-p (car arts)))))
9697 (setq arts (cdr arts)))
9698 (if (setq result
9699 (if unread
9700 (progn
9701 (while arts
9702 (and (gnus-data-unread-p (car arts))
9703 (setq result (car arts)
9704 arts nil))
9705 (setq arts (cdr arts)))
9706 result)
9707 (car arts)))
9708 (progn
9709 (goto-char (gnus-data-pos result))
9710 (gnus-data-number result)))))
9712 (defun gnus-summary-find-subject (subject &optional unread backward article)
9713 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9714 (article (or article (gnus-summary-article-number)))
9715 (articles (gnus-data-list backward))
9716 (arts (gnus-data-find-list article articles))
9717 result)
9718 (when (or (not gnus-summary-check-current)
9719 (not unread)
9720 (not (gnus-data-unread-p (car arts))))
9721 (setq arts (cdr arts)))
9722 (while arts
9723 (and (or (not unread)
9724 (gnus-data-unread-p (car arts)))
9725 (vectorp (gnus-data-header (car arts)))
9726 (gnus-subject-equal
9727 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9728 (setq result (car arts)
9729 arts nil))
9730 (setq arts (cdr arts)))
9731 (and result
9732 (goto-char (gnus-data-pos result))
9733 (gnus-data-number result))))
9735 (defun gnus-summary-search-forward (&optional unread subject backward)
9736 "Search forward for an article.
9737 If UNREAD, look for unread articles. If SUBJECT, look for
9738 articles with that subject. If BACKWARD, search backward instead."
9739 (cond (subject (gnus-summary-find-subject subject unread backward))
9740 (backward (gnus-summary-find-prev unread))
9741 (t (gnus-summary-find-next unread))))
9743 (defun gnus-recenter (&optional n)
9744 "Center point in window and redisplay frame.
9745 Also do horizontal recentering."
9746 (interactive "P")
9747 (when (and gnus-auto-center-summary
9748 (not (eq gnus-auto-center-summary 'vertical)))
9749 (gnus-horizontal-recenter))
9750 (recenter n))
9752 (defun gnus-summary-recenter ()
9753 "Center point in the summary window.
9754 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9755 displayed, no centering will be performed."
9756 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9757 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9758 (let* ((top (cond ((< (window-height) 4) 0)
9759 ((< (window-height) 7) 1)
9760 (t 2)))
9761 (height (1- (window-height)))
9762 (bottom (save-excursion (goto-char (point-max))
9763 (forward-line (- height))
9764 (point)))
9765 (window (get-buffer-window (current-buffer))))
9766 ;; The user has to want it.
9767 (when gnus-auto-center-summary
9768 (when (get-buffer-window gnus-article-buffer)
9769 ;; Only do recentering when the article buffer is displayed,
9770 ;; Set the window start to either `bottom', which is the biggest
9771 ;; possible valid number, or the second line from the top,
9772 ;; whichever is the least.
9773 (set-window-start
9774 window (min bottom (save-excursion
9775 (forward-line (- top)) (point)))))
9776 ;; Do horizontal recentering while we're at it.
9777 (when (and (get-buffer-window (current-buffer) t)
9778 (not (eq gnus-auto-center-summary 'vertical)))
9779 (let ((selected (selected-window)))
9780 (select-window (get-buffer-window (current-buffer) t))
9781 (gnus-summary-position-point)
9782 (gnus-horizontal-recenter)
9783 (select-window selected))))))
9785 (defun gnus-horizontal-recenter ()
9786 "Recenter the current buffer horizontally."
9787 (if (< (current-column) (/ (window-width) 2))
9788 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9789 (let* ((orig (point))
9790 (end (window-end (get-buffer-window (current-buffer) t)))
9791 (max 0))
9792 ;; Find the longest line currently displayed in the window.
9793 (goto-char (window-start))
9794 (while (and (not (eobp))
9795 (< (point) end))
9796 (end-of-line)
9797 (setq max (max max (current-column)))
9798 (forward-line 1))
9799 (goto-char orig)
9800 ;; Scroll horizontally to center (sort of) the point.
9801 (if (> max (window-width))
9802 (set-window-hscroll
9803 (get-buffer-window (current-buffer) t)
9804 (min (- (current-column) (/ (window-width) 3))
9805 (+ 2 (- max (window-width)))))
9806 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9807 max)))
9809 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9810 (defun gnus-short-group-name (group &optional levels)
9811 "Collapse GROUP name LEVELS."
9812 (let* ((name "")
9813 (foreign "")
9814 (depth 0)
9815 (skip 1)
9816 (levels (or levels
9817 (progn
9818 (while (string-match "\\." group skip)
9819 (setq skip (match-end 0)
9820 depth (+ depth 1)))
9821 depth))))
9822 (if (string-match ":" group)
9823 (setq foreign (substring group 0 (match-end 0))
9824 group (substring group (match-end 0))))
9825 (while group
9826 (if (and (string-match "\\." group)
9827 (> levels (- gnus-group-uncollapsed-levels 1)))
9828 (setq name (concat name (substring group 0 1))
9829 group (substring group (match-end 0))
9830 levels (- levels 1)
9831 name (concat name "."))
9832 (setq name (concat foreign name group)
9833 group nil)))
9834 name))
9836 (defun gnus-summary-jump-to-group (newsgroup)
9837 "Move point to NEWSGROUP in group mode buffer."
9838 ;; Keep update point of group mode buffer if visible.
9839 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9840 (save-window-excursion
9841 ;; Take care of tree window mode.
9842 (if (get-buffer-window gnus-group-buffer)
9843 (pop-to-buffer gnus-group-buffer))
9844 (gnus-group-jump-to-group newsgroup))
9845 (save-excursion
9846 ;; Take care of tree window mode.
9847 (if (get-buffer-window gnus-group-buffer)
9848 (pop-to-buffer gnus-group-buffer)
9849 (set-buffer gnus-group-buffer))
9850 (gnus-group-jump-to-group newsgroup))))
9852 ;; This function returns a list of article numbers based on the
9853 ;; difference between the ranges of read articles in this group and
9854 ;; the range of active articles.
9855 (defun gnus-list-of-unread-articles (group)
9856 (let* ((read (gnus-info-read (gnus-get-info group)))
9857 (active (gnus-active group))
9858 (last (cdr active))
9859 first nlast unread)
9860 ;; If none are read, then all are unread.
9861 (if (not read)
9862 (setq first (car active))
9863 ;; If the range of read articles is a single range, then the
9864 ;; first unread article is the article after the last read
9865 ;; article. Sounds logical, doesn't it?
9866 (if (not (listp (cdr read)))
9867 (setq first (1+ (cdr read)))
9868 ;; `read' is a list of ranges.
9869 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9870 (caar read))) 1)
9871 (setq first 1))
9872 (while read
9873 (if first
9874 (while (< first nlast)
9875 (setq unread (cons first unread))
9876 (setq first (1+ first))))
9877 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9878 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9879 (setq read (cdr read)))))
9880 ;; And add the last unread articles.
9881 (while (<= first last)
9882 (setq unread (cons first unread))
9883 (setq first (1+ first)))
9884 ;; Return the list of unread articles.
9885 (nreverse unread)))
9887 (defun gnus-list-of-read-articles (group)
9888 "Return a list of unread, unticked and non-dormant articles."
9889 (let* ((info (gnus-get-info group))
9890 (marked (gnus-info-marks info))
9891 (active (gnus-active group)))
9892 (and info active
9893 (gnus-set-difference
9894 (gnus-sorted-complement
9895 (gnus-uncompress-range active)
9896 (gnus-list-of-unread-articles group))
9897 (append
9898 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9899 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9901 ;; Various summary commands
9903 (defun gnus-summary-universal-argument (arg)
9904 "Perform any operation on all articles that are process/prefixed."
9905 (interactive "P")
9906 (gnus-set-global-variables)
9907 (let ((articles (gnus-summary-work-articles arg))
9908 func article)
9909 (if (eq
9910 (setq
9911 func
9912 (key-binding
9913 (read-key-sequence
9914 (substitute-command-keys
9915 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9916 ))))
9917 'undefined)
9918 (gnus-error 1 "Undefined key")
9919 (save-excursion
9920 (while articles
9921 (gnus-summary-goto-subject (setq article (pop articles)))
9922 (command-execute func)
9923 (gnus-summary-remove-process-mark article)))))
9924 (gnus-summary-position-point))
9926 (defun gnus-summary-toggle-truncation (&optional arg)
9927 "Toggle truncation of summary lines.
9928 With arg, turn line truncation on iff arg is positive."
9929 (interactive "P")
9930 (setq truncate-lines
9931 (if (null arg) (not truncate-lines)
9932 (> (prefix-numeric-value arg) 0)))
9933 (redraw-display))
9935 (defun gnus-summary-reselect-current-group (&optional all rescan)
9936 "Exit and then reselect the current newsgroup.
9937 The prefix argument ALL means to select all articles."
9938 (interactive "P")
9939 (gnus-set-global-variables)
9940 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
9941 (error "Ephemeral groups can't be reselected"))
9942 (let ((current-subject (gnus-summary-article-number))
9943 (group gnus-newsgroup-name))
9944 (setq gnus-newsgroup-begin nil)
9945 (gnus-summary-exit)
9946 ;; We have to adjust the point of group mode buffer because the
9947 ;; current point was moved to the next unread newsgroup by
9948 ;; exiting.
9949 (gnus-summary-jump-to-group group)
9950 (when rescan
9951 (save-excursion
9952 (gnus-group-get-new-news-this-group 1)))
9953 (gnus-group-read-group all t)
9954 (gnus-summary-goto-subject current-subject nil t)))
9956 (defun gnus-summary-rescan-group (&optional all)
9957 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9958 (interactive "P")
9959 (gnus-summary-reselect-current-group all t))
9961 (defun gnus-summary-update-info ()
9962 (let* ((group gnus-newsgroup-name))
9963 (when gnus-newsgroup-kill-headers
9964 (setq gnus-newsgroup-killed
9965 (gnus-compress-sequence
9966 (nconc
9967 (gnus-set-sorted-intersection
9968 (gnus-uncompress-range gnus-newsgroup-killed)
9969 (setq gnus-newsgroup-unselected
9970 (sort gnus-newsgroup-unselected '<)))
9971 (setq gnus-newsgroup-unreads
9972 (sort gnus-newsgroup-unreads '<))) t)))
9973 (unless (listp (cdr gnus-newsgroup-killed))
9974 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9975 (let ((headers gnus-newsgroup-headers))
9976 (run-hooks 'gnus-exit-group-hook)
9977 (unless gnus-save-score
9978 (setq gnus-newsgroup-scored nil))
9979 ;; Set the new ranges of read articles.
9980 (gnus-update-read-articles
9981 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9982 ;; Set the current article marks.
9983 (gnus-update-marks)
9984 ;; Do the cross-ref thing.
9985 (when gnus-use-cross-reference
9986 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9987 ;; Do adaptive scoring, and possibly save score files.
9988 (when gnus-newsgroup-adaptive
9989 (gnus-score-adaptive))
9990 (when gnus-use-scoring
9991 (gnus-score-save))
9992 ;; Do not switch windows but change the buffer to work.
9993 (set-buffer gnus-group-buffer)
9994 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9995 (gnus-group-update-group group)))))
9997 (defun gnus-summary-exit (&optional temporary)
9998 "Exit reading current newsgroup, and then return to group selection mode.
9999 gnus-exit-group-hook is called with no arguments if that value is non-nil."
10000 (interactive)
10001 (gnus-set-global-variables)
10002 (gnus-kill-save-kill-buffer)
10003 (let* ((group gnus-newsgroup-name)
10004 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
10005 (mode major-mode)
10006 (buf (current-buffer)))
10007 (run-hooks 'gnus-summary-prepare-exit-hook)
10008 ;; If we have several article buffers, we kill them at exit.
10009 (unless gnus-single-article-buffer
10010 (gnus-kill-buffer gnus-original-article-buffer)
10011 (setq gnus-article-current nil))
10012 (when gnus-use-cache
10013 (gnus-cache-possibly-remove-articles)
10014 (gnus-cache-save-buffers))
10015 (when gnus-use-trees
10016 (gnus-tree-close group))
10017 ;; Make all changes in this group permanent.
10018 (unless quit-config
10019 (gnus-summary-update-info))
10020 (gnus-close-group group)
10021 ;; Make sure where I was, and go to next newsgroup.
10022 (set-buffer gnus-group-buffer)
10023 (unless quit-config
10024 (gnus-group-jump-to-group group))
10025 (run-hooks 'gnus-summary-exit-hook)
10026 (unless quit-config
10027 (gnus-group-next-unread-group 1))
10028 (if temporary
10029 nil ;Nothing to do.
10030 ;; If we have several article buffers, we kill them at exit.
10031 (unless gnus-single-article-buffer
10032 (gnus-kill-buffer gnus-article-buffer)
10033 (gnus-kill-buffer gnus-original-article-buffer)
10034 (setq gnus-article-current nil))
10035 (set-buffer buf)
10036 (if (not gnus-kill-summary-on-exit)
10037 (gnus-deaden-summary)
10038 ;; We set all buffer-local variables to nil. It is unclear why
10039 ;; this is needed, but if we don't, buffer-local variables are
10040 ;; not garbage-collected, it seems. This would the lead to en
10041 ;; ever-growing Emacs.
10042 (gnus-summary-clear-local-variables)
10043 (when (get-buffer gnus-article-buffer)
10044 (bury-buffer gnus-article-buffer))
10045 ;; We clear the global counterparts of the buffer-local
10046 ;; variables as well, just to be on the safe side.
10047 (gnus-configure-windows 'group 'force)
10048 (gnus-summary-clear-local-variables)
10049 ;; Return to group mode buffer.
10050 (if (eq mode 'gnus-summary-mode)
10051 (gnus-kill-buffer buf)))
10052 (setq gnus-current-select-method gnus-select-method)
10053 (pop-to-buffer gnus-group-buffer)
10054 ;; Clear the current group name.
10055 (if (not quit-config)
10056 (progn
10057 (gnus-group-jump-to-group group)
10058 (gnus-group-next-unread-group 1)
10059 (gnus-configure-windows 'group 'force))
10060 (if (not (buffer-name (car quit-config)))
10061 (gnus-configure-windows 'group 'force)
10062 (set-buffer (car quit-config))
10063 (and (eq major-mode 'gnus-summary-mode)
10064 (gnus-set-global-variables))
10065 (gnus-configure-windows (cdr quit-config))))
10066 (unless quit-config
10067 (setq gnus-newsgroup-name nil)))))
10069 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
10070 (defun gnus-summary-exit-no-update (&optional no-questions)
10071 "Quit reading current newsgroup without updating read article info."
10072 (interactive)
10073 (gnus-set-global-variables)
10074 (let* ((group gnus-newsgroup-name)
10075 (quit-config (gnus-group-quit-config group)))
10076 (when (or no-questions
10077 gnus-expert-user
10078 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10079 ;; If we have several article buffers, we kill them at exit.
10080 (unless gnus-single-article-buffer
10081 (gnus-kill-buffer gnus-article-buffer)
10082 (gnus-kill-buffer gnus-original-article-buffer)
10083 (setq gnus-article-current nil))
10084 (if (not gnus-kill-summary-on-exit)
10085 (gnus-deaden-summary)
10086 (gnus-close-group group)
10087 (gnus-summary-clear-local-variables)
10088 (set-buffer gnus-group-buffer)
10089 (gnus-summary-clear-local-variables)
10090 (when (get-buffer gnus-summary-buffer)
10091 (kill-buffer gnus-summary-buffer)))
10092 (unless gnus-single-article-buffer
10093 (setq gnus-article-current nil))
10094 (when gnus-use-trees
10095 (gnus-tree-close group))
10096 (when (get-buffer gnus-article-buffer)
10097 (bury-buffer gnus-article-buffer))
10098 ;; Return to the group buffer.
10099 (gnus-configure-windows 'group 'force)
10100 ;; Clear the current group name.
10101 (setq gnus-newsgroup-name nil)
10102 (when (equal (gnus-group-group-name) group)
10103 (gnus-group-next-unread-group 1))
10104 (when quit-config
10105 (if (not (buffer-name (car quit-config)))
10106 (gnus-configure-windows 'group 'force)
10107 (set-buffer (car quit-config))
10108 (when (eq major-mode 'gnus-summary-mode)
10109 (gnus-set-global-variables))
10110 (gnus-configure-windows (cdr quit-config)))))))
10112 ;;; Dead summaries.
10114 (defvar gnus-dead-summary-mode-map nil)
10116 (if gnus-dead-summary-mode-map
10118 (setq gnus-dead-summary-mode-map (make-keymap))
10119 (suppress-keymap gnus-dead-summary-mode-map)
10120 (substitute-key-definition
10121 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10122 (let ((keys '("\C-d" "\r" "\177")))
10123 (while keys
10124 (define-key gnus-dead-summary-mode-map
10125 (pop keys) 'gnus-summary-wake-up-the-dead))))
10127 (defvar gnus-dead-summary-mode nil
10128 "Minor mode for Gnus summary buffers.")
10130 (defun gnus-dead-summary-mode (&optional arg)
10131 "Minor mode for Gnus summary buffers."
10132 (interactive "P")
10133 (when (eq major-mode 'gnus-summary-mode)
10134 (make-local-variable 'gnus-dead-summary-mode)
10135 (setq gnus-dead-summary-mode
10136 (if (null arg) (not gnus-dead-summary-mode)
10137 (> (prefix-numeric-value arg) 0)))
10138 (when gnus-dead-summary-mode
10139 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10140 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10141 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10142 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10143 minor-mode-map-alist)))))
10145 (defun gnus-deaden-summary ()
10146 "Make the current summary buffer into a dead summary buffer."
10147 ;; Kill any previous dead summary buffer.
10148 (when (and gnus-dead-summary
10149 (buffer-name gnus-dead-summary))
10150 (save-excursion
10151 (set-buffer gnus-dead-summary)
10152 (when gnus-dead-summary-mode
10153 (kill-buffer (current-buffer)))))
10154 ;; Make this the current dead summary.
10155 (setq gnus-dead-summary (current-buffer))
10156 (gnus-dead-summary-mode 1)
10157 (let ((name (buffer-name)))
10158 (when (string-match "Summary" name)
10159 (rename-buffer
10160 (concat (substring name 0 (match-beginning 0)) "Dead "
10161 (substring name (match-beginning 0))) t))))
10163 (defun gnus-kill-or-deaden-summary (buffer)
10164 "Kill or deaden the summary BUFFER."
10165 (when (and (buffer-name buffer)
10166 (not gnus-single-article-buffer))
10167 (save-excursion
10168 (set-buffer buffer)
10169 (gnus-kill-buffer gnus-article-buffer)
10170 (gnus-kill-buffer gnus-original-article-buffer)))
10171 (cond (gnus-kill-summary-on-exit
10172 (when (and gnus-use-trees
10173 (and (get-buffer buffer)
10174 (buffer-name (get-buffer buffer))))
10175 (save-excursion
10176 (set-buffer (get-buffer buffer))
10177 (gnus-tree-close gnus-newsgroup-name)))
10178 (gnus-kill-buffer buffer))
10179 ((and (get-buffer buffer)
10180 (buffer-name (get-buffer buffer)))
10181 (save-excursion
10182 (set-buffer buffer)
10183 (gnus-deaden-summary)))))
10185 (defun gnus-summary-wake-up-the-dead (&rest args)
10186 "Wake up the dead summary buffer."
10187 (interactive)
10188 (gnus-dead-summary-mode -1)
10189 (let ((name (buffer-name)))
10190 (when (string-match "Dead " name)
10191 (rename-buffer
10192 (concat (substring name 0 (match-beginning 0))
10193 (substring name (match-end 0))) t)))
10194 (gnus-message 3 "This dead summary is now alive again"))
10196 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10197 (defun gnus-summary-fetch-faq (&optional faq-dir)
10198 "Fetch the FAQ for the current group.
10199 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10200 in."
10201 (interactive
10202 (list
10203 (if current-prefix-arg
10204 (completing-read
10205 "Faq dir: " (and (listp gnus-group-faq-directory)
10206 gnus-group-faq-directory)))))
10207 (let (gnus-faq-buffer)
10208 (and (setq gnus-faq-buffer
10209 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10210 (gnus-configure-windows 'summary-faq))))
10212 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10213 (defun gnus-summary-describe-group (&optional force)
10214 "Describe the current newsgroup."
10215 (interactive "P")
10216 (gnus-group-describe-group force gnus-newsgroup-name))
10218 (defun gnus-summary-describe-briefly ()
10219 "Describe summary mode commands briefly."
10220 (interactive)
10221 (gnus-message 6
10222 (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")))
10224 ;; Walking around group mode buffer from summary mode.
10226 (defun gnus-summary-next-group (&optional no-article target-group backward)
10227 "Exit current newsgroup and then select next unread newsgroup.
10228 If prefix argument NO-ARTICLE is non-nil, no article is selected
10229 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10230 previous group instead."
10231 (interactive "P")
10232 (gnus-set-global-variables)
10233 (let ((current-group gnus-newsgroup-name)
10234 (current-buffer (current-buffer))
10235 entered)
10236 ;; First we semi-exit this group to update Xrefs and all variables.
10237 ;; We can't do a real exit, because the window conf must remain
10238 ;; the same in case the user is prompted for info, and we don't
10239 ;; want the window conf to change before that...
10240 (gnus-summary-exit t)
10241 (while (not entered)
10242 ;; Then we find what group we are supposed to enter.
10243 (set-buffer gnus-group-buffer)
10244 (gnus-group-jump-to-group current-group)
10245 (setq target-group
10246 (or target-group
10247 (if (eq gnus-keep-same-level 'best)
10248 (gnus-summary-best-group gnus-newsgroup-name)
10249 (gnus-summary-search-group backward gnus-keep-same-level))))
10250 (if (not target-group)
10251 ;; There are no further groups, so we return to the group
10252 ;; buffer.
10253 (progn
10254 (gnus-message 5 "Returning to the group buffer")
10255 (setq entered t)
10256 (set-buffer current-buffer)
10257 (gnus-summary-exit))
10258 ;; We try to enter the target group.
10259 (gnus-group-jump-to-group target-group)
10260 (let ((unreads (gnus-group-group-unread)))
10261 (if (and (or (eq t unreads)
10262 (and unreads (not (zerop unreads))))
10263 (gnus-summary-read-group
10264 target-group nil no-article current-buffer))
10265 (setq entered t)
10266 (setq current-group target-group
10267 target-group nil)))))))
10269 (defun gnus-summary-prev-group (&optional no-article)
10270 "Exit current newsgroup and then select previous unread newsgroup.
10271 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10272 (interactive "P")
10273 (gnus-summary-next-group no-article nil t))
10275 ;; Walking around summary lines.
10277 (defun gnus-summary-first-subject (&optional unread)
10278 "Go to the first unread subject.
10279 If UNREAD is non-nil, go to the first unread article.
10280 Returns the article selected or nil if there are no unread articles."
10281 (interactive "P")
10282 (prog1
10283 (cond
10284 ;; Empty summary.
10285 ((null gnus-newsgroup-data)
10286 (gnus-message 3 "No articles in the group")
10287 nil)
10288 ;; Pick the first article.
10289 ((not unread)
10290 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10291 (gnus-data-number (car gnus-newsgroup-data)))
10292 ;; No unread articles.
10293 ((null gnus-newsgroup-unreads)
10294 (gnus-message 3 "No more unread articles")
10295 nil)
10296 ;; Find the first unread article.
10298 (let ((data gnus-newsgroup-data))
10299 (while (and data
10300 (not (gnus-data-unread-p (car data))))
10301 (setq data (cdr data)))
10302 (if data
10303 (progn
10304 (goto-char (gnus-data-pos (car data)))
10305 (gnus-data-number (car data)))))))
10306 (gnus-summary-position-point)))
10308 (defun gnus-summary-next-subject (n &optional unread dont-display)
10309 "Go to next N'th summary line.
10310 If N is negative, go to the previous N'th subject line.
10311 If UNREAD is non-nil, only unread articles are selected.
10312 The difference between N and the actual number of steps taken is
10313 returned."
10314 (interactive "p")
10315 (let ((backward (< n 0))
10316 (n (abs n)))
10317 (while (and (> n 0)
10318 (if backward
10319 (gnus-summary-find-prev unread)
10320 (gnus-summary-find-next unread)))
10321 (setq n (1- n)))
10322 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10323 (if unread " unread" "")))
10324 (unless dont-display
10325 (gnus-summary-recenter)
10326 (gnus-summary-position-point))
10329 (defun gnus-summary-next-unread-subject (n)
10330 "Go to next N'th unread summary line."
10331 (interactive "p")
10332 (gnus-summary-next-subject n t))
10334 (defun gnus-summary-prev-subject (n &optional unread)
10335 "Go to previous N'th summary line.
10336 If optional argument UNREAD is non-nil, only unread article is selected."
10337 (interactive "p")
10338 (gnus-summary-next-subject (- n) unread))
10340 (defun gnus-summary-prev-unread-subject (n)
10341 "Go to previous N'th unread summary line."
10342 (interactive "p")
10343 (gnus-summary-next-subject (- n) t))
10345 (defun gnus-summary-goto-subject (article &optional force silent)
10346 "Go the subject line of ARTICLE.
10347 If FORCE, also allow jumping to articles not currently shown."
10348 (let ((b (point))
10349 (data (gnus-data-find article)))
10350 ;; We read in the article if we have to.
10351 (and (not data)
10352 force
10353 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10354 (setq data (gnus-data-find article)))
10355 (goto-char b)
10356 (if (not data)
10357 (progn
10358 (unless silent
10359 (gnus-message 3 "Can't find article %d" article))
10360 nil)
10361 (goto-char (gnus-data-pos data))
10362 article)))
10364 ;; Walking around summary lines with displaying articles.
10366 (defun gnus-summary-expand-window (&optional arg)
10367 "Make the summary buffer take up the entire Emacs frame.
10368 Given a prefix, will force an `article' buffer configuration."
10369 (interactive "P")
10370 (gnus-set-global-variables)
10371 (if arg
10372 (gnus-configure-windows 'article 'force)
10373 (gnus-configure-windows 'summary 'force)))
10375 (defun gnus-summary-display-article (article &optional all-header)
10376 "Display ARTICLE in article buffer."
10377 (gnus-set-global-variables)
10378 (if (null article)
10380 (prog1
10381 (if gnus-summary-display-article-function
10382 (funcall gnus-summary-display-article-function article all-header)
10383 (gnus-article-prepare article all-header))
10384 (run-hooks 'gnus-select-article-hook)
10385 (unless (zerop gnus-current-article)
10386 (gnus-summary-goto-subject gnus-current-article))
10387 (gnus-summary-recenter)
10388 (when gnus-use-trees
10389 (gnus-possibly-generate-tree article)
10390 (gnus-highlight-selected-tree article))
10391 ;; Successfully display article.
10392 (gnus-article-set-window-start
10393 (cdr (assq article gnus-newsgroup-bookmarks))))))
10395 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10396 "Select the current article.
10397 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10398 non-nil, the article will be re-fetched even if it already present in
10399 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10400 be displayed."
10401 ;; Make sure we are in the summary buffer to work around bbdb bug.
10402 (unless (eq major-mode 'gnus-summary-mode)
10403 (set-buffer gnus-summary-buffer))
10404 (let ((article (or article (gnus-summary-article-number)))
10405 (all-headers (not (not all-headers))) ;Must be T or NIL.
10406 gnus-summary-display-article-function
10407 did)
10408 (and (not pseudo)
10409 (gnus-summary-article-pseudo-p article)
10410 (error "This is a pseudo-article."))
10411 (prog1
10412 (save-excursion
10413 (set-buffer gnus-summary-buffer)
10414 (if (or (and gnus-single-article-buffer
10415 (or (null gnus-current-article)
10416 (null gnus-article-current)
10417 (null (get-buffer gnus-article-buffer))
10418 (not (eq article (cdr gnus-article-current)))
10419 (not (equal (car gnus-article-current)
10420 gnus-newsgroup-name))))
10421 (and (not gnus-single-article-buffer)
10422 (or (null gnus-current-article)
10423 (not (eq gnus-current-article article))))
10424 force)
10425 ;; The requested article is different from the current article.
10426 (prog1
10427 (gnus-summary-display-article article all-headers)
10428 (setq did article))
10429 (if (or all-headers gnus-show-all-headers)
10430 (gnus-article-show-all-headers))
10431 'old))
10432 (if did
10433 (gnus-article-set-window-start
10434 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10436 (defun gnus-summary-set-current-mark (&optional current-mark)
10437 "Obsolete function."
10438 nil)
10440 (defun gnus-summary-next-article (&optional unread subject backward push)
10441 "Select the next article.
10442 If UNREAD, only unread articles are selected.
10443 If SUBJECT, only articles with SUBJECT are selected.
10444 If BACKWARD, the previous article is selected instead of the next."
10445 (interactive "P")
10446 (gnus-set-global-variables)
10447 (cond
10448 ;; Is there such an article?
10449 ((and (gnus-summary-search-forward unread subject backward)
10450 (or (gnus-summary-display-article (gnus-summary-article-number))
10451 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10452 (gnus-summary-position-point))
10453 ;; If not, we try the first unread, if that is wanted.
10454 ((and subject
10455 gnus-auto-select-same
10456 (gnus-summary-first-unread-article))
10457 (gnus-summary-position-point)
10458 (gnus-message 6 "Wrapped"))
10459 ;; Try to get next/previous article not displayed in this group.
10460 ((and gnus-auto-extend-newsgroup
10461 (not unread) (not subject))
10462 (gnus-summary-goto-article
10463 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10464 nil t))
10465 ;; Go to next/previous group.
10467 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10468 (gnus-summary-jump-to-group gnus-newsgroup-name))
10469 (let ((cmd last-command-char)
10470 (group
10471 (if (eq gnus-keep-same-level 'best)
10472 (gnus-summary-best-group gnus-newsgroup-name)
10473 (gnus-summary-search-group backward gnus-keep-same-level))))
10474 ;; For some reason, the group window gets selected. We change
10475 ;; it back.
10476 (select-window (get-buffer-window (current-buffer)))
10477 ;; Select next unread newsgroup automagically.
10478 (cond
10479 ((or (not gnus-auto-select-next)
10480 (not cmd))
10481 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10482 ((or (eq gnus-auto-select-next 'quietly)
10483 (and (eq gnus-auto-select-next 'slightly-quietly)
10484 push)
10485 (and (eq gnus-auto-select-next 'almost-quietly)
10486 (gnus-summary-last-article-p)))
10487 ;; Select quietly.
10488 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10489 (gnus-summary-exit)
10490 (gnus-message 7 "No more%s articles (%s)..."
10491 (if unread " unread" "")
10492 (if group (concat "selecting " group)
10493 "exiting"))
10494 (gnus-summary-next-group nil group backward)))
10496 (gnus-summary-walk-group-buffer
10497 gnus-newsgroup-name cmd unread backward)))))))
10499 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10500 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10501 (?\C-p (gnus-group-prev-unread-group 1))))
10502 keve key group ended)
10503 (save-excursion
10504 (set-buffer gnus-group-buffer)
10505 (gnus-summary-jump-to-group from-group)
10506 (setq group
10507 (if (eq gnus-keep-same-level 'best)
10508 (gnus-summary-best-group gnus-newsgroup-name)
10509 (gnus-summary-search-group backward gnus-keep-same-level))))
10510 (while (not ended)
10511 (gnus-message
10512 5 "No more%s articles%s" (if unread " unread" "")
10513 (if (and group
10514 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10515 (format " (Type %s for %s [%s])"
10516 (single-key-description cmd) group
10517 (car (gnus-gethash group gnus-newsrc-hashtb)))
10518 (format " (Type %s to exit %s)"
10519 (single-key-description cmd)
10520 gnus-newsgroup-name)))
10521 ;; Confirm auto selection.
10522 (setq key (car (setq keve (gnus-read-event-char))))
10523 (setq ended t)
10524 (cond
10525 ((assq key keystrokes)
10526 (let ((obuf (current-buffer)))
10527 (switch-to-buffer gnus-group-buffer)
10528 (and group
10529 (gnus-group-jump-to-group group))
10530 (eval (cadr (assq key keystrokes)))
10531 (setq group (gnus-group-group-name))
10532 (switch-to-buffer obuf))
10533 (setq ended nil))
10534 ((equal key cmd)
10535 (if (or (not group)
10536 (gnus-ephemeral-group-p gnus-newsgroup-name))
10537 (gnus-summary-exit)
10538 (gnus-summary-next-group nil group backward)))
10540 (push (cdr keve) unread-command-events))))))
10542 (defun gnus-read-event-char ()
10543 "Get the next event."
10544 (let ((event (read-event)))
10545 (cons (and (numberp event) event) event)))
10547 (defun gnus-summary-next-unread-article ()
10548 "Select unread article after current one."
10549 (interactive)
10550 (gnus-summary-next-article t (and gnus-auto-select-same
10551 (gnus-summary-article-subject))))
10553 (defun gnus-summary-prev-article (&optional unread subject)
10554 "Select the article after the current one.
10555 If UNREAD is non-nil, only unread articles are selected."
10556 (interactive "P")
10557 (gnus-summary-next-article unread subject t))
10559 (defun gnus-summary-prev-unread-article ()
10560 "Select unred article before current one."
10561 (interactive)
10562 (gnus-summary-prev-article t (and gnus-auto-select-same
10563 (gnus-summary-article-subject))))
10565 (defun gnus-summary-next-page (&optional lines circular)
10566 "Show next page of the selected article.
10567 If at the end of the current article, select the next article.
10568 LINES says how many lines should be scrolled up.
10570 If CIRCULAR is non-nil, go to the start of the article instead of
10571 selecting the next article when reaching the end of the current
10572 article."
10573 (interactive "P")
10574 (setq gnus-summary-buffer (current-buffer))
10575 (gnus-set-global-variables)
10576 (let ((article (gnus-summary-article-number))
10577 (endp nil))
10578 (gnus-configure-windows 'article)
10579 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10580 (if (and (eq gnus-summary-goto-unread 'never)
10581 (not (gnus-summary-last-article-p article)))
10582 (gnus-summary-next-article)
10583 (gnus-summary-next-unread-article))
10584 (if (or (null gnus-current-article)
10585 (null gnus-article-current)
10586 (/= article (cdr gnus-article-current))
10587 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10588 ;; Selected subject is different from current article's.
10589 (gnus-summary-display-article article)
10590 (gnus-eval-in-buffer-window gnus-article-buffer
10591 (setq endp (gnus-article-next-page lines)))
10592 (if endp
10593 (cond (circular
10594 (gnus-summary-beginning-of-article))
10595 (lines
10596 (gnus-message 3 "End of message"))
10597 ((null lines)
10598 (if (and (eq gnus-summary-goto-unread 'never)
10599 (not (gnus-summary-last-article-p article)))
10600 (gnus-summary-next-article)
10601 (gnus-summary-next-unread-article)))))))
10602 (gnus-summary-recenter)
10603 (gnus-summary-position-point)))
10605 (defun gnus-summary-prev-page (&optional lines)
10606 "Show previous page of selected article.
10607 Argument LINES specifies lines to be scrolled down."
10608 (interactive "P")
10609 (gnus-set-global-variables)
10610 (let ((article (gnus-summary-article-number)))
10611 (gnus-configure-windows 'article)
10612 (if (or (null gnus-current-article)
10613 (null gnus-article-current)
10614 (/= article (cdr gnus-article-current))
10615 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10616 ;; Selected subject is different from current article's.
10617 (gnus-summary-display-article article)
10618 (gnus-summary-recenter)
10619 (gnus-eval-in-buffer-window gnus-article-buffer
10620 (gnus-article-prev-page lines))))
10621 (gnus-summary-position-point))
10623 (defun gnus-summary-scroll-up (lines)
10624 "Scroll up (or down) one line current article.
10625 Argument LINES specifies lines to be scrolled up (or down if negative)."
10626 (interactive "p")
10627 (gnus-set-global-variables)
10628 (gnus-configure-windows 'article)
10629 (gnus-summary-show-thread)
10630 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10631 (gnus-eval-in-buffer-window gnus-article-buffer
10632 (cond ((> lines 0)
10633 (if (gnus-article-next-page lines)
10634 (gnus-message 3 "End of message")))
10635 ((< lines 0)
10636 (gnus-article-prev-page (- lines))))))
10637 (gnus-summary-recenter)
10638 (gnus-summary-position-point))
10640 (defun gnus-summary-next-same-subject ()
10641 "Select next article which has the same subject as current one."
10642 (interactive)
10643 (gnus-set-global-variables)
10644 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10646 (defun gnus-summary-prev-same-subject ()
10647 "Select previous article which has the same subject as current one."
10648 (interactive)
10649 (gnus-set-global-variables)
10650 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10652 (defun gnus-summary-next-unread-same-subject ()
10653 "Select next unread article which has the same subject as current one."
10654 (interactive)
10655 (gnus-set-global-variables)
10656 (gnus-summary-next-article t (gnus-summary-article-subject)))
10658 (defun gnus-summary-prev-unread-same-subject ()
10659 "Select previous unread article which has the same subject as current one."
10660 (interactive)
10661 (gnus-set-global-variables)
10662 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10664 (defun gnus-summary-first-unread-article ()
10665 "Select the first unread article.
10666 Return nil if there are no unread articles."
10667 (interactive)
10668 (gnus-set-global-variables)
10669 (prog1
10670 (if (gnus-summary-first-subject t)
10671 (progn
10672 (gnus-summary-show-thread)
10673 (gnus-summary-first-subject t)
10674 (gnus-summary-display-article (gnus-summary-article-number))))
10675 (gnus-summary-position-point)))
10677 (defun gnus-summary-best-unread-article ()
10678 "Select the unread article with the highest score."
10679 (interactive)
10680 (gnus-set-global-variables)
10681 (let ((best -1000000)
10682 (data gnus-newsgroup-data)
10683 article score)
10684 (while data
10685 (and (gnus-data-unread-p (car data))
10686 (> (setq score
10687 (gnus-summary-article-score (gnus-data-number (car data))))
10688 best)
10689 (setq best score
10690 article (gnus-data-number (car data))))
10691 (setq data (cdr data)))
10692 (prog1
10693 (if article
10694 (gnus-summary-goto-article article)
10695 (error "No unread articles"))
10696 (gnus-summary-position-point))))
10698 (defun gnus-summary-last-subject ()
10699 "Go to the last displayed subject line in the group."
10700 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10701 (when article
10702 (gnus-summary-goto-subject article))))
10704 (defun gnus-summary-goto-article (article &optional all-headers force)
10705 "Fetch ARTICLE and display it if it exists.
10706 If ALL-HEADERS is non-nil, no header lines are hidden."
10707 (interactive
10708 (list
10709 (string-to-int
10710 (completing-read
10711 "Article number: "
10712 (mapcar (lambda (number) (list (int-to-string number)))
10713 gnus-newsgroup-limit)))
10714 current-prefix-arg
10716 (prog1
10717 (if (gnus-summary-goto-subject article force)
10718 (gnus-summary-display-article article all-headers)
10719 (gnus-message 4 "Couldn't go to article %s" article) nil)
10720 (gnus-summary-position-point)))
10722 (defun gnus-summary-goto-last-article ()
10723 "Go to the previously read article."
10724 (interactive)
10725 (prog1
10726 (and gnus-last-article
10727 (gnus-summary-goto-article gnus-last-article))
10728 (gnus-summary-position-point)))
10730 (defun gnus-summary-pop-article (number)
10731 "Pop one article off the history and go to the previous.
10732 NUMBER articles will be popped off."
10733 (interactive "p")
10734 (let (to)
10735 (setq gnus-newsgroup-history
10736 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10737 (if to
10738 (gnus-summary-goto-article (car to))
10739 (error "Article history empty")))
10740 (gnus-summary-position-point))
10742 ;; Summary commands and functions for limiting the summary buffer.
10744 (defun gnus-summary-limit-to-articles (n)
10745 "Limit the summary buffer to the next N articles.
10746 If not given a prefix, use the process marked articles instead."
10747 (interactive "P")
10748 (gnus-set-global-variables)
10749 (prog1
10750 (let ((articles (gnus-summary-work-articles n)))
10751 (setq gnus-newsgroup-processable nil)
10752 (gnus-summary-limit articles))
10753 (gnus-summary-position-point)))
10755 (defun gnus-summary-pop-limit (&optional total)
10756 "Restore the previous limit.
10757 If given a prefix, remove all limits."
10758 (interactive "P")
10759 (gnus-set-global-variables)
10760 (when total
10761 (setq gnus-newsgroup-limits
10762 (list (mapcar (lambda (h) (mail-header-number h))
10763 gnus-newsgroup-headers))))
10764 (unless gnus-newsgroup-limits
10765 (error "No limit to pop"))
10766 (prog1
10767 (gnus-summary-limit nil 'pop)
10768 (gnus-summary-position-point)))
10770 (defun gnus-summary-limit-to-subject (subject &optional header)
10771 "Limit the summary buffer to articles that have subjects that match a regexp."
10772 (interactive "sRegexp: ")
10773 (unless header
10774 (setq header "subject"))
10775 (when (not (equal "" subject))
10776 (prog1
10777 (let ((articles (gnus-summary-find-matching
10778 (or header "subject") subject 'all)))
10779 (or articles (error "Found no matches for \"%s\"" subject))
10780 (gnus-summary-limit articles))
10781 (gnus-summary-position-point))))
10783 (defun gnus-summary-limit-to-author (from)
10784 "Limit the summary buffer to articles that have authors that match a regexp."
10785 (interactive "sRegexp: ")
10786 (gnus-summary-limit-to-subject from "from"))
10788 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10789 (make-obsolete
10790 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10792 (defun gnus-summary-limit-to-unread (&optional all)
10793 "Limit the summary buffer to articles that are not marked as read.
10794 If ALL is non-nil, limit strictly to unread articles."
10795 (interactive "P")
10796 (if all
10797 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10798 (gnus-summary-limit-to-marks
10799 ;; Concat all the marks that say that an article is read and have
10800 ;; those removed.
10801 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10802 gnus-killed-mark gnus-kill-file-mark
10803 gnus-low-score-mark gnus-expirable-mark
10804 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10805 'reverse)))
10807 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10808 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10810 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10811 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10812 If REVERSE, limit the summary buffer to articles that are not marked
10813 with MARKS. MARKS can either be a string of marks or a list of marks.
10814 Returns how many articles were removed."
10815 (interactive "sMarks: ")
10816 (gnus-set-global-variables)
10817 (prog1
10818 (let ((data gnus-newsgroup-data)
10819 (marks (if (listp marks) marks
10820 (append marks nil))) ; Transform to list.
10821 articles)
10822 (while data
10823 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10824 (memq (gnus-data-mark (car data)) marks))
10825 (setq articles (cons (gnus-data-number (car data)) articles)))
10826 (setq data (cdr data)))
10827 (gnus-summary-limit articles))
10828 (gnus-summary-position-point)))
10830 (defun gnus-summary-limit-to-score (&optional score)
10831 "Limit to articles with score at or above SCORE."
10832 (interactive "P")
10833 (gnus-set-global-variables)
10834 (setq score (if score
10835 (prefix-numeric-value score)
10836 (or gnus-summary-default-score 0)))
10837 (let ((data gnus-newsgroup-data)
10838 articles)
10839 (while data
10840 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10841 score)
10842 (push (gnus-data-number (car data)) articles))
10843 (setq data (cdr data)))
10844 (prog1
10845 (gnus-summary-limit articles)
10846 (gnus-summary-position-point))))
10848 (defun gnus-summary-limit-include-dormant ()
10849 "Display all the hidden articles that are marked as dormant."
10850 (interactive)
10851 (gnus-set-global-variables)
10852 (or gnus-newsgroup-dormant
10853 (error "There are no dormant articles in this group"))
10854 (prog1
10855 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10856 (gnus-summary-position-point)))
10858 (defun gnus-summary-limit-exclude-dormant ()
10859 "Hide all dormant articles."
10860 (interactive)
10861 (gnus-set-global-variables)
10862 (prog1
10863 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10864 (gnus-summary-position-point)))
10866 (defun gnus-summary-limit-exclude-childless-dormant ()
10867 "Hide all dormant articles that have no children."
10868 (interactive)
10869 (gnus-set-global-variables)
10870 (let ((data (gnus-data-list t))
10871 articles d children)
10872 ;; Find all articles that are either not dormant or have
10873 ;; children.
10874 (while (setq d (pop data))
10875 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10876 (and (setq children
10877 (gnus-article-children (gnus-data-number d)))
10878 (let (found)
10879 (while children
10880 (when (memq (car children) articles)
10881 (setq children nil
10882 found t))
10883 (pop children))
10884 found)))
10885 (push (gnus-data-number d) articles)))
10886 ;; Do the limiting.
10887 (prog1
10888 (gnus-summary-limit articles)
10889 (gnus-summary-position-point))))
10891 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10892 "Mark all unread excluded articles as read.
10893 If ALL, mark even excluded ticked and dormants as read."
10894 (interactive "P")
10895 (let ((articles (gnus-sorted-complement
10896 (sort
10897 (mapcar (lambda (h) (mail-header-number h))
10898 gnus-newsgroup-headers)
10900 (sort gnus-newsgroup-limit '<)))
10901 article)
10902 (setq gnus-newsgroup-unreads nil)
10903 (if all
10904 (setq gnus-newsgroup-dormant nil
10905 gnus-newsgroup-marked nil
10906 gnus-newsgroup-reads
10907 (nconc
10908 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10909 gnus-newsgroup-reads))
10910 (while (setq article (pop articles))
10911 (unless (or (memq article gnus-newsgroup-dormant)
10912 (memq article gnus-newsgroup-marked))
10913 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10915 (defun gnus-summary-limit (articles &optional pop)
10916 (if pop
10917 ;; We pop the previous limit off the stack and use that.
10918 (setq articles (car gnus-newsgroup-limits)
10919 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10920 ;; We use the new limit, so we push the old limit on the stack.
10921 (setq gnus-newsgroup-limits
10922 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10923 ;; Set the limit.
10924 (setq gnus-newsgroup-limit articles)
10925 (let ((total (length gnus-newsgroup-data))
10926 (data (gnus-data-find-list (gnus-summary-article-number)))
10927 (gnus-summary-mark-below nil) ; Inhibit this.
10928 found)
10929 ;; This will do all the work of generating the new summary buffer
10930 ;; according to the new limit.
10931 (gnus-summary-prepare)
10932 ;; Hide any threads, possibly.
10933 (and gnus-show-threads
10934 gnus-thread-hide-subtree
10935 (gnus-summary-hide-all-threads))
10936 ;; Try to return to the article you were at, or one in the
10937 ;; neighborhood.
10938 (if data
10939 ;; We try to find some article after the current one.
10940 (while data
10941 (and (gnus-summary-goto-subject
10942 (gnus-data-number (car data)) nil t)
10943 (setq data nil
10944 found t))
10945 (setq data (cdr data))))
10946 (or found
10947 ;; If there is no data, that means that we were after the last
10948 ;; article. The same goes when we can't find any articles
10949 ;; after the current one.
10950 (progn
10951 (goto-char (point-max))
10952 (gnus-summary-find-prev)))
10953 ;; We return how many articles were removed from the summary
10954 ;; buffer as a result of the new limit.
10955 (- total (length gnus-newsgroup-data))))
10957 (defsubst gnus-invisible-cut-children (threads)
10958 (let ((num 0))
10959 (while threads
10960 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10961 (incf num))
10962 (pop threads))
10963 (< num 2)))
10965 (defsubst gnus-cut-thread (thread)
10966 "Go forwards in the thread until we find an article that we want to display."
10967 (when (or (eq gnus-fetch-old-headers 'some)
10968 (eq gnus-build-sparse-threads 'some)
10969 (eq gnus-build-sparse-threads 'more))
10970 ;; Deal with old-fetched headers and sparse threads.
10971 (while (and
10972 thread
10974 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10975 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10976 (or (<= (length (cdr thread)) 1)
10977 (gnus-invisible-cut-children (cdr thread))))
10978 (setq thread (cadr thread))))
10979 thread)
10981 (defun gnus-cut-threads (threads)
10982 "Cut off all uninteresting articles from the beginning of threads."
10983 (when (or (eq gnus-fetch-old-headers 'some)
10984 (eq gnus-build-sparse-threads 'some)
10985 (eq gnus-build-sparse-threads 'more))
10986 (let ((th threads))
10987 (while th
10988 (setcar th (gnus-cut-thread (car th)))
10989 (setq th (cdr th)))))
10990 ;; Remove nixed out threads.
10991 (delq nil threads))
10993 (defun gnus-summary-initial-limit (&optional show-if-empty)
10994 "Figure out what the initial limit is supposed to be on group entry.
10995 This entails weeding out unwanted dormants, low-scored articles,
10996 fetch-old-headers verbiage, and so on."
10997 ;; Most groups have nothing to remove.
10998 (if (or gnus-inhibit-limiting
10999 (and (null gnus-newsgroup-dormant)
11000 (not (eq gnus-fetch-old-headers 'some))
11001 (null gnus-summary-expunge-below)
11002 (not (eq gnus-build-sparse-threads 'some))
11003 (not (eq gnus-build-sparse-threads 'more))
11004 (null gnus-thread-expunge-below)
11005 (not gnus-use-nocem)))
11006 () ; Do nothing.
11007 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11008 (setq gnus-newsgroup-limit nil)
11009 (mapatoms
11010 (lambda (node)
11011 (unless (car (symbol-value node))
11012 ;; These threads have no parents -- they are roots.
11013 (let ((nodes (cdr (symbol-value node)))
11014 thread)
11015 (while nodes
11016 (if (and gnus-thread-expunge-below
11017 (< (gnus-thread-total-score (car nodes))
11018 gnus-thread-expunge-below))
11019 (gnus-expunge-thread (pop nodes))
11020 (setq thread (pop nodes))
11021 (gnus-summary-limit-children thread))))))
11022 gnus-newsgroup-dependencies)
11023 ;; If this limitation resulted in an empty group, we might
11024 ;; pop the previous limit and use it instead.
11025 (when (and (not gnus-newsgroup-limit)
11026 show-if-empty)
11027 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
11028 gnus-newsgroup-limit))
11030 (defun gnus-summary-limit-children (thread)
11031 "Return 1 if this subthread is visible and 0 if it is not."
11032 ;; First we get the number of visible children to this thread. This
11033 ;; is done by recursing down the thread using this function, so this
11034 ;; will really go down to a leaf article first, before slowly
11035 ;; working its way up towards the root.
11036 (when thread
11037 (let ((children
11038 (if (cdr thread)
11039 (apply '+ (mapcar 'gnus-summary-limit-children
11040 (cdr thread)))
11042 (number (mail-header-number (car thread)))
11043 score)
11044 (if (or
11045 ;; If this article is dormant and has absolutely no visible
11046 ;; children, then this article isn't visible.
11047 (and (memq number gnus-newsgroup-dormant)
11048 (= children 0))
11049 ;; If this is "fetch-old-headered" and there is only one
11050 ;; visible child (or less), then we don't want this article.
11051 (and (eq gnus-fetch-old-headers 'some)
11052 (memq number gnus-newsgroup-ancient)
11053 (zerop children))
11054 ;; If this is a sparsely inserted article with no children,
11055 ;; we don't want it.
11056 (and (eq gnus-build-sparse-threads 'some)
11057 (memq number gnus-newsgroup-sparse)
11058 (zerop children))
11059 ;; If we use expunging, and this article is really
11060 ;; low-scored, then we don't want this article.
11061 (when (and gnus-summary-expunge-below
11062 (< (setq score
11063 (or (cdr (assq number gnus-newsgroup-scored))
11064 gnus-summary-default-score))
11065 gnus-summary-expunge-below))
11066 ;; We increase the expunge-tally here, but that has
11067 ;; nothing to do with the limits, really.
11068 (incf gnus-newsgroup-expunged-tally)
11069 ;; We also mark as read here, if that's wanted.
11070 (when (and gnus-summary-mark-below
11071 (< score gnus-summary-mark-below))
11072 (setq gnus-newsgroup-unreads
11073 (delq number gnus-newsgroup-unreads))
11074 (if gnus-newsgroup-auto-expire
11075 (push number gnus-newsgroup-expirable)
11076 (push (cons number gnus-low-score-mark)
11077 gnus-newsgroup-reads)))
11079 (and gnus-use-nocem
11080 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11081 ;; Nope, invisible article.
11083 ;; Ok, this article is to be visible, so we add it to the limit
11084 ;; and return 1.
11085 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11086 1))))
11088 (defun gnus-expunge-thread (thread)
11089 "Mark all articles in THREAD as read."
11090 (let* ((number (mail-header-number (car thread))))
11091 (incf gnus-newsgroup-expunged-tally)
11092 ;; We also mark as read here, if that's wanted.
11093 (setq gnus-newsgroup-unreads
11094 (delq number gnus-newsgroup-unreads))
11095 (if gnus-newsgroup-auto-expire
11096 (push number gnus-newsgroup-expirable)
11097 (push (cons number gnus-low-score-mark)
11098 gnus-newsgroup-reads)))
11099 ;; Go recursively through all subthreads.
11100 (mapcar 'gnus-expunge-thread (cdr thread)))
11102 ;; Summary article oriented commands
11104 (defun gnus-summary-refer-parent-article (n)
11105 "Refer parent article N times.
11106 The difference between N and the number of articles fetched is returned."
11107 (interactive "p")
11108 (gnus-set-global-variables)
11109 (while
11110 (and
11111 (> n 0)
11112 (let* ((header (gnus-summary-article-header))
11113 (ref
11114 ;; If we try to find the parent of the currently
11115 ;; displayed article, then we take a look at the actual
11116 ;; References header, since this is slightly more
11117 ;; reliable than the References field we got from the
11118 ;; server.
11119 (if (and (eq (mail-header-number header)
11120 (cdr gnus-article-current))
11121 (equal gnus-newsgroup-name
11122 (car gnus-article-current)))
11123 (save-excursion
11124 (set-buffer gnus-original-article-buffer)
11125 (nnheader-narrow-to-headers)
11126 (prog1
11127 (message-fetch-field "references")
11128 (widen)))
11129 ;; It's not the current article, so we take a bet on
11130 ;; the value we got from the server.
11131 (mail-header-references header))))
11132 (if (setq ref (or ref (mail-header-references header)))
11133 (or (gnus-summary-refer-article (gnus-parent-id ref))
11134 (gnus-message 1 "Couldn't find parent"))
11135 (gnus-message 1 "No references in article %d"
11136 (gnus-summary-article-number))
11137 nil)))
11138 (setq n (1- n)))
11139 (gnus-summary-position-point)
11142 (defun gnus-summary-refer-references ()
11143 "Fetch all articles mentioned in the References header.
11144 Return how many articles were fetched."
11145 (interactive)
11146 (gnus-set-global-variables)
11147 (let ((ref (mail-header-references (gnus-summary-article-header)))
11148 (current (gnus-summary-article-number))
11149 (n 0))
11150 ;; For each Message-ID in the References header...
11151 (while (string-match "<[^>]*>" ref)
11152 (incf n)
11153 ;; ... fetch that article.
11154 (gnus-summary-refer-article
11155 (prog1 (match-string 0 ref)
11156 (setq ref (substring ref (match-end 0))))))
11157 (gnus-summary-goto-subject current)
11158 (gnus-summary-position-point)
11161 (defun gnus-summary-refer-article (message-id)
11162 "Fetch an article specified by MESSAGE-ID."
11163 (interactive "sMessage-ID: ")
11164 (when (and (stringp message-id)
11165 (not (zerop (length message-id))))
11166 ;; Construct the correct Message-ID if necessary.
11167 ;; Suggested by tale@pawl.rpi.edu.
11168 (unless (string-match "^<" message-id)
11169 (setq message-id (concat "<" message-id)))
11170 (unless (string-match ">$" message-id)
11171 (setq message-id (concat message-id ">")))
11172 (let* ((header (gnus-id-to-header message-id))
11173 (sparse (and header
11174 (memq (mail-header-number header)
11175 gnus-newsgroup-sparse))))
11176 (if header
11177 (prog1
11178 ;; The article is present in the buffer, to we just go to it.
11179 (gnus-summary-goto-article
11180 (mail-header-number header) nil header)
11181 (when sparse
11182 (gnus-summary-update-article (mail-header-number header))))
11183 ;; We fetch the article
11184 (let ((gnus-override-method
11185 (and (gnus-news-group-p gnus-newsgroup-name)
11186 gnus-refer-article-method))
11187 number)
11188 ;; Start the special refer-article method, if necessary.
11189 (when (and gnus-refer-article-method
11190 (gnus-news-group-p gnus-newsgroup-name))
11191 (gnus-check-server gnus-refer-article-method))
11192 ;; Fetch the header, and display the article.
11193 (if (setq number (gnus-summary-insert-subject message-id))
11194 (gnus-summary-select-article nil nil nil number)
11195 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11197 (defun gnus-summary-enter-digest-group (&optional force)
11198 "Enter a digest group based on the current article."
11199 (interactive "P")
11200 (gnus-set-global-variables)
11201 (gnus-summary-select-article)
11202 (let ((name (format "%s-%d"
11203 (gnus-group-prefixed-name
11204 gnus-newsgroup-name (list 'nndoc ""))
11205 gnus-current-article))
11206 (ogroup gnus-newsgroup-name)
11207 (case-fold-search t)
11208 (buf (current-buffer))
11209 dig)
11210 (save-excursion
11211 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11212 (insert-buffer-substring gnus-original-article-buffer)
11213 (narrow-to-region
11214 (goto-char (point-min))
11215 (or (search-forward "\n\n" nil t) (point)))
11216 (goto-char (point-min))
11217 (delete-matching-lines "^\\(Path\\):\\|^From ")
11218 (widen))
11219 (unwind-protect
11220 (if (gnus-group-read-ephemeral-group
11221 name `(nndoc ,name (nndoc-address
11222 ,(get-buffer dig))
11223 (nndoc-article-type ,(if force 'digest 'guess))) t)
11224 ;; Make all postings to this group go to the parent group.
11225 (nconc (gnus-info-params (gnus-get-info name))
11226 (list (cons 'to-group ogroup)))
11227 ;; Couldn't select this doc group.
11228 (switch-to-buffer buf)
11229 (gnus-set-global-variables)
11230 (gnus-configure-windows 'summary)
11231 (gnus-message 3 "Article couldn't be entered?"))
11232 (kill-buffer dig))))
11234 (defun gnus-summary-isearch-article (&optional regexp-p)
11235 "Do incremental search forward on the current article.
11236 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11237 (interactive "P")
11238 (gnus-set-global-variables)
11239 (gnus-summary-select-article)
11240 (gnus-configure-windows 'article)
11241 (gnus-eval-in-buffer-window gnus-article-buffer
11242 (goto-char (point-min))
11243 (isearch-forward regexp-p)))
11245 (defun gnus-summary-search-article-forward (regexp &optional backward)
11246 "Search for an article containing REGEXP forward.
11247 If BACKWARD, search backward instead."
11248 (interactive
11249 (list (read-string
11250 (format "Search article %s (regexp%s): "
11251 (if current-prefix-arg "backward" "forward")
11252 (if gnus-last-search-regexp
11253 (concat ", default " gnus-last-search-regexp)
11254 "")))
11255 current-prefix-arg))
11256 (gnus-set-global-variables)
11257 (if (string-equal regexp "")
11258 (setq regexp (or gnus-last-search-regexp ""))
11259 (setq gnus-last-search-regexp regexp))
11260 (unless (gnus-summary-search-article regexp backward)
11261 (error "Search failed: \"%s\"" regexp)))
11263 (defun gnus-summary-search-article-backward (regexp)
11264 "Search for an article containing REGEXP backward."
11265 (interactive
11266 (list (read-string
11267 (format "Search article backward (regexp%s): "
11268 (if gnus-last-search-regexp
11269 (concat ", default " gnus-last-search-regexp)
11270 "")))))
11271 (gnus-summary-search-article-forward regexp 'backward))
11273 (defun gnus-summary-search-article (regexp &optional backward)
11274 "Search for an article containing REGEXP.
11275 Optional argument BACKWARD means do search for backward.
11276 `gnus-select-article-hook' is not called during the search."
11277 (let ((gnus-select-article-hook nil) ;Disable hook.
11278 (gnus-article-display-hook nil)
11279 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11280 (re-search
11281 (if backward
11282 're-search-backward 're-search-forward))
11283 (sum (current-buffer))
11284 (found nil))
11285 (gnus-save-hidden-threads
11286 (gnus-summary-select-article)
11287 (set-buffer gnus-article-buffer)
11288 (when backward
11289 (forward-line -1))
11290 (while (not found)
11291 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11292 (if (if backward
11293 (re-search-backward regexp nil t)
11294 (re-search-forward regexp nil t))
11295 ;; We found the regexp.
11296 (progn
11297 (setq found 'found)
11298 (beginning-of-line)
11299 (set-window-start
11300 (get-buffer-window (current-buffer))
11301 (point))
11302 (forward-line 1)
11303 (set-buffer sum))
11304 ;; We didn't find it, so we go to the next article.
11305 (set-buffer sum)
11306 (if (not (if backward (gnus-summary-find-prev)
11307 (gnus-summary-find-next)))
11308 ;; No more articles.
11309 (setq found t)
11310 ;; Select the next article and adjust point.
11311 (gnus-summary-select-article)
11312 (set-buffer gnus-article-buffer)
11313 (widen)
11314 (goto-char (if backward (point-max) (point-min))))))
11315 (gnus-message 7 ""))
11316 ;; Return whether we found the regexp.
11317 (when (eq found 'found)
11318 (gnus-summary-show-thread)
11319 (gnus-summary-goto-subject gnus-current-article)
11320 (gnus-summary-position-point)
11321 t)))
11323 (defun gnus-summary-find-matching (header regexp &optional backward unread
11324 not-case-fold)
11325 "Return a list of all articles that match REGEXP on HEADER.
11326 The search stars on the current article and goes forwards unless
11327 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11328 If UNREAD is non-nil, only unread articles will
11329 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11330 in the comparisons."
11331 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11332 (gnus-data-find-list
11333 (gnus-summary-article-number) (gnus-data-list backward))))
11334 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11335 (case-fold-search (not not-case-fold))
11336 articles d)
11337 (or (fboundp (intern (concat "mail-header-" header)))
11338 (error "%s is not a valid header" header))
11339 (while data
11340 (setq d (car data))
11341 (and (or (not unread) ; We want all articles...
11342 (gnus-data-unread-p d)) ; Or just unreads.
11343 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11344 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11345 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11346 (setq data (cdr data)))
11347 (nreverse articles)))
11349 (defun gnus-summary-execute-command (header regexp command &optional backward)
11350 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11351 If HEADER is an empty string (or nil), the match is done on the entire
11352 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11353 (interactive
11354 (list (let ((completion-ignore-case t))
11355 (completing-read
11356 "Header name: "
11357 (mapcar (lambda (string) (list string))
11358 '("Number" "Subject" "From" "Lines" "Date"
11359 "Message-ID" "Xref" "References" "Body"))
11360 nil 'require-match))
11361 (read-string "Regexp: ")
11362 (read-key-sequence "Command: ")
11363 current-prefix-arg))
11364 (when (equal header "Body")
11365 (setq header ""))
11366 (gnus-set-global-variables)
11367 ;; Hidden thread subtrees must be searched as well.
11368 (gnus-summary-show-all-threads)
11369 ;; We don't want to change current point nor window configuration.
11370 (save-excursion
11371 (save-window-excursion
11372 (gnus-message 6 "Executing %s..." (key-description command))
11373 ;; We'd like to execute COMMAND interactively so as to give arguments.
11374 (gnus-execute header regexp
11375 `(lambda () (call-interactively ',(key-binding command)))
11376 backward)
11377 (gnus-message 6 "Executing %s...done" (key-description command)))))
11379 (defun gnus-summary-beginning-of-article ()
11380 "Scroll the article back to the beginning."
11381 (interactive)
11382 (gnus-set-global-variables)
11383 (gnus-summary-select-article)
11384 (gnus-configure-windows 'article)
11385 (gnus-eval-in-buffer-window gnus-article-buffer
11386 (widen)
11387 (goto-char (point-min))
11388 (and gnus-break-pages (gnus-narrow-to-page))))
11390 (defun gnus-summary-end-of-article ()
11391 "Scroll to the end of the article."
11392 (interactive)
11393 (gnus-set-global-variables)
11394 (gnus-summary-select-article)
11395 (gnus-configure-windows 'article)
11396 (gnus-eval-in-buffer-window gnus-article-buffer
11397 (widen)
11398 (goto-char (point-max))
11399 (recenter -3)
11400 (and gnus-break-pages (gnus-narrow-to-page))))
11402 (defun gnus-summary-show-article (&optional arg)
11403 "Force re-fetching of the current article.
11404 If ARG (the prefix) is non-nil, show the raw article without any
11405 article massaging functions being run."
11406 (interactive "P")
11407 (gnus-set-global-variables)
11408 (if (not arg)
11409 ;; Select the article the normal way.
11410 (gnus-summary-select-article nil 'force)
11411 ;; Bind the article treatment functions to nil.
11412 (let ((gnus-have-all-headers t)
11413 gnus-article-display-hook
11414 gnus-article-prepare-hook
11415 gnus-break-pages
11416 gnus-visual)
11417 (gnus-summary-select-article nil 'force)))
11418 (gnus-summary-goto-subject gnus-current-article)
11419 ; (gnus-configure-windows 'article)
11420 (gnus-summary-position-point))
11422 (defun gnus-summary-verbose-headers (&optional arg)
11423 "Toggle permanent full header display.
11424 If ARG is a positive number, turn header display on.
11425 If ARG is a negative number, turn header display off."
11426 (interactive "P")
11427 (gnus-set-global-variables)
11428 (gnus-summary-toggle-header arg)
11429 (setq gnus-show-all-headers
11430 (cond ((or (not (numberp arg))
11431 (zerop arg))
11432 (not gnus-show-all-headers))
11433 ((natnump arg)
11434 t))))
11436 (defun gnus-summary-toggle-header (&optional arg)
11437 "Show the headers if they are hidden, or hide them if they are shown.
11438 If ARG is a positive number, show the entire header.
11439 If ARG is a negative number, hide the unwanted header lines."
11440 (interactive "P")
11441 (gnus-set-global-variables)
11442 (save-excursion
11443 (set-buffer gnus-article-buffer)
11444 (let* ((buffer-read-only nil)
11445 (inhibit-point-motion-hooks t)
11446 (hidden (text-property-any
11447 (goto-char (point-min)) (search-forward "\n\n")
11448 'invisible t))
11450 (goto-char (point-min))
11451 (when (search-forward "\n\n" nil t)
11452 (delete-region (point-min) (1- (point))))
11453 (goto-char (point-min))
11454 (save-excursion
11455 (set-buffer gnus-original-article-buffer)
11456 (goto-char (point-min))
11457 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11458 (insert-buffer-substring gnus-original-article-buffer 1 e)
11459 (let ((gnus-inhibit-hiding t))
11460 (run-hooks 'gnus-article-display-hook))
11461 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11462 (gnus-article-hide-headers)))))
11464 (defun gnus-summary-show-all-headers ()
11465 "Make all header lines visible."
11466 (interactive)
11467 (gnus-set-global-variables)
11468 (gnus-article-show-all-headers))
11470 (defun gnus-summary-toggle-mime (&optional arg)
11471 "Toggle MIME processing.
11472 If ARG is a positive number, turn MIME processing on."
11473 (interactive "P")
11474 (gnus-set-global-variables)
11475 (setq gnus-show-mime
11476 (if (null arg) (not gnus-show-mime)
11477 (> (prefix-numeric-value arg) 0)))
11478 (gnus-summary-select-article t 'force))
11480 (defun gnus-summary-caesar-message (&optional arg)
11481 "Caesar rotate the current article by 13.
11482 The numerical prefix specifies how manu places to rotate each letter
11483 forward."
11484 (interactive "P")
11485 (gnus-set-global-variables)
11486 (gnus-summary-select-article)
11487 (let ((mail-header-separator ""))
11488 (gnus-eval-in-buffer-window gnus-article-buffer
11489 (save-restriction
11490 (widen)
11491 (let ((start (window-start))
11492 buffer-read-only)
11493 (message-caesar-buffer-body arg)
11494 (set-window-start (get-buffer-window (current-buffer)) start))))))
11496 (defun gnus-summary-stop-page-breaking ()
11497 "Stop page breaking in the current article."
11498 (interactive)
11499 (gnus-set-global-variables)
11500 (gnus-summary-select-article)
11501 (gnus-eval-in-buffer-window gnus-article-buffer
11502 (widen)))
11504 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11505 "Move the current article to a different newsgroup.
11506 If N is a positive number, move the N next articles.
11507 If N is a negative number, move the N previous articles.
11508 If N is nil and any articles have been marked with the process mark,
11509 move those articles instead.
11510 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11511 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11512 re-spool using this method.
11514 For this function to work, both the current newsgroup and the
11515 newsgroup that you want to move to have to support the `request-move'
11516 and `request-accept' functions."
11517 (interactive "P")
11518 (unless action (setq action 'move))
11519 (gnus-set-global-variables)
11520 ;; Check whether the source group supports the required functions.
11521 (cond ((and (eq action 'move)
11522 (not (gnus-check-backend-function
11523 'request-move-article gnus-newsgroup-name)))
11524 (error "The current group does not support article moving"))
11525 ((and (eq action 'crosspost)
11526 (not (gnus-check-backend-function
11527 'request-replace-article gnus-newsgroup-name)))
11528 (error "The current group does not support article editing")))
11529 (let ((articles (gnus-summary-work-articles n))
11530 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11531 (names '((move "Move" "Moving")
11532 (copy "Copy" "Copying")
11533 (crosspost "Crosspost" "Crossposting")))
11534 (copy-buf (save-excursion
11535 (nnheader-set-temp-buffer " *copy article*")))
11536 art-group to-method new-xref article to-groups)
11537 (unless (assq action names)
11538 (error "Unknown action %s" action))
11539 ;; Read the newsgroup name.
11540 (when (and (not to-newsgroup)
11541 (not select-method))
11542 (setq to-newsgroup
11543 (gnus-read-move-group-name
11544 (cadr (assq action names))
11545 (symbol-value (intern (format "gnus-current-%s-group" action)))
11546 articles prefix))
11547 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11548 (setq to-method (or select-method
11549 (gnus-group-name-to-method to-newsgroup)))
11550 ;; Check the method we are to move this article to...
11551 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11552 (error "%s does not support article copying" (car to-method)))
11553 (or (gnus-check-server to-method)
11554 (error "Can't open server %s" (car to-method)))
11555 (gnus-message 6 "%s to %s: %s..."
11556 (caddr (assq action names))
11557 (or (car select-method) to-newsgroup) articles)
11558 (while articles
11559 (setq article (pop articles))
11560 (setq
11561 art-group
11562 (cond
11563 ;; Move the article.
11564 ((eq action 'move)
11565 (gnus-request-move-article
11566 article ; Article to move
11567 gnus-newsgroup-name ; From newsgrouo
11568 (nth 1 (gnus-find-method-for-group
11569 gnus-newsgroup-name)) ; Server
11570 (list 'gnus-request-accept-article
11571 to-newsgroup (list 'quote select-method)
11572 (not articles)) ; Accept form
11573 (not articles))) ; Only save nov last time
11574 ;; Copy the article.
11575 ((eq action 'copy)
11576 (save-excursion
11577 (set-buffer copy-buf)
11578 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11579 (gnus-request-accept-article
11580 to-newsgroup select-method (not articles))))
11581 ;; Crosspost the article.
11582 ((eq action 'crosspost)
11583 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11584 (setq new-xref (concat gnus-newsgroup-name ":" article))
11585 (if (and xref (not (string= xref "")))
11586 (progn
11587 (when (string-match "^Xref: " xref)
11588 (setq xref (substring xref (match-end 0))))
11589 (setq new-xref (concat xref " " new-xref)))
11590 (setq new-xref (concat (system-name) " " new-xref)))
11591 (save-excursion
11592 (set-buffer copy-buf)
11593 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11594 (nnheader-replace-header "xref" new-xref)
11595 (gnus-request-accept-article
11596 to-newsgroup select-method (not articles)))))))
11597 (if (not art-group)
11598 (gnus-message 1 "Couldn't %s article %s"
11599 (cadr (assq action names)) article)
11600 (let* ((entry
11602 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11603 (gnus-gethash
11604 (gnus-group-prefixed-name
11605 (car art-group)
11606 (or select-method
11607 (gnus-find-method-for-group to-newsgroup)))
11608 gnus-newsrc-hashtb)))
11609 (info (nth 2 entry))
11610 (to-group (gnus-info-group info)))
11611 ;; Update the group that has been moved to.
11612 (when (and info
11613 (memq action '(move copy)))
11614 (unless (member to-group to-groups)
11615 (push to-group to-groups))
11617 (unless (memq article gnus-newsgroup-unreads)
11618 (gnus-info-set-read
11619 info (gnus-add-to-range (gnus-info-read info)
11620 (list (cdr art-group)))))
11622 ;; Copy any marks over to the new group.
11623 (let ((marks gnus-article-mark-lists)
11624 (to-article (cdr art-group)))
11626 ;; See whether the article is to be put in the cache.
11627 (when gnus-use-cache
11628 (gnus-cache-possibly-enter-article
11629 to-group to-article
11630 (let ((header (copy-sequence
11631 (gnus-summary-article-header article))))
11632 (mail-header-set-number header to-article)
11633 header)
11634 (memq article gnus-newsgroup-marked)
11635 (memq article gnus-newsgroup-dormant)
11636 (memq article gnus-newsgroup-unreads)))
11638 (while marks
11639 (when (memq article (symbol-value
11640 (intern (format "gnus-newsgroup-%s"
11641 (caar marks)))))
11642 ;; If the other group is the same as this group,
11643 ;; then we have to add the mark to the list.
11644 (when (equal to-group gnus-newsgroup-name)
11645 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11646 (cons to-article
11647 (symbol-value
11648 (intern (format "gnus-newsgroup-%s"
11649 (caar marks)))))))
11650 ;; Copy mark to other group.
11651 (gnus-add-marked-articles
11652 to-group (cdar marks) (list to-article) info))
11653 (setq marks (cdr marks)))))
11655 ;; Update the Xref header in this article to point to
11656 ;; the new crossposted article we have just created.
11657 (when (eq action 'crosspost)
11658 (save-excursion
11659 (set-buffer copy-buf)
11660 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11661 (nnheader-replace-header
11662 "xref" (concat new-xref " " (gnus-group-prefixed-name
11663 (car art-group) to-method)
11664 ":" (cdr art-group)))
11665 (gnus-request-replace-article
11666 article gnus-newsgroup-name (current-buffer)))))
11668 (gnus-summary-goto-subject article)
11669 (when (eq action 'move)
11670 (gnus-summary-mark-article article gnus-canceled-mark)))
11671 (gnus-summary-remove-process-mark article))
11672 ;; Re-activate all groups that have been moved to.
11673 (while to-groups
11674 (gnus-activate-group (pop to-groups)))
11676 (gnus-kill-buffer copy-buf)
11677 (gnus-summary-position-point)
11678 (gnus-set-mode-line 'summary)))
11680 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11681 "Move the current article to a different newsgroup.
11682 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11683 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11684 re-spool using this method."
11685 (interactive "P")
11686 (gnus-summary-move-article n nil select-method 'copy))
11688 (defun gnus-summary-crosspost-article (&optional n)
11689 "Crosspost the current article to some other group."
11690 (interactive "P")
11691 (gnus-summary-move-article n nil nil 'crosspost))
11693 (defvar gnus-summary-respool-default-method nil
11694 "Default method for respooling an article.
11695 If nil, use to the current newsgroup method.")
11697 (defun gnus-summary-respool-article (&optional n method)
11698 "Respool the current article.
11699 The article will be squeezed through the mail spooling process again,
11700 which means that it will be put in some mail newsgroup or other
11701 depending on `nnmail-split-methods'.
11702 If N is a positive number, respool the N next articles.
11703 If N is a negative number, respool the N previous articles.
11704 If N is nil and any articles have been marked with the process mark,
11705 respool those articles instead.
11707 Respooling can be done both from mail groups and \"real\" newsgroups.
11708 In the former case, the articles in question will be moved from the
11709 current group into whatever groups they are destined to. In the
11710 latter case, they will be copied into the relevant groups."
11711 (interactive
11712 (list current-prefix-arg
11713 (let* ((methods (gnus-methods-using 'respool))
11714 (methname
11715 (symbol-name (or gnus-summary-respool-default-method
11716 (car (gnus-find-method-for-group
11717 gnus-newsgroup-name)))))
11718 (method
11719 (gnus-completing-read
11720 methname "What backend do you want to use when respooling?"
11721 methods nil t nil 'gnus-method-history))
11723 (cond
11724 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11725 (list (intern method) ""))
11726 ((= 1 (length ms))
11727 (car ms))
11729 (cdr (completing-read
11730 "Server name: "
11731 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11732 (gnus-set-global-variables)
11733 (unless method
11734 (error "No method given for respooling"))
11735 (if (assoc (symbol-name
11736 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11737 (gnus-methods-using 'respool))
11738 (gnus-summary-move-article n nil method)
11739 (gnus-summary-copy-article n nil method)))
11741 (defun gnus-summary-import-article (file)
11742 "Import a random file into a mail newsgroup."
11743 (interactive "fImport file: ")
11744 (gnus-set-global-variables)
11745 (let ((group gnus-newsgroup-name)
11746 (now (current-time))
11747 atts lines)
11748 (or (gnus-check-backend-function 'request-accept-article group)
11749 (error "%s does not support article importing" group))
11750 (or (file-readable-p file)
11751 (not (file-regular-p file))
11752 (error "Can't read %s" file))
11753 (save-excursion
11754 (set-buffer (get-buffer-create " *import file*"))
11755 (buffer-disable-undo (current-buffer))
11756 (erase-buffer)
11757 (insert-file-contents file)
11758 (goto-char (point-min))
11759 (unless (nnheader-article-p)
11760 ;; This doesn't look like an article, so we fudge some headers.
11761 (setq atts (file-attributes file)
11762 lines (count-lines (point-min) (point-max)))
11763 (insert "From: " (read-string "From: ") "\n"
11764 "Subject: " (read-string "Subject: ") "\n"
11765 "Date: " (timezone-make-date-arpa-standard
11766 (current-time-string (nth 5 atts))
11767 (current-time-zone now)
11768 (current-time-zone now)) "\n"
11769 "Message-ID: " (message-make-message-id) "\n"
11770 "Lines: " (int-to-string lines) "\n"
11771 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11772 (gnus-request-accept-article group nil t)
11773 (kill-buffer (current-buffer)))))
11775 (defun gnus-summary-expire-articles (&optional now)
11776 "Expire all articles that are marked as expirable in the current group."
11777 (interactive)
11778 (gnus-set-global-variables)
11779 (when (gnus-check-backend-function
11780 'request-expire-articles gnus-newsgroup-name)
11781 ;; This backend supports expiry.
11782 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11783 (expirable (if total
11784 (gnus-list-of-read-articles gnus-newsgroup-name)
11785 (setq gnus-newsgroup-expirable
11786 (sort gnus-newsgroup-expirable '<))))
11787 (expiry-wait (if now 'immediate
11788 (gnus-group-get-parameter
11789 gnus-newsgroup-name 'expiry-wait)))
11791 (when expirable
11792 ;; There are expirable articles in this group, so we run them
11793 ;; through the expiry process.
11794 (gnus-message 6 "Expiring articles...")
11795 ;; The list of articles that weren't expired is returned.
11796 (if expiry-wait
11797 (let ((nnmail-expiry-wait-function nil)
11798 (nnmail-expiry-wait expiry-wait))
11799 (setq es (gnus-request-expire-articles
11800 expirable gnus-newsgroup-name)))
11801 (setq es (gnus-request-expire-articles
11802 expirable gnus-newsgroup-name)))
11803 (or total (setq gnus-newsgroup-expirable es))
11804 ;; We go through the old list of expirable, and mark all
11805 ;; really expired articles as nonexistent.
11806 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11807 (let ((gnus-use-cache nil))
11808 (while expirable
11809 (unless (memq (car expirable) es)
11810 (when (gnus-data-find (car expirable))
11811 (gnus-summary-mark-article
11812 (car expirable) gnus-canceled-mark)))
11813 (setq expirable (cdr expirable)))))
11814 (gnus-message 6 "Expiring articles...done")))))
11816 (defun gnus-summary-expire-articles-now ()
11817 "Expunge all expirable articles in the current group.
11818 This means that *all* articles that are marked as expirable will be
11819 deleted forever, right now."
11820 (interactive)
11821 (gnus-set-global-variables)
11822 (or gnus-expert-user
11823 (gnus-y-or-n-p
11824 "Are you really, really, really sure you want to delete all these messages? ")
11825 (error "Phew!"))
11826 (gnus-summary-expire-articles t))
11828 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11829 (defun gnus-summary-delete-article (&optional n)
11830 "Delete the N next (mail) articles.
11831 This command actually deletes articles. This is not a marking
11832 command. The article will disappear forever from your life, never to
11833 return.
11834 If N is negative, delete backwards.
11835 If N is nil and articles have been marked with the process mark,
11836 delete these instead."
11837 (interactive "P")
11838 (gnus-set-global-variables)
11839 (or (gnus-check-backend-function 'request-expire-articles
11840 gnus-newsgroup-name)
11841 (error "The current newsgroup does not support article deletion."))
11842 ;; Compute the list of articles to delete.
11843 (let ((articles (gnus-summary-work-articles n))
11844 not-deleted)
11845 (if (and gnus-novice-user
11846 (not (gnus-y-or-n-p
11847 (format "Do you really want to delete %s forever? "
11848 (if (> (length articles) 1)
11849 (format "these %s articles" (length articles))
11850 "this article")))))
11852 ;; Delete the articles.
11853 (setq not-deleted (gnus-request-expire-articles
11854 articles gnus-newsgroup-name 'force))
11855 (while articles
11856 (gnus-summary-remove-process-mark (car articles))
11857 ;; The backend might not have been able to delete the article
11858 ;; after all.
11859 (or (memq (car articles) not-deleted)
11860 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11861 (setq articles (cdr articles))))
11862 (gnus-summary-position-point)
11863 (gnus-set-mode-line 'summary)
11864 not-deleted))
11866 (defun gnus-summary-edit-article (&optional force)
11867 "Enter into a buffer and edit the current article.
11868 This will have permanent effect only in mail groups.
11869 If FORCE is non-nil, allow editing of articles even in read-only
11870 groups."
11871 (interactive "P")
11872 (save-excursion
11873 (set-buffer gnus-summary-buffer)
11874 (gnus-set-global-variables)
11875 (when (and (not force)
11876 (gnus-group-read-only-p))
11877 (error "The current newsgroup does not support article editing."))
11878 (gnus-summary-select-article t nil t)
11879 (gnus-configure-windows 'article)
11880 (select-window (get-buffer-window gnus-article-buffer))
11881 (gnus-message 6 "C-c C-c to end edits")
11882 (setq buffer-read-only nil)
11883 (text-mode)
11884 (use-local-map (copy-keymap (current-local-map)))
11885 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11886 (buffer-enable-undo)
11887 (widen)
11888 (goto-char (point-min))
11889 (search-forward "\n\n" nil t)))
11891 (defun gnus-summary-edit-article-done ()
11892 "Make edits to the current article permanent."
11893 (interactive)
11894 (if (gnus-group-read-only-p)
11895 (progn
11896 (let ((beep (not (eq major-mode 'text-mode))))
11897 (gnus-summary-edit-article-postpone)
11898 (when beep
11899 (gnus-error
11900 3 "The current newsgroup does not support article editing."))))
11901 (let ((buf (format "%s" (buffer-string))))
11902 (erase-buffer)
11903 (insert buf)
11904 (if (not (gnus-request-replace-article
11905 (cdr gnus-article-current) (car gnus-article-current)
11906 (current-buffer)))
11907 (error "Couldn't replace article.")
11908 (gnus-article-mode)
11909 (use-local-map gnus-article-mode-map)
11910 (setq buffer-read-only t)
11911 (buffer-disable-undo (current-buffer))
11912 (gnus-configure-windows 'summary)
11913 (gnus-summary-update-article (cdr gnus-article-current))
11914 (when gnus-use-cache
11915 (gnus-cache-update-article
11916 (car gnus-article-current) (cdr gnus-article-current)))
11917 (when gnus-keep-backlog
11918 (gnus-backlog-remove-article
11919 (car gnus-article-current) (cdr gnus-article-current))))
11920 (save-excursion
11921 (when (get-buffer gnus-original-article-buffer)
11922 (set-buffer gnus-original-article-buffer)
11923 (setq gnus-original-article nil)))
11924 (setq gnus-article-current nil
11925 gnus-current-article nil)
11926 (run-hooks 'gnus-article-display-hook)
11927 (and (gnus-visual-p 'summary-highlight 'highlight)
11928 (run-hooks 'gnus-visual-mark-article-hook)))))
11930 (defun gnus-summary-edit-article-postpone ()
11931 "Postpone changes to the current article."
11932 (interactive)
11933 (gnus-article-mode)
11934 (use-local-map gnus-article-mode-map)
11935 (setq buffer-read-only t)
11936 (buffer-disable-undo (current-buffer))
11937 (gnus-configure-windows 'summary)
11938 (and (gnus-visual-p 'summary-highlight 'highlight)
11939 (run-hooks 'gnus-visual-mark-article-hook)))
11941 (defun gnus-summary-respool-query ()
11942 "Query where the respool algorithm would put this article."
11943 (interactive)
11944 (gnus-set-global-variables)
11945 (gnus-summary-select-article)
11946 (save-excursion
11947 (set-buffer gnus-article-buffer)
11948 (save-restriction
11949 (goto-char (point-min))
11950 (search-forward "\n\n")
11951 (narrow-to-region (point-min) (point))
11952 (pp-eval-expression
11953 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11955 ;; Summary marking commands.
11957 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11958 "Mark articles which has the same subject as read, and then select the next.
11959 If UNMARK is positive, remove any kind of mark.
11960 If UNMARK is negative, tick articles."
11961 (interactive "P")
11962 (gnus-set-global-variables)
11963 (if unmark
11964 (setq unmark (prefix-numeric-value unmark)))
11965 (let ((count
11966 (gnus-summary-mark-same-subject
11967 (gnus-summary-article-subject) unmark)))
11968 ;; Select next unread article. If auto-select-same mode, should
11969 ;; select the first unread article.
11970 (gnus-summary-next-article t (and gnus-auto-select-same
11971 (gnus-summary-article-subject)))
11972 (gnus-message 7 "%d article%s marked as %s"
11973 count (if (= count 1) " is" "s are")
11974 (if unmark "unread" "read"))))
11976 (defun gnus-summary-kill-same-subject (&optional unmark)
11977 "Mark articles which has the same subject as read.
11978 If UNMARK is positive, remove any kind of mark.
11979 If UNMARK is negative, tick articles."
11980 (interactive "P")
11981 (gnus-set-global-variables)
11982 (if unmark
11983 (setq unmark (prefix-numeric-value unmark)))
11984 (let ((count
11985 (gnus-summary-mark-same-subject
11986 (gnus-summary-article-subject) unmark)))
11987 ;; If marked as read, go to next unread subject.
11988 (if (null unmark)
11989 ;; Go to next unread subject.
11990 (gnus-summary-next-subject 1 t))
11991 (gnus-message 7 "%d articles are marked as %s"
11992 count (if unmark "unread" "read"))))
11994 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11995 "Mark articles with same SUBJECT as read, and return marked number.
11996 If optional argument UNMARK is positive, remove any kinds of marks.
11997 If optional argument UNMARK is negative, mark articles as unread instead."
11998 (let ((count 1))
11999 (save-excursion
12000 (cond
12001 ((null unmark) ; Mark as read.
12002 (while (and
12003 (progn
12004 (gnus-summary-mark-article-as-read gnus-killed-mark)
12005 (gnus-summary-show-thread) t)
12006 (gnus-summary-find-subject subject))
12007 (setq count (1+ count))))
12008 ((> unmark 0) ; Tick.
12009 (while (and
12010 (progn
12011 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
12012 (gnus-summary-show-thread) t)
12013 (gnus-summary-find-subject subject))
12014 (setq count (1+ count))))
12015 (t ; Mark as unread.
12016 (while (and
12017 (progn
12018 (gnus-summary-mark-article-as-unread gnus-unread-mark)
12019 (gnus-summary-show-thread) t)
12020 (gnus-summary-find-subject subject))
12021 (setq count (1+ count)))))
12022 (gnus-set-mode-line 'summary)
12023 ;; Return the number of marked articles.
12024 count)))
12026 (defun gnus-summary-mark-as-processable (n &optional unmark)
12027 "Set the process mark on the next N articles.
12028 If N is negative, mark backward instead. If UNMARK is non-nil, remove
12029 the process mark instead. The difference between N and the actual
12030 number of articles marked is returned."
12031 (interactive "p")
12032 (gnus-set-global-variables)
12033 (let ((backward (< n 0))
12034 (n (abs n)))
12035 (while (and
12036 (> n 0)
12037 (if unmark
12038 (gnus-summary-remove-process-mark
12039 (gnus-summary-article-number))
12040 (gnus-summary-set-process-mark (gnus-summary-article-number)))
12041 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
12042 (setq n (1- n)))
12043 (if (/= 0 n) (gnus-message 7 "No more articles"))
12044 (gnus-summary-recenter)
12045 (gnus-summary-position-point)
12048 (defun gnus-summary-unmark-as-processable (n)
12049 "Remove the process mark from the next N articles.
12050 If N is negative, mark backward instead. The difference between N and
12051 the actual number of articles marked is returned."
12052 (interactive "p")
12053 (gnus-set-global-variables)
12054 (gnus-summary-mark-as-processable n t))
12056 (defun gnus-summary-unmark-all-processable ()
12057 "Remove the process mark from all articles."
12058 (interactive)
12059 (gnus-set-global-variables)
12060 (save-excursion
12061 (while gnus-newsgroup-processable
12062 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
12063 (gnus-summary-position-point))
12065 (defun gnus-summary-mark-as-expirable (n)
12066 "Mark N articles forward as expirable.
12067 If N is negative, mark backward instead. The difference between N and
12068 the actual number of articles marked is returned."
12069 (interactive "p")
12070 (gnus-set-global-variables)
12071 (gnus-summary-mark-forward n gnus-expirable-mark))
12073 (defun gnus-summary-mark-article-as-replied (article)
12074 "Mark ARTICLE replied and update the summary line."
12075 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12076 (let ((buffer-read-only nil))
12077 (when (gnus-summary-goto-subject article)
12078 (gnus-summary-update-secondary-mark article))))
12080 (defun gnus-summary-set-bookmark (article)
12081 "Set a bookmark in current article."
12082 (interactive (list (gnus-summary-article-number)))
12083 (gnus-set-global-variables)
12084 (if (or (not (get-buffer gnus-article-buffer))
12085 (not gnus-current-article)
12086 (not gnus-article-current)
12087 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12088 (error "No current article selected"))
12089 ;; Remove old bookmark, if one exists.
12090 (let ((old (assq article gnus-newsgroup-bookmarks)))
12091 (if old (setq gnus-newsgroup-bookmarks
12092 (delq old gnus-newsgroup-bookmarks))))
12093 ;; Set the new bookmark, which is on the form
12094 ;; (article-number . line-number-in-body).
12095 (setq gnus-newsgroup-bookmarks
12096 (cons
12097 (cons article
12098 (save-excursion
12099 (set-buffer gnus-article-buffer)
12100 (count-lines
12101 (min (point)
12102 (save-excursion
12103 (goto-char (point-min))
12104 (search-forward "\n\n" nil t)
12105 (point)))
12106 (point))))
12107 gnus-newsgroup-bookmarks))
12108 (gnus-message 6 "A bookmark has been added to the current article."))
12110 (defun gnus-summary-remove-bookmark (article)
12111 "Remove the bookmark from the current article."
12112 (interactive (list (gnus-summary-article-number)))
12113 (gnus-set-global-variables)
12114 ;; Remove old bookmark, if one exists.
12115 (let ((old (assq article gnus-newsgroup-bookmarks)))
12116 (if old
12117 (progn
12118 (setq gnus-newsgroup-bookmarks
12119 (delq old gnus-newsgroup-bookmarks))
12120 (gnus-message 6 "Removed bookmark."))
12121 (gnus-message 6 "No bookmark in current article."))))
12123 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12124 (defun gnus-summary-mark-as-dormant (n)
12125 "Mark N articles forward as dormant.
12126 If N is negative, mark backward instead. The difference between N and
12127 the actual number of articles marked is returned."
12128 (interactive "p")
12129 (gnus-set-global-variables)
12130 (gnus-summary-mark-forward n gnus-dormant-mark))
12132 (defun gnus-summary-set-process-mark (article)
12133 "Set the process mark on ARTICLE and update the summary line."
12134 (setq gnus-newsgroup-processable
12135 (cons article
12136 (delq article gnus-newsgroup-processable)))
12137 (when (gnus-summary-goto-subject article)
12138 (gnus-summary-show-thread)
12139 (gnus-summary-update-secondary-mark article)))
12141 (defun gnus-summary-remove-process-mark (article)
12142 "Remove the process mark from ARTICLE and update the summary line."
12143 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12144 (when (gnus-summary-goto-subject article)
12145 (gnus-summary-show-thread)
12146 (gnus-summary-update-secondary-mark article)))
12148 (defun gnus-summary-set-saved-mark (article)
12149 "Set the process mark on ARTICLE and update the summary line."
12150 (push article gnus-newsgroup-saved)
12151 (when (gnus-summary-goto-subject article)
12152 (gnus-summary-update-secondary-mark article)))
12154 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12155 "Mark N articles as read forwards.
12156 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
12157 The difference between N and the actual number of articles marked is
12158 returned."
12159 (interactive "p")
12160 (gnus-set-global-variables)
12161 (let ((backward (< n 0))
12162 (gnus-summary-goto-unread
12163 (and gnus-summary-goto-unread
12164 (not (eq gnus-summary-goto-unread 'never))
12165 (not (memq mark (list gnus-unread-mark
12166 gnus-ticked-mark gnus-dormant-mark)))))
12167 (n (abs n))
12168 (mark (or mark gnus-del-mark)))
12169 (while (and (> n 0)
12170 (gnus-summary-mark-article nil mark no-expire)
12171 (zerop (gnus-summary-next-subject
12172 (if backward -1 1)
12173 (and gnus-summary-goto-unread
12174 (not (eq gnus-summary-goto-unread 'never)))
12175 t)))
12176 (setq n (1- n)))
12177 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12178 (gnus-summary-recenter)
12179 (gnus-summary-position-point)
12180 (gnus-set-mode-line 'summary)
12183 (defun gnus-summary-mark-article-as-read (mark)
12184 "Mark the current article quickly as read with MARK."
12185 (let ((article (gnus-summary-article-number)))
12186 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12187 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12188 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12189 (setq gnus-newsgroup-reads
12190 (cons (cons article mark) gnus-newsgroup-reads))
12191 ;; Possibly remove from cache, if that is used.
12192 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12193 ;; Allow the backend to change the mark.
12194 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12195 ;; Check for auto-expiry.
12196 (when (and gnus-newsgroup-auto-expire
12197 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12198 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12199 (= mark gnus-ancient-mark)
12200 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12201 (setq mark gnus-expirable-mark)
12202 (push article gnus-newsgroup-expirable))
12203 ;; Set the mark in the buffer.
12204 (gnus-summary-update-mark mark 'unread)
12207 (defun gnus-summary-mark-article-as-unread (mark)
12208 "Mark the current article quickly as unread with MARK."
12209 (let ((article (gnus-summary-article-number)))
12210 (if (< article 0)
12211 (gnus-error 1 "Unmarkable article")
12212 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12213 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12214 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12215 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12216 (cond ((= mark gnus-ticked-mark)
12217 (push article gnus-newsgroup-marked))
12218 ((= mark gnus-dormant-mark)
12219 (push article gnus-newsgroup-dormant))
12221 (push article gnus-newsgroup-unreads)))
12222 (setq gnus-newsgroup-reads
12223 (delq (assq article gnus-newsgroup-reads)
12224 gnus-newsgroup-reads))
12226 ;; See whether the article is to be put in the cache.
12227 (and gnus-use-cache
12228 (vectorp (gnus-summary-article-header article))
12229 (save-excursion
12230 (gnus-cache-possibly-enter-article
12231 gnus-newsgroup-name article
12232 (gnus-summary-article-header article)
12233 (= mark gnus-ticked-mark)
12234 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12236 ;; Fix the mark.
12237 (gnus-summary-update-mark mark 'unread))
12240 (defun gnus-summary-mark-article (&optional article mark no-expire)
12241 "Mark ARTICLE with MARK. MARK can be any character.
12242 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12243 `??' (dormant) and `?E' (expirable).
12244 If MARK is nil, then the default character `?D' is used.
12245 If ARTICLE is nil, then the article on the current line will be
12246 marked."
12247 ;; The mark might be a string.
12248 (and (stringp mark)
12249 (setq mark (aref mark 0)))
12250 ;; If no mark is given, then we check auto-expiring.
12251 (and (not no-expire)
12252 gnus-newsgroup-auto-expire
12253 (or (not mark)
12254 (and (numberp mark)
12255 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12256 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12257 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12258 (setq mark gnus-expirable-mark))
12259 (let* ((mark (or mark gnus-del-mark))
12260 (article (or article (gnus-summary-article-number))))
12261 (or article (error "No article on current line"))
12262 (if (or (= mark gnus-unread-mark)
12263 (= mark gnus-ticked-mark)
12264 (= mark gnus-dormant-mark))
12265 (gnus-mark-article-as-unread article mark)
12266 (gnus-mark-article-as-read article mark))
12268 ;; See whether the article is to be put in the cache.
12269 (and gnus-use-cache
12270 (not (= mark gnus-canceled-mark))
12271 (vectorp (gnus-summary-article-header article))
12272 (save-excursion
12273 (gnus-cache-possibly-enter-article
12274 gnus-newsgroup-name article
12275 (gnus-summary-article-header article)
12276 (= mark gnus-ticked-mark)
12277 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12279 (if (gnus-summary-goto-subject article nil t)
12280 (let ((buffer-read-only nil))
12281 (gnus-summary-show-thread)
12282 ;; Fix the mark.
12283 (gnus-summary-update-mark mark 'unread)
12284 t))))
12286 (defun gnus-summary-update-secondary-mark (article)
12287 "Update the secondary (read, process, cache) mark."
12288 (gnus-summary-update-mark
12289 (cond ((memq article gnus-newsgroup-processable)
12290 gnus-process-mark)
12291 ((memq article gnus-newsgroup-cached)
12292 gnus-cached-mark)
12293 ((memq article gnus-newsgroup-replied)
12294 gnus-replied-mark)
12295 ((memq article gnus-newsgroup-saved)
12296 gnus-saved-mark)
12297 (t gnus-unread-mark))
12298 'replied)
12299 (when (gnus-visual-p 'summary-highlight 'highlight)
12300 (run-hooks 'gnus-summary-update-hook))
12303 (defun gnus-summary-update-mark (mark type)
12304 (beginning-of-line)
12305 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12306 (buffer-read-only nil))
12307 (when (and forward
12308 (<= (+ forward (point)) (point-max)))
12309 ;; Go to the right position on the line.
12310 (goto-char (+ forward (point)))
12311 ;; Replace the old mark with the new mark.
12312 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12313 ;; Optionally update the marks by some user rule.
12314 (when (eq type 'unread)
12315 (gnus-data-set-mark
12316 (gnus-data-find (gnus-summary-article-number)) mark)
12317 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12319 (defun gnus-mark-article-as-read (article &optional mark)
12320 "Enter ARTICLE in the pertinent lists and remove it from others."
12321 ;; Make the article expirable.
12322 (let ((mark (or mark gnus-del-mark)))
12323 (if (= mark gnus-expirable-mark)
12324 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12325 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12326 ;; Remove from unread and marked lists.
12327 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12328 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12329 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12330 (push (cons article mark) gnus-newsgroup-reads)
12331 ;; Possibly remove from cache, if that is used.
12332 (when gnus-use-cache
12333 (gnus-cache-enter-remove-article article))))
12335 (defun gnus-mark-article-as-unread (article &optional mark)
12336 "Enter ARTICLE in the pertinent lists and remove it from others."
12337 (let ((mark (or mark gnus-ticked-mark)))
12338 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12339 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12340 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12341 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12342 (cond ((= mark gnus-ticked-mark)
12343 (push article gnus-newsgroup-marked))
12344 ((= mark gnus-dormant-mark)
12345 (push article gnus-newsgroup-dormant))
12347 (push article gnus-newsgroup-unreads)))
12348 (setq gnus-newsgroup-reads
12349 (delq (assq article gnus-newsgroup-reads)
12350 gnus-newsgroup-reads))))
12352 (defalias 'gnus-summary-mark-as-unread-forward
12353 'gnus-summary-tick-article-forward)
12354 (make-obsolete 'gnus-summary-mark-as-unread-forward
12355 'gnus-summary-tick-article-forward)
12356 (defun gnus-summary-tick-article-forward (n)
12357 "Tick N articles forwards.
12358 If N is negative, tick backwards instead.
12359 The difference between N and the number of articles ticked is returned."
12360 (interactive "p")
12361 (gnus-summary-mark-forward n gnus-ticked-mark))
12363 (defalias 'gnus-summary-mark-as-unread-backward
12364 'gnus-summary-tick-article-backward)
12365 (make-obsolete 'gnus-summary-mark-as-unread-backward
12366 'gnus-summary-tick-article-backward)
12367 (defun gnus-summary-tick-article-backward (n)
12368 "Tick N articles backwards.
12369 The difference between N and the number of articles ticked is returned."
12370 (interactive "p")
12371 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12373 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12374 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12375 (defun gnus-summary-tick-article (&optional article clear-mark)
12376 "Mark current article as unread.
12377 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12378 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12379 (interactive)
12380 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12381 gnus-ticked-mark)))
12383 (defun gnus-summary-mark-as-read-forward (n)
12384 "Mark N articles as read forwards.
12385 If N is negative, mark backwards instead.
12386 The difference between N and the actual number of articles marked is
12387 returned."
12388 (interactive "p")
12389 (gnus-summary-mark-forward n gnus-del-mark t))
12391 (defun gnus-summary-mark-as-read-backward (n)
12392 "Mark the N articles as read backwards.
12393 The difference between N and the actual number of articles marked is
12394 returned."
12395 (interactive "p")
12396 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12398 (defun gnus-summary-mark-as-read (&optional article mark)
12399 "Mark current article as read.
12400 ARTICLE specifies the article to be marked as read.
12401 MARK specifies a string to be inserted at the beginning of the line."
12402 (gnus-summary-mark-article article mark))
12404 (defun gnus-summary-clear-mark-forward (n)
12405 "Clear marks from N articles forward.
12406 If N is negative, clear backward instead.
12407 The difference between N and the number of marks cleared is returned."
12408 (interactive "p")
12409 (gnus-summary-mark-forward n gnus-unread-mark))
12411 (defun gnus-summary-clear-mark-backward (n)
12412 "Clear marks from N articles backward.
12413 The difference between N and the number of marks cleared is returned."
12414 (interactive "p")
12415 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12417 (defun gnus-summary-mark-unread-as-read ()
12418 "Intended to be used by `gnus-summary-mark-article-hook'."
12419 (when (memq gnus-current-article gnus-newsgroup-unreads)
12420 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12422 (defun gnus-summary-mark-read-and-unread-as-read ()
12423 "Intended to be used by `gnus-summary-mark-article-hook'."
12424 (let ((mark (gnus-summary-article-mark)))
12425 (when (or (gnus-unread-mark-p mark)
12426 (gnus-read-mark-p mark))
12427 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12429 (defun gnus-summary-mark-region-as-read (point mark all)
12430 "Mark all unread articles between point and mark as read.
12431 If given a prefix, mark all articles between point and mark as read,
12432 even ticked and dormant ones."
12433 (interactive "r\nP")
12434 (save-excursion
12435 (let (article)
12436 (goto-char point)
12437 (beginning-of-line)
12438 (while (and
12439 (< (point) mark)
12440 (progn
12441 (when (or all
12442 (memq (setq article (gnus-summary-article-number))
12443 gnus-newsgroup-unreads))
12444 (gnus-summary-mark-article article gnus-del-mark))
12446 (gnus-summary-find-next))))))
12448 (defun gnus-summary-mark-below (score mark)
12449 "Mark articles with score less than SCORE with MARK."
12450 (interactive "P\ncMark: ")
12451 (gnus-set-global-variables)
12452 (setq score (if score
12453 (prefix-numeric-value score)
12454 (or gnus-summary-default-score 0)))
12455 (save-excursion
12456 (set-buffer gnus-summary-buffer)
12457 (goto-char (point-min))
12458 (while
12459 (progn
12460 (and (< (gnus-summary-article-score) score)
12461 (gnus-summary-mark-article nil mark))
12462 (gnus-summary-find-next)))))
12464 (defun gnus-summary-kill-below (&optional score)
12465 "Mark articles with score below SCORE as read."
12466 (interactive "P")
12467 (gnus-set-global-variables)
12468 (gnus-summary-mark-below score gnus-killed-mark))
12470 (defun gnus-summary-clear-above (&optional score)
12471 "Clear all marks from articles with score above SCORE."
12472 (interactive "P")
12473 (gnus-set-global-variables)
12474 (gnus-summary-mark-above score gnus-unread-mark))
12476 (defun gnus-summary-tick-above (&optional score)
12477 "Tick all articles with score above SCORE."
12478 (interactive "P")
12479 (gnus-set-global-variables)
12480 (gnus-summary-mark-above score gnus-ticked-mark))
12482 (defun gnus-summary-mark-above (score mark)
12483 "Mark articles with score over SCORE with MARK."
12484 (interactive "P\ncMark: ")
12485 (gnus-set-global-variables)
12486 (setq score (if score
12487 (prefix-numeric-value score)
12488 (or gnus-summary-default-score 0)))
12489 (save-excursion
12490 (set-buffer gnus-summary-buffer)
12491 (goto-char (point-min))
12492 (while (and (progn
12493 (if (> (gnus-summary-article-score) score)
12494 (gnus-summary-mark-article nil mark))
12496 (gnus-summary-find-next)))))
12498 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12499 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12500 (defun gnus-summary-limit-include-expunged ()
12501 "Display all the hidden articles that were expunged for low scores."
12502 (interactive)
12503 (gnus-set-global-variables)
12504 (let ((buffer-read-only nil))
12505 (let ((scored gnus-newsgroup-scored)
12506 headers h)
12507 (while scored
12508 (or (gnus-summary-goto-subject (caar scored))
12509 (and (setq h (gnus-summary-article-header (caar scored)))
12510 (< (cdar scored) gnus-summary-expunge-below)
12511 (setq headers (cons h headers))))
12512 (setq scored (cdr scored)))
12513 (or headers (error "No expunged articles hidden."))
12514 (goto-char (point-min))
12515 (gnus-summary-prepare-unthreaded (nreverse headers)))
12516 (goto-char (point-min))
12517 (gnus-summary-position-point)))
12519 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12520 "Mark all articles not marked as unread in this newsgroup as read.
12521 If prefix argument ALL is non-nil, all articles are marked as read.
12522 If QUIETLY is non-nil, no questions will be asked.
12523 If TO-HERE is non-nil, it should be a point in the buffer. All
12524 articles before this point will be marked as read.
12525 The number of articles marked as read is returned."
12526 (interactive "P")
12527 (gnus-set-global-variables)
12528 (prog1
12529 (if (or quietly
12530 (not gnus-interactive-catchup) ;Without confirmation?
12531 gnus-expert-user
12532 (gnus-y-or-n-p
12533 (if all
12534 "Mark absolutely all articles as read? "
12535 "Mark all unread articles as read? ")))
12536 (if (and not-mark
12537 (not gnus-newsgroup-adaptive)
12538 (not gnus-newsgroup-auto-expire))
12539 (progn
12540 (when all
12541 (setq gnus-newsgroup-marked nil
12542 gnus-newsgroup-dormant nil))
12543 (setq gnus-newsgroup-unreads nil))
12544 ;; We actually mark all articles as canceled, which we
12545 ;; have to do when using auto-expiry or adaptive scoring.
12546 (gnus-summary-show-all-threads)
12547 (if (gnus-summary-first-subject (not all))
12548 (while (and
12549 (if to-here (< (point) to-here) t)
12550 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12551 (gnus-summary-find-next (not all)))))
12552 (unless to-here
12553 (setq gnus-newsgroup-unreads nil))
12554 (gnus-set-mode-line 'summary)))
12555 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12556 (if (and (not to-here) (eq 'nnvirtual (car method)))
12557 (nnvirtual-catchup-group
12558 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12559 (gnus-summary-position-point)))
12561 (defun gnus-summary-catchup-to-here (&optional all)
12562 "Mark all unticked articles before the current one as read.
12563 If ALL is non-nil, also mark ticked and dormant articles as read."
12564 (interactive "P")
12565 (gnus-set-global-variables)
12566 (save-excursion
12567 (gnus-save-hidden-threads
12568 (let ((beg (point)))
12569 ;; We check that there are unread articles.
12570 (when (or all (gnus-summary-find-prev))
12571 (gnus-summary-catchup all t beg)))))
12572 (gnus-summary-position-point))
12574 (defun gnus-summary-catchup-all (&optional quietly)
12575 "Mark all articles in this newsgroup as read."
12576 (interactive "P")
12577 (gnus-set-global-variables)
12578 (gnus-summary-catchup t quietly))
12580 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12581 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12582 If prefix argument ALL is non-nil, all articles are marked as read."
12583 (interactive "P")
12584 (gnus-set-global-variables)
12585 (gnus-summary-catchup all quietly nil 'fast)
12586 ;; Select next newsgroup or exit.
12587 (if (eq gnus-auto-select-next 'quietly)
12588 (gnus-summary-next-group nil)
12589 (gnus-summary-exit)))
12591 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12592 "Mark all articles in this newsgroup as read, and then exit."
12593 (interactive "P")
12594 (gnus-set-global-variables)
12595 (gnus-summary-catchup-and-exit t quietly))
12597 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12598 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12599 "Mark all articles in this group as read and select the next group.
12600 If given a prefix, mark all articles, unread as well as ticked, as
12601 read."
12602 (interactive "P")
12603 (gnus-set-global-variables)
12604 (save-excursion
12605 (gnus-summary-catchup all))
12606 (gnus-summary-next-article t nil nil t))
12608 ;; Thread-based commands.
12610 (defun gnus-summary-articles-in-thread (&optional article)
12611 "Return a list of all articles in the current thread.
12612 If ARTICLE is non-nil, return all articles in the thread that starts
12613 with that article."
12614 (let* ((article (or article (gnus-summary-article-number)))
12615 (data (gnus-data-find-list article))
12616 (top-level (gnus-data-level (car data)))
12617 (top-subject
12618 (cond ((null gnus-thread-operation-ignore-subject)
12619 (gnus-simplify-subject-re
12620 (mail-header-subject (gnus-data-header (car data)))))
12621 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12622 (gnus-simplify-subject-fuzzy
12623 (mail-header-subject (gnus-data-header (car data)))))
12624 (t nil)))
12625 (end-point (save-excursion
12626 (if (gnus-summary-go-to-next-thread)
12627 (point) (point-max))))
12628 articles)
12629 (while (and data
12630 (< (gnus-data-pos (car data)) end-point))
12631 (when (or (not top-subject)
12632 (string= top-subject
12633 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12634 (gnus-simplify-subject-fuzzy
12635 (mail-header-subject
12636 (gnus-data-header (car data))))
12637 (gnus-simplify-subject-re
12638 (mail-header-subject
12639 (gnus-data-header (car data)))))))
12640 (push (gnus-data-number (car data)) articles))
12641 (unless (and (setq data (cdr data))
12642 (> (gnus-data-level (car data)) top-level))
12643 (setq data nil)))
12644 ;; Return the list of articles.
12645 (nreverse articles)))
12647 (defun gnus-summary-rethread-current ()
12648 "Rethread the thread the current article is part of."
12649 (interactive)
12650 (gnus-set-global-variables)
12651 (let* ((gnus-show-threads t)
12652 (article (gnus-summary-article-number))
12653 (id (mail-header-id (gnus-summary-article-header)))
12654 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12655 (unless id
12656 (error "No article on the current line"))
12657 (gnus-rebuild-thread id)
12658 (gnus-summary-goto-subject article)))
12660 (defun gnus-summary-reparent-thread ()
12661 "Make current article child of the marked (or previous) article.
12663 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12664 is non-nil or the Subject: of both articles are the same."
12665 (interactive)
12666 (or (not (gnus-group-read-only-p))
12667 (error "The current newsgroup does not support article editing."))
12668 (or (<= (length gnus-newsgroup-processable) 1)
12669 (error "No more than one article may be marked."))
12670 (save-window-excursion
12671 (let ((gnus-article-buffer " *reparent*")
12672 (current-article (gnus-summary-article-number))
12673 ; first grab the marked article, otherwise one line up.
12674 (parent-article (if (not (null gnus-newsgroup-processable))
12675 (car gnus-newsgroup-processable)
12676 (save-excursion
12677 (if (eq (forward-line -1) 0)
12678 (gnus-summary-article-number)
12679 (error "Beginning of summary buffer."))))))
12680 (or (not (eq current-article parent-article))
12681 (error "An article may not be self-referential."))
12682 (let ((message-id (mail-header-id
12683 (gnus-summary-article-header parent-article))))
12684 (or (and message-id (not (equal message-id "")))
12685 (error "No message-id in desired parent."))
12686 (gnus-summary-select-article t t nil current-article)
12687 (set-buffer gnus-article-buffer)
12688 (setq buffer-read-only nil)
12689 (let ((buf (format "%s" (buffer-string))))
12690 (erase-buffer)
12691 (insert buf))
12692 (goto-char (point-min))
12693 (if (search-forward-regexp "^References: " nil t)
12694 (insert message-id " " )
12695 (insert "References: " message-id "\n"))
12696 (or (gnus-request-replace-article current-article
12697 (car gnus-article-current)
12698 gnus-article-buffer)
12699 (error "Couldn't replace article."))
12700 (set-buffer gnus-summary-buffer)
12701 (gnus-summary-unmark-all-processable)
12702 (gnus-summary-rethread-current)
12703 (gnus-message 3 "Article %d is now the child of article %d."
12704 current-article parent-article)))))
12706 (defun gnus-summary-toggle-threads (&optional arg)
12707 "Toggle showing conversation threads.
12708 If ARG is positive number, turn showing conversation threads on."
12709 (interactive "P")
12710 (gnus-set-global-variables)
12711 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12712 (setq gnus-show-threads
12713 (if (null arg) (not gnus-show-threads)
12714 (> (prefix-numeric-value arg) 0)))
12715 (gnus-summary-prepare)
12716 (gnus-summary-goto-subject current)
12717 (gnus-summary-position-point)))
12719 (defun gnus-summary-show-all-threads ()
12720 "Show all threads."
12721 (interactive)
12722 (gnus-set-global-variables)
12723 (save-excursion
12724 (let ((buffer-read-only nil))
12725 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12726 (gnus-summary-position-point))
12728 (defun gnus-summary-show-thread ()
12729 "Show thread subtrees.
12730 Returns nil if no thread was there to be shown."
12731 (interactive)
12732 (gnus-set-global-variables)
12733 (let ((buffer-read-only nil)
12734 (orig (point))
12735 ;; first goto end then to beg, to have point at beg after let
12736 (end (progn (end-of-line) (point)))
12737 (beg (progn (beginning-of-line) (point))))
12738 (prog1
12739 ;; Any hidden lines here?
12740 (search-forward "\r" end t)
12741 (subst-char-in-region beg end ?\^M ?\n t)
12742 (goto-char orig)
12743 (gnus-summary-position-point))))
12745 (defun gnus-summary-hide-all-threads ()
12746 "Hide all thread subtrees."
12747 (interactive)
12748 (gnus-set-global-variables)
12749 (save-excursion
12750 (goto-char (point-min))
12751 (gnus-summary-hide-thread)
12752 (while (zerop (gnus-summary-next-thread 1 t))
12753 (gnus-summary-hide-thread)))
12754 (gnus-summary-position-point))
12756 (defun gnus-summary-hide-thread ()
12757 "Hide thread subtrees.
12758 Returns nil if no threads were there to be hidden."
12759 (interactive)
12760 (gnus-set-global-variables)
12761 (let ((buffer-read-only nil)
12762 (start (point))
12763 (article (gnus-summary-article-number)))
12764 (goto-char start)
12765 ;; Go forward until either the buffer ends or the subthread
12766 ;; ends.
12767 (when (and (not (eobp))
12768 (or (zerop (gnus-summary-next-thread 1 t))
12769 (goto-char (point-max))))
12770 (prog1
12771 (if (and (> (point) start)
12772 (search-backward "\n" start t))
12773 (progn
12774 (subst-char-in-region start (point) ?\n ?\^M)
12775 (gnus-summary-goto-subject article))
12776 (goto-char start)
12777 nil)
12778 ;;(gnus-summary-position-point)
12779 ))))
12781 (defun gnus-summary-go-to-next-thread (&optional previous)
12782 "Go to the same level (or less) next thread.
12783 If PREVIOUS is non-nil, go to previous thread instead.
12784 Return the article number moved to, or nil if moving was impossible."
12785 (let ((level (gnus-summary-thread-level))
12786 (way (if previous -1 1))
12787 (beg (point)))
12788 (forward-line way)
12789 (while (and (not (eobp))
12790 (< level (gnus-summary-thread-level)))
12791 (forward-line way))
12792 (if (eobp)
12793 (progn
12794 (goto-char beg)
12795 nil)
12796 (setq beg (point))
12797 (prog1
12798 (gnus-summary-article-number)
12799 (goto-char beg)))))
12801 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12802 "Go to the same level (or less) next thread.
12803 If PREVIOUS is non-nil, go to previous thread instead.
12804 Return the article number moved to, or nil if moving was impossible."
12805 (if (and (eq gnus-summary-make-false-root 'dummy)
12806 (gnus-summary-article-intangible-p))
12807 (let ((beg (point)))
12808 (while (and (zerop (forward-line 1))
12809 (not (gnus-summary-article-intangible-p))
12810 (not (zerop (save-excursion
12811 (gnus-summary-thread-level))))))
12812 (if (eobp)
12813 (progn
12814 (goto-char beg)
12815 nil)
12816 (point)))
12817 (let* ((level (gnus-summary-thread-level))
12818 (article (gnus-summary-article-number))
12819 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12820 oart)
12821 (while data
12822 (if (<= (gnus-data-level (car data)) level)
12823 (setq oart (gnus-data-number (car data))
12824 data nil)
12825 (setq data (cdr data))))
12826 (and oart
12827 (gnus-summary-goto-subject oart)))))
12829 (defun gnus-summary-next-thread (n &optional silent)
12830 "Go to the same level next N'th thread.
12831 If N is negative, search backward instead.
12832 Returns the difference between N and the number of skips actually
12833 done.
12835 If SILENT, don't output messages."
12836 (interactive "p")
12837 (gnus-set-global-variables)
12838 (let ((backward (< n 0))
12839 (n (abs n))
12840 old dum int)
12841 (while (and (> n 0)
12842 (gnus-summary-go-to-next-thread backward))
12843 (decf n))
12844 (unless silent
12845 (gnus-summary-position-point))
12846 (when (and (not silent) (/= 0 n))
12847 (gnus-message 7 "No more threads"))
12850 (defun gnus-summary-prev-thread (n)
12851 "Go to the same level previous N'th thread.
12852 Returns the difference between N and the number of skips actually
12853 done."
12854 (interactive "p")
12855 (gnus-set-global-variables)
12856 (gnus-summary-next-thread (- n)))
12858 (defun gnus-summary-go-down-thread ()
12859 "Go down one level in the current thread."
12860 (let ((children (gnus-summary-article-children)))
12861 (and children
12862 (gnus-summary-goto-subject (car children)))))
12864 (defun gnus-summary-go-up-thread ()
12865 "Go up one level in the current thread."
12866 (let ((parent (gnus-summary-article-parent)))
12867 (and parent
12868 (gnus-summary-goto-subject parent))))
12870 (defun gnus-summary-down-thread (n)
12871 "Go down thread N steps.
12872 If N is negative, go up instead.
12873 Returns the difference between N and how many steps down that were
12874 taken."
12875 (interactive "p")
12876 (gnus-set-global-variables)
12877 (let ((up (< n 0))
12878 (n (abs n)))
12879 (while (and (> n 0)
12880 (if up (gnus-summary-go-up-thread)
12881 (gnus-summary-go-down-thread)))
12882 (setq n (1- n)))
12883 (gnus-summary-position-point)
12884 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12887 (defun gnus-summary-up-thread (n)
12888 "Go up thread N steps.
12889 If N is negative, go up instead.
12890 Returns the difference between N and how many steps down that were
12891 taken."
12892 (interactive "p")
12893 (gnus-set-global-variables)
12894 (gnus-summary-down-thread (- n)))
12896 (defun gnus-summary-top-thread ()
12897 "Go to the top of the thread."
12898 (interactive)
12899 (gnus-set-global-variables)
12900 (while (gnus-summary-go-up-thread))
12901 (gnus-summary-article-number))
12903 (defun gnus-summary-kill-thread (&optional unmark)
12904 "Mark articles under current thread as read.
12905 If the prefix argument is positive, remove any kinds of marks.
12906 If the prefix argument is negative, tick articles instead."
12907 (interactive "P")
12908 (gnus-set-global-variables)
12909 (when unmark
12910 (setq unmark (prefix-numeric-value unmark)))
12911 (let ((articles (gnus-summary-articles-in-thread)))
12912 (save-excursion
12913 ;; Expand the thread.
12914 (gnus-summary-show-thread)
12915 ;; Mark all the articles.
12916 (while articles
12917 (gnus-summary-goto-subject (car articles))
12918 (cond ((null unmark)
12919 (gnus-summary-mark-article-as-read gnus-killed-mark))
12920 ((> unmark 0)
12921 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12923 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12924 (setq articles (cdr articles))))
12925 ;; Hide killed subtrees.
12926 (and (null unmark)
12927 gnus-thread-hide-killed
12928 (gnus-summary-hide-thread))
12929 ;; If marked as read, go to next unread subject.
12930 (if (null unmark)
12931 ;; Go to next unread subject.
12932 (gnus-summary-next-subject 1 t)))
12933 (gnus-set-mode-line 'summary))
12935 ;; Summary sorting commands
12937 (defun gnus-summary-sort-by-number (&optional reverse)
12938 "Sort summary buffer by article number.
12939 Argument REVERSE means reverse order."
12940 (interactive "P")
12941 (gnus-summary-sort 'number reverse))
12943 (defun gnus-summary-sort-by-author (&optional reverse)
12944 "Sort summary buffer by author name alphabetically.
12945 If case-fold-search is non-nil, case of letters is ignored.
12946 Argument REVERSE means reverse order."
12947 (interactive "P")
12948 (gnus-summary-sort 'author reverse))
12950 (defun gnus-summary-sort-by-subject (&optional reverse)
12951 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12952 If case-fold-search is non-nil, case of letters is ignored.
12953 Argument REVERSE means reverse order."
12954 (interactive "P")
12955 (gnus-summary-sort 'subject reverse))
12957 (defun gnus-summary-sort-by-date (&optional reverse)
12958 "Sort summary buffer by date.
12959 Argument REVERSE means reverse order."
12960 (interactive "P")
12961 (gnus-summary-sort 'date reverse))
12963 (defun gnus-summary-sort-by-score (&optional reverse)
12964 "Sort summary buffer by score.
12965 Argument REVERSE means reverse order."
12966 (interactive "P")
12967 (gnus-summary-sort 'score reverse))
12969 (defun gnus-summary-sort (predicate reverse)
12970 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12971 (gnus-set-global-variables)
12972 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12973 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12974 (gnus-thread-sort-functions
12975 (list
12976 (if (not reverse)
12977 thread
12978 `(lambda (t1 t2)
12979 (,thread t2 t1)))))
12980 (gnus-article-sort-functions
12981 (list
12982 (if (not reverse)
12983 article
12984 `(lambda (t1 t2)
12985 (,article t2 t1)))))
12986 (buffer-read-only)
12987 (gnus-summary-prepare-hook nil))
12988 ;; We do the sorting by regenerating the threads.
12989 (gnus-summary-prepare)
12990 ;; Hide subthreads if needed.
12991 (when (and gnus-show-threads gnus-thread-hide-subtree)
12992 (gnus-summary-hide-all-threads)))
12993 ;; If in async mode, we send some info to the backend.
12994 (when gnus-newsgroup-async
12995 (gnus-request-asynchronous
12996 gnus-newsgroup-name gnus-newsgroup-data)))
12998 (defun gnus-sortable-date (date)
12999 "Make sortable string by string-lessp from DATE.
13000 Timezone package is used."
13001 (condition-case ()
13002 (progn
13003 (setq date (inline (timezone-fix-time
13004 date nil
13005 (aref (inline (timezone-parse-date date)) 4))))
13006 (inline
13007 (timezone-make-sortable-date
13008 (aref date 0) (aref date 1) (aref date 2)
13009 (inline
13010 (timezone-make-time-string
13011 (aref date 3) (aref date 4) (aref date 5))))))
13012 (error "")))
13014 ;; Summary saving commands.
13016 (defun gnus-summary-save-article (&optional n not-saved)
13017 "Save the current article using the default saver function.
13018 If N is a positive number, save the N next articles.
13019 If N is a negative number, save the N previous articles.
13020 If N is nil and any articles have been marked with the process mark,
13021 save those articles instead.
13022 The variable `gnus-default-article-saver' specifies the saver function."
13023 (interactive "P")
13024 (gnus-set-global-variables)
13025 (let ((articles (gnus-summary-work-articles n))
13026 (save-buffer (save-excursion
13027 (nnheader-set-temp-buffer " *Gnus Save*")))
13028 file header article)
13029 (while articles
13030 (setq header (gnus-summary-article-header
13031 (setq article (pop articles))))
13032 (if (not (vectorp header))
13033 ;; This is a pseudo-article.
13034 (if (assq 'name header)
13035 (gnus-copy-file (cdr (assq 'name header)))
13036 (gnus-message 1 "Article %d is unsaveable" article))
13037 ;; This is a real article.
13038 (save-window-excursion
13039 (gnus-summary-select-article t nil nil article))
13040 (save-excursion
13041 (set-buffer save-buffer)
13042 (erase-buffer)
13043 (insert-buffer-substring gnus-original-article-buffer))
13044 (unless gnus-save-all-headers
13045 ;; Remove headers accoring to `gnus-saved-headers'.
13046 (let ((gnus-visible-headers
13047 (or gnus-saved-headers gnus-visible-headers))
13048 (gnus-article-buffer save-buffer))
13049 (gnus-article-hide-headers 1 t)))
13050 (save-window-excursion
13051 (if (not gnus-default-article-saver)
13052 (error "No default saver is defined.")
13053 ;; !!! Magic! The saving functions all save
13054 ;; `gnus-original-article-buffer' (or so they think),
13055 ;; but we bind that variable to our save-buffer.
13056 (set-buffer gnus-article-buffer)
13057 (let ((gnus-original-article-buffer save-buffer))
13058 (set-buffer gnus-summary-buffer)
13059 (setq file (funcall
13060 gnus-default-article-saver
13061 (cond
13062 ((not gnus-prompt-before-saving)
13063 'default)
13064 ((eq gnus-prompt-before-saving 'always)
13065 nil)
13066 (t file)))))))
13067 (gnus-summary-remove-process-mark article)
13068 (unless not-saved
13069 (gnus-summary-set-saved-mark article))))
13070 (gnus-kill-buffer save-buffer)
13071 (gnus-summary-position-point)
13074 (defun gnus-summary-pipe-output (&optional arg)
13075 "Pipe the current article to a subprocess.
13076 If N is a positive number, pipe the N next articles.
13077 If N is a negative number, pipe the N previous articles.
13078 If N is nil and any articles have been marked with the process mark,
13079 pipe those articles instead."
13080 (interactive "P")
13081 (gnus-set-global-variables)
13082 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13083 (gnus-summary-save-article arg t))
13084 (gnus-configure-windows 'pipe))
13086 (defun gnus-summary-save-article-mail (&optional arg)
13087 "Append the current article to an mail file.
13088 If N is a positive number, save the N next articles.
13089 If N is a negative number, save the N previous articles.
13090 If N is nil and any articles have been marked with the process mark,
13091 save those articles instead."
13092 (interactive "P")
13093 (gnus-set-global-variables)
13094 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13095 (gnus-summary-save-article arg)))
13097 (defun gnus-summary-save-article-rmail (&optional arg)
13098 "Append the current article to an rmail file.
13099 If N is a positive number, save the N next articles.
13100 If N is a negative number, save the N previous articles.
13101 If N is nil and any articles have been marked with the process mark,
13102 save those articles instead."
13103 (interactive "P")
13104 (gnus-set-global-variables)
13105 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13106 (gnus-summary-save-article arg)))
13108 (defun gnus-summary-save-article-file (&optional arg)
13109 "Append the current article to a file.
13110 If N is a positive number, save the N next articles.
13111 If N is a negative number, save the N previous articles.
13112 If N is nil and any articles have been marked with the process mark,
13113 save those articles instead."
13114 (interactive "P")
13115 (gnus-set-global-variables)
13116 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13117 (gnus-summary-save-article arg)))
13119 (defun gnus-summary-save-article-body-file (&optional arg)
13120 "Append the current article body to a file.
13121 If N is a positive number, save the N next articles.
13122 If N is a negative number, save the N previous articles.
13123 If N is nil and any articles have been marked with the process mark,
13124 save those articles instead."
13125 (interactive "P")
13126 (gnus-set-global-variables)
13127 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13128 (gnus-summary-save-article arg)))
13130 (defun gnus-get-split-value (methods)
13131 "Return a value based on the split METHODS."
13132 (let (split-name method result match)
13133 (when methods
13134 (save-excursion
13135 (set-buffer gnus-original-article-buffer)
13136 (save-restriction
13137 (nnheader-narrow-to-headers)
13138 (while methods
13139 (goto-char (point-min))
13140 (setq method (pop methods))
13141 (setq match (car method))
13142 (when (cond
13143 ((stringp match)
13144 ;; Regular expression.
13145 (condition-case ()
13146 (re-search-forward match nil t)
13147 (error nil)))
13148 ((gnus-functionp match)
13149 ;; Function.
13150 (save-restriction
13151 (widen)
13152 (setq result (funcall match gnus-newsgroup-name))))
13153 ((consp match)
13154 ;; Form.
13155 (save-restriction
13156 (widen)
13157 (setq result (eval match)))))
13158 (setq split-name (append (cdr method) split-name))
13159 (cond ((stringp result)
13160 (push result split-name))
13161 ((consp result)
13162 (setq split-name (append result split-name)))))))))
13163 split-name))
13165 (defun gnus-read-move-group-name (prompt default articles prefix)
13166 "Read a group name."
13167 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13168 (minibuffer-confirm-incomplete nil) ; XEmacs
13169 group-map
13170 (dum (mapatoms
13171 (lambda (g)
13172 (and (boundp g)
13173 (symbol-name g)
13174 (memq 'respool
13175 (assoc (symbol-name
13176 (car (gnus-find-method-for-group
13177 (symbol-name g))))
13178 gnus-valid-select-methods))
13179 (push (list (symbol-name g)) group-map)))
13180 gnus-active-hashtb))
13181 (prom
13182 (format "%s %s to:"
13183 prompt
13184 (if (> (length articles) 1)
13185 (format "these %d articles" (length articles))
13186 "this article")))
13187 (to-newsgroup
13188 (cond
13189 ((null split-name)
13190 (gnus-completing-read default prom
13191 group-map nil nil prefix
13192 'gnus-group-history))
13193 ((= 1 (length split-name))
13194 (gnus-completing-read (car split-name) prom group-map
13195 nil nil nil
13196 'gnus-group-history))
13198 (gnus-completing-read nil prom
13199 (mapcar (lambda (el) (list el))
13200 (nreverse split-name))
13201 nil nil nil
13202 'gnus-group-history)))))
13203 (when to-newsgroup
13204 (if (or (string= to-newsgroup "")
13205 (string= to-newsgroup prefix))
13206 (setq to-newsgroup (or default "")))
13207 (or (gnus-active to-newsgroup)
13208 (gnus-activate-group to-newsgroup)
13209 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13210 to-newsgroup))
13211 (or (and (gnus-request-create-group
13212 to-newsgroup (gnus-group-name-to-method to-newsgroup))
13213 (gnus-activate-group to-newsgroup nil nil
13214 (gnus-group-name-to-method
13215 to-newsgroup)))
13216 (error "Couldn't create group %s" to-newsgroup)))
13217 (error "No such group: %s" to-newsgroup)))
13218 to-newsgroup))
13220 (defun gnus-read-save-file-name (prompt default-name)
13221 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13222 (file
13223 ;; Let the split methods have their say.
13224 (cond
13225 ;; No split name was found.
13226 ((null split-name)
13227 (read-file-name
13228 (concat prompt " (default "
13229 (file-name-nondirectory default-name) ") ")
13230 (file-name-directory default-name)
13231 default-name))
13232 ;; A single split name was found
13233 ((= 1 (length split-name))
13234 (let* ((name (car split-name))
13235 (dir (cond ((file-directory-p name)
13236 (file-name-as-directory name))
13237 ((file-exists-p name) name)
13238 (t gnus-article-save-directory))))
13239 (read-file-name
13240 (concat prompt " (default " name ") ")
13241 dir name)))
13242 ;; A list of splits was found.
13244 (setq split-name (nreverse split-name))
13245 (let (result)
13246 (let ((file-name-history (nconc split-name file-name-history)))
13247 (setq result
13248 (read-file-name
13249 (concat prompt " (`M-p' for defaults) ")
13250 gnus-article-save-directory
13251 (car split-name))))
13252 (car (push result file-name-history)))))))
13253 ;; If we have read a directory, we append the default file name.
13254 (when (file-directory-p file)
13255 (setq file (concat (file-name-as-directory file)
13256 (file-name-nondirectory default-name))))
13257 ;; Possibly translate some charaters.
13258 (nnheader-translate-file-chars file)))
13260 (defun gnus-article-archive-name (group)
13261 "Return the first instance of an \"Archive-name\" in the current buffer."
13262 (let ((case-fold-search t))
13263 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13264 (match-string 1))))
13266 (defun gnus-summary-save-in-rmail (&optional filename)
13267 "Append this article to Rmail file.
13268 Optional argument FILENAME specifies file name.
13269 Directory to save to is default to `gnus-article-save-directory'."
13270 (interactive)
13271 (gnus-set-global-variables)
13272 (let ((default-name
13273 (funcall gnus-rmail-save-name gnus-newsgroup-name
13274 gnus-current-headers gnus-newsgroup-last-rmail)))
13275 (setq filename
13276 (cond ((eq filename 'default)
13277 default-name)
13278 (filename filename)
13279 (t (gnus-read-save-file-name
13280 "Save in rmail file:" default-name))))
13281 (gnus-make-directory (file-name-directory filename))
13282 (gnus-eval-in-buffer-window gnus-original-article-buffer
13283 (save-excursion
13284 (save-restriction
13285 (widen)
13286 (gnus-output-to-rmail filename))))
13287 ;; Remember the directory name to save articles
13288 (setq gnus-newsgroup-last-rmail filename)))
13290 (defun gnus-summary-save-in-mail (&optional filename)
13291 "Append this article to Unix mail file.
13292 Optional argument FILENAME specifies file name.
13293 Directory to save to is default to `gnus-article-save-directory'."
13294 (interactive)
13295 (gnus-set-global-variables)
13296 (let ((default-name
13297 (funcall gnus-mail-save-name gnus-newsgroup-name
13298 gnus-current-headers gnus-newsgroup-last-mail)))
13299 (setq filename
13300 (cond ((eq filename 'default)
13301 default-name)
13302 (filename filename)
13303 (t (gnus-read-save-file-name
13304 "Save in Unix mail file:" default-name))))
13305 (setq filename
13306 (expand-file-name filename
13307 (and default-name
13308 (file-name-directory default-name))))
13309 (gnus-make-directory (file-name-directory filename))
13310 (gnus-eval-in-buffer-window gnus-original-article-buffer
13311 (save-excursion
13312 (save-restriction
13313 (widen)
13314 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13315 (gnus-output-to-rmail filename)
13316 (let ((mail-use-rfc822 t))
13317 (rmail-output filename 1 t t))))))
13318 ;; Remember the directory name to save articles.
13319 (setq gnus-newsgroup-last-mail filename)))
13321 (defun gnus-summary-save-in-file (&optional filename)
13322 "Append this article to file.
13323 Optional argument FILENAME specifies file name.
13324 Directory to save to is default to `gnus-article-save-directory'."
13325 (interactive)
13326 (gnus-set-global-variables)
13327 (let ((default-name
13328 (funcall gnus-file-save-name gnus-newsgroup-name
13329 gnus-current-headers gnus-newsgroup-last-file)))
13330 (setq filename
13331 (cond ((eq filename 'default)
13332 default-name)
13333 (filename filename)
13334 (t (gnus-read-save-file-name
13335 "Save in file:" default-name))))
13336 (gnus-make-directory (file-name-directory filename))
13337 (gnus-eval-in-buffer-window gnus-original-article-buffer
13338 (save-excursion
13339 (save-restriction
13340 (widen)
13341 (gnus-output-to-file filename))))
13342 ;; Remember the directory name to save articles.
13343 (setq gnus-newsgroup-last-file filename)))
13345 (defun gnus-summary-save-body-in-file (&optional filename)
13346 "Append this article body to a file.
13347 Optional argument FILENAME specifies file name.
13348 The directory to save in defaults to `gnus-article-save-directory'."
13349 (interactive)
13350 (gnus-set-global-variables)
13351 (let ((default-name
13352 (funcall gnus-file-save-name gnus-newsgroup-name
13353 gnus-current-headers gnus-newsgroup-last-file)))
13354 (setq filename
13355 (cond ((eq filename 'default)
13356 default-name)
13357 (filename filename)
13358 (t (gnus-read-save-file-name
13359 "Save body in file:" default-name))))
13360 (gnus-make-directory (file-name-directory filename))
13361 (gnus-eval-in-buffer-window gnus-original-article-buffer
13362 (save-excursion
13363 (save-restriction
13364 (widen)
13365 (goto-char (point-min))
13366 (and (search-forward "\n\n" nil t)
13367 (narrow-to-region (point) (point-max)))
13368 (gnus-output-to-file filename))))
13369 ;; Remember the directory name to save articles.
13370 (setq gnus-newsgroup-last-file filename)))
13372 (defun gnus-summary-save-in-pipe (&optional command)
13373 "Pipe this article to subprocess."
13374 (interactive)
13375 (gnus-set-global-variables)
13376 (setq command
13377 (cond ((eq command 'default)
13378 gnus-last-shell-command)
13379 (command command)
13380 (t (read-string "Shell command on article: "
13381 gnus-last-shell-command))))
13382 (if (string-equal command "")
13383 (setq command gnus-last-shell-command))
13384 (gnus-eval-in-buffer-window gnus-article-buffer
13385 (save-restriction
13386 (widen)
13387 (shell-command-on-region (point-min) (point-max) command nil)))
13388 (setq gnus-last-shell-command command))
13390 ;; Summary extract commands
13392 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13393 (let ((buffer-read-only nil)
13394 (article (gnus-summary-article-number))
13395 after-article b e)
13396 (or (gnus-summary-goto-subject article)
13397 (error (format "No such article: %d" article)))
13398 (gnus-summary-position-point)
13399 ;; If all commands are to be bunched up on one line, we collect
13400 ;; them here.
13401 (if gnus-view-pseudos-separately
13403 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13404 files action)
13405 (while ps
13406 (setq action (cdr (assq 'action (car ps))))
13407 (setq files (list (cdr (assq 'name (car ps)))))
13408 (while (and ps (cdr ps)
13409 (string= (or action "1")
13410 (or (cdr (assq 'action (cadr ps))) "2")))
13411 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13412 (setcdr ps (cddr ps)))
13413 (if (not files)
13415 (if (not (string-match "%s" action))
13416 (setq files (cons " " files)))
13417 (setq files (cons " " files))
13418 (and (assq 'execute (car ps))
13419 (setcdr (assq 'execute (car ps))
13420 (funcall (if (string-match "%s" action)
13421 'format 'concat)
13422 action
13423 (mapconcat (lambda (f) f) files " ")))))
13424 (setq ps (cdr ps)))))
13425 (if (and gnus-view-pseudos (not not-view))
13426 (while pslist
13427 (and (assq 'execute (car pslist))
13428 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13429 (eq gnus-view-pseudos 'not-confirm)))
13430 (setq pslist (cdr pslist)))
13431 (save-excursion
13432 (while pslist
13433 (setq after-article (or (cdr (assq 'article (car pslist)))
13434 (gnus-summary-article-number)))
13435 (gnus-summary-goto-subject after-article)
13436 (forward-line 1)
13437 (setq b (point))
13438 (insert " " (file-name-nondirectory
13439 (cdr (assq 'name (car pslist))))
13440 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13441 (setq e (point))
13442 (forward-line -1) ; back to `b'
13443 (gnus-add-text-properties
13444 b (1- e) (list 'gnus-number gnus-reffed-article-number
13445 gnus-mouse-face-prop gnus-mouse-face))
13446 (gnus-data-enter
13447 after-article gnus-reffed-article-number
13448 gnus-unread-mark b (car pslist) 0 (- e b))
13449 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13450 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13451 (setq pslist (cdr pslist)))))))
13453 (defun gnus-pseudos< (p1 p2)
13454 (let ((c1 (cdr (assq 'action p1)))
13455 (c2 (cdr (assq 'action p2))))
13456 (and c1 c2 (string< c1 c2))))
13458 (defun gnus-request-pseudo-article (props)
13459 (cond ((assq 'execute props)
13460 (gnus-execute-command (cdr (assq 'execute props)))))
13461 (let ((gnus-current-article (gnus-summary-article-number)))
13462 (run-hooks 'gnus-mark-article-hook)))
13464 (defun gnus-execute-command (command &optional automatic)
13465 (save-excursion
13466 (gnus-article-setup-buffer)
13467 (set-buffer gnus-article-buffer)
13468 (setq buffer-read-only nil)
13469 (let ((command (if automatic command (read-string "Command: " command)))
13470 ;; Just binding this here doesn't help, because there might
13471 ;; be output from the process after exiting the scope of
13472 ;; this `let'.
13473 ;; (buffer-read-only nil)
13475 (erase-buffer)
13476 (insert "$ " command "\n\n")
13477 (if gnus-view-pseudo-asynchronously
13478 (start-process "gnus-execute" nil shell-file-name
13479 shell-command-switch command)
13480 (call-process shell-file-name nil t nil
13481 shell-command-switch command)))))
13483 (defun gnus-copy-file (file &optional to)
13484 "Copy FILE to TO."
13485 (interactive
13486 (list (read-file-name "Copy file: " default-directory)
13487 (read-file-name "Copy file to: " default-directory)))
13488 (gnus-set-global-variables)
13489 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13490 (and (file-directory-p to)
13491 (setq to (concat (file-name-as-directory to)
13492 (file-name-nondirectory file))))
13493 (copy-file file to))
13495 ;; Summary kill commands.
13497 (defun gnus-summary-edit-global-kill (article)
13498 "Edit the \"global\" kill file."
13499 (interactive (list (gnus-summary-article-number)))
13500 (gnus-set-global-variables)
13501 (gnus-group-edit-global-kill article))
13503 (defun gnus-summary-edit-local-kill ()
13504 "Edit a local kill file applied to the current newsgroup."
13505 (interactive)
13506 (gnus-set-global-variables)
13507 (setq gnus-current-headers (gnus-summary-article-header))
13508 (gnus-set-global-variables)
13509 (gnus-group-edit-local-kill
13510 (gnus-summary-article-number) gnus-newsgroup-name))
13514 ;;; Gnus article mode
13517 (put 'gnus-article-mode 'mode-class 'special)
13519 (if gnus-article-mode-map
13521 (setq gnus-article-mode-map (make-keymap))
13522 (suppress-keymap gnus-article-mode-map)
13524 (gnus-define-keys gnus-article-mode-map
13525 " " gnus-article-goto-next-page
13526 "\177" gnus-article-goto-prev-page
13527 [delete] gnus-article-goto-prev-page
13528 "\C-c^" gnus-article-refer-article
13529 "h" gnus-article-show-summary
13530 "s" gnus-article-show-summary
13531 "\C-c\C-m" gnus-article-mail
13532 "?" gnus-article-describe-briefly
13533 gnus-mouse-2 gnus-article-push-button
13534 "\r" gnus-article-press-button
13535 "\t" gnus-article-next-button
13536 "\M-\t" gnus-article-prev-button
13537 "<" beginning-of-buffer
13538 ">" end-of-buffer
13539 "\C-c\C-i" gnus-info-find-node
13540 "\C-c\C-b" gnus-bug)
13542 (substitute-key-definition
13543 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13545 (defun gnus-article-mode ()
13546 "Major mode for displaying an article.
13548 All normal editing commands are switched off.
13550 The following commands are available:
13552 \\<gnus-article-mode-map>
13553 \\[gnus-article-next-page]\t Scroll the article one page forwards
13554 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13555 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13556 \\[gnus-article-show-summary]\t Display the summary buffer
13557 \\[gnus-article-mail]\t Send a reply to the address near point
13558 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13559 \\[gnus-info-find-node]\t Go to the Gnus info node"
13560 (interactive)
13561 (when (and menu-bar-mode
13562 (gnus-visual-p 'article-menu 'menu))
13563 (gnus-article-make-menu-bar))
13564 (kill-all-local-variables)
13565 (gnus-simplify-mode-line)
13566 (setq mode-name "Article")
13567 (setq major-mode 'gnus-article-mode)
13568 (make-local-variable 'minor-mode-alist)
13569 (or (assq 'gnus-show-mime minor-mode-alist)
13570 (setq minor-mode-alist
13571 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13572 (use-local-map gnus-article-mode-map)
13573 (make-local-variable 'page-delimiter)
13574 (setq page-delimiter gnus-page-delimiter)
13575 (buffer-disable-undo (current-buffer))
13576 (setq buffer-read-only t) ;Disable modification
13577 (run-hooks 'gnus-article-mode-hook))
13579 (defun gnus-article-setup-buffer ()
13580 "Initialize the article buffer."
13581 (let* ((name (if gnus-single-article-buffer "*Article*"
13582 (concat "*Article " gnus-newsgroup-name "*")))
13583 (original
13584 (progn (string-match "\\*Article" name)
13585 (concat " *Original Article"
13586 (substring name (match-end 0))))))
13587 (setq gnus-article-buffer name)
13588 (setq gnus-original-article-buffer original)
13589 ;; This might be a variable local to the summary buffer.
13590 (unless gnus-single-article-buffer
13591 (save-excursion
13592 (set-buffer gnus-summary-buffer)
13593 (setq gnus-article-buffer name)
13594 (setq gnus-original-article-buffer original)
13595 (gnus-set-global-variables))
13596 (make-local-variable 'gnus-summary-buffer))
13597 ;; Init original article buffer.
13598 (save-excursion
13599 (set-buffer (get-buffer-create gnus-original-article-buffer))
13600 (buffer-disable-undo (current-buffer))
13601 (setq major-mode 'gnus-original-article-mode)
13602 (make-local-variable 'gnus-original-article))
13603 (if (get-buffer name)
13604 (save-excursion
13605 (set-buffer name)
13606 (buffer-disable-undo (current-buffer))
13607 (setq buffer-read-only t)
13608 (gnus-add-current-to-buffer-list)
13609 (or (eq major-mode 'gnus-article-mode)
13610 (gnus-article-mode))
13611 (current-buffer))
13612 (save-excursion
13613 (set-buffer (get-buffer-create name))
13614 (gnus-add-current-to-buffer-list)
13615 (gnus-article-mode)
13616 (current-buffer)))))
13618 ;; Set article window start at LINE, where LINE is the number of lines
13619 ;; from the head of the article.
13620 (defun gnus-article-set-window-start (&optional line)
13621 (set-window-start
13622 (get-buffer-window gnus-article-buffer t)
13623 (save-excursion
13624 (set-buffer gnus-article-buffer)
13625 (goto-char (point-min))
13626 (if (not line)
13627 (point-min)
13628 (gnus-message 6 "Moved to bookmark")
13629 (search-forward "\n\n" nil t)
13630 (forward-line line)
13631 (point)))))
13633 (defun gnus-kill-all-overlays ()
13634 "Delete all overlays in the current buffer."
13635 (when (fboundp 'overlay-lists)
13636 (let* ((overlayss (overlay-lists))
13637 (buffer-read-only nil)
13638 (overlays (nconc (car overlayss) (cdr overlayss))))
13639 (while overlays
13640 (delete-overlay (pop overlays))))))
13642 (defun gnus-request-article-this-buffer (article group)
13643 "Get an article and insert it into this buffer."
13644 (let (do-update-line)
13645 (prog1
13646 (save-excursion
13647 (erase-buffer)
13648 (gnus-kill-all-overlays)
13649 (setq group (or group gnus-newsgroup-name))
13651 ;; Open server if it has closed.
13652 (gnus-check-server (gnus-find-method-for-group group))
13654 ;; Using `gnus-request-article' directly will insert the article into
13655 ;; `nntp-server-buffer' - so we'll save some time by not having to
13656 ;; copy it from the server buffer into the article buffer.
13658 ;; We only request an article by message-id when we do not have the
13659 ;; headers for it, so we'll have to get those.
13660 (when (stringp article)
13661 (let ((gnus-override-method gnus-refer-article-method))
13662 (gnus-read-header article)))
13664 ;; If the article number is negative, that means that this article
13665 ;; doesn't belong in this newsgroup (possibly), so we find its
13666 ;; message-id and request it by id instead of number.
13667 (when (and (numberp article)
13668 gnus-summary-buffer
13669 (get-buffer gnus-summary-buffer)
13670 (buffer-name (get-buffer gnus-summary-buffer)))
13671 (save-excursion
13672 (set-buffer gnus-summary-buffer)
13673 (let ((header (gnus-summary-article-header article)))
13674 (if (< article 0)
13675 (cond
13676 ((memq article gnus-newsgroup-sparse)
13677 ;; This is a sparse gap article.
13678 (setq do-update-line article)
13679 (setq article (mail-header-id header))
13680 (let ((gnus-override-method gnus-refer-article-method))
13681 (gnus-read-header article))
13682 (setq gnus-newsgroup-sparse
13683 (delq article gnus-newsgroup-sparse)))
13684 ((vectorp header)
13685 ;; It's a real article.
13686 (setq article (mail-header-id header)))
13688 ;; It is an extracted pseudo-article.
13689 (setq article 'pseudo)
13690 (gnus-request-pseudo-article header))))
13692 (let ((method (gnus-find-method-for-group
13693 gnus-newsgroup-name)))
13694 (if (not (eq (car method) 'nneething))
13696 (let ((dir (concat (file-name-as-directory (nth 1 method))
13697 (mail-header-subject header))))
13698 (if (file-directory-p dir)
13699 (progn
13700 (setq article 'nneething)
13701 (gnus-group-enter-directory dir)))))))))
13703 (cond
13704 ;; Refuse to select canceled articles.
13705 ((and (numberp article)
13706 gnus-summary-buffer
13707 (get-buffer gnus-summary-buffer)
13708 (buffer-name (get-buffer gnus-summary-buffer))
13709 (eq (cdr (save-excursion
13710 (set-buffer gnus-summary-buffer)
13711 (assq article gnus-newsgroup-reads)))
13712 gnus-canceled-mark))
13713 nil)
13714 ;; We first check `gnus-original-article-buffer'.
13715 ((and (get-buffer gnus-original-article-buffer)
13716 (numberp article)
13717 (save-excursion
13718 (set-buffer gnus-original-article-buffer)
13719 (and (equal (car gnus-original-article) group)
13720 (eq (cdr gnus-original-article) article))))
13721 (insert-buffer-substring gnus-original-article-buffer)
13722 'article)
13723 ;; Check the backlog.
13724 ((and gnus-keep-backlog
13725 (gnus-backlog-request-article group article (current-buffer)))
13726 'article)
13727 ;; Check the cache.
13728 ((and gnus-use-cache
13729 (numberp article)
13730 (gnus-cache-request-article article group))
13731 'article)
13732 ;; Get the article and put into the article buffer.
13733 ((or (stringp article) (numberp article))
13734 (let ((gnus-override-method
13735 (and (stringp article) gnus-refer-article-method))
13736 (buffer-read-only nil))
13737 (erase-buffer)
13738 (gnus-kill-all-overlays)
13739 (if (gnus-request-article article group (current-buffer))
13740 (progn
13741 (and gnus-keep-backlog
13742 (numberp article)
13743 (gnus-backlog-enter-article
13744 group article (current-buffer)))
13745 'article))))
13746 ;; It was a pseudo.
13747 (t article)))
13749 ;; Take the article from the original article buffer
13750 ;; and place it in the buffer it's supposed to be in.
13751 (when (and (get-buffer gnus-article-buffer)
13752 ;;(numberp article)
13753 (equal (buffer-name (current-buffer))
13754 (buffer-name (get-buffer gnus-article-buffer))))
13755 (save-excursion
13756 (if (get-buffer gnus-original-article-buffer)
13757 (set-buffer (get-buffer gnus-original-article-buffer))
13758 (set-buffer (get-buffer-create gnus-original-article-buffer))
13759 (buffer-disable-undo (current-buffer))
13760 (setq major-mode 'gnus-original-article-mode)
13761 (setq buffer-read-only t)
13762 (gnus-add-current-to-buffer-list))
13763 (let (buffer-read-only)
13764 (erase-buffer)
13765 (insert-buffer-substring gnus-article-buffer))
13766 (setq gnus-original-article (cons group article))))
13768 ;; Update sparse articles.
13769 (when (and do-update-line
13770 (or (numberp article)
13771 (stringp article)))
13772 (let ((buf (current-buffer)))
13773 (set-buffer gnus-summary-buffer)
13774 (gnus-summary-update-article do-update-line)
13775 (gnus-summary-goto-subject do-update-line nil t)
13776 (set-window-point (get-buffer-window (current-buffer) t)
13777 (point))
13778 (set-buffer buf))))))
13780 (defun gnus-read-header (id &optional header)
13781 "Read the headers of article ID and enter them into the Gnus system."
13782 (let ((group gnus-newsgroup-name)
13783 (gnus-override-method
13784 (and (gnus-news-group-p gnus-newsgroup-name)
13785 gnus-refer-article-method))
13786 where)
13787 ;; First we check to see whether the header in question is already
13788 ;; fetched.
13789 (if (stringp id)
13790 ;; This is a Message-ID.
13791 (setq header (or header (gnus-id-to-header id)))
13792 ;; This is an article number.
13793 (setq header (or header (gnus-summary-article-header id))))
13794 (if (and header
13795 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13796 ;; We have found the header.
13797 header
13798 ;; We have to really fetch the header to this article.
13799 (when (setq where (gnus-request-head id group))
13800 (save-excursion
13801 (set-buffer nntp-server-buffer)
13802 (goto-char (point-max))
13803 (insert ".\n")
13804 (goto-char (point-min))
13805 (insert "211 ")
13806 (princ (cond
13807 ((numberp id) id)
13808 ((cdr where) (cdr where))
13809 (header (mail-header-number header))
13810 (t gnus-reffed-article-number))
13811 (current-buffer))
13812 (insert " Article retrieved.\n"))
13813 ;(when (and header
13814 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13815 ; (setcar (gnus-id-to-thread id) nil))
13816 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13817 () ; Malformed head.
13818 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13819 (if (and (stringp id)
13820 (not (string= (gnus-group-real-name group)
13821 (car where))))
13822 ;; If we fetched by Message-ID and the article came
13823 ;; from a different group, we fudge some bogus article
13824 ;; numbers for this article.
13825 (mail-header-set-number header gnus-reffed-article-number))
13826 (decf gnus-reffed-article-number)
13827 (gnus-remove-header (mail-header-number header))
13828 (push header gnus-newsgroup-headers)
13829 (setq gnus-current-headers header)
13830 (push (mail-header-number header) gnus-newsgroup-limit))
13831 header)))))
13833 (defun gnus-remove-header (number)
13834 "Remove header NUMBER from `gnus-newsgroup-headers'."
13835 (if (and gnus-newsgroup-headers
13836 (= number (mail-header-number (car gnus-newsgroup-headers))))
13837 (pop gnus-newsgroup-headers)
13838 (let ((headers gnus-newsgroup-headers))
13839 (while (and (cdr headers)
13840 (not (= number (mail-header-number (cadr headers)))))
13841 (pop headers))
13842 (when (cdr headers)
13843 (setcdr headers (cddr headers))))))
13845 (defun gnus-article-prepare (article &optional all-headers header)
13846 "Prepare ARTICLE in article mode buffer.
13847 ARTICLE should either be an article number or a Message-ID.
13848 If ARTICLE is an id, HEADER should be the article headers.
13849 If ALL-HEADERS is non-nil, no headers are hidden."
13850 (save-excursion
13851 ;; Make sure we start in a summary buffer.
13852 (unless (eq major-mode 'gnus-summary-mode)
13853 (set-buffer gnus-summary-buffer))
13854 (setq gnus-summary-buffer (current-buffer))
13855 ;; Make sure the connection to the server is alive.
13856 (unless (gnus-server-opened
13857 (gnus-find-method-for-group gnus-newsgroup-name))
13858 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13859 (gnus-request-group gnus-newsgroup-name t))
13860 (let* ((article (if header (mail-header-number header) article))
13861 (summary-buffer (current-buffer))
13862 (internal-hook gnus-article-internal-prepare-hook)
13863 (group gnus-newsgroup-name)
13864 result)
13865 (save-excursion
13866 (gnus-article-setup-buffer)
13867 (set-buffer gnus-article-buffer)
13868 ;; Deactivate active regions.
13869 (when (and (boundp 'transient-mark-mode)
13870 transient-mark-mode)
13871 (setq mark-active nil))
13872 (if (not (setq result (let ((buffer-read-only nil))
13873 (gnus-request-article-this-buffer
13874 article group))))
13875 ;; There is no such article.
13876 (save-excursion
13877 (when (and (numberp article)
13878 (not (memq article gnus-newsgroup-sparse)))
13879 (setq gnus-article-current
13880 (cons gnus-newsgroup-name article))
13881 (set-buffer gnus-summary-buffer)
13882 (setq gnus-current-article article)
13883 (gnus-summary-mark-article article gnus-canceled-mark))
13884 (unless (memq article gnus-newsgroup-sparse)
13885 (gnus-error
13886 1 "No such article (may have expired or been canceled)")))
13887 (if (or (eq result 'pseudo) (eq result 'nneething))
13888 (progn
13889 (save-excursion
13890 (set-buffer summary-buffer)
13891 (setq gnus-last-article gnus-current-article
13892 gnus-newsgroup-history (cons gnus-current-article
13893 gnus-newsgroup-history)
13894 gnus-current-article 0
13895 gnus-current-headers nil
13896 gnus-article-current nil)
13897 (if (eq result 'nneething)
13898 (gnus-configure-windows 'summary)
13899 (gnus-configure-windows 'article))
13900 (gnus-set-global-variables))
13901 (gnus-set-mode-line 'article))
13902 ;; The result from the `request' was an actual article -
13903 ;; or at least some text that is now displayed in the
13904 ;; article buffer.
13905 (if (and (numberp article)
13906 (not (eq article gnus-current-article)))
13907 ;; Seems like a new article has been selected.
13908 ;; `gnus-current-article' must be an article number.
13909 (save-excursion
13910 (set-buffer summary-buffer)
13911 (setq gnus-last-article gnus-current-article
13912 gnus-newsgroup-history (cons gnus-current-article
13913 gnus-newsgroup-history)
13914 gnus-current-article article
13915 gnus-current-headers
13916 (gnus-summary-article-header gnus-current-article)
13917 gnus-article-current
13918 (cons gnus-newsgroup-name gnus-current-article))
13919 (unless (vectorp gnus-current-headers)
13920 (setq gnus-current-headers nil))
13921 (gnus-summary-show-thread)
13922 (run-hooks 'gnus-mark-article-hook)
13923 (gnus-set-mode-line 'summary)
13924 (and (gnus-visual-p 'article-highlight 'highlight)
13925 (run-hooks 'gnus-visual-mark-article-hook))
13926 ;; Set the global newsgroup variables here.
13927 ;; Suggested by Jim Sisolak
13928 ;; <sisolak@trans4.neep.wisc.edu>.
13929 (gnus-set-global-variables)
13930 (setq gnus-have-all-headers
13931 (or all-headers gnus-show-all-headers))
13932 (and gnus-use-cache
13933 (vectorp (gnus-summary-article-header article))
13934 (gnus-cache-possibly-enter-article
13935 group article
13936 (gnus-summary-article-header article)
13937 (memq article gnus-newsgroup-marked)
13938 (memq article gnus-newsgroup-dormant)
13939 (memq article gnus-newsgroup-unreads)))))
13940 (when (or (numberp article)
13941 (stringp article))
13942 ;; Hooks for getting information from the article.
13943 ;; This hook must be called before being narrowed.
13944 (let (buffer-read-only)
13945 (run-hooks 'internal-hook)
13946 (run-hooks 'gnus-article-prepare-hook)
13947 ;; Decode MIME message.
13948 (if gnus-show-mime
13949 (if (or (not gnus-strict-mime)
13950 (gnus-fetch-field "Mime-Version"))
13951 (funcall gnus-show-mime-method)
13952 (funcall gnus-decode-encoded-word-method)))
13953 ;; Perform the article display hooks.
13954 (run-hooks 'gnus-article-display-hook))
13955 ;; Do page break.
13956 (goto-char (point-min))
13957 (and gnus-break-pages (gnus-narrow-to-page)))
13958 (gnus-set-mode-line 'article)
13959 (gnus-configure-windows 'article)
13960 (goto-char (point-min))
13961 t))))))
13963 (defun gnus-article-show-all-headers ()
13964 "Show all article headers in article mode buffer."
13965 (save-excursion
13966 (gnus-article-setup-buffer)
13967 (set-buffer gnus-article-buffer)
13968 (let ((buffer-read-only nil))
13969 (gnus-unhide-text (point-min) (point-max)))))
13971 (defun gnus-article-hide-headers-if-wanted ()
13972 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13973 Provided for backwards compatibility."
13974 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13975 gnus-inhibit-hiding
13976 (gnus-article-hide-headers)))
13978 (defsubst gnus-article-header-rank ()
13979 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13980 (let ((list gnus-sorted-header-list)
13981 (i 0))
13982 (while list
13983 (when (looking-at (car list))
13984 (setq list nil))
13985 (setq list (cdr list))
13986 (incf i))
13989 (defun gnus-article-hide-headers (&optional arg delete)
13990 "Toggle whether to hide unwanted headers and possibly sort them as well.
13991 If given a negative prefix, always show; if given a positive prefix,
13992 always hide."
13993 (interactive (gnus-hidden-arg))
13994 (if (gnus-article-check-hidden-text 'headers arg)
13995 ;; Show boring headers as well.
13996 (gnus-article-show-hidden-text 'boring-headers)
13997 ;; This function might be inhibited.
13998 (unless gnus-inhibit-hiding
13999 (save-excursion
14000 (set-buffer gnus-article-buffer)
14001 (save-restriction
14002 (let ((buffer-read-only nil)
14003 (props (nconc (list 'gnus-type 'headers)
14004 gnus-hidden-properties))
14005 (max (1+ (length gnus-sorted-header-list)))
14006 (ignored (when (not (stringp gnus-visible-headers))
14007 (cond ((stringp gnus-ignored-headers)
14008 gnus-ignored-headers)
14009 ((listp gnus-ignored-headers)
14010 (mapconcat 'identity gnus-ignored-headers
14011 "\\|")))))
14012 (visible
14013 (cond ((stringp gnus-visible-headers)
14014 gnus-visible-headers)
14015 ((and gnus-visible-headers
14016 (listp gnus-visible-headers))
14017 (mapconcat 'identity gnus-visible-headers "\\|"))))
14018 (inhibit-point-motion-hooks t)
14019 want-list beg)
14020 ;; First we narrow to just the headers.
14021 (widen)
14022 (goto-char (point-min))
14023 ;; Hide any "From " lines at the beginning of (mail) articles.
14024 (while (looking-at "From ")
14025 (forward-line 1))
14026 (unless (bobp)
14027 (if delete
14028 (delete-region (point-min) (point))
14029 (gnus-hide-text (point-min) (point) props)))
14030 ;; Then treat the rest of the header lines.
14031 (narrow-to-region
14032 (point)
14033 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
14034 ;; Then we use the two regular expressions
14035 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
14036 ;; select which header lines is to remain visible in the
14037 ;; article buffer.
14038 (goto-char (point-min))
14039 (while (re-search-forward "^[^ \t]*:" nil t)
14040 (beginning-of-line)
14041 ;; We add the headers we want to keep to a list and delete
14042 ;; them from the buffer.
14043 (gnus-put-text-property
14044 (point) (1+ (point)) 'message-rank
14045 (if (or (and visible (looking-at visible))
14046 (and ignored
14047 (not (looking-at ignored))))
14048 (gnus-article-header-rank)
14049 (+ 2 max)))
14050 (forward-line 1))
14051 (message-sort-headers-1)
14052 (when (setq beg (text-property-any
14053 (point-min) (point-max) 'message-rank (+ 2 max)))
14054 ;; We make the unwanted headers invisible.
14055 (if delete
14056 (delete-region beg (point-max))
14057 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
14058 (gnus-hide-text-type beg (point-max) 'headers))
14059 ;; Work around XEmacs lossage.
14060 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
14062 (defun gnus-article-hide-boring-headers (&optional arg)
14063 "Toggle hiding of headers that aren't very interesting.
14064 If given a negative prefix, always show; if given a positive prefix,
14065 always hide."
14066 (interactive (gnus-hidden-arg))
14067 (unless (gnus-article-check-hidden-text 'boring-headers arg)
14068 (save-excursion
14069 (set-buffer gnus-article-buffer)
14070 (save-restriction
14071 (let ((buffer-read-only nil)
14072 (list gnus-boring-article-headers)
14073 (inhibit-point-motion-hooks t)
14074 elem)
14075 (nnheader-narrow-to-headers)
14076 (while list
14077 (setq elem (pop list))
14078 (goto-char (point-min))
14079 (cond
14080 ;; Hide empty headers.
14081 ((eq elem 'empty)
14082 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
14083 (forward-line -1)
14084 (gnus-hide-text-type
14085 (progn (beginning-of-line) (point))
14086 (progn
14087 (end-of-line)
14088 (if (re-search-forward "^[^ \t]" nil t)
14089 (match-beginning 0)
14090 (point-max)))
14091 'boring-headers)))
14092 ;; Hide boring Newsgroups header.
14093 ((eq elem 'newsgroups)
14094 (when (equal (message-fetch-field "newsgroups")
14095 (gnus-group-real-name gnus-newsgroup-name))
14096 (gnus-article-hide-header "newsgroups")))
14097 ((eq elem 'followup-to)
14098 (when (equal (message-fetch-field "followup-to")
14099 (message-fetch-field "newsgroups"))
14100 (gnus-article-hide-header "followup-to")))
14101 ((eq elem 'reply-to)
14102 (let ((from (message-fetch-field "from"))
14103 (reply-to (message-fetch-field "reply-to")))
14104 (when (and
14105 from reply-to
14106 (equal
14107 (nth 1 (funcall gnus-extract-address-components from))
14108 (nth 1 (funcall gnus-extract-address-components
14109 reply-to))))
14110 (gnus-article-hide-header "reply-to"))))
14111 ((eq elem 'date)
14112 (let ((date (message-fetch-field "date")))
14113 (when (and date
14114 (< (gnus-days-between date (current-time-string))
14116 (gnus-article-hide-header "date")))))))))))
14118 (defun gnus-article-hide-header (header)
14119 (save-excursion
14120 (goto-char (point-min))
14121 (when (re-search-forward (concat "^" header ":") nil t)
14122 (gnus-hide-text-type
14123 (progn (beginning-of-line) (point))
14124 (progn
14125 (end-of-line)
14126 (if (re-search-forward "^[^ \t]" nil t)
14127 (match-beginning 0)
14128 (point-max)))
14129 'boring-headers))))
14131 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14132 (defun gnus-article-treat-overstrike ()
14133 "Translate overstrikes into bold text."
14134 (interactive)
14135 (save-excursion
14136 (set-buffer gnus-article-buffer)
14137 (let ((buffer-read-only nil))
14138 (while (search-forward "\b" nil t)
14139 (let ((next (following-char))
14140 (previous (char-after (- (point) 2))))
14141 (cond
14142 ((eq next previous)
14143 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14144 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14145 ((eq next ?_)
14146 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14147 (gnus-put-text-property
14148 (- (point) 2) (1- (point)) 'face 'underline))
14149 ((eq previous ?_)
14150 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14151 (gnus-put-text-property
14152 (point) (1+ (point)) 'face 'underline))))))))
14154 (defun gnus-article-word-wrap ()
14155 "Format too long lines."
14156 (interactive)
14157 (save-excursion
14158 (set-buffer gnus-article-buffer)
14159 (let ((buffer-read-only nil))
14160 (widen)
14161 (goto-char (point-min))
14162 (search-forward "\n\n" nil t)
14163 (end-of-line 1)
14164 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14165 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14166 (adaptive-fill-mode t))
14167 (while (not (eobp))
14168 (and (>= (current-column) (min fill-column (window-width)))
14169 (/= (preceding-char) ?:)
14170 (fill-paragraph nil))
14171 (end-of-line 2))))))
14173 (defun gnus-article-remove-cr ()
14174 "Remove carriage returns from an article."
14175 (interactive)
14176 (save-excursion
14177 (set-buffer gnus-article-buffer)
14178 (let ((buffer-read-only nil))
14179 (goto-char (point-min))
14180 (while (search-forward "\r" nil t)
14181 (replace-match "" t t)))))
14183 (defun gnus-article-remove-trailing-blank-lines ()
14184 "Remove all trailing blank lines from the article."
14185 (interactive)
14186 (save-excursion
14187 (set-buffer gnus-article-buffer)
14188 (let ((buffer-read-only nil))
14189 (goto-char (point-max))
14190 (delete-region
14191 (point)
14192 (progn
14193 (while (looking-at "^[ \t]*$")
14194 (forward-line -1))
14195 (forward-line 1)
14196 (point))))))
14198 (defun gnus-article-display-x-face (&optional force)
14199 "Look for an X-Face header and display it if present."
14200 (interactive (list 'force))
14201 (save-excursion
14202 (set-buffer gnus-article-buffer)
14203 ;; Delete the old process, if any.
14204 (when (process-status "gnus-x-face")
14205 (delete-process "gnus-x-face"))
14206 (let ((inhibit-point-motion-hooks t)
14207 (case-fold-search nil)
14208 from)
14209 (save-restriction
14210 (nnheader-narrow-to-headers)
14211 (setq from (message-fetch-field "from"))
14212 (goto-char (point-min))
14213 (when (and gnus-article-x-face-command
14214 (or force
14215 ;; Check whether this face is censored.
14216 (not gnus-article-x-face-too-ugly)
14217 (and gnus-article-x-face-too-ugly from
14218 (not (string-match gnus-article-x-face-too-ugly
14219 from))))
14220 ;; Has to be present.
14221 (re-search-forward "^X-Face: " nil t))
14222 ;; We now have the area of the buffer where the X-Face is stored.
14223 (let ((beg (point))
14224 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14225 ;; We display the face.
14226 (if (symbolp gnus-article-x-face-command)
14227 ;; The command is a lisp function, so we call it.
14228 (if (gnus-functionp gnus-article-x-face-command)
14229 (funcall gnus-article-x-face-command beg end)
14230 (error "%s is not a function" gnus-article-x-face-command))
14231 ;; The command is a string, so we interpret the command
14232 ;; as a, well, command, and fork it off.
14233 (let ((process-connection-type nil))
14234 (process-kill-without-query
14235 (start-process
14236 "gnus-x-face" nil shell-file-name shell-command-switch
14237 gnus-article-x-face-command))
14238 (process-send-region "gnus-x-face" beg end)
14239 (process-send-eof "gnus-x-face")))))))))
14241 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14242 (defun gnus-decode-rfc1522 ()
14243 "Hack to remove QP encoding from headers."
14244 (let ((case-fold-search t)
14245 (inhibit-point-motion-hooks t)
14246 (buffer-read-only nil)
14247 string)
14248 (save-restriction
14249 (narrow-to-region
14250 (goto-char (point-min))
14251 (or (search-forward "\n\n" nil t) (point-max)))
14253 (goto-char (point-min))
14254 (while (re-search-forward
14255 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14256 (setq string (match-string 1))
14257 (narrow-to-region (match-beginning 0) (match-end 0))
14258 (delete-region (point-min) (point-max))
14259 (insert string)
14260 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14261 (subst-char-in-region (point-min) (point-max) ?_ ? )
14262 (widen)
14263 (goto-char (point-min))))))
14265 (defun gnus-article-de-quoted-unreadable (&optional force)
14266 "Do a naive translation of a quoted-printable-encoded article.
14267 This is in no way, shape or form meant as a replacement for real MIME
14268 processing, but is simply a stop-gap measure until MIME support is
14269 written.
14270 If FORCE, decode the article whether it is marked as quoted-printable
14271 or not."
14272 (interactive (list 'force))
14273 (save-excursion
14274 (set-buffer gnus-article-buffer)
14275 (let ((case-fold-search t)
14276 (buffer-read-only nil)
14277 (type (gnus-fetch-field "content-transfer-encoding")))
14278 (gnus-decode-rfc1522)
14279 (when (or force
14280 (and type (string-match "quoted-printable" (downcase type))))
14281 (goto-char (point-min))
14282 (search-forward "\n\n" nil 'move)
14283 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14285 (defun gnus-mime-decode-quoted-printable (from to)
14286 "Decode Quoted-Printable in the region between FROM and TO."
14287 (interactive "r")
14288 (goto-char from)
14289 (while (search-forward "=" to t)
14290 (cond ((eq (following-char) ?\n)
14291 (delete-char -1)
14292 (delete-char 1))
14293 ((looking-at "[0-9A-F][0-9A-F]")
14294 (subst-char-in-region
14295 (1- (point)) (point) ?=
14296 (hexl-hex-string-to-integer
14297 (buffer-substring (point) (+ 2 (point)))))
14298 (delete-char 2))
14299 ((looking-at "=")
14300 (delete-char 1))
14301 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14303 (defun gnus-article-hide-pgp (&optional arg)
14304 "Toggle hiding of any PGP headers and signatures in the current article.
14305 If given a negative prefix, always show; if given a positive prefix,
14306 always hide."
14307 (interactive (gnus-hidden-arg))
14308 (unless (gnus-article-check-hidden-text 'pgp arg)
14309 (save-excursion
14310 (set-buffer gnus-article-buffer)
14311 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14312 buffer-read-only beg end)
14313 (widen)
14314 (goto-char (point-min))
14315 ;; Hide the "header".
14316 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14317 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14318 (setq beg (point))
14319 ;; Hide the actual signature.
14320 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14321 (setq end (1+ (match-beginning 0)))
14322 (gnus-hide-text
14324 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14325 (match-end 0)
14326 ;; Perhaps we shouldn't hide to the end of the buffer
14327 ;; if there is no end to the signature?
14328 (point-max))
14329 props))
14330 ;; Hide "- " PGP quotation markers.
14331 (when (and beg end)
14332 (narrow-to-region beg end)
14333 (goto-char (point-min))
14334 (while (re-search-forward "^- " nil t)
14335 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14336 (widen))))))
14338 (defun gnus-article-hide-signature (&optional arg)
14339 "Hide the signature in the current article.
14340 If given a negative prefix, always show; if given a positive prefix,
14341 always hide."
14342 (interactive (gnus-hidden-arg))
14343 (unless (gnus-article-check-hidden-text 'signature arg)
14344 (save-excursion
14345 (set-buffer gnus-article-buffer)
14346 (save-restriction
14347 (let ((buffer-read-only nil))
14348 (when (gnus-narrow-to-signature)
14349 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14351 (defun gnus-article-strip-leading-blank-lines ()
14352 "Remove all blank lines from the beginning of the article."
14353 (interactive)
14354 (save-excursion
14355 (set-buffer gnus-article-buffer)
14356 (let (buffer-read-only)
14357 (goto-char (point-min))
14358 (when (search-forward "\n\n" nil t)
14359 (while (looking-at "[ \t]$")
14360 (gnus-delete-line))))))
14362 (defvar mime::preview/content-list)
14363 (defvar mime::preview-content-info/point-min)
14364 (defun gnus-narrow-to-signature ()
14365 "Narrow to the signature."
14366 (widen)
14367 (if (and (boundp 'mime::preview/content-list)
14368 mime::preview/content-list)
14369 (let ((pcinfo (car (last mime::preview/content-list))))
14370 (condition-case ()
14371 (narrow-to-region
14372 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14373 (point-max))
14374 (error nil))))
14375 (goto-char (point-max))
14376 (when (re-search-backward gnus-signature-separator nil t)
14377 (forward-line 1)
14378 (when (or (null gnus-signature-limit)
14379 (and (numberp gnus-signature-limit)
14380 (< (- (point-max) (point)) gnus-signature-limit))
14381 (and (gnus-functionp gnus-signature-limit)
14382 (funcall gnus-signature-limit))
14383 (and (stringp gnus-signature-limit)
14384 (not (re-search-forward gnus-signature-limit nil t))))
14385 (narrow-to-region (point) (point-max))
14386 t)))
14388 (defun gnus-hidden-arg ()
14389 "Return the current prefix arg as a number, or 0 if no prefix."
14390 (list (if current-prefix-arg
14391 (prefix-numeric-value current-prefix-arg)
14392 0)))
14394 (defun gnus-article-check-hidden-text (type arg)
14395 "Return nil if hiding is necessary.
14396 Arg can be nil or a number. Nil and positive means hide, negative
14397 means show, 0 means toggle."
14398 (save-excursion
14399 (set-buffer gnus-article-buffer)
14400 (let ((hide (gnus-article-hidden-text-p type)))
14401 (cond
14402 ((or (null arg)
14403 (> arg 0))
14404 nil)
14405 ((< arg 0)
14406 (gnus-article-show-hidden-text type))
14408 (if (eq hide 'hidden)
14409 (gnus-article-show-hidden-text type)
14410 nil))))))
14412 (defun gnus-article-hidden-text-p (type)
14413 "Say whether the current buffer contains hidden text of type TYPE."
14414 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14415 (when pos
14416 (if (get-text-property pos 'invisible)
14417 'hidden
14418 'shown))))
14420 (defun gnus-article-hide (&optional arg force)
14421 "Hide all the gruft in the current article.
14422 This means that PGP stuff, signatures, cited text and (some)
14423 headers will be hidden.
14424 If given a prefix, show the hidden text instead."
14425 (interactive (list current-prefix-arg 'force))
14426 (gnus-article-hide-headers arg)
14427 (gnus-article-hide-pgp arg)
14428 (gnus-article-hide-citation-maybe arg force)
14429 (gnus-article-hide-signature arg))
14431 (defun gnus-article-show-hidden-text (type &optional hide)
14432 "Show all hidden text of type TYPE.
14433 If HIDE, hide the text instead."
14434 (save-excursion
14435 (set-buffer gnus-article-buffer)
14436 (let ((buffer-read-only nil)
14437 (inhibit-point-motion-hooks t)
14438 (beg (point-min)))
14439 (while (gnus-goto-char (text-property-any
14440 beg (point-max) 'gnus-type type))
14441 (setq beg (point))
14442 (forward-char)
14443 (if hide
14444 (gnus-hide-text beg (point) gnus-hidden-properties)
14445 (gnus-unhide-text beg (point)))
14446 (setq beg (point)))
14447 t)))
14449 (defvar gnus-article-time-units
14450 `((year . ,(* 365.25 24 60 60))
14451 (week . ,(* 7 24 60 60))
14452 (day . ,(* 24 60 60))
14453 (hour . ,(* 60 60))
14454 (minute . 60)
14455 (second . 1))
14456 "Mapping from time units to seconds.")
14458 (defun gnus-article-date-ut (&optional type highlight)
14459 "Convert DATE date to universal time in the current article.
14460 If TYPE is `local', convert to local time; if it is `lapsed', output
14461 how much time has lapsed since DATE."
14462 (interactive (list 'ut t))
14463 (let* ((header (or gnus-current-headers
14464 (gnus-summary-article-header) ""))
14465 (date (and (vectorp header) (mail-header-date header)))
14466 (date-regexp "^Date: \\|^X-Sent: ")
14467 (now (current-time))
14468 (inhibit-point-motion-hooks t)
14469 bface eface)
14470 (when (and date (not (string= date "")))
14471 (save-excursion
14472 (set-buffer gnus-article-buffer)
14473 (save-restriction
14474 (nnheader-narrow-to-headers)
14475 (let ((buffer-read-only nil))
14476 ;; Delete any old Date headers.
14477 (if (re-search-forward date-regexp nil t)
14478 (progn
14479 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14480 eface (get-text-property (1- (gnus-point-at-eol))
14481 'face))
14482 (message-remove-header date-regexp t)
14483 (beginning-of-line))
14484 (goto-char (point-max)))
14485 (insert (gnus-make-date-line date type))
14486 ;; Do highlighting.
14487 (forward-line -1)
14488 (when (and (gnus-visual-p 'article-highlight 'highlight)
14489 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14490 (gnus-put-text-property (match-beginning 1) (match-end 1)
14491 'face bface)
14492 (gnus-put-text-property (match-beginning 2) (match-end 2)
14493 'face eface))))))))
14495 (defun gnus-make-date-line (date type)
14496 "Return a DATE line of TYPE."
14497 (cond
14498 ;; Convert to the local timezone. We have to slap a
14499 ;; `condition-case' round the calls to the timezone
14500 ;; functions since they aren't particularly resistant to
14501 ;; buggy dates.
14502 ((eq type 'local)
14503 (concat "Date: " (condition-case ()
14504 (timezone-make-date-arpa-standard date)
14505 (error date))
14506 "\n"))
14507 ;; Convert to Universal Time.
14508 ((eq type 'ut)
14509 (concat "Date: "
14510 (condition-case ()
14511 (timezone-make-date-arpa-standard date nil "UT")
14512 (error date))
14513 "\n"))
14514 ;; Get the original date from the article.
14515 ((eq type 'original)
14516 (concat "Date: " date "\n"))
14517 ;; Do an X-Sent lapsed format.
14518 ((eq type 'lapsed)
14519 ;; If the date is seriously mangled, the timezone
14520 ;; functions are liable to bug out, so we condition-case
14521 ;; the entire thing.
14522 (let* ((now (current-time))
14523 (real-time
14524 (condition-case ()
14525 (gnus-time-minus
14526 (gnus-encode-date
14527 (timezone-make-date-arpa-standard
14528 (current-time-string now)
14529 (current-time-zone now) "UT"))
14530 (gnus-encode-date
14531 (timezone-make-date-arpa-standard
14532 date nil "UT")))
14533 (error '(0 0))))
14534 (real-sec (+ (* (float (car real-time)) 65536)
14535 (cadr real-time)))
14536 (sec (abs real-sec))
14537 num prev)
14538 (cond
14539 ((equal real-time '(0 0))
14540 "X-Sent: Unknown\n")
14541 ((zerop sec)
14542 "X-Sent: Now\n")
14544 (concat
14545 "X-Sent: "
14546 ;; This is a bit convoluted, but basically we go
14547 ;; through the time units for years, weeks, etc,
14548 ;; and divide things to see whether that results
14549 ;; in positive answers.
14550 (mapconcat
14551 (lambda (unit)
14552 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14553 ;; The (remaining) seconds are too few to
14554 ;; be divided into this time unit.
14556 ;; It's big enough, so we output it.
14557 (setq sec (- sec (* num (cdr unit))))
14558 (prog1
14559 (concat (if prev ", " "") (int-to-string
14560 (floor num))
14561 " " (symbol-name (car unit))
14562 (if (> num 1) "s" ""))
14563 (setq prev t))))
14564 gnus-article-time-units "")
14565 ;; If dates are odd, then it might appear like the
14566 ;; article was sent in the future.
14567 (if (> real-sec 0)
14568 " ago\n"
14569 " in the future\n"))))))
14571 (error "Unknown conversion type: %s" type))))
14573 (defun gnus-article-date-local (&optional highlight)
14574 "Convert the current article date to the local timezone."
14575 (interactive (list t))
14576 (gnus-article-date-ut 'local highlight))
14578 (defun gnus-article-date-original (&optional highlight)
14579 "Convert the current article date to what it was originally.
14580 This is only useful if you have used some other date conversion
14581 function and want to see what the date was before converting."
14582 (interactive (list t))
14583 (gnus-article-date-ut 'original highlight))
14585 (defun gnus-article-date-lapsed (&optional highlight)
14586 "Convert the current article date to time lapsed since it was sent."
14587 (interactive (list t))
14588 (gnus-article-date-ut 'lapsed highlight))
14590 (defun gnus-article-maybe-highlight ()
14591 "Do some article highlighting if `gnus-visual' is non-nil."
14592 (if (gnus-visual-p 'article-highlight 'highlight)
14593 (gnus-article-highlight-some)))
14595 ;;; Article savers.
14597 (defun gnus-output-to-rmail (file-name)
14598 "Append the current article to an Rmail file named FILE-NAME."
14599 (require 'rmail)
14600 ;; Most of these codes are borrowed from rmailout.el.
14601 (setq file-name (expand-file-name file-name))
14602 (setq rmail-default-rmail-file file-name)
14603 (let ((artbuf (current-buffer))
14604 (tmpbuf (get-buffer-create " *Gnus-output*")))
14605 (save-excursion
14606 (or (get-file-buffer file-name)
14607 (file-exists-p file-name)
14608 (if (gnus-yes-or-no-p
14609 (concat "\"" file-name "\" does not exist, create it? "))
14610 (let ((file-buffer (create-file-buffer file-name)))
14611 (save-excursion
14612 (set-buffer file-buffer)
14613 (rmail-insert-rmail-file-header)
14614 (let ((require-final-newline nil))
14615 (write-region (point-min) (point-max) file-name t 1)))
14616 (kill-buffer file-buffer))
14617 (error "Output file does not exist")))
14618 (set-buffer tmpbuf)
14619 (buffer-disable-undo (current-buffer))
14620 (erase-buffer)
14621 (insert-buffer-substring artbuf)
14622 (gnus-convert-article-to-rmail)
14623 ;; Decide whether to append to a file or to an Emacs buffer.
14624 (let ((outbuf (get-file-buffer file-name)))
14625 (if (not outbuf)
14626 (append-to-file (point-min) (point-max) file-name)
14627 ;; File has been visited, in buffer OUTBUF.
14628 (set-buffer outbuf)
14629 (let ((buffer-read-only nil)
14630 (msg (and (boundp 'rmail-current-message)
14631 (symbol-value 'rmail-current-message))))
14632 ;; If MSG is non-nil, buffer is in RMAIL mode.
14633 (if msg
14634 (progn (widen)
14635 (narrow-to-region (point-max) (point-max))))
14636 (insert-buffer-substring tmpbuf)
14637 (if msg
14638 (progn
14639 (goto-char (point-min))
14640 (widen)
14641 (search-backward "\^_")
14642 (narrow-to-region (point) (point-max))
14643 (goto-char (1+ (point-min)))
14644 (rmail-count-new-messages t)
14645 (rmail-show-message msg)))))))
14646 (kill-buffer tmpbuf)))
14648 (defun gnus-output-to-file (file-name)
14649 "Append the current article to a file named FILE-NAME."
14650 (let ((artbuf (current-buffer)))
14651 (nnheader-temp-write nil
14652 (insert-buffer-substring artbuf)
14653 ;; Append newline at end of the buffer as separator, and then
14654 ;; save it to file.
14655 (goto-char (point-max))
14656 (insert "\n")
14657 (append-to-file (point-min) (point-max) file-name))))
14659 (defun gnus-convert-article-to-rmail ()
14660 "Convert article in current buffer to Rmail message format."
14661 (let ((buffer-read-only nil))
14662 ;; Convert article directly into Babyl format.
14663 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14664 (goto-char (point-min))
14665 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14666 (while (search-forward "\n\^_" nil t) ;single char
14667 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14668 (goto-char (point-max))
14669 (insert "\^_")))
14671 (defun gnus-narrow-to-page (&optional arg)
14672 "Narrow the article buffer to a page.
14673 If given a numerical ARG, move forward ARG pages."
14674 (interactive "P")
14675 (setq arg (if arg (prefix-numeric-value arg) 0))
14676 (save-excursion
14677 (set-buffer gnus-article-buffer)
14678 (goto-char (point-min))
14679 (widen)
14680 (when (gnus-visual-p 'page-marker)
14681 (let ((buffer-read-only nil))
14682 (gnus-remove-text-with-property 'gnus-prev)
14683 (gnus-remove-text-with-property 'gnus-next)))
14684 (when
14685 (cond ((< arg 0)
14686 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14687 ((> arg 0)
14688 (re-search-forward page-delimiter nil 'move arg)))
14689 (goto-char (match-end 0)))
14690 (narrow-to-region
14691 (point)
14692 (if (re-search-forward page-delimiter nil 'move)
14693 (match-beginning 0)
14694 (point)))
14695 (when (and (gnus-visual-p 'page-marker)
14696 (not (= (point-min) 1)))
14697 (save-excursion
14698 (goto-char (point-min))
14699 (gnus-insert-prev-page-button)))
14700 (when (and (gnus-visual-p 'page-marker)
14701 (not (= (1- (point-max)) (buffer-size))))
14702 (save-excursion
14703 (goto-char (point-max))
14704 (gnus-insert-next-page-button)))))
14706 ;; Article mode commands
14708 (defun gnus-article-goto-next-page ()
14709 "Show the next page of the article."
14710 (interactive)
14711 (when (gnus-article-next-page)
14712 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14714 (defun gnus-article-goto-prev-page ()
14715 "Show the next page of the article."
14716 (interactive)
14717 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14718 (gnus-article-prev-page nil)))
14720 (defun gnus-article-next-page (&optional lines)
14721 "Show the next page of the current article.
14722 If end of article, return non-nil. Otherwise return nil.
14723 Argument LINES specifies lines to be scrolled up."
14724 (interactive "p")
14725 (move-to-window-line -1)
14726 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14727 (if (save-excursion
14728 (end-of-line)
14729 (and (pos-visible-in-window-p) ;Not continuation line.
14730 (eobp)))
14731 ;; Nothing in this page.
14732 (if (or (not gnus-break-pages)
14733 (save-excursion
14734 (save-restriction
14735 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14736 t ;Nothing more.
14737 (gnus-narrow-to-page 1) ;Go to next page.
14738 nil)
14739 ;; More in this page.
14740 (condition-case ()
14741 (scroll-up lines)
14742 (end-of-buffer
14743 ;; Long lines may cause an end-of-buffer error.
14744 (goto-char (point-max))))
14745 (move-to-window-line 0)
14746 nil))
14748 (defun gnus-article-prev-page (&optional lines)
14749 "Show previous page of current article.
14750 Argument LINES specifies lines to be scrolled down."
14751 (interactive "p")
14752 (move-to-window-line 0)
14753 (if (and gnus-break-pages
14754 (bobp)
14755 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14756 (progn
14757 (gnus-narrow-to-page -1) ;Go to previous page.
14758 (goto-char (point-max))
14759 (recenter -1))
14760 (prog1
14761 (condition-case ()
14762 (scroll-down lines)
14763 (error nil))
14764 (move-to-window-line 0))))
14766 (defun gnus-article-refer-article ()
14767 "Read article specified by message-id around point."
14768 (interactive)
14769 (let ((point (point)))
14770 (search-forward ">" nil t) ;Move point to end of "<....>".
14771 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14772 (let ((message-id (match-string 1)))
14773 (goto-char point)
14774 (set-buffer gnus-summary-buffer)
14775 (gnus-summary-refer-article message-id))
14776 (goto-char (point))
14777 (error "No references around point"))))
14779 (defun gnus-article-show-summary ()
14780 "Reconfigure windows to show summary buffer."
14781 (interactive)
14782 (gnus-configure-windows 'article)
14783 (gnus-summary-goto-subject gnus-current-article))
14785 (defun gnus-article-describe-briefly ()
14786 "Describe article mode commands briefly."
14787 (interactive)
14788 (gnus-message 6
14789 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
14791 (defun gnus-article-summary-command ()
14792 "Execute the last keystroke in the summary buffer."
14793 (interactive)
14794 (let ((obuf (current-buffer))
14795 (owin (current-window-configuration))
14796 func)
14797 (switch-to-buffer gnus-summary-buffer 'norecord)
14798 (setq func (lookup-key (current-local-map) (this-command-keys)))
14799 (call-interactively func)
14800 (set-buffer obuf)
14801 (set-window-configuration owin)
14802 (set-window-point (get-buffer-window (current-buffer)) (point))))
14804 (defun gnus-article-summary-command-nosave ()
14805 "Execute the last keystroke in the summary buffer."
14806 (interactive)
14807 (let (func)
14808 (pop-to-buffer gnus-summary-buffer 'norecord)
14809 (setq func (lookup-key (current-local-map) (this-command-keys)))
14810 (call-interactively func)))
14812 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14813 "Read a summary buffer key sequence and execute it from the article buffer."
14814 (interactive "P")
14815 (let ((nosaves
14816 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14817 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14818 "=" "^" "\M-^" "|"))
14819 (nosave-but-article
14820 '("A\r"))
14821 keys)
14822 (save-excursion
14823 (set-buffer gnus-summary-buffer)
14824 (push (or key last-command-event) unread-command-events)
14825 (setq keys (read-key-sequence nil)))
14826 (message "")
14828 (if (or (member keys nosaves)
14829 (member keys nosave-but-article))
14830 (let (func)
14831 (save-window-excursion
14832 (pop-to-buffer gnus-summary-buffer 'norecord)
14833 (setq func (lookup-key (current-local-map) keys)))
14834 (if (not func)
14835 (ding)
14836 (set-buffer gnus-summary-buffer)
14837 (call-interactively func))
14838 (when (member keys nosave-but-article)
14839 (pop-to-buffer gnus-article-buffer 'norecord)))
14840 (let ((obuf (current-buffer))
14841 (owin (current-window-configuration))
14842 (opoint (point))
14843 func in-buffer)
14844 (if not-restore-window
14845 (pop-to-buffer gnus-summary-buffer 'norecord)
14846 (switch-to-buffer gnus-summary-buffer 'norecord))
14847 (setq in-buffer (current-buffer))
14848 (if (setq func (lookup-key (current-local-map) keys))
14849 (call-interactively func)
14850 (ding))
14851 (when (eq in-buffer (current-buffer))
14852 (set-buffer obuf)
14853 (unless not-restore-window
14854 (set-window-configuration owin))
14855 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14859 ;;; Kill file handling.
14862 ;;;###autoload
14863 (defalias 'gnus-batch-kill 'gnus-batch-score)
14864 ;;;###autoload
14865 (defun gnus-batch-score ()
14866 "Run batched scoring.
14867 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14868 Newsgroups is a list of strings in Bnews format. If you want to score
14869 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14870 score the alt hierarchy, you'd say \"!alt.all\"."
14871 (interactive)
14872 (let* ((yes-and-no
14873 (gnus-newsrc-parse-options
14874 (apply (function concat)
14875 (mapcar (lambda (g) (concat g " "))
14876 command-line-args-left))))
14877 (gnus-expert-user t)
14878 (nnmail-spool-file nil)
14879 (gnus-use-dribble-file nil)
14880 (yes (car yes-and-no))
14881 (no (cdr yes-and-no))
14882 group newsrc entry
14883 ;; Disable verbose message.
14884 gnus-novice-user gnus-large-newsgroup)
14885 ;; Eat all arguments.
14886 (setq command-line-args-left nil)
14887 ;; Start Gnus.
14888 (gnus)
14889 ;; Apply kills to specified newsgroups in command line arguments.
14890 (setq newsrc (cdr gnus-newsrc-alist))
14891 (while newsrc
14892 (setq group (caar newsrc))
14893 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14894 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14895 (and (car entry)
14896 (or (eq (car entry) t)
14897 (not (zerop (car entry)))))
14898 (if yes (string-match yes group) t)
14899 (or (null no) (not (string-match no group))))
14900 (progn
14901 (gnus-summary-read-group group nil t nil t)
14902 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14903 (gnus-summary-exit))))
14904 (setq newsrc (cdr newsrc)))
14905 ;; Exit Emacs.
14906 (switch-to-buffer gnus-group-buffer)
14907 (gnus-group-save-newsrc)))
14909 (defun gnus-apply-kill-file ()
14910 "Apply a kill file to the current newsgroup.
14911 Returns the number of articles marked as read."
14912 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14913 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14914 (gnus-apply-kill-file-internal)
14917 (defun gnus-kill-save-kill-buffer ()
14918 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14919 (when (get-file-buffer file)
14920 (save-excursion
14921 (set-buffer (get-file-buffer file))
14922 (and (buffer-modified-p) (save-buffer))
14923 (kill-buffer (current-buffer))))))
14925 (defvar gnus-kill-file-name "KILL"
14926 "Suffix of the kill files.")
14928 (defun gnus-newsgroup-kill-file (newsgroup)
14929 "Return the name of a kill file name for NEWSGROUP.
14930 If NEWSGROUP is nil, return the global kill file name instead."
14931 (cond
14932 ;; The global KILL file is placed at top of the directory.
14933 ((or (null newsgroup)
14934 (string-equal newsgroup ""))
14935 (expand-file-name gnus-kill-file-name
14936 gnus-kill-files-directory))
14937 ;; Append ".KILL" to newsgroup name.
14938 ((gnus-use-long-file-name 'not-kill)
14939 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14940 "." gnus-kill-file-name)
14941 gnus-kill-files-directory))
14942 ;; Place "KILL" under the hierarchical directory.
14944 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14945 "/" gnus-kill-file-name)
14946 gnus-kill-files-directory))))
14950 ;;; Dribble file
14953 (defvar gnus-dribble-ignore nil)
14954 (defvar gnus-dribble-eval-file nil)
14956 (defun gnus-dribble-file-name ()
14957 "Return the dribble file for the current .newsrc."
14958 (concat
14959 (if gnus-dribble-directory
14960 (concat (file-name-as-directory gnus-dribble-directory)
14961 (file-name-nondirectory gnus-current-startup-file))
14962 gnus-current-startup-file)
14963 "-dribble"))
14965 (defun gnus-dribble-enter (string)
14966 "Enter STRING into the dribble buffer."
14967 (if (and (not gnus-dribble-ignore)
14968 gnus-dribble-buffer
14969 (buffer-name gnus-dribble-buffer))
14970 (let ((obuf (current-buffer)))
14971 (set-buffer gnus-dribble-buffer)
14972 (insert string "\n")
14973 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14974 (bury-buffer gnus-dribble-buffer)
14975 (set-buffer obuf))))
14977 (defun gnus-dribble-read-file ()
14978 "Read the dribble file from disk."
14979 (let ((dribble-file (gnus-dribble-file-name)))
14980 (save-excursion
14981 (set-buffer (setq gnus-dribble-buffer
14982 (get-buffer-create
14983 (file-name-nondirectory dribble-file))))
14984 (gnus-add-current-to-buffer-list)
14985 (erase-buffer)
14986 (setq buffer-file-name dribble-file)
14987 (auto-save-mode t)
14988 (buffer-disable-undo (current-buffer))
14989 (bury-buffer (current-buffer))
14990 (set-buffer-modified-p nil)
14991 (let ((auto (make-auto-save-file-name))
14992 (gnus-dribble-ignore t)
14993 modes)
14994 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14995 ;; Load whichever file is newest -- the auto save file
14996 ;; or the "real" file.
14997 (if (file-newer-than-file-p auto dribble-file)
14998 (insert-file-contents auto)
14999 (insert-file-contents dribble-file))
15000 (unless (zerop (buffer-size))
15001 (set-buffer-modified-p t))
15002 ;; Set the file modes to reflect the .newsrc file modes.
15003 (save-buffer)
15004 (when (and (file-exists-p gnus-current-startup-file)
15005 (setq modes (file-modes gnus-current-startup-file)))
15006 (set-file-modes dribble-file modes))
15007 ;; Possibly eval the file later.
15008 (when (gnus-y-or-n-p
15009 "Auto-save file exists. Do you want to read it? ")
15010 (setq gnus-dribble-eval-file t)))))))
15012 (defun gnus-dribble-eval-file ()
15013 (when gnus-dribble-eval-file
15014 (setq gnus-dribble-eval-file nil)
15015 (save-excursion
15016 (let ((gnus-dribble-ignore t))
15017 (set-buffer gnus-dribble-buffer)
15018 (eval-buffer (current-buffer))))))
15020 (defun gnus-dribble-delete-file ()
15021 (when (file-exists-p (gnus-dribble-file-name))
15022 (delete-file (gnus-dribble-file-name)))
15023 (when gnus-dribble-buffer
15024 (save-excursion
15025 (set-buffer gnus-dribble-buffer)
15026 (let ((auto (make-auto-save-file-name)))
15027 (if (file-exists-p auto)
15028 (delete-file auto))
15029 (erase-buffer)
15030 (set-buffer-modified-p nil)))))
15032 (defun gnus-dribble-save ()
15033 (when (and gnus-dribble-buffer
15034 (buffer-name gnus-dribble-buffer))
15035 (save-excursion
15036 (set-buffer gnus-dribble-buffer)
15037 (save-buffer))))
15039 (defun gnus-dribble-clear ()
15040 (when (gnus-buffer-exists-p gnus-dribble-buffer)
15041 (save-excursion
15042 (set-buffer gnus-dribble-buffer)
15043 (erase-buffer)
15044 (set-buffer-modified-p nil)
15045 (setq buffer-saved-size (buffer-size)))))
15049 ;;; Server Communication
15052 (defun gnus-start-news-server (&optional confirm)
15053 "Open a method for getting news.
15054 If CONFIRM is non-nil, the user will be asked for an NNTP server."
15055 (let (how)
15056 (if gnus-current-select-method
15057 ;; Stream is already opened.
15059 ;; Open NNTP server.
15060 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
15061 (if confirm
15062 (progn
15063 ;; Read server name with completion.
15064 (setq gnus-nntp-server
15065 (completing-read "NNTP server: "
15066 (mapcar (lambda (server) (list server))
15067 (cons (list gnus-nntp-server)
15068 gnus-secondary-servers))
15069 nil nil gnus-nntp-server))))
15071 (if (and gnus-nntp-server
15072 (stringp gnus-nntp-server)
15073 (not (string= gnus-nntp-server "")))
15074 (setq gnus-select-method
15075 (cond ((or (string= gnus-nntp-server "")
15076 (string= gnus-nntp-server "::"))
15077 (list 'nnspool (system-name)))
15078 ((string-match "^:" gnus-nntp-server)
15079 (list 'nnmh gnus-nntp-server
15080 (list 'nnmh-directory
15081 (file-name-as-directory
15082 (expand-file-name
15083 (concat "~/" (substring
15084 gnus-nntp-server 1)))))
15085 (list 'nnmh-get-new-mail nil)))
15087 (list 'nntp gnus-nntp-server)))))
15089 (setq how (car gnus-select-method))
15090 (cond ((eq how 'nnspool)
15091 (require 'nnspool)
15092 (gnus-message 5 "Looking up local news spool..."))
15093 ((eq how 'nnmh)
15094 (require 'nnmh)
15095 (gnus-message 5 "Looking up mh spool..."))
15097 (require 'nntp)))
15098 (setq gnus-current-select-method gnus-select-method)
15099 (run-hooks 'gnus-open-server-hook)
15101 ;; gnus-open-server-hook might have opened it
15102 (gnus-server-opened gnus-select-method)
15103 (gnus-open-server gnus-select-method)
15104 (gnus-y-or-n-p
15105 (format
15106 "%s (%s) open error: '%s'. Continue? "
15107 (car gnus-select-method) (cadr gnus-select-method)
15108 (gnus-status-message gnus-select-method)))
15109 (gnus-error 1 "Couldn't open server on %s"
15110 (nth 1 gnus-select-method))))))
15112 (defun gnus-check-group (group)
15113 "Try to make sure that the server where GROUP exists is alive."
15114 (let ((method (gnus-find-method-for-group group)))
15115 (or (gnus-server-opened method)
15116 (gnus-open-server method))))
15118 (defun gnus-check-server (&optional method silent)
15119 "Check whether the connection to METHOD is down.
15120 If METHOD is nil, use `gnus-select-method'.
15121 If it is down, start it up (again)."
15122 (let ((method (or method gnus-select-method)))
15123 ;; Transform virtual server names into select methods.
15124 (when (stringp method)
15125 (setq method (gnus-server-to-method method)))
15126 (if (gnus-server-opened method)
15127 ;; The stream is already opened.
15129 ;; Open the server.
15130 (unless silent
15131 (gnus-message 5 "Opening %s server%s..." (car method)
15132 (if (equal (nth 1 method) "") ""
15133 (format " on %s" (nth 1 method)))))
15134 (run-hooks 'gnus-open-server-hook)
15135 (prog1
15136 (gnus-open-server method)
15137 (unless silent
15138 (message ""))))))
15140 (defun gnus-get-function (method function &optional noerror)
15141 "Return a function symbol based on METHOD and FUNCTION."
15142 ;; Translate server names into methods.
15143 (unless method
15144 (error "Attempted use of a nil select method"))
15145 (when (stringp method)
15146 (setq method (gnus-server-to-method method)))
15147 (let ((func (intern (format "%s-%s" (car method) function))))
15148 ;; If the functions isn't bound, we require the backend in
15149 ;; question.
15150 (unless (fboundp func)
15151 (require (car method))
15152 (when (and (not (fboundp func))
15153 (not noerror))
15154 ;; This backend doesn't implement this function.
15155 (error "No such function: %s" func)))
15156 func))
15160 ;;; Interface functions to the backends.
15163 (defun gnus-open-server (method)
15164 "Open a connection to METHOD."
15165 (when (stringp method)
15166 (setq method (gnus-server-to-method method)))
15167 (let ((elem (assoc method gnus-opened-servers)))
15168 ;; If this method was previously denied, we just return nil.
15169 (if (eq (nth 1 elem) 'denied)
15170 (progn
15171 (gnus-message 1 "Denied server")
15172 nil)
15173 ;; Open the server.
15174 (let ((result
15175 (funcall (gnus-get-function method 'open-server)
15176 (nth 1 method) (nthcdr 2 method))))
15177 ;; If this hasn't been opened before, we add it to the list.
15178 (unless elem
15179 (setq elem (list method nil)
15180 gnus-opened-servers (cons elem gnus-opened-servers)))
15181 ;; Set the status of this server.
15182 (setcar (cdr elem) (if result 'ok 'denied))
15183 ;; Return the result from the "open" call.
15184 result))))
15186 (defun gnus-close-server (method)
15187 "Close the connection to METHOD."
15188 (when (stringp method)
15189 (setq method (gnus-server-to-method method)))
15190 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15192 (defun gnus-request-list (method)
15193 "Request the active file from METHOD."
15194 (when (stringp method)
15195 (setq method (gnus-server-to-method method)))
15196 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15198 (defun gnus-request-list-newsgroups (method)
15199 "Request the newsgroups file from METHOD."
15200 (when (stringp method)
15201 (setq method (gnus-server-to-method method)))
15202 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15204 (defun gnus-request-newgroups (date method)
15205 "Request all new groups since DATE from METHOD."
15206 (when (stringp method)
15207 (setq method (gnus-server-to-method method)))
15208 (funcall (gnus-get-function method 'request-newgroups)
15209 date (nth 1 method)))
15211 (defun gnus-server-opened (method)
15212 "Check whether a connection to METHOD has been opened."
15213 (when (stringp method)
15214 (setq method (gnus-server-to-method method)))
15215 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15217 (defun gnus-status-message (method)
15218 "Return the status message from METHOD.
15219 If METHOD is a string, it is interpreted as a group name. The method
15220 this group uses will be queried."
15221 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15222 method)))
15223 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15225 (defun gnus-request-group (group &optional dont-check method)
15226 "Request GROUP. If DONT-CHECK, no information is required."
15227 (let ((method (or method (gnus-find-method-for-group group))))
15228 (when (stringp method)
15229 (setq method (gnus-server-to-method method)))
15230 (funcall (gnus-get-function method 'request-group)
15231 (gnus-group-real-name group) (nth 1 method) dont-check)))
15233 (defun gnus-request-asynchronous (group &optional articles)
15234 "Request that GROUP behave asynchronously.
15235 ARTICLES is the `data' of the group."
15236 (let ((method (gnus-find-method-for-group group)))
15237 (funcall (gnus-get-function method 'request-asynchronous)
15238 (gnus-group-real-name group) (nth 1 method) articles)))
15240 (defun gnus-list-active-group (group)
15241 "Request active information on GROUP."
15242 (let ((method (gnus-find-method-for-group group))
15243 (func 'list-active-group))
15244 (when (gnus-check-backend-function func group)
15245 (funcall (gnus-get-function method func)
15246 (gnus-group-real-name group) (nth 1 method)))))
15248 (defun gnus-request-group-description (group)
15249 "Request a description of GROUP."
15250 (let ((method (gnus-find-method-for-group group))
15251 (func 'request-group-description))
15252 (when (gnus-check-backend-function func group)
15253 (funcall (gnus-get-function method func)
15254 (gnus-group-real-name group) (nth 1 method)))))
15256 (defun gnus-close-group (group)
15257 "Request the GROUP be closed."
15258 (let ((method (gnus-find-method-for-group group)))
15259 (funcall (gnus-get-function method 'close-group)
15260 (gnus-group-real-name group) (nth 1 method))))
15262 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15263 "Request headers for ARTICLES in GROUP.
15264 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15265 (let ((method (gnus-find-method-for-group group)))
15266 (if (and gnus-use-cache (numberp (car articles)))
15267 (gnus-cache-retrieve-headers articles group fetch-old)
15268 (funcall (gnus-get-function method 'retrieve-headers)
15269 articles (gnus-group-real-name group) (nth 1 method)
15270 fetch-old))))
15272 (defun gnus-retrieve-groups (groups method)
15273 "Request active information on GROUPS from METHOD."
15274 (when (stringp method)
15275 (setq method (gnus-server-to-method method)))
15276 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15278 (defun gnus-request-type (group &optional article)
15279 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15280 (let ((method (gnus-find-method-for-group group)))
15281 (if (not (gnus-check-backend-function 'request-type (car method)))
15282 'unknown
15283 (funcall (gnus-get-function method 'request-type)
15284 (gnus-group-real-name group) article))))
15286 (defun gnus-request-update-mark (group article mark)
15287 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15288 (let ((method (gnus-find-method-for-group group)))
15289 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15290 mark
15291 (funcall (gnus-get-function method 'request-update-mark)
15292 (gnus-group-real-name group) article mark))))
15294 (defun gnus-request-article (article group &optional buffer)
15295 "Request the ARTICLE in GROUP.
15296 ARTICLE can either be an article number or an article Message-ID.
15297 If BUFFER, insert the article in that group."
15298 (let ((method (gnus-find-method-for-group group)))
15299 (funcall (gnus-get-function method 'request-article)
15300 article (gnus-group-real-name group) (nth 1 method) buffer)))
15302 (defun gnus-request-head (article group)
15303 "Request the head of ARTICLE in GROUP."
15304 (let* ((method (gnus-find-method-for-group group))
15305 (head (gnus-get-function method 'request-head t)))
15306 (if (fboundp head)
15307 (funcall head article (gnus-group-real-name group) (nth 1 method))
15308 (let ((res (gnus-request-article article group)))
15309 (when res
15310 (save-excursion
15311 (set-buffer nntp-server-buffer)
15312 (goto-char (point-min))
15313 (when (search-forward "\n\n" nil t)
15314 (delete-region (1- (point)) (point-max)))
15315 (nnheader-fold-continuation-lines)))
15316 res))))
15318 (defun gnus-request-body (article group)
15319 "Request the body of ARTICLE in GROUP."
15320 (let ((method (gnus-find-method-for-group group)))
15321 (funcall (gnus-get-function method 'request-body)
15322 article (gnus-group-real-name group) (nth 1 method))))
15324 (defun gnus-request-post (method)
15325 "Post the current buffer using METHOD."
15326 (when (stringp method)
15327 (setq method (gnus-server-to-method method)))
15328 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15330 (defun gnus-request-scan (group method)
15331 "Request a SCAN being performed in GROUP from METHOD.
15332 If GROUP is nil, all groups on METHOD are scanned."
15333 (let ((method (if group (gnus-find-method-for-group group) method)))
15334 (funcall (gnus-get-function method 'request-scan)
15335 (and group (gnus-group-real-name group)) (nth 1 method))))
15337 (defsubst gnus-request-update-info (info method)
15338 "Request that METHOD update INFO."
15339 (when (stringp method)
15340 (setq method (gnus-server-to-method method)))
15341 (when (gnus-check-backend-function 'request-update-info (car method))
15342 (funcall (gnus-get-function method 'request-update-info)
15343 (gnus-group-real-name (gnus-info-group info))
15344 info (nth 1 method))))
15346 (defun gnus-request-expire-articles (articles group &optional force)
15347 (let ((method (gnus-find-method-for-group group)))
15348 (funcall (gnus-get-function method 'request-expire-articles)
15349 articles (gnus-group-real-name group) (nth 1 method)
15350 force)))
15352 (defun gnus-request-move-article
15353 (article group server accept-function &optional last)
15354 (let ((method (gnus-find-method-for-group group)))
15355 (funcall (gnus-get-function method 'request-move-article)
15356 article (gnus-group-real-name group)
15357 (nth 1 method) accept-function last)))
15359 (defun gnus-request-accept-article (group method &optional last)
15360 ;; Make sure there's a newline at the end of the article.
15361 (when (stringp method)
15362 (setq method (gnus-server-to-method method)))
15363 (when (and (not method)
15364 (stringp group))
15365 (setq method (gnus-group-name-to-method group)))
15366 (goto-char (point-max))
15367 (unless (bolp)
15368 (insert "\n"))
15369 (let ((func (car (or method (gnus-find-method-for-group group)))))
15370 (funcall (intern (format "%s-request-accept-article" func))
15371 (if (stringp group) (gnus-group-real-name group) group)
15372 (cadr method)
15373 last)))
15375 (defun gnus-request-replace-article (article group buffer)
15376 (let ((func (car (gnus-find-method-for-group group))))
15377 (funcall (intern (format "%s-request-replace-article" func))
15378 article (gnus-group-real-name group) buffer)))
15380 (defun gnus-request-associate-buffer (group)
15381 (let ((method (gnus-find-method-for-group group)))
15382 (funcall (gnus-get-function method 'request-associate-buffer)
15383 (gnus-group-real-name group))))
15385 (defun gnus-request-restore-buffer (article group)
15386 "Request a new buffer restored to the state of ARTICLE."
15387 (let ((method (gnus-find-method-for-group group)))
15388 (funcall (gnus-get-function method 'request-restore-buffer)
15389 article (gnus-group-real-name group) (nth 1 method))))
15391 (defun gnus-request-create-group (group &optional method)
15392 (when (stringp method)
15393 (setq method (gnus-server-to-method method)))
15394 (let ((method (or method (gnus-find-method-for-group group))))
15395 (funcall (gnus-get-function method 'request-create-group)
15396 (gnus-group-real-name group) (nth 1 method))))
15398 (defun gnus-request-delete-group (group &optional force)
15399 (let ((method (gnus-find-method-for-group group)))
15400 (funcall (gnus-get-function method 'request-delete-group)
15401 (gnus-group-real-name group) force (nth 1 method))))
15403 (defun gnus-request-rename-group (group new-name)
15404 (let ((method (gnus-find-method-for-group group)))
15405 (funcall (gnus-get-function method 'request-rename-group)
15406 (gnus-group-real-name group)
15407 (gnus-group-real-name new-name) (nth 1 method))))
15409 (defun gnus-member-of-valid (symbol group)
15410 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15411 (memq symbol (assoc
15412 (symbol-name (car (gnus-find-method-for-group group)))
15413 gnus-valid-select-methods)))
15415 (defun gnus-method-option-p (method option)
15416 "Return non-nil if select METHOD has OPTION as a parameter."
15417 (when (stringp method)
15418 (setq method (gnus-server-to-method method)))
15419 (memq option (assoc (format "%s" (car method))
15420 gnus-valid-select-methods)))
15422 (defun gnus-server-extend-method (group method)
15423 ;; This function "extends" a virtual server. If the server is
15424 ;; "hello", and the select method is ("hello" (my-var "something"))
15425 ;; in the group "alt.alt", this will result in a new virtual server
15426 ;; called "hello+alt.alt".
15427 (let ((entry
15428 (gnus-copy-sequence
15429 (if (equal (car method) "native") gnus-select-method
15430 (cdr (assoc (car method) gnus-server-alist))))))
15431 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15432 (nconc entry (cdr method))))
15434 (defun gnus-server-status (method)
15435 "Return the status of METHOD."
15436 (nth 1 (assoc method gnus-opened-servers)))
15438 (defun gnus-group-name-to-method (group)
15439 "Return a select method suitable for GROUP."
15440 (if (string-match ":" group)
15441 (let ((server (substring group 0 (match-beginning 0))))
15442 (if (string-match "\\+" server)
15443 (list (intern (substring server 0 (match-beginning 0)))
15444 (substring server (match-end 0)))
15445 (list (intern server) "")))
15446 gnus-select-method))
15448 (defun gnus-find-method-for-group (group &optional info)
15449 "Find the select method that GROUP uses."
15450 (or gnus-override-method
15451 (and (not group)
15452 gnus-select-method)
15453 (let ((info (or info (gnus-get-info group)))
15454 method)
15455 (if (or (not info)
15456 (not (setq method (gnus-info-method info)))
15457 (equal method "native"))
15458 gnus-select-method
15459 (setq method
15460 (cond ((stringp method)
15461 (gnus-server-to-method method))
15462 ((stringp (car method))
15463 (gnus-server-extend-method group method))
15465 method)))
15466 (cond ((equal (cadr method) "")
15467 method)
15468 ((null (cadr method))
15469 (list (car method) ""))
15471 (gnus-server-add-address method)))))))
15473 (defun gnus-check-backend-function (func group)
15474 "Check whether GROUP supports function FUNC."
15475 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15476 group)))
15477 (fboundp (intern (format "%s-%s" method func)))))
15479 (defun gnus-methods-using (feature)
15480 "Find all methods that have FEATURE."
15481 (let ((valids gnus-valid-select-methods)
15482 outs)
15483 (while valids
15484 (if (memq feature (car valids))
15485 (setq outs (cons (car valids) outs)))
15486 (setq valids (cdr valids)))
15487 outs))
15491 ;;; Active & Newsrc File Handling
15494 (defun gnus-setup-news (&optional rawfile level dont-connect)
15495 "Setup news information.
15496 If RAWFILE is non-nil, the .newsrc file will also be read.
15497 If LEVEL is non-nil, the news will be set up at level LEVEL."
15498 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15500 (when init
15501 ;; Clear some variables to re-initialize news information.
15502 (setq gnus-newsrc-alist nil
15503 gnus-active-hashtb nil)
15504 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15505 (gnus-read-newsrc-file rawfile))
15507 (when (and (not (assoc "archive" gnus-server-alist))
15508 (gnus-archive-server-wanted-p))
15509 (push (cons "archive" gnus-message-archive-method)
15510 gnus-server-alist))
15512 ;; If we don't read the complete active file, we fill in the
15513 ;; hashtb here.
15514 (if (or (null gnus-read-active-file)
15515 (eq gnus-read-active-file 'some))
15516 (gnus-update-active-hashtb-from-killed))
15518 ;; Read the active file and create `gnus-active-hashtb'.
15519 ;; If `gnus-read-active-file' is nil, then we just create an empty
15520 ;; hash table. The partial filling out of the hash table will be
15521 ;; done in `gnus-get-unread-articles'.
15522 (and gnus-read-active-file
15523 (not level)
15524 (gnus-read-active-file))
15526 (or gnus-active-hashtb
15527 (setq gnus-active-hashtb (make-vector 4095 0)))
15529 ;; Initialize the cache.
15530 (when gnus-use-cache
15531 (gnus-cache-open))
15533 ;; Possibly eval the dribble file.
15534 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15536 ;; Slave Gnusii should then clear the dribble buffer.
15537 (when (and init gnus-slave)
15538 (gnus-dribble-clear))
15540 (gnus-update-format-specifications)
15542 ;; See whether we need to read the description file.
15543 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15544 (not gnus-description-hashtb)
15545 (not dont-connect)
15546 gnus-read-active-file)
15547 (gnus-read-all-descriptions-files))
15549 ;; Find new newsgroups and treat them.
15550 (if (and init gnus-check-new-newsgroups (not level)
15551 (gnus-check-server gnus-select-method))
15552 (gnus-find-new-newsgroups))
15554 ;; We might read in new NoCeM messages here.
15555 (when (and gnus-use-nocem
15556 (not level)
15557 (not dont-connect))
15558 (gnus-nocem-scan-groups))
15560 ;; Find the number of unread articles in each non-dead group.
15561 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15562 (gnus-get-unread-articles level))
15564 (if (and init gnus-check-bogus-newsgroups
15565 gnus-read-active-file (not level)
15566 (gnus-server-opened gnus-select-method))
15567 (gnus-check-bogus-newsgroups))))
15569 (defun gnus-find-new-newsgroups (&optional arg)
15570 "Search for new newsgroups and add them.
15571 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15572 The `-n' option line from .newsrc is respected.
15573 If ARG (the prefix), use the `ask-server' method to query
15574 the server for new groups."
15575 (interactive "P")
15576 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15577 (null gnus-read-active-file)
15578 (eq gnus-read-active-file 'some))
15579 'ask-server gnus-check-new-newsgroups)))
15580 (unless (gnus-check-first-time-used)
15581 (if (or (consp check)
15582 (eq check 'ask-server))
15583 ;; Ask the server for new groups.
15584 (gnus-ask-server-for-new-groups)
15585 ;; Go through the active hashtb and look for new groups.
15586 (let ((groups 0)
15587 group new-newsgroups)
15588 (gnus-message 5 "Looking for new newsgroups...")
15589 (unless gnus-have-read-active-file
15590 (gnus-read-active-file))
15591 (setq gnus-newsrc-last-checked-date (current-time-string))
15592 (unless gnus-killed-hashtb
15593 (gnus-make-hashtable-from-killed))
15594 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15595 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15596 (mapatoms
15597 (lambda (sym)
15598 (if (or (null (setq group (symbol-name sym)))
15599 (not (boundp sym))
15600 (null (symbol-value sym))
15601 (gnus-gethash group gnus-killed-hashtb)
15602 (gnus-gethash group gnus-newsrc-hashtb))
15604 (let ((do-sub (gnus-matches-options-n group)))
15605 (cond
15606 ((eq do-sub 'subscribe)
15607 (setq groups (1+ groups))
15608 (gnus-sethash group group gnus-killed-hashtb)
15609 (funcall gnus-subscribe-options-newsgroup-method group))
15610 ((eq do-sub 'ignore)
15611 nil)
15613 (setq groups (1+ groups))
15614 (gnus-sethash group group gnus-killed-hashtb)
15615 (if gnus-subscribe-hierarchical-interactive
15616 (setq new-newsgroups (cons group new-newsgroups))
15617 (funcall gnus-subscribe-newsgroup-method group)))))))
15618 gnus-active-hashtb)
15619 (when new-newsgroups
15620 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15621 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15622 (if (> groups 0)
15623 (gnus-message 6 "%d new newsgroup%s arrived."
15624 groups (if (> groups 1) "s have" " has"))
15625 (gnus-message 6 "No new newsgroups.")))))))
15627 (defun gnus-matches-options-n (group)
15628 ;; Returns `subscribe' if the group is to be unconditionally
15629 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15630 ;; no match for the group.
15632 ;; First we check the two user variables.
15633 (cond
15634 ((and gnus-options-subscribe
15635 (string-match gnus-options-subscribe group))
15636 'subscribe)
15637 ((and gnus-auto-subscribed-groups
15638 (string-match gnus-auto-subscribed-groups group))
15639 'subscribe)
15640 ((and gnus-options-not-subscribe
15641 (string-match gnus-options-not-subscribe group))
15642 'ignore)
15643 ;; Then we go through the list that was retrieved from the .newsrc
15644 ;; file. This list has elements on the form
15645 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15646 ;; is in the reverse order of the options line) is returned.
15648 (let ((regs gnus-newsrc-options-n))
15649 (while (and regs
15650 (not (string-match (caar regs) group)))
15651 (setq regs (cdr regs)))
15652 (and regs (cdar regs))))))
15654 (defun gnus-ask-server-for-new-groups ()
15655 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15656 (methods (cons gnus-select-method
15657 (nconc
15658 (when (gnus-archive-server-wanted-p)
15659 (list "archive"))
15660 (append
15661 (and (consp gnus-check-new-newsgroups)
15662 gnus-check-new-newsgroups)
15663 gnus-secondary-select-methods))))
15664 (groups 0)
15665 (new-date (current-time-string))
15666 group new-newsgroups got-new method hashtb
15667 gnus-override-subscribe-method)
15668 ;; Go through both primary and secondary select methods and
15669 ;; request new newsgroups.
15670 (while (setq method (gnus-server-get-method nil (pop methods)))
15671 (setq new-newsgroups nil)
15672 (setq gnus-override-subscribe-method method)
15673 (when (and (gnus-check-server method)
15674 (gnus-request-newgroups date method))
15675 (save-excursion
15676 (setq got-new t)
15677 (setq hashtb (gnus-make-hashtable 100))
15678 (set-buffer nntp-server-buffer)
15679 ;; Enter all the new groups into a hashtable.
15680 (gnus-active-to-gnus-format method hashtb 'ignore))
15681 ;; Now all new groups from `method' are in `hashtb'.
15682 (mapatoms
15683 (lambda (group-sym)
15684 (if (or (null (setq group (symbol-name group-sym)))
15685 (not (boundp group-sym))
15686 (null (symbol-value group-sym))
15687 (gnus-gethash group gnus-newsrc-hashtb)
15688 (member group gnus-zombie-list)
15689 (member group gnus-killed-list))
15690 ;; The group is already known.
15692 ;; Make this group active.
15693 (when (symbol-value group-sym)
15694 (gnus-set-active group (symbol-value group-sym)))
15695 ;; Check whether we want it or not.
15696 (let ((do-sub (gnus-matches-options-n group)))
15697 (cond
15698 ((eq do-sub 'subscribe)
15699 (incf groups)
15700 (gnus-sethash group group gnus-killed-hashtb)
15701 (funcall gnus-subscribe-options-newsgroup-method group))
15702 ((eq do-sub 'ignore)
15703 nil)
15705 (incf groups)
15706 (gnus-sethash group group gnus-killed-hashtb)
15707 (if gnus-subscribe-hierarchical-interactive
15708 (push group new-newsgroups)
15709 (funcall gnus-subscribe-newsgroup-method group)))))))
15710 hashtb))
15711 (when new-newsgroups
15712 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15713 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15714 (when (> groups 0)
15715 (gnus-message 6 "%d new newsgroup%s arrived."
15716 groups (if (> groups 1) "s have" " has")))
15717 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15718 got-new))
15720 (defun gnus-check-first-time-used ()
15721 (if (or (> (length gnus-newsrc-alist) 1)
15722 (file-exists-p gnus-startup-file)
15723 (file-exists-p (concat gnus-startup-file ".el"))
15724 (file-exists-p (concat gnus-startup-file ".eld")))
15726 (gnus-message 6 "First time user; subscribing you to default groups")
15727 (unless (gnus-read-active-file-p)
15728 (gnus-read-active-file))
15729 (setq gnus-newsrc-last-checked-date (current-time-string))
15730 (let ((groups gnus-default-subscribed-newsgroups)
15731 group)
15732 (if (eq groups t)
15734 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15735 (mapatoms
15736 (lambda (sym)
15737 (if (null (setq group (symbol-name sym)))
15739 (let ((do-sub (gnus-matches-options-n group)))
15740 (cond
15741 ((eq do-sub 'subscribe)
15742 (gnus-sethash group group gnus-killed-hashtb)
15743 (funcall gnus-subscribe-options-newsgroup-method group))
15744 ((eq do-sub 'ignore)
15745 nil)
15747 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15748 gnus-active-hashtb)
15749 (while groups
15750 (if (gnus-active (car groups))
15751 (gnus-group-change-level
15752 (car groups) gnus-level-default-subscribed gnus-level-killed))
15753 (setq groups (cdr groups)))
15754 (gnus-group-make-help-group)
15755 (and gnus-novice-user
15756 (gnus-message 7 "`A k' to list killed groups"))))))
15758 (defun gnus-subscribe-group (group previous &optional method)
15759 (gnus-group-change-level
15760 (if method
15761 (list t group gnus-level-default-subscribed nil nil method)
15762 group)
15763 gnus-level-default-subscribed gnus-level-killed previous t))
15765 ;; `gnus-group-change-level' is the fundamental function for changing
15766 ;; subscription levels of newsgroups. This might mean just changing
15767 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15768 ;; again, which subscribes/unsubscribes a group, which is equally
15769 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15770 ;; from 8-9 to 1-7 means that you remove the group from the list of
15771 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15772 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15773 ;; which is trivial.
15774 ;; ENTRY can either be a string (newsgroup name) or a list (if
15775 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15776 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15777 ;; entries.
15778 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15779 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15780 ;; after.
15781 (defun gnus-group-change-level (entry level &optional oldlevel
15782 previous fromkilled)
15783 (let (group info active num)
15784 ;; Glean what info we can from the arguments
15785 (if (consp entry)
15786 (if fromkilled (setq group (nth 1 entry))
15787 (setq group (car (nth 2 entry))))
15788 (setq group entry))
15789 (if (and (stringp entry)
15790 oldlevel
15791 (< oldlevel gnus-level-zombie))
15792 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15793 (if (and (not oldlevel)
15794 (consp entry))
15795 (setq oldlevel (gnus-info-level (nth 2 entry)))
15796 (setq oldlevel (or oldlevel 9)))
15797 (if (stringp previous)
15798 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15800 (if (and (>= oldlevel gnus-level-zombie)
15801 (gnus-gethash group gnus-newsrc-hashtb))
15802 ;; We are trying to subscribe a group that is already
15803 ;; subscribed.
15804 () ; Do nothing.
15806 (or (gnus-ephemeral-group-p group)
15807 (gnus-dribble-enter
15808 (format "(gnus-group-change-level %S %S %S %S %S)"
15809 group level oldlevel (car (nth 2 previous)) fromkilled)))
15811 ;; Then we remove the newgroup from any old structures, if needed.
15812 ;; If the group was killed, we remove it from the killed or zombie
15813 ;; list. If not, and it is in fact going to be killed, we remove
15814 ;; it from the newsrc hash table and assoc.
15815 (cond
15816 ((>= oldlevel gnus-level-zombie)
15817 (if (= oldlevel gnus-level-zombie)
15818 (setq gnus-zombie-list (delete group gnus-zombie-list))
15819 (setq gnus-killed-list (delete group gnus-killed-list))))
15821 (if (and (>= level gnus-level-zombie)
15822 entry)
15823 (progn
15824 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15825 (if (nth 3 entry)
15826 (setcdr (gnus-gethash (car (nth 3 entry))
15827 gnus-newsrc-hashtb)
15828 (cdr entry)))
15829 (setcdr (cdr entry) (cdddr entry))))))
15831 ;; Finally we enter (if needed) the list where it is supposed to
15832 ;; go, and change the subscription level. If it is to be killed,
15833 ;; we enter it into the killed or zombie list.
15834 (cond
15835 ((>= level gnus-level-zombie)
15836 ;; Remove from the hash table.
15837 (gnus-sethash group nil gnus-newsrc-hashtb)
15838 ;; We do not enter foreign groups into the list of dead
15839 ;; groups.
15840 (unless (gnus-group-foreign-p group)
15841 (if (= level gnus-level-zombie)
15842 (setq gnus-zombie-list (cons group gnus-zombie-list))
15843 (setq gnus-killed-list (cons group gnus-killed-list)))))
15845 ;; If the list is to be entered into the newsrc assoc, and
15846 ;; it was killed, we have to create an entry in the newsrc
15847 ;; hashtb format and fix the pointers in the newsrc assoc.
15848 (if (< oldlevel gnus-level-zombie)
15849 ;; It was alive, and it is going to stay alive, so we
15850 ;; just change the level and don't change any pointers or
15851 ;; hash table entries.
15852 (setcar (cdaddr entry) level)
15853 (if (listp entry)
15854 (setq info (cdr entry)
15855 num (car entry))
15856 (setq active (gnus-active group))
15857 (setq num
15858 (if active (- (1+ (cdr active)) (car active)) t))
15859 ;; Check whether the group is foreign. If so, the
15860 ;; foreign select method has to be entered into the
15861 ;; info.
15862 (let ((method (or gnus-override-subscribe-method
15863 (gnus-group-method group))))
15864 (if (eq method gnus-select-method)
15865 (setq info (list group level nil))
15866 (setq info (list group level nil nil method)))))
15867 (unless previous
15868 (setq previous
15869 (let ((p gnus-newsrc-alist))
15870 (while (cddr p)
15871 (setq p (cdr p)))
15872 p)))
15873 (setq entry (cons info (cddr previous)))
15874 (if (cdr previous)
15875 (progn
15876 (setcdr (cdr previous) entry)
15877 (gnus-sethash group (cons num (cdr previous))
15878 gnus-newsrc-hashtb))
15879 (setcdr previous entry)
15880 (gnus-sethash group (cons num previous)
15881 gnus-newsrc-hashtb))
15882 (when (cdr entry)
15883 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15884 (when gnus-group-change-level-function
15885 (funcall gnus-group-change-level-function group level oldlevel)))))
15887 (defun gnus-kill-newsgroup (newsgroup)
15888 "Obsolete function. Kills a newsgroup."
15889 (gnus-group-change-level
15890 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15892 (defun gnus-check-bogus-newsgroups (&optional confirm)
15893 "Remove bogus newsgroups.
15894 If CONFIRM is non-nil, the user has to confirm the deletion of every
15895 newsgroup."
15896 (let ((newsrc (cdr gnus-newsrc-alist))
15897 bogus group entry info)
15898 (gnus-message 5 "Checking bogus newsgroups...")
15899 (unless (gnus-read-active-file-p)
15900 (gnus-read-active-file))
15901 (when (gnus-read-active-file-p)
15902 ;; Find all bogus newsgroup that are subscribed.
15903 (while newsrc
15904 (setq info (pop newsrc)
15905 group (gnus-info-group info))
15906 (unless (or (gnus-active group) ; Active
15907 (gnus-info-method info) ; Foreign
15908 (and confirm
15909 (not (gnus-y-or-n-p
15910 (format "Remove bogus newsgroup: %s " group)))))
15911 ;; Found a bogus newsgroup.
15912 (push group bogus)))
15913 ;; Remove all bogus subscribed groups by first killing them, and
15914 ;; then removing them from the list of killed groups.
15915 (while bogus
15916 (when (setq entry (gnus-gethash (setq group (pop bogus))
15917 gnus-newsrc-hashtb))
15918 (gnus-group-change-level entry gnus-level-killed)
15919 (setq gnus-killed-list (delete group gnus-killed-list))))
15920 ;; Then we remove all bogus groups from the list of killed and
15921 ;; zombie groups. They are are removed without confirmation.
15922 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15923 killed)
15924 (while dead-lists
15925 (setq killed (symbol-value (car dead-lists)))
15926 (while killed
15927 (unless (gnus-active (setq group (pop killed)))
15928 ;; The group is bogus.
15929 ;; !!!Slow as hell.
15930 (set (car dead-lists)
15931 (delete group (symbol-value (car dead-lists))))))
15932 (setq dead-lists (cdr dead-lists))))
15933 (gnus-message 5 "Checking bogus newsgroups...done"))))
15935 (defun gnus-check-duplicate-killed-groups ()
15936 "Remove duplicates from the list of killed groups."
15937 (interactive)
15938 (let ((killed gnus-killed-list))
15939 (while killed
15940 (gnus-message 9 "%d" (length killed))
15941 (setcdr killed (delete (car killed) (cdr killed)))
15942 (setq killed (cdr killed)))))
15944 ;; We want to inline a function from gnus-cache, so we cheat here:
15945 (eval-when-compile
15946 (provide 'gnus)
15947 (setq gnus-directory (or (getenv "SAVEDIR") "~/News/"))
15948 (require 'gnus-cache))
15950 (defun gnus-get-unread-articles-in-group (info active &optional update)
15951 (when active
15952 ;; Allow the backend to update the info in the group.
15953 (when (and update
15954 (gnus-request-update-info
15955 info (gnus-find-method-for-group (gnus-info-group info))))
15956 (gnus-activate-group (gnus-info-group info) nil t))
15957 (let* ((range (gnus-info-read info))
15958 (num 0))
15959 ;; If a cache is present, we may have to alter the active info.
15960 (when (and gnus-use-cache info)
15961 (inline (gnus-cache-possibly-alter-active
15962 (gnus-info-group info) active)))
15963 ;; Modify the list of read articles according to what articles
15964 ;; are available; then tally the unread articles and add the
15965 ;; number to the group hash table entry.
15966 (cond
15967 ((zerop (cdr active))
15968 (setq num 0))
15969 ((not range)
15970 (setq num (- (1+ (cdr active)) (car active))))
15971 ((not (listp (cdr range)))
15972 ;; Fix a single (num . num) range according to the
15973 ;; active hash table.
15974 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15975 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15976 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15977 ;; Compute number of unread articles.
15978 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15980 ;; The read list is a list of ranges. Fix them according to
15981 ;; the active hash table.
15982 ;; First peel off any elements that are below the lower
15983 ;; active limit.
15984 (while (and (cdr range)
15985 (>= (car active)
15986 (or (and (atom (cadr range)) (cadr range))
15987 (caadr range))))
15988 (if (numberp (car range))
15989 (setcar range
15990 (cons (car range)
15991 (or (and (numberp (cadr range))
15992 (cadr range))
15993 (cdadr range))))
15994 (setcdr (car range)
15995 (or (and (numberp (nth 1 range)) (nth 1 range))
15996 (cdadr range))))
15997 (setcdr range (cddr range)))
15998 ;; Adjust the first element to be the same as the lower limit.
15999 (if (and (not (atom (car range)))
16000 (< (cdar range) (car active)))
16001 (setcdr (car range) (1- (car active))))
16002 ;; Then we want to peel off any elements that are higher
16003 ;; than the upper active limit.
16004 (let ((srange range))
16005 ;; Go past all legal elements.
16006 (while (and (cdr srange)
16007 (<= (or (and (atom (cadr srange))
16008 (cadr srange))
16009 (caadr srange)) (cdr active)))
16010 (setq srange (cdr srange)))
16011 (if (cdr srange)
16012 ;; Nuke all remaining illegal elements.
16013 (setcdr srange nil))
16015 ;; Adjust the final element.
16016 (if (and (not (atom (car srange)))
16017 (> (cdar srange) (cdr active)))
16018 (setcdr (car srange) (cdr active))))
16019 ;; Compute the number of unread articles.
16020 (while range
16021 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
16022 (cdar range)))
16023 (or (and (atom (car range)) (car range))
16024 (caar range)))))
16025 (setq range (cdr range)))
16026 (setq num (max 0 (- (cdr active) num)))))
16027 ;; Set the number of unread articles.
16028 (when info
16029 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
16030 num)))
16032 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
16033 ;; and compute how many unread articles there are in each group.
16034 (defun gnus-get-unread-articles (&optional level)
16035 (let* ((newsrc (cdr gnus-newsrc-alist))
16036 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
16037 (foreign-level
16038 (min
16039 (cond ((and gnus-activate-foreign-newsgroups
16040 (not (numberp gnus-activate-foreign-newsgroups)))
16041 (1+ gnus-level-subscribed))
16042 ((numberp gnus-activate-foreign-newsgroups)
16043 gnus-activate-foreign-newsgroups)
16044 (t 0))
16045 level))
16046 info group active method)
16047 (gnus-message 5 "Checking new news...")
16049 (while newsrc
16050 (setq active (gnus-active (setq group (gnus-info-group
16051 (setq info (pop newsrc))))))
16053 ;; Check newsgroups. If the user doesn't want to check them, or
16054 ;; they can't be checked (for instance, if the news server can't
16055 ;; be reached) we just set the number of unread articles in this
16056 ;; newsgroup to t. This means that Gnus thinks that there are
16057 ;; unread articles, but it has no idea how many.
16058 (if (and (setq method (gnus-info-method info))
16059 (not (gnus-server-equal
16060 gnus-select-method
16061 (setq method (gnus-server-get-method nil method))))
16062 (not (gnus-secondary-method-p method)))
16063 ;; These groups are foreign. Check the level.
16064 (when (<= (gnus-info-level info) foreign-level)
16065 (setq active (gnus-activate-group group 'scan))
16066 (unless (inline (gnus-virtual-group-p group))
16067 (inline (gnus-close-group group)))
16068 (when (fboundp (intern (concat (symbol-name (car method))
16069 "-request-update-info")))
16070 (inline (gnus-request-update-info info method))))
16071 ;; These groups are native or secondary.
16072 (when (and (<= (gnus-info-level info) level)
16073 (not gnus-read-active-file))
16074 (setq active (gnus-activate-group group 'scan))
16075 (inline (gnus-close-group group))))
16077 ;; Get the number of unread articles in the group.
16078 (if active
16079 (inline (gnus-get-unread-articles-in-group info active))
16080 ;; The group couldn't be reached, so we nix out the number of
16081 ;; unread articles and stuff.
16082 (gnus-set-active group nil)
16083 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
16085 (gnus-message 5 "Checking new news...done")))
16087 ;; Create a hash table out of the newsrc alist. The `car's of the
16088 ;; alist elements are used as keys.
16089 (defun gnus-make-hashtable-from-newsrc-alist ()
16090 (let ((alist gnus-newsrc-alist)
16091 (ohashtb gnus-newsrc-hashtb)
16092 prev)
16093 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
16094 (setq alist
16095 (setq prev (setq gnus-newsrc-alist
16096 (if (equal (caar gnus-newsrc-alist)
16097 "dummy.group")
16098 gnus-newsrc-alist
16099 (cons (list "dummy.group" 0 nil) alist)))))
16100 (while alist
16101 (gnus-sethash
16102 (caar alist)
16103 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
16104 prev)
16105 gnus-newsrc-hashtb)
16106 (setq prev alist
16107 alist (cdr alist)))))
16109 (defun gnus-make-hashtable-from-killed ()
16110 "Create a hash table from the killed and zombie lists."
16111 (let ((lists '(gnus-killed-list gnus-zombie-list))
16112 list)
16113 (setq gnus-killed-hashtb
16114 (gnus-make-hashtable
16115 (+ (length gnus-killed-list) (length gnus-zombie-list))))
16116 (while (setq list (pop lists))
16117 (setq list (symbol-value list))
16118 (while list
16119 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
16121 (defun gnus-activate-group (group &optional scan dont-check method)
16122 ;; Check whether a group has been activated or not.
16123 ;; If SCAN, request a scan of that group as well.
16124 (let ((method (or method (gnus-find-method-for-group group)))
16125 active)
16126 (and (gnus-check-server method)
16127 ;; We escape all bugs and quit here to make it possible to
16128 ;; continue if a group is so out-there that it reports bugs
16129 ;; and stuff.
16130 (progn
16131 (and scan
16132 (gnus-check-backend-function 'request-scan (car method))
16133 (gnus-request-scan group method))
16135 (condition-case ()
16136 (gnus-request-group group dont-check method)
16137 ; (error nil)
16138 (quit nil))
16139 (save-excursion
16140 (set-buffer nntp-server-buffer)
16141 (goto-char (point-min))
16142 ;; Parse the result we got from `gnus-request-group'.
16143 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16144 (progn
16145 (goto-char (match-beginning 1))
16146 (gnus-set-active
16147 group (setq active (cons (read (current-buffer))
16148 (read (current-buffer)))))
16149 ;; Return the new active info.
16150 active))))))
16152 (defun gnus-update-read-articles (group unread)
16153 "Update the list of read and ticked articles in GROUP using the
16154 UNREAD and TICKED lists.
16155 Note: UNSELECTED has to be sorted over `<'.
16156 Returns whether the updating was successful."
16157 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16158 (entry (gnus-gethash group gnus-newsrc-hashtb))
16159 (info (nth 2 entry))
16160 (prev 1)
16161 (unread (sort (copy-sequence unread) '<))
16162 read)
16163 (if (or (not info) (not active))
16164 ;; There is no info on this group if it was, in fact,
16165 ;; killed. Gnus stores no information on killed groups, so
16166 ;; there's nothing to be done.
16167 ;; One could store the information somewhere temporarily,
16168 ;; perhaps... Hmmm...
16170 ;; Remove any negative articles numbers.
16171 (while (and unread (< (car unread) 0))
16172 (setq unread (cdr unread)))
16173 ;; Remove any expired article numbers
16174 (while (and unread (< (car unread) (car active)))
16175 (setq unread (cdr unread)))
16176 ;; Compute the ranges of read articles by looking at the list of
16177 ;; unread articles.
16178 (while unread
16179 (if (/= (car unread) prev)
16180 (setq read (cons (if (= prev (1- (car unread))) prev
16181 (cons prev (1- (car unread)))) read)))
16182 (setq prev (1+ (car unread)))
16183 (setq unread (cdr unread)))
16184 (when (<= prev (cdr active))
16185 (setq read (cons (cons prev (cdr active)) read)))
16186 ;; Enter this list into the group info.
16187 (gnus-info-set-read
16188 info (if (> (length read) 1) (nreverse read) read))
16189 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16190 (gnus-get-unread-articles-in-group info (gnus-active group))
16191 t)))
16193 (defun gnus-make-articles-unread (group articles)
16194 "Mark ARTICLES in GROUP as unread."
16195 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16196 (gnus-gethash (gnus-group-real-name group)
16197 gnus-newsrc-hashtb))))
16198 (ranges (gnus-info-read info))
16199 news article)
16200 (while articles
16201 (when (gnus-member-of-range
16202 (setq article (pop articles)) ranges)
16203 (setq news (cons article news))))
16204 (when news
16205 (gnus-info-set-read
16206 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16207 (gnus-group-update-group group t))))
16209 ;; Enter all dead groups into the hashtb.
16210 (defun gnus-update-active-hashtb-from-killed ()
16211 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16212 (lists (list gnus-killed-list gnus-zombie-list))
16213 killed)
16214 (while lists
16215 (setq killed (car lists))
16216 (while killed
16217 (gnus-sethash (car killed) nil hashtb)
16218 (setq killed (cdr killed)))
16219 (setq lists (cdr lists)))))
16221 (defun gnus-get-killed-groups ()
16222 "Go through the active hashtb and all all unknown groups as killed."
16223 ;; First make sure active file has been read.
16224 (unless (gnus-read-active-file-p)
16225 (let ((gnus-read-active-file t))
16226 (gnus-read-active-file)))
16227 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16228 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16229 (mapatoms
16230 (lambda (sym)
16231 (let ((groups 0)
16232 (group (symbol-name sym)))
16233 (if (or (null group)
16234 (gnus-gethash group gnus-killed-hashtb)
16235 (gnus-gethash group gnus-newsrc-hashtb))
16237 (let ((do-sub (gnus-matches-options-n group)))
16238 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16240 (setq groups (1+ groups))
16241 (setq gnus-killed-list
16242 (cons group gnus-killed-list))
16243 (gnus-sethash group group gnus-killed-hashtb))))))
16244 gnus-active-hashtb))
16246 ;; Get the active file(s) from the backend(s).
16247 (defun gnus-read-active-file ()
16248 (gnus-group-set-mode-line)
16249 (let ((methods
16250 (append
16251 (if (gnus-check-server gnus-select-method)
16252 ;; The native server is available.
16253 (cons gnus-select-method gnus-secondary-select-methods)
16254 ;; The native server is down, so we just do the
16255 ;; secondary ones.
16256 gnus-secondary-select-methods)
16257 ;; Also read from the archive server.
16258 (when (gnus-archive-server-wanted-p)
16259 (list "archive"))))
16260 list-type)
16261 (setq gnus-have-read-active-file nil)
16262 (save-excursion
16263 (set-buffer nntp-server-buffer)
16264 (while methods
16265 (let* ((method (if (stringp (car methods))
16266 (gnus-server-get-method nil (car methods))
16267 (car methods)))
16268 (where (nth 1 method))
16269 (mesg (format "Reading active file%s via %s..."
16270 (if (and where (not (zerop (length where))))
16271 (concat " from " where) "")
16272 (car method))))
16273 (gnus-message 5 mesg)
16274 (when (gnus-check-server method)
16275 ;; Request that the backend scan its incoming messages.
16276 (and (gnus-check-backend-function 'request-scan (car method))
16277 (gnus-request-scan nil method))
16278 (cond
16279 ((and (eq gnus-read-active-file 'some)
16280 (gnus-check-backend-function 'retrieve-groups (car method)))
16281 (let ((newsrc (cdr gnus-newsrc-alist))
16282 (gmethod (gnus-server-get-method nil method))
16283 groups info)
16284 (while (setq info (pop newsrc))
16285 (when (gnus-server-equal
16286 (gnus-find-method-for-group
16287 (gnus-info-group info) info)
16288 gmethod)
16289 (push (gnus-group-real-name (gnus-info-group info))
16290 groups)))
16291 (when groups
16292 (gnus-check-server method)
16293 (setq list-type (gnus-retrieve-groups groups method))
16294 (cond
16295 ((not list-type)
16296 (gnus-error
16297 1.2 "Cannot read partial active file from %s server."
16298 (car method)))
16299 ((eq list-type 'active)
16300 (gnus-active-to-gnus-format method gnus-active-hashtb))
16302 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16304 (if (not (gnus-request-list method))
16305 (unless (equal method gnus-message-archive-method)
16306 (gnus-error 1 "Cannot read active file from %s server."
16307 (car method)))
16308 (gnus-message 5 mesg)
16309 (gnus-active-to-gnus-format method gnus-active-hashtb)
16310 ;; We mark this active file as read.
16311 (push method gnus-have-read-active-file)
16312 (gnus-message 5 "%sdone" mesg))))))
16313 (setq methods (cdr methods))))))
16315 ;; Read an active file and place the results in `gnus-active-hashtb'.
16316 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16317 (unless method
16318 (setq method gnus-select-method))
16319 (let ((cur (current-buffer))
16320 (hashtb (or hashtb
16321 (if (and gnus-active-hashtb
16322 (not (equal method gnus-select-method)))
16323 gnus-active-hashtb
16324 (setq gnus-active-hashtb
16325 (if (equal method gnus-select-method)
16326 (gnus-make-hashtable
16327 (count-lines (point-min) (point-max)))
16328 (gnus-make-hashtable 4096)))))))
16329 ;; Delete unnecessary lines.
16330 (goto-char (point-min))
16331 (while (search-forward "\nto." nil t)
16332 (delete-region (1+ (match-beginning 0))
16333 (progn (forward-line 1) (point))))
16334 (or (string= gnus-ignored-newsgroups "")
16335 (progn
16336 (goto-char (point-min))
16337 (delete-matching-lines gnus-ignored-newsgroups)))
16338 ;; Make the group names readable as a lisp expression even if they
16339 ;; contain special characters.
16340 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16341 (goto-char (point-max))
16342 (while (re-search-backward "[][';?()#]" nil t)
16343 (insert ?\\))
16344 ;; If these are groups from a foreign select method, we insert the
16345 ;; group prefix in front of the group names.
16346 (and method (not (gnus-server-equal
16347 (gnus-server-get-method nil method)
16348 (gnus-server-get-method nil gnus-select-method)))
16349 (let ((prefix (gnus-group-prefixed-name "" method)))
16350 (goto-char (point-min))
16351 (while (and (not (eobp))
16352 (progn (insert prefix)
16353 (zerop (forward-line 1)))))))
16354 ;; Store the active file in a hash table.
16355 (goto-char (point-min))
16356 (if (string-match "%[oO]" gnus-group-line-format)
16357 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16358 ;; If we want information on moderated groups, we use this
16359 ;; loop...
16360 (let* ((mod-hashtb (make-vector 7 0))
16361 (m (intern "m" mod-hashtb))
16362 group max min)
16363 (while (not (eobp))
16364 (condition-case nil
16365 (progn
16366 (narrow-to-region (point) (gnus-point-at-eol))
16367 (setq group (let ((obarray hashtb)) (read cur)))
16368 (if (and (numberp (setq max (read cur)))
16369 (numberp (setq min (read cur)))
16370 (progn
16371 (skip-chars-forward " \t")
16372 (not
16373 (or (= (following-char) ?=)
16374 (= (following-char) ?x)
16375 (= (following-char) ?j)))))
16376 (set group (cons min max))
16377 (set group nil))
16378 ;; Enter moderated groups into a list.
16379 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16380 (setq gnus-moderated-list
16381 (cons (symbol-name group) gnus-moderated-list))))
16382 (error
16383 (and group
16384 (symbolp group)
16385 (set group nil))))
16386 (widen)
16387 (forward-line 1)))
16388 ;; And if we do not care about moderation, we use this loop,
16389 ;; which is faster.
16390 (let (group max min)
16391 (while (not (eobp))
16392 (condition-case ()
16393 (progn
16394 (narrow-to-region (point) (gnus-point-at-eol))
16395 ;; group gets set to a symbol interned in the hash table
16396 ;; (what a hack!!) - jwz
16397 (setq group (let ((obarray hashtb)) (read cur)))
16398 (if (and (numberp (setq max (read cur)))
16399 (numberp (setq min (read cur)))
16400 (progn
16401 (skip-chars-forward " \t")
16402 (not
16403 (or (= (following-char) ?=)
16404 (= (following-char) ?x)
16405 (= (following-char) ?j)))))
16406 (set group (cons min max))
16407 (set group nil)))
16408 (error
16409 (progn
16410 (and group
16411 (symbolp group)
16412 (set group nil))
16413 (or ignore-errors
16414 (gnus-message 3 "Warning - illegal active: %s"
16415 (buffer-substring
16416 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16417 (widen)
16418 (forward-line 1))))))
16420 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16421 ;; Parse a "groups" active file.
16422 (let ((cur (current-buffer))
16423 (hashtb (or hashtb
16424 (if (and method gnus-active-hashtb)
16425 gnus-active-hashtb
16426 (setq gnus-active-hashtb
16427 (gnus-make-hashtable
16428 (count-lines (point-min) (point-max)))))))
16429 (prefix (and method
16430 (not (gnus-server-equal
16431 (gnus-server-get-method nil method)
16432 (gnus-server-get-method nil gnus-select-method)))
16433 (gnus-group-prefixed-name "" method))))
16435 (goto-char (point-min))
16436 ;; We split this into to separate loops, one with the prefix
16437 ;; and one without to speed the reading up somewhat.
16438 (if prefix
16439 (let (min max opoint group)
16440 (while (not (eobp))
16441 (condition-case ()
16442 (progn
16443 (read cur) (read cur)
16444 (setq min (read cur)
16445 max (read cur)
16446 opoint (point))
16447 (skip-chars-forward " \t")
16448 (insert prefix)
16449 (goto-char opoint)
16450 (set (let ((obarray hashtb)) (read cur))
16451 (cons min max)))
16452 (error (and group (symbolp group) (set group nil))))
16453 (forward-line 1)))
16454 (let (min max group)
16455 (while (not (eobp))
16456 (condition-case ()
16457 (if (= (following-char) ?2)
16458 (progn
16459 (read cur) (read cur)
16460 (setq min (read cur)
16461 max (read cur))
16462 (set (setq group (let ((obarray hashtb)) (read cur)))
16463 (cons min max))))
16464 (error (and group (symbolp group) (set group nil))))
16465 (forward-line 1))))))
16467 (defun gnus-read-newsrc-file (&optional force)
16468 "Read startup file.
16469 If FORCE is non-nil, the .newsrc file is read."
16470 ;; Reset variables that might be defined in the .newsrc.eld file.
16471 (let ((variables gnus-variable-list))
16472 (while variables
16473 (set (car variables) nil)
16474 (setq variables (cdr variables))))
16475 (let* ((newsrc-file gnus-current-startup-file)
16476 (quick-file (concat newsrc-file ".el")))
16477 (save-excursion
16478 ;; We always load the .newsrc.eld file. If always contains
16479 ;; much information that can not be gotten from the .newsrc
16480 ;; file (ticked articles, killed groups, foreign methods, etc.)
16481 (gnus-read-newsrc-el-file quick-file)
16483 (if (and (file-exists-p gnus-current-startup-file)
16484 (or force
16485 (and (file-newer-than-file-p newsrc-file quick-file)
16486 (file-newer-than-file-p newsrc-file
16487 (concat quick-file "d")))
16488 (not gnus-newsrc-alist)))
16489 ;; We read the .newsrc file. Note that if there if a
16490 ;; .newsrc.eld file exists, it has already been read, and
16491 ;; the `gnus-newsrc-hashtb' has been created. While reading
16492 ;; the .newsrc file, Gnus will only use the information it
16493 ;; can find there for changing the data already read -
16494 ;; ie. reading the .newsrc file will not trash the data
16495 ;; already read (except for read articles).
16496 (save-excursion
16497 (gnus-message 5 "Reading %s..." newsrc-file)
16498 (set-buffer (find-file-noselect newsrc-file))
16499 (buffer-disable-undo (current-buffer))
16500 (gnus-newsrc-to-gnus-format)
16501 (kill-buffer (current-buffer))
16502 (gnus-message 5 "Reading %s...done" newsrc-file)))
16504 ;; Read any slave files.
16505 (unless gnus-slave
16506 (gnus-master-read-slave-newsrc))
16508 ;; Convert old to new.
16509 (gnus-convert-old-newsrc))))
16511 (defun gnus-continuum-version (version)
16512 "Return VERSION as a floating point number."
16513 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16514 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16515 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16516 (number (match-string 2 version))
16517 major minor least)
16518 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16519 (setq major (string-to-number (match-string 1 number)))
16520 (setq minor (string-to-number (match-string 2 number)))
16521 (setq least (if (match-beginning 3)
16522 (string-to-number (match-string 3 number))
16524 (string-to-number
16525 (if (zerop major)
16526 (format "%s00%02d%02d"
16527 (cond
16528 ((member alpha '("(ding)" "d")) "4.99")
16529 ((member alpha '("September" "s")) "5.01")
16530 ((member alpha '("Red" "r")) "5.03"))
16531 minor least)
16532 (format "%d.%02d%02d" major minor least))))))
16534 (defun gnus-convert-old-newsrc ()
16535 "Convert old newsrc into the new format, if needed."
16536 (let ((fcv (and gnus-newsrc-file-version
16537 (gnus-continuum-version gnus-newsrc-file-version))))
16538 (cond
16539 ;; No .newsrc.eld file was loaded.
16540 ((null fcv) nil)
16541 ;; Gnus 5 .newsrc.eld was loaded.
16542 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16543 (gnus-convert-old-ticks)))))
16545 (defun gnus-convert-old-ticks ()
16546 (let ((newsrc (cdr gnus-newsrc-alist))
16547 marks info dormant ticked)
16548 (while (setq info (pop newsrc))
16549 (when (setq marks (gnus-info-marks info))
16550 (setq dormant (cdr (assq 'dormant marks))
16551 ticked (cdr (assq 'tick marks)))
16552 (when (or dormant ticked)
16553 (gnus-info-set-read
16554 info
16555 (gnus-add-to-range
16556 (gnus-info-read info)
16557 (nconc (gnus-uncompress-range dormant)
16558 (gnus-uncompress-range ticked)))))))))
16560 (defun gnus-read-newsrc-el-file (file)
16561 (let ((ding-file (concat file "d")))
16562 ;; We always, always read the .eld file.
16563 (gnus-message 5 "Reading %s..." ding-file)
16564 (let (gnus-newsrc-assoc)
16565 (condition-case nil
16566 (load ding-file t t t)
16567 (error
16568 (gnus-error 1 "Error in %s" ding-file)))
16569 (when gnus-newsrc-assoc
16570 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16571 (gnus-make-hashtable-from-newsrc-alist)
16572 (when (file-newer-than-file-p file ding-file)
16573 ;; Old format quick file
16574 (gnus-message 5 "Reading %s..." file)
16575 ;; The .el file is newer than the .eld file, so we read that one
16576 ;; as well.
16577 (gnus-read-old-newsrc-el-file file))))
16579 ;; Parse the old-style quick startup file
16580 (defun gnus-read-old-newsrc-el-file (file)
16581 (let (newsrc killed marked group m info)
16582 (prog1
16583 (let ((gnus-killed-assoc nil)
16584 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16585 (prog1
16586 (condition-case nil
16587 (load file t t t)
16588 (error nil))
16589 (setq newsrc gnus-newsrc-assoc
16590 killed gnus-killed-assoc
16591 marked gnus-marked-assoc)))
16592 (setq gnus-newsrc-alist nil)
16593 (while (setq group (pop newsrc))
16594 (if (setq info (gnus-get-info (car group)))
16595 (progn
16596 (gnus-info-set-read info (cddr group))
16597 (gnus-info-set-level
16598 info (if (nth 1 group) gnus-level-default-subscribed
16599 gnus-level-default-unsubscribed))
16600 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16601 (push (setq info
16602 (list (car group)
16603 (if (nth 1 group) gnus-level-default-subscribed
16604 gnus-level-default-unsubscribed)
16605 (cddr group)))
16606 gnus-newsrc-alist))
16607 ;; Copy marks into info.
16608 (when (setq m (assoc (car group) marked))
16609 (unless (nthcdr 3 info)
16610 (nconc info (list nil)))
16611 (gnus-info-set-marks
16612 info (list (cons 'tick (gnus-compress-sequence
16613 (sort (cdr m) '<) t))))))
16614 (setq newsrc killed)
16615 (while newsrc
16616 (setcar newsrc (caar newsrc))
16617 (setq newsrc (cdr newsrc)))
16618 (setq gnus-killed-list killed))
16619 ;; The .el file version of this variable does not begin with
16620 ;; "options", while the .eld version does, so we just add it if it
16621 ;; isn't there.
16622 (and
16623 gnus-newsrc-options
16624 (progn
16625 (and (not (string-match "^ *options" gnus-newsrc-options))
16626 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16627 (and (not (string-match "\n$" gnus-newsrc-options))
16628 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16629 ;; Finally, if we read some options lines, we parse them.
16630 (or (string= gnus-newsrc-options "")
16631 (gnus-newsrc-parse-options gnus-newsrc-options))))
16633 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16634 (gnus-make-hashtable-from-newsrc-alist)))
16636 (defun gnus-make-newsrc-file (file)
16637 "Make server dependent file name by catenating FILE and server host name."
16638 (let* ((file (expand-file-name file nil))
16639 (real-file (concat file "-" (nth 1 gnus-select-method))))
16640 (if (or (file-exists-p real-file)
16641 (file-exists-p (concat real-file ".el"))
16642 (file-exists-p (concat real-file ".eld")))
16643 real-file file)))
16645 (defun gnus-newsrc-to-gnus-format ()
16646 (setq gnus-newsrc-options "")
16647 (setq gnus-newsrc-options-n nil)
16649 (or gnus-active-hashtb
16650 (setq gnus-active-hashtb (make-vector 4095 0)))
16651 (let ((buf (current-buffer))
16652 (already-read (> (length gnus-newsrc-alist) 1))
16653 group subscribed options-symbol newsrc Options-symbol
16654 symbol reads num1)
16655 (goto-char (point-min))
16656 ;; We intern the symbol `options' in the active hashtb so that we
16657 ;; can `eq' against it later.
16658 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16659 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16661 (while (not (eobp))
16662 ;; We first read the first word on the line by narrowing and
16663 ;; then reading into `gnus-active-hashtb'. Most groups will
16664 ;; already exist in that hashtb, so this will save some string
16665 ;; space.
16666 (narrow-to-region
16667 (point)
16668 (progn (skip-chars-forward "^ \t!:\n") (point)))
16669 (goto-char (point-min))
16670 (setq symbol
16671 (and (/= (point-min) (point-max))
16672 (let ((obarray gnus-active-hashtb)) (read buf))))
16673 (widen)
16674 ;; Now, the symbol we have read is either `options' or a group
16675 ;; name. If it is an options line, we just add it to a string.
16676 (cond
16677 ((or (eq symbol options-symbol)
16678 (eq symbol Options-symbol))
16679 (setq gnus-newsrc-options
16680 ;; This concating is quite inefficient, but since our
16681 ;; thorough studies show that approx 99.37% of all
16682 ;; .newsrc files only contain a single options line, we
16683 ;; don't give a damn, frankly, my dear.
16684 (concat gnus-newsrc-options
16685 (buffer-substring
16686 (gnus-point-at-bol)
16687 ;; Options may continue on the next line.
16688 (or (and (re-search-forward "^[^ \t]" nil 'move)
16689 (progn (beginning-of-line) (point)))
16690 (point)))))
16691 (forward-line -1))
16692 (symbol
16693 ;; Group names can be just numbers.
16694 (when (numberp symbol)
16695 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16696 (or (boundp symbol) (set symbol nil))
16697 ;; It was a group name.
16698 (setq subscribed (= (following-char) ?:)
16699 group (symbol-name symbol)
16700 reads nil)
16701 (if (eolp)
16702 ;; If the line ends here, this is clearly a buggy line, so
16703 ;; we put point a the beginning of line and let the cond
16704 ;; below do the error handling.
16705 (beginning-of-line)
16706 ;; We skip to the beginning of the ranges.
16707 (skip-chars-forward "!: \t"))
16708 ;; We are now at the beginning of the list of read articles.
16709 ;; We read them range by range.
16710 (while
16711 (cond
16712 ((looking-at "[0-9]+")
16713 ;; We narrow and read a number instead of buffer-substring/
16714 ;; string-to-int because it's faster. narrow/widen is
16715 ;; faster than save-restriction/narrow, and save-restriction
16716 ;; produces a garbage object.
16717 (setq num1 (progn
16718 (narrow-to-region (match-beginning 0) (match-end 0))
16719 (read buf)))
16720 (widen)
16721 ;; If the next character is a dash, then this is a range.
16722 (if (= (following-char) ?-)
16723 (progn
16724 ;; We read the upper bound of the range.
16725 (forward-char 1)
16726 (if (not (looking-at "[0-9]+"))
16727 ;; This is a buggy line, by we pretend that
16728 ;; it's kinda OK. Perhaps the user should be
16729 ;; dinged?
16730 (setq reads (cons num1 reads))
16731 (setq reads
16732 (cons
16733 (cons num1
16734 (progn
16735 (narrow-to-region (match-beginning 0)
16736 (match-end 0))
16737 (read buf)))
16738 reads))
16739 (widen)))
16740 ;; It was just a simple number, so we add it to the
16741 ;; list of ranges.
16742 (setq reads (cons num1 reads)))
16743 ;; If the next char in ?\n, then we have reached the end
16744 ;; of the line and return nil.
16745 (/= (following-char) ?\n))
16746 ((= (following-char) ?\n)
16747 ;; End of line, so we end.
16748 nil)
16750 ;; Not numbers and not eol, so this might be a buggy
16751 ;; line...
16752 (or (eobp)
16753 ;; If it was eob instead of ?\n, we allow it.
16754 (progn
16755 ;; The line was buggy.
16756 (setq group nil)
16757 (gnus-error 3.1 "Mangled line: %s"
16758 (buffer-substring (gnus-point-at-bol)
16759 (gnus-point-at-eol)))))
16760 nil))
16761 ;; Skip past ", ". Spaces are illegal in these ranges, but
16762 ;; we allow them, because it's a common mistake to put a
16763 ;; space after the comma.
16764 (skip-chars-forward ", "))
16766 ;; We have already read .newsrc.eld, so we gently update the
16767 ;; data in the hash table with the information we have just
16768 ;; read.
16769 (when group
16770 (let ((info (gnus-get-info group))
16771 level)
16772 (if info
16773 ;; There is an entry for this file in the alist.
16774 (progn
16775 (gnus-info-set-read info (nreverse reads))
16776 ;; We update the level very gently. In fact, we
16777 ;; only change it if there's been a status change
16778 ;; from subscribed to unsubscribed, or vice versa.
16779 (setq level (gnus-info-level info))
16780 (cond ((and (<= level gnus-level-subscribed)
16781 (not subscribed))
16782 (setq level (if reads
16783 gnus-level-default-unsubscribed
16784 (1+ gnus-level-default-unsubscribed))))
16785 ((and (> level gnus-level-subscribed) subscribed)
16786 (setq level gnus-level-default-subscribed)))
16787 (gnus-info-set-level info level))
16788 ;; This is a new group.
16789 (setq info (list group
16790 (if subscribed
16791 gnus-level-default-subscribed
16792 (if reads
16793 (1+ gnus-level-subscribed)
16794 gnus-level-default-unsubscribed))
16795 (nreverse reads))))
16796 (setq newsrc (cons info newsrc))))))
16797 (forward-line 1))
16799 (setq newsrc (nreverse newsrc))
16801 (if (not already-read)
16803 ;; We now have two newsrc lists - `newsrc', which is what we
16804 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16805 ;; what we've read from .newsrc.eld. We have to merge these
16806 ;; lists. We do this by "attaching" any (foreign) groups in the
16807 ;; gnus-newsrc-alist to the (native) group that precedes them.
16808 (let ((rc (cdr gnus-newsrc-alist))
16809 (prev gnus-newsrc-alist)
16810 entry mentry)
16811 (while rc
16812 (or (null (nth 4 (car rc))) ; It's a native group.
16813 (assoc (caar rc) newsrc) ; It's already in the alist.
16814 (if (setq entry (assoc (caar prev) newsrc))
16815 (setcdr (setq mentry (memq entry newsrc))
16816 (cons (car rc) (cdr mentry)))
16817 (setq newsrc (cons (car rc) newsrc))))
16818 (setq prev rc
16819 rc (cdr rc)))))
16821 (setq gnus-newsrc-alist newsrc)
16822 ;; We make the newsrc hashtb.
16823 (gnus-make-hashtable-from-newsrc-alist)
16825 ;; Finally, if we read some options lines, we parse them.
16826 (or (string= gnus-newsrc-options "")
16827 (gnus-newsrc-parse-options gnus-newsrc-options))))
16829 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16830 ;; The return value will be a list on the form
16831 ;; ((regexp1 . ignore)
16832 ;; (regexp2 . subscribe)...)
16833 ;; When handling new newsgroups, groups that match a `ignore' regexp
16834 ;; will be ignored, and groups that match a `subscribe' regexp will be
16835 ;; subscribed. A line like
16836 ;; options -n !all rec.all
16837 ;; will lead to a list that looks like
16838 ;; (("^rec\\..+" . subscribe)
16839 ;; ("^.+" . ignore))
16840 ;; So all "rec.*" groups will be subscribed, while all the other
16841 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16842 ;; different from "options -n rec.all !all".
16843 (defun gnus-newsrc-parse-options (options)
16844 (let (out eol)
16845 (save-excursion
16846 (gnus-set-work-buffer)
16847 (insert (regexp-quote options))
16848 ;; First we treat all continuation lines.
16849 (goto-char (point-min))
16850 (while (re-search-forward "\n[ \t]+" nil t)
16851 (replace-match " " t t))
16852 ;; Then we transform all "all"s into ".+"s.
16853 (goto-char (point-min))
16854 (while (re-search-forward "\\ball\\b" nil t)
16855 (replace-match ".+" t t))
16856 (goto-char (point-min))
16857 ;; We remove all other options than the "-n" ones.
16858 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16859 (replace-match " ")
16860 (forward-char -1))
16861 (goto-char (point-min))
16863 ;; We are only interested in "options -n" lines - we
16864 ;; ignore the other option lines.
16865 (while (re-search-forward "[ \t]-n" nil t)
16866 (setq eol
16867 (or (save-excursion
16868 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16869 (- (point) 2)))
16870 (gnus-point-at-eol)))
16871 ;; Search for all "words"...
16872 (while (re-search-forward "[^ \t,\n]+" eol t)
16873 (if (= (char-after (match-beginning 0)) ?!)
16874 ;; If the word begins with a bang (!), this is a "not"
16875 ;; spec. We put this spec (minus the bang) and the
16876 ;; symbol `ignore' into the list.
16877 (setq out (cons (cons (concat
16878 "^" (buffer-substring
16879 (1+ (match-beginning 0))
16880 (match-end 0)))
16881 'ignore) out))
16882 ;; There was no bang, so this is a "yes" spec.
16883 (setq out (cons (cons (concat "^" (match-string 0))
16884 'subscribe) out)))))
16886 (setq gnus-newsrc-options-n out))))
16888 (defun gnus-save-newsrc-file (&optional force)
16889 "Save .newsrc file."
16890 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16891 ;; from the variable gnus-newsrc-alist.
16892 (when (and (or gnus-newsrc-alist gnus-killed-list)
16893 gnus-current-startup-file)
16894 (save-excursion
16895 (if (and (or gnus-use-dribble-file gnus-slave)
16896 (not force)
16897 (or (not gnus-dribble-buffer)
16898 (not (buffer-name gnus-dribble-buffer))
16899 (zerop (save-excursion
16900 (set-buffer gnus-dribble-buffer)
16901 (buffer-size)))))
16902 (gnus-message 4 "(No changes need to be saved)")
16903 (run-hooks 'gnus-save-newsrc-hook)
16904 (if gnus-slave
16905 (gnus-slave-save-newsrc)
16906 ;; Save .newsrc.
16907 (when gnus-save-newsrc-file
16908 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16909 (gnus-gnus-to-newsrc-format)
16910 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16911 ;; Save .newsrc.eld.
16912 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16913 (make-local-variable 'version-control)
16914 (setq version-control 'never)
16915 (setq buffer-file-name
16916 (concat gnus-current-startup-file ".eld"))
16917 (setq default-directory (file-name-directory buffer-file-name))
16918 (gnus-add-current-to-buffer-list)
16919 (buffer-disable-undo (current-buffer))
16920 (erase-buffer)
16921 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16922 (gnus-gnus-to-quick-newsrc-format)
16923 (run-hooks 'gnus-save-quick-newsrc-hook)
16924 (save-buffer)
16925 (kill-buffer (current-buffer))
16926 (gnus-message
16927 5 "Saving %s.eld...done" gnus-current-startup-file))
16928 (gnus-dribble-delete-file)
16929 (gnus-group-set-mode-line)))))
16931 (defun gnus-gnus-to-quick-newsrc-format ()
16932 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16933 (insert ";; Gnus startup file.\n")
16934 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16935 (insert ";; to read .newsrc.\n")
16936 (insert "(setq gnus-newsrc-file-version "
16937 (prin1-to-string gnus-version) ")\n")
16938 (let ((variables
16939 (if gnus-save-killed-list gnus-variable-list
16940 ;; Remove the `gnus-killed-list' from the list of variables
16941 ;; to be saved, if required.
16942 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16943 ;; Peel off the "dummy" group.
16944 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16945 variable)
16946 ;; Insert the variables into the file.
16947 (while variables
16948 (when (and (boundp (setq variable (pop variables)))
16949 (symbol-value variable))
16950 (insert "(setq " (symbol-name variable) " '")
16951 (prin1 (symbol-value variable) (current-buffer))
16952 (insert ")\n")))))
16954 (defun gnus-gnus-to-newsrc-format ()
16955 ;; Generate and save the .newsrc file.
16956 (save-excursion
16957 (set-buffer (create-file-buffer gnus-current-startup-file))
16958 (let ((newsrc (cdr gnus-newsrc-alist))
16959 (standard-output (current-buffer))
16960 info ranges range method)
16961 (setq buffer-file-name gnus-current-startup-file)
16962 (setq default-directory (file-name-directory buffer-file-name))
16963 (buffer-disable-undo (current-buffer))
16964 (erase-buffer)
16965 ;; Write options.
16966 (if gnus-newsrc-options (insert gnus-newsrc-options))
16967 ;; Write subscribed and unsubscribed.
16968 (while (setq info (pop newsrc))
16969 ;; Don't write foreign groups to .newsrc.
16970 (when (or (null (setq method (gnus-info-method info)))
16971 (equal method "native")
16972 (gnus-server-equal method gnus-select-method))
16973 (insert (gnus-info-group info)
16974 (if (> (gnus-info-level info) gnus-level-subscribed)
16975 "!" ":"))
16976 (when (setq ranges (gnus-info-read info))
16977 (insert " ")
16978 (if (not (listp (cdr ranges)))
16979 (if (= (car ranges) (cdr ranges))
16980 (princ (car ranges))
16981 (princ (car ranges))
16982 (insert "-")
16983 (princ (cdr ranges)))
16984 (while (setq range (pop ranges))
16985 (if (or (atom range) (= (car range) (cdr range)))
16986 (princ (or (and (atom range) range) (car range)))
16987 (princ (car range))
16988 (insert "-")
16989 (princ (cdr range)))
16990 (if ranges (insert ",")))))
16991 (insert "\n")))
16992 (make-local-variable 'version-control)
16993 (setq version-control 'never)
16994 ;; It has been reported that sometime the modtime on the .newsrc
16995 ;; file seems to be off. We really do want to overwrite it, so
16996 ;; we clear the modtime here before saving. It's a bit odd,
16997 ;; though...
16998 ;; sometimes the modtime clear isn't sufficient. most brute force:
16999 ;; delete the silly thing entirely first. but this fails to provide
17000 ;; such niceties as .newsrc~ creation.
17001 (if gnus-modtime-botch
17002 (delete-file gnus-startup-file)
17003 (clear-visited-file-modtime))
17004 (run-hooks 'gnus-save-standard-newsrc-hook)
17005 (save-buffer)
17006 (kill-buffer (current-buffer)))))
17010 ;;; Slave functions.
17013 (defun gnus-slave-save-newsrc ()
17014 (save-excursion
17015 (set-buffer gnus-dribble-buffer)
17016 (let ((slave-name
17017 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
17018 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
17020 (defun gnus-master-read-slave-newsrc ()
17021 (let ((slave-files
17022 (directory-files
17023 (file-name-directory gnus-current-startup-file)
17024 t (concat
17025 "^" (regexp-quote
17026 (concat
17027 (file-name-nondirectory gnus-current-startup-file)
17028 "-slave-")))
17030 file)
17031 (if (not slave-files)
17032 () ; There are no slave files to read.
17033 (gnus-message 7 "Reading slave newsrcs...")
17034 (save-excursion
17035 (set-buffer (get-buffer-create " *gnus slave*"))
17036 (buffer-disable-undo (current-buffer))
17037 (setq slave-files
17038 (sort (mapcar (lambda (file)
17039 (list (nth 5 (file-attributes file)) file))
17040 slave-files)
17041 (lambda (f1 f2)
17042 (or (< (caar f1) (caar f2))
17043 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
17044 (while slave-files
17045 (erase-buffer)
17046 (setq file (nth 1 (car slave-files)))
17047 (insert-file-contents file)
17048 (if (condition-case ()
17049 (progn
17050 (eval-buffer (current-buffer))
17052 (error
17053 (gnus-error 3.2 "Possible error in %s" file)
17054 nil))
17055 (or gnus-slave ; Slaves shouldn't delete these files.
17056 (condition-case ()
17057 (delete-file file)
17058 (error nil))))
17059 (setq slave-files (cdr slave-files))))
17060 (gnus-message 7 "Reading slave newsrcs...done"))))
17064 ;;; Group description.
17067 (defun gnus-read-all-descriptions-files ()
17068 (let ((methods (cons gnus-select-method
17069 (nconc
17070 (when (gnus-archive-server-wanted-p)
17071 (list "archive"))
17072 gnus-secondary-select-methods))))
17073 (while methods
17074 (gnus-read-descriptions-file (car methods))
17075 (setq methods (cdr methods)))
17078 (defun gnus-read-descriptions-file (&optional method)
17079 (let ((method (or method gnus-select-method))
17080 group)
17081 (when (stringp method)
17082 (setq method (gnus-server-to-method method)))
17083 ;; We create the hashtable whether we manage to read the desc file
17084 ;; to avoid trying to re-read after a failed read.
17085 (or gnus-description-hashtb
17086 (setq gnus-description-hashtb
17087 (gnus-make-hashtable (length gnus-active-hashtb))))
17088 ;; Mark this method's desc file as read.
17089 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
17090 gnus-description-hashtb)
17092 (gnus-message 5 "Reading descriptions file via %s..." (car method))
17093 (cond
17094 ((not (gnus-check-server method))
17095 (gnus-message 1 "Couldn't open server")
17096 nil)
17097 ((not (gnus-request-list-newsgroups method))
17098 (gnus-message 1 "Couldn't read newsgroups descriptions")
17099 nil)
17101 (save-excursion
17102 (save-restriction
17103 (set-buffer nntp-server-buffer)
17104 (goto-char (point-min))
17105 (when (or (search-forward "\n.\n" nil t)
17106 (goto-char (point-max)))
17107 (beginning-of-line)
17108 (narrow-to-region (point-min) (point)))
17109 ;; If these are groups from a foreign select method, we insert the
17110 ;; group prefix in front of the group names.
17111 (and method (not (gnus-server-equal
17112 (gnus-server-get-method nil method)
17113 (gnus-server-get-method nil gnus-select-method)))
17114 (let ((prefix (gnus-group-prefixed-name "" method)))
17115 (goto-char (point-min))
17116 (while (and (not (eobp))
17117 (progn (insert prefix)
17118 (zerop (forward-line 1)))))))
17119 (goto-char (point-min))
17120 (while (not (eobp))
17121 ;; If we get an error, we set group to 0, which is not a
17122 ;; symbol...
17123 (setq group
17124 (condition-case ()
17125 (let ((obarray gnus-description-hashtb))
17126 ;; Group is set to a symbol interned in this
17127 ;; hash table.
17128 (read nntp-server-buffer))
17129 (error 0)))
17130 (skip-chars-forward " \t")
17131 ;; ... which leads to this line being effectively ignored.
17132 (and (symbolp group)
17133 (set group (buffer-substring
17134 (point) (progn (end-of-line) (point)))))
17135 (forward-line 1))))
17136 (gnus-message 5 "Reading descriptions file...done")
17137 t))))
17139 (defun gnus-group-get-description (group)
17140 "Get the description of a group by sending XGTITLE to the server."
17141 (when (gnus-request-group-description group)
17142 (save-excursion
17143 (set-buffer nntp-server-buffer)
17144 (goto-char (point-min))
17145 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17146 (match-string 1)))))
17150 ;;; Buffering of read articles.
17153 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17154 (defvar gnus-backlog-articles nil)
17155 (defvar gnus-backlog-hashtb nil)
17157 (defun gnus-backlog-buffer ()
17158 "Return the backlog buffer."
17159 (or (get-buffer gnus-backlog-buffer)
17160 (save-excursion
17161 (set-buffer (get-buffer-create gnus-backlog-buffer))
17162 (buffer-disable-undo (current-buffer))
17163 (setq buffer-read-only t)
17164 (gnus-add-current-to-buffer-list)
17165 (get-buffer gnus-backlog-buffer))))
17167 (defun gnus-backlog-setup ()
17168 "Initialize backlog variables."
17169 (unless gnus-backlog-hashtb
17170 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17172 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17174 (defun gnus-backlog-shutdown ()
17175 "Clear all backlog variables and buffers."
17176 (when (get-buffer gnus-backlog-buffer)
17177 (kill-buffer gnus-backlog-buffer))
17178 (setq gnus-backlog-hashtb nil
17179 gnus-backlog-articles nil))
17181 (defun gnus-backlog-enter-article (group number buffer)
17182 (gnus-backlog-setup)
17183 (let ((ident (intern (concat group ":" (int-to-string number))
17184 gnus-backlog-hashtb))
17186 (if (memq ident gnus-backlog-articles)
17187 () ; It's already kept.
17188 ;; Remove the oldest article, if necessary.
17189 (and (numberp gnus-keep-backlog)
17190 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17191 (gnus-backlog-remove-oldest-article))
17192 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17193 ;; Insert the new article.
17194 (save-excursion
17195 (set-buffer (gnus-backlog-buffer))
17196 (let (buffer-read-only)
17197 (goto-char (point-max))
17198 (or (bolp) (insert "\n"))
17199 (setq b (point))
17200 (insert-buffer-substring buffer)
17201 ;; Tag the beginning of the article with the ident.
17202 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17204 (defun gnus-backlog-remove-oldest-article ()
17205 (save-excursion
17206 (set-buffer (gnus-backlog-buffer))
17207 (goto-char (point-min))
17208 (if (zerop (buffer-size))
17209 () ; The buffer is empty.
17210 (let ((ident (get-text-property (point) 'gnus-backlog))
17211 buffer-read-only)
17212 ;; Remove the ident from the list of articles.
17213 (when ident
17214 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17215 ;; Delete the article itself.
17216 (delete-region
17217 (point) (next-single-property-change
17218 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17220 (defun gnus-backlog-remove-article (group number)
17221 "Remove article NUMBER in GROUP from the backlog."
17222 (when (numberp number)
17223 (gnus-backlog-setup)
17224 (let ((ident (intern (concat group ":" (int-to-string number))
17225 gnus-backlog-hashtb))
17226 beg end)
17227 (when (memq ident gnus-backlog-articles)
17228 ;; It was in the backlog.
17229 (save-excursion
17230 (set-buffer (gnus-backlog-buffer))
17231 (let (buffer-read-only)
17232 (when (setq beg (text-property-any
17233 (point-min) (point-max) 'gnus-backlog
17234 ident))
17235 ;; Find the end (i. e., the beginning of the next article).
17236 (setq end
17237 (next-single-property-change
17238 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17239 (delete-region beg end)
17240 ;; Return success.
17241 t)))))))
17243 (defun gnus-backlog-request-article (group number buffer)
17244 (when (numberp number)
17245 (gnus-backlog-setup)
17246 (let ((ident (intern (concat group ":" (int-to-string number))
17247 gnus-backlog-hashtb))
17248 beg end)
17249 (when (memq ident gnus-backlog-articles)
17250 ;; It was in the backlog.
17251 (save-excursion
17252 (set-buffer (gnus-backlog-buffer))
17253 (if (not (setq beg (text-property-any
17254 (point-min) (point-max) 'gnus-backlog
17255 ident)))
17256 ;; It wasn't in the backlog after all.
17257 (ignore
17258 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17259 ;; Find the end (i. e., the beginning of the next article).
17260 (setq end
17261 (next-single-property-change
17262 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17263 (let ((buffer-read-only nil))
17264 (erase-buffer)
17265 (insert-buffer-substring gnus-backlog-buffer beg end)
17266 t)))))
17268 ;; Allow redefinition of Gnus functions.
17270 (gnus-ems-redefine)
17272 (provide 'gnus)
17274 ;;; gnus.el ends here