1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;; Although Gnus looks suspiciously like GNUS, it isn't quite the same
27 ;; beast. Most internal structures have been changed. If you have
28 ;; written packages that depend on any of the hash tables,
29 ;; `gnus-newsrc-alist', `gnus-killed-assoc', marked lists, the .newsrc
30 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
31 ;; dependence on the buffers having a certain format, your code will
36 (eval '(run-hooks 'gnus-load-hook))
42 ;; Site dependent variables. These variables should be defined in
45 (defvar gnus-default-nntp-server nil
46 "Specify a default NNTP server.
47 This variable should be defined in paths.el, and should never be set
49 If you want to change servers, you should use `gnus-select-method'.
50 See the documentation to that variable.")
52 (defconst gnus-backup-default-subscribed-newsgroups
53 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
54 "Default default new newsgroups the first time Gnus is run.
55 Should be set in paths.el, and shouldn't be touched by the user.")
57 (defvar gnus-local-domain nil
58 "Local domain name without a host name.
59 The DOMAINNAME environment variable is used instead if it is defined.
60 If the `system-name' function returns the full Internet name, there is
61 no need to set this variable.")
63 (defvar gnus-local-organization nil
64 "String with a description of what organization (if any) the user belongs to.
65 The ORGANIZATION environment variable is used instead if it is defined.
66 If this variable contains a function, this function will be called
67 with the current newsgroup name as the argument. The function should
70 In any case, if the string (either in the variable, in the environment
71 variable, or returned by the function) is a file name, the contents of
72 this file will be used as the organization.")
74 (defvar gnus-use-generic-from nil
75 "If nil, the full host name will be the system name prepended to the domain name.
76 If this is a string, the full host name will be this string.
77 If this is non-nil, non-string, the domain name will be used as the
80 (defvar gnus-use-generic-path nil
81 "If nil, use the NNTP server name in the Path header.
82 If stringp, use this; if non-nil, use no host name (user name only).")
85 ;; Customization variables
87 ;; Don't touch this variable.
88 (defvar gnus-nntp-service "nntp"
89 "*NNTP service name (\"nntp\" or 119).
90 This is an obsolete variable, which is scarcely used. If you use an
91 nntp server for your newsgroup and want to change the port number
92 used to 899, you would say something along these lines:
94 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
96 (defvar gnus-nntpserver-file "/etc/nntpserver"
97 "*A file with only the name of the nntp server in it.")
99 ;; This function is used to check both the environment variable
100 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
101 ;; an nntp server name default.
102 (defun gnus-getenv-nntpserver ()
103 (or (getenv "NNTPSERVER")
104 (and (file-readable-p gnus-nntpserver-file)
106 (set-buffer (get-buffer-create " *gnus nntp*"))
107 (buffer-disable-undo (current-buffer))
108 (insert-file-contents gnus-nntpserver-file)
109 (let ((name (buffer-string)))
111 (if (string-match "^[ \t\n]*$" name)
114 (kill-buffer (current-buffer))))))))
116 (defvar gnus-select-method
118 (list 'nntp (or (condition-case ()
119 (gnus-getenv-nntpserver)
121 (if (and gnus-default-nntp-server
122 (not (string= gnus-default-nntp-server "")))
123 gnus-default-nntp-server)
125 (if (or (null gnus-nntp-service)
126 (equal gnus-nntp-service "nntp"))
128 (list gnus-nntp-service)))
129 "*Default method for selecting a newsgroup.
130 This variable should be a list, where the first element is how the
131 news is to be fetched, the second is the address.
133 For instance, if you want to get your news via NNTP from
134 \"flab.flab.edu\", you could say:
136 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
138 If you want to use your local spool, say:
140 (setq gnus-select-method (list 'nnspool (system-name)))
142 If you use this variable, you must set `gnus-nntp-server' to nil.
144 There is a lot more to know about select methods and virtual servers -
145 see the manual for details.")
147 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
148 (defvar gnus-post-method nil
149 "*Preferred method for posting USENET news.
150 If this variable is nil, Gnus will use the current method to decide
151 which method to use when posting. If it is non-nil, it will override
152 the current method. This method will not be used in mail groups and
153 the like, only in \"real\" newsgroups.
155 The value must be a valid method as discussed in the documentation of
156 `gnus-select-method'.")
158 (defvar gnus-refer-article-method nil
159 "*Preferred method for fetching an article by Message-ID.
160 If you are reading news from the local spool (with nnspool), fetching
161 articles by Message-ID is painfully slow. By setting this method to an
162 nntp method, you might get acceptable results.
164 The value of this variable must be a valid select method as discussed
165 in the documentation of `gnus-select-method'")
167 (defvar gnus-secondary-select-methods nil
168 "*A list of secondary methods that will be used for reading news.
169 This is a list where each element is a complete select method (see
170 `gnus-select-method').
172 If, for instance, you want to read your mail with the nnml backend,
173 you could set this variable:
175 (setq gnus-secondary-select-methods '((nnml \"\")))")
177 (defvar gnus-secondary-servers nil
178 "*List of NNTP servers that the user can choose between interactively.
179 To make Gnus query you for a server, you have to give `gnus' a
180 non-numeric prefix - `C-u M-x gnus', in short.")
182 (defvar gnus-nntp-server nil
183 "*The name of the host running the NNTP server.
184 This variable is semi-obsolete. Use the `gnus-select-method'
187 (defvar gnus-startup-file "~/.newsrc"
188 "*Your `.newsrc' file.
189 `.newsrc-SERVER' will be used instead if that exists.")
191 (defvar gnus-init-file "~/.gnus"
192 "*Your Gnus elisp startup file.
193 If a file with the .el or .elc suffixes exist, it will be read
196 (defvar gnus-group-faq-directory
197 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
198 "/ftp@ftp.uu.net:/usenet/news.answers/"
199 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
200 "/ftp@rtfm.mit.edu:/pub/usenet/news.answers/"
201 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
202 "/ftp@ftp.Germany.EU.net:/pub/newsarchive/news.answers/"
203 "/ftp@ftp.sunet.se:/pub/usenet/"
204 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
205 "/ftp@hwarang.postech.ac.kr:/pub/usenet/news.answers/"
206 "/ftp@ftp.hk.super.net:/mirror/faqs/")
207 "*Directory where the group FAQs are stored.
208 This will most commonly be on a remote machine, and the file will be
211 This variable can also be a list of directories. In that case, the
212 first element in the list will be used by default, and the others will
213 be used as backup sites.
215 Note that Gnus uses an aol machine as the default directory. If this
216 feels fundamentally unclean, just think of it as a way to finally get
217 something of value back from them.
219 If the default site is too slow, try one of these:
221 North America: ftp.uu.net /usenet/news.answers
222 mirrors.aol.com /pub/rtfm/usenet
223 ftp.seas.gwu.edu /pub/rtfm
224 rtfm.mit.edu /pub/usenet/news.answers
225 Europe: ftp.uni-paderborn.de /pub/FAQ
226 ftp.Germany.EU.net /pub/newsarchive/news.answers
227 ftp.sunet.se /pub/usenet
228 Asia: nctuccca.edu.tw /USENET/FAQ
229 hwarang.postech.ac.kr /pub/usenet/news.answers
230 ftp.hk.super.net /mirror/faqs")
232 (defvar gnus-group-archive-directory
233 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
234 "*The address of the (ding) archives.")
236 (defvar gnus-group-recent-archive-directory
237 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
238 "*The address of the most recent (ding) articles.")
240 (defvar gnus-default-subscribed-newsgroups nil
241 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
242 It should be a list of strings.
243 If it is `t', Gnus will not do anything special the first time it is
244 started; it'll just use the normal newsgroups subscription methods.")
246 (defvar gnus-use-cross-reference t
247 "*Non-nil means that cross referenced articles will be marked as read.
248 If nil, ignore cross references. If t, mark articles as read in
249 subscribed newsgroups. If neither t nor nil, mark as read in all
252 (defvar gnus-use-dribble-file t
253 "*Non-nil means that Gnus will use a dribble file to store user updates.
254 If Emacs should crash without saving the .newsrc files, complete
255 information can be restored from the dribble file.")
257 (defvar gnus-dribble-directory nil
258 "*The directory where dribble files will be saved.
259 If this variable is nil, the directory where the .newsrc files are
260 saved will be used.")
262 (defvar gnus-asynchronous nil
263 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
265 (defvar gnus-score-file-single-match-alist nil
266 "*Alist mapping regexps to lists of score files.
267 Each element of this alist should be of the form
268 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
270 If the name of a group is matched by REGEXP, the corresponding scorefiles
271 will be used for that group.
272 The first match found is used, subsequent matching entries are ignored (to
273 use multiple matches, see gnus-score-file-multiple-match-alist).
275 These score files are loaded in addition to any files returned by
276 gnus-score-find-score-files-function (which see).")
278 (defvar gnus-score-file-multiple-match-alist nil
279 "*Alist mapping regexps to lists of score files.
280 Each element of this alist should be of the form
281 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
283 If the name of a group is matched by REGEXP, the corresponding scorefiles
284 will be used for that group.
285 If multiple REGEXPs match a group, the score files corresponding to each
286 match will be used (for only one match to be used, see
287 gnus-score-file-single-match-alist).
289 These score files are loaded in addition to any files returned by
290 gnus-score-find-score-files-function (which see).")
292 (defvar gnus-score-file-suffix "SCORE"
293 "*Suffix of the score files.")
295 (defvar gnus-adaptive-file-suffix "ADAPT"
296 "*Suffix of the adaptive score files.")
298 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
299 "*Function used to find score files.
300 The function will be called with the group name as the argument, and
301 should return a list of score files to apply to that group. The score
302 files do not actually have to exist.
304 Predefined values are:
306 gnus-score-find-single: Only apply the group's own score file.
307 gnus-score-find-hierarchical: Also apply score files from parent groups.
308 gnus-score-find-bnews: Apply score files whose names matches.
310 See the documentation to these functions for more information.
312 This variable can also be a list of functions to be called. Each
313 function should either return a list of score files, or a list of
316 (defvar gnus-score-interactive-default-score 1000
317 "*Scoring commands will raise/lower the score with this number as the default.")
319 (defvar gnus-large-newsgroup 200
320 "*The number of articles which indicates a large newsgroup.
321 If the number of articles in a newsgroup is greater than this value,
322 confirmation is required for selecting the newsgroup.")
324 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
325 (defvar gnus-no-groups-message "No news is horrible news"
326 "*Message displayed by Gnus when no groups are available.")
328 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
329 "*Non-nil means that the default name of a file to save articles in is the group name.
330 If it's nil, the directory form of the group name is used instead.
332 If this variable is a list, and the list contains the element
333 `not-score', long file names will not be used for score files; if it
334 contains the element `not-save', long file names will not be used for
335 saving; and if it contains the element `not-kill', long file names
336 will not be used for kill files.")
338 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
339 "*Name of the directory articles will be saved in (default \"~/News\").
340 Initialized from the SAVEDIR environment variable.")
342 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
343 "*Name of the directory where kill files will be stored (default \"~/News\").
344 Initialized from the SAVEDIR environment variable.")
346 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
347 "*A function to save articles in your favorite format.
348 The function must be interactively callable (in other words, it must
349 be an Emacs command).
351 Gnus provides the following functions:
353 * gnus-summary-save-in-rmail (Rmail format)
354 * gnus-summary-save-in-mail (Unix mail format)
355 * gnus-summary-save-in-folder (MH folder)
356 * gnus-summary-save-in-file (article format).
357 * gnus-summary-save-in-vm (use VM's folder format).")
359 (defvar gnus-prompt-before-saving 'always
360 "*This variable says how much prompting is to be done when saving articles.
361 If it is nil, no prompting will be done, and the articles will be
362 saved to the default files. If this variable is `always', each and
363 every article that is saved will be preceded by a prompt, even when
364 saving large batches of articles. If this variable is neither nil not
365 `always', there the user will be prompted once for a file name for
366 each invocation of the saving commands.")
368 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
369 "*A function generating a file name to save articles in Rmail format.
370 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
372 (defvar gnus-mail-save-name (function gnus-plain-save-name)
373 "*A function generating a file name to save articles in Unix mail format.
374 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
376 (defvar gnus-folder-save-name (function gnus-folder-save-name)
377 "*A function generating a file name to save articles in MH folder.
378 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
380 (defvar gnus-file-save-name (function gnus-numeric-save-name)
381 "*A function generating a file name to save articles in article format.
382 The function is called with NEWSGROUP, HEADERS, and optional
385 (defvar gnus-split-methods nil
386 "*Variable used to suggest where articles are to be saved.
387 The syntax of this variable is the same as `nnmail-split-methods'.
389 For instance, if you would like to save articles related to Gnus in
390 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
391 you could set this variable to something like:
393 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
394 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
396 (defvar gnus-save-score nil
397 "*If non-nil, save group scoring info.")
399 (defvar gnus-use-adaptive-scoring nil
400 "*If non-nil, use some adaptive scoring scheme.")
402 (defvar gnus-use-cache nil
403 "*If non-nil, Gnus will cache (some) articles locally.")
405 (defvar gnus-use-scoring t
406 "*If non-nil, enable scoring.")
408 (defvar gnus-fetch-old-headers nil
409 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
410 If an unread article in the group refers to an older, already read (or
411 just marked as read) article, the old article will not normally be
412 displayed in the Summary buffer. If this variable is non-nil, Gnus
413 will attempt to grab the headers to the old articles, and thereby
414 build complete threads. If it has the value `some', only enough
415 headers to connect otherwise loose threads will be displayed.
416 This variable can also be a number. In that case, no more than that
417 number of old headers will be fetched.
419 The server has to support NOV for any of this to work.")
422 ;(defvar gnus-visual t
423 ; "*If non-nil, will do various highlighting.
424 ;If nil, no mouse highlights (or any other highlights) will be
425 ;performed. This might speed up Gnus some when generating large group
426 ;and summary buffers.")
428 (defvar gnus-novice-user t
429 "*Non-nil means that you are a usenet novice.
430 If non-nil, verbose messages may be displayed and confirmations may be
433 (defvar gnus-expert-user nil
434 "*Non-nil means that you will never be asked for confirmation about anything.
435 And that means *anything*.")
437 (defvar gnus-verbose 7
438 "*Integer that says how verbose Gnus should be.
439 The higher the number, the more messages Gnus will flash to say what
440 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
441 display most important messages; and at ten, Gnus will keep on
442 jabbering all the time.")
444 (defvar gnus-keep-same-level nil
445 "*Non-nil means that the next newsgroup after the current will be on the same level.
446 When you type, for instance, `n' after reading the last article in the
447 current newsgroup, you will go to the next newsgroup. If this variable
448 is nil, the next newsgroup will be the next from the group
450 If this variable is non-nil, Gnus will either put you in the
451 next newsgroup with the same level, or, if no such newsgroup is
452 available, the next newsgroup with the lowest possible level higher
453 than the current level.
454 If this variable is `best', Gnus will make the next newsgroup the one
455 with the best level.")
457 (defvar gnus-summary-make-false-root 'adopt
458 "*nil means that Gnus won't gather loose threads.
459 If the root of a thread has expired or been read in a previous
460 session, the information necessary to build a complete thread has been
461 lost. Instead of having many small sub-threads from this original thread
462 scattered all over the summary buffer, Gnus can gather them.
464 If non-nil, Gnus will try to gather all loose sub-threads from an
465 original thread into one large thread.
467 If this variable is non-nil, it should be one of `none', `adopt',
470 If this variable is `none', Gnus will not make a false root, but just
471 present the sub-threads after another.
472 If this variable is `dummy', Gnus will create a dummy root that will
473 have all the sub-threads as children.
474 If this variable is `adopt', Gnus will make one of the \"children\"
475 the parent and mark all the step-children as such.
476 If this variable is `empty', the \"children\" are printed with empty
477 subject fields. (Or rather, they will be printed with a string
478 given by the `gnus-summary-same-subject' variable.)")
480 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
481 "*A regexp to match subjects to be excluded from loose thread gathering.
482 As loose thread gathering is done on subjects only, that means that
483 there can be many false gatherings performed. By rooting out certain
484 common subjects, gathering might become saner.")
486 (defvar gnus-summary-gather-subject-limit nil
487 "*Maximum length of subject comparisons when gathering loose threads.
488 Use nil to compare full subjects. Setting this variable to a low
489 number will help gather threads that have been corrupted by
490 newsreaders chopping off subject lines, but it might also mean that
491 unrelated articles that have subject that happen to begin with the
492 same few characters will be incorrectly gathered.
494 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
495 comparing subjects.")
497 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
498 (defvar gnus-summary-same-subject ""
499 "*String indicating that the current article has the same subject as the previous.
500 This variable will only be used if the value of
501 `gnus-summary-make-false-root' is `empty'.")
503 (defvar gnus-summary-goto-unread t
504 "*If non-nil, marking commands will go to the next unread article.")
506 (defvar gnus-group-goto-unread t
507 "*If non-nil, movement commands will go to the next unread and subscribed group.")
509 (defvar gnus-check-new-newsgroups t
510 "*Non-nil means that Gnus will add new newsgroups at startup.
511 If this variable is `ask-server', Gnus will ask the server for new
512 groups since the last time it checked. This means that the killed list
513 is no longer necessary, so you could set `gnus-save-killed-list' to
516 A variant is to have this variable be a list of select methods. Gnus
517 will then use the `ask-server' method on all these select methods to
518 query for new groups from all those servers.
521 (setq gnus-check-new-newsgroups
522 '((nntp \"some.server\") (nntp \"other.server\")))
524 If this variable is nil, then you have to tell Gnus explicitly to
525 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
527 (defvar gnus-check-bogus-newsgroups nil
528 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
529 If this variable is nil, then you have to tell Gnus explicitly to
530 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
532 (defvar gnus-read-active-file t
533 "*Non-nil means that Gnus will read the entire active file at startup.
534 If this variable is nil, Gnus will only know about the groups in your
537 If this variable is `some', Gnus will try to only read the relevant
538 parts of the active file from the server. Not all servers support
539 this, and it might be quite slow with other servers, but this should
540 generally be faster than both the t and nil value.
542 If you set this variable to nil or `some', you probably still want to
543 be told about new newsgroups that arrive. To do that, set
544 `gnus-check-new-newsgroups' to `ask-server'. This may not work
545 properly with all servers.")
547 (defvar gnus-level-subscribed 5
548 "*Groups with levels less than or equal to this variable are subscribed.")
550 (defvar gnus-level-unsubscribed 7
551 "*Groups with levels less than or equal to this variable are unsubscribed.
552 Groups with levels less than `gnus-level-subscribed', which should be
553 less than this variable, are subscribed.")
555 (defvar gnus-level-zombie 8
556 "*Groups with this level are zombie groups.")
558 (defvar gnus-level-killed 9
559 "*Groups with this level are killed.")
561 (defvar gnus-level-default-subscribed 3
562 "*New subscribed groups will be subscribed at this level.")
564 (defvar gnus-level-default-unsubscribed 6
565 "*New unsubscribed groups will be unsubscribed at this level.")
567 (defvar gnus-activate-foreign-newsgroups 4
568 "*If nil, Gnus will not check foreign newsgroups at startup.
569 If it is non-nil, it should be a number between one and nine. Foreign
570 newsgroups that have a level lower or equal to this number will be
571 activated on startup. For instance, if you want to active all
572 subscribed newsgroups, but not the rest, you'd set this variable to
573 `gnus-level-subscribed'.
575 If you subscribe to lots of newsgroups from different servers, startup
576 might take a while. By setting this variable to nil, you'll save time,
577 but you won't be told how many unread articles there are in the
580 (defvar gnus-save-newsrc-file t
581 "*Non-nil means that Gnus will save the `.newsrc' file.
582 Gnus always saves its own startup file, which is called
583 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
584 be readily understood by other newsreaders. If you don't plan on
585 using other newsreaders, set this variable to nil to save some time on
588 (defvar gnus-save-killed-list t
589 "*If non-nil, save the list of killed groups to the startup file.
590 This will save both time (when starting and quitting) and space (both
591 memory and disk), but it will also mean that Gnus has no record of
592 which groups are new and which are old, so the automatic new
593 newsgroups subscription methods become meaningless. You should always
594 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
597 (defvar gnus-interactive-catchup t
598 "*If non-nil, require your confirmation when catching up a group.")
600 (defvar gnus-interactive-post t
601 "*If non-nil, group name will be asked for when posting.")
603 (defvar gnus-interactive-exit t
604 "*If non-nil, require your confirmation when exiting Gnus.")
606 (defvar gnus-kill-killed t
607 "*If non-nil, Gnus will apply kill files to already killed articles.
608 If it is nil, Gnus will never apply kill files to articles that have
609 already been through the scoring process, which might very well save lots
612 (defvar gnus-extract-address-components 'gnus-extract-address-components
613 "*Function for extracting address components from a From header.
614 Two pre-defined function exist: `gnus-extract-address-components',
615 which is the default, quite fast, and too simplistic solution, and
616 `mail-extract-address-components', which works much better, but is
619 (defvar gnus-summary-default-score 0
620 "*Default article score level.
621 If this variable is nil, scoring will be disabled.")
623 (defvar gnus-summary-zcore-fuzz 0
624 "*Fuzziness factor for the zcore in the summary buffer.
625 Articles with scores closer than this to `gnus-summary-default-score'
626 will not be marked.")
628 (defvar gnus-simplify-subject-fuzzy-regexp nil
629 "*Regular expression or list of regular expressions that will be removed
630 from subject strings if fuzzy subject simplification is selected.")
632 (defvar gnus-group-default-list-level gnus-level-subscribed
633 "*Default listing level.
634 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
636 (defvar gnus-group-use-permanent-levels nil
637 "*If non-nil, once you set a level, Gnus will use this level.")
639 (defvar gnus-show-mime nil
640 "*If non-nil, do mime processing of articles.
641 The articles will simply be fed to the function given by
642 `gnus-show-mime-method'.")
644 (defvar gnus-strict-mime t
645 "*If nil, decode MIME header even if there is not Mime-Version field.")
647 (defvar gnus-show-mime-method (function metamail-buffer)
648 "*Function to process a MIME message.
649 The function is called from the article buffer.")
651 (defvar gnus-show-threads t
652 "*If non-nil, display threads in summary mode.")
654 (defvar gnus-thread-hide-subtree nil
655 "*If non-nil, hide all threads initially.
656 If threads are hidden, you have to run the command
657 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
658 to expose hidden threads.")
660 (defvar gnus-thread-hide-killed t
661 "*If non-nil, hide killed threads automatically.")
663 (defvar gnus-thread-ignore-subject nil
664 "*If non-nil, ignore subjects and do all threading based on the Reference header.
665 If nil, which is the default, articles that have different subjects
666 from their parents will start separate threads.")
668 (defvar gnus-thread-operation-ignore-subject t
669 "*If non-nil, subjects will be ignored when doing thread commands.
670 This affects commands like `gnus-summary-kill-thread' and
671 `gnus-summary-lower-thread'.
673 If this variable is nil, articles in the same thread with different
674 subjects will not be included in the operation in question. If this
675 variable is `fuzzy', only articles that have subjects that are fuzzily
676 equal will be included.")
678 (defvar gnus-thread-indent-level 4
679 "*Number that says how much each sub-thread should be indented.")
681 (defvar gnus-ignored-newsgroups
682 (purecopy (mapconcat 'identity
683 '("^to\\." ; not "real" groups
684 "^[0-9. \t]+ " ; all digits in name
685 "[][\"#'()]" ; bogus characters
688 "*A regexp to match uninteresting newsgroups in the active file.
689 Any lines in the active file matching this regular expression are
690 removed from the newsgroup list before anything else is done to it,
691 thus making them effectively non-existent.")
693 (defvar gnus-ignored-headers
694 "^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:"
695 "*All headers that match this regexp will be hidden.
696 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
698 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
699 "*All headers that do not match this regexp will be hidden.
700 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
702 (defvar gnus-sorted-header-list
703 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
704 "^Cc:" "^Date:" "^Organization:")
705 "*This variable is a list of regular expressions.
706 If it is non-nil, headers that match the regular expressions will
707 be placed first in the article buffer in the sequence specified by
710 (defvar gnus-show-all-headers nil
711 "*If non-nil, don't hide any headers.")
713 (defvar gnus-save-all-headers t
714 "*If non-nil, don't remove any headers before saving.")
716 (defvar gnus-inhibit-startup-message nil
717 "*If non-nil, the startup message will not be displayed.")
719 (defvar gnus-signature-separator "^-- *$"
720 "Regexp matching signature separator.")
722 (defvar gnus-auto-extend-newsgroup t
723 "*If non-nil, extend newsgroup forward and backward when requested.")
725 (defvar gnus-auto-select-first t
726 "*If non-nil, select the first unread article when entering a group.
727 If you want to prevent automatic selection of the first unread article
728 in some newsgroups, set the variable to nil in
729 `gnus-select-group-hook'.")
731 (defvar gnus-auto-select-next t
732 "*If non-nil, offer to go to the next group from the end of the previous.
733 If the value is t and the next newsgroup is empty, Gnus will exit
734 summary mode and go back to group mode. If the value is neither nil
735 nor t, Gnus will select the following unread newsgroup. In
736 particular, if the value is the symbol `quietly', the next unread
737 newsgroup will be selected without any confirmation, and if it is
738 `almost-quietly', the next group will be selected without any
739 confirmation if you are located on the last article in the group.")
741 (defvar gnus-auto-select-same nil
742 "*If non-nil, select the next article with the same subject.")
744 (defvar gnus-summary-check-current nil
745 "*If non-nil, consider the current article when moving.
746 The \"unread\" movement commands will stay on the same line if the
747 current article is unread.")
749 (defvar gnus-auto-center-summary t
750 "*If non-nil, always center the current summary buffer.")
752 (defvar gnus-break-pages t
753 "*If non-nil, do page breaking on articles.
754 The page delimiter is specified by the `gnus-page-delimiter'
757 (defvar gnus-page-delimiter "^\^L"
758 "*Regexp describing what to use as article page delimiters.
759 The default value is \"^\^L\", which is a form linefeed at the
760 beginning of a line.")
762 (defvar gnus-use-full-window t
763 "*If non-nil, use the entire Emacs screen.")
765 (defvar gnus-window-configuration nil
766 "Obsolete variable. See `gnus-buffer-configuration'.")
768 (defvar gnus-buffer-configuration
769 '((group ([group 1.0 point]
770 (if gnus-carpal [group-carpal 4])))
771 (summary ([summary 1.0 point]
772 (if gnus-carpal [summary-carpal 4])))
773 (article ([summary 0.25 point]
774 (if gnus-carpal [summary-carpal 4])
776 (server ([server 1.0 point]
777 (if gnus-carpal [server-carpal 2])))
778 (browse ([browse 1.0 point]
779 (if gnus-carpal [browse-carpal 2])))
780 (group-mail ([mail 1.0 point]))
781 (summary-mail ([mail 1.0 point]))
782 (summary-reply ([article 0.5]
784 (info ([nil 1.0 point]))
785 (summary-faq ([summary 0.25]
787 (edit-group ([group 0.5]
788 [edit-group 1.0 point]))
789 (edit-server ([server 0.5]
790 [edit-server 1.0 point]))
791 (edit-score ([summary 0.25]
792 [edit-score 1.0 point]))
793 (post ([post 1.0 point]))
794 (reply ([article 0.5]
796 (mail-forward ([mail 1.0 point]))
797 (post-forward ([post 1.0 point]))
798 (reply-yank ([mail 1.0 point]))
799 (mail-bounce ([article 0.5]
801 (draft ([draft 1.0 point]))
802 (followup ([article 0.5]
804 (followup-yank ([post 1.0 point])))
805 "Window configuration for all possible Gnus buffers.
806 This variable is a list of lists. Each of these lists has a NAME and
807 a RULE. The NAMEs are commonsense names like `group', which names a
808 rule used when displaying the group buffer; `summary', which names a
809 rule for what happens when you enter a group and do not display an
810 article buffer; and so on. See the value of this variable for a
811 complete list of NAMEs.
813 Each RULE is a list of vectors. The first element in this vector is
814 the name of the buffer to be displayed; the second element is the
815 percentage of the screen this buffer is to occupy (a number in the
816 0.0-0.99 range); the optional third element is `point', which should
817 be present to denote which buffer point is to go to after making this
818 buffer configuration.")
820 (defvar gnus-window-to-buffer
821 '((group . gnus-group-buffer)
822 (summary . gnus-summary-buffer)
823 (article . gnus-article-buffer)
824 (server . gnus-server-buffer)
825 (browse . "*Gnus Browse Server*")
826 (edit-group . gnus-group-edit-buffer)
827 (edit-server . gnus-server-edit-buffer)
828 (group-carpal . gnus-carpal-group-buffer)
829 (summary-carpal . gnus-carpal-summary-buffer)
830 (server-carpal . gnus-carpal-server-buffer)
831 (browse-carpal . gnus-carpal-browse-buffer)
832 (edit-score . gnus-score-edit-buffer)
833 (mail . gnus-mail-buffer)
834 (post . gnus-post-news-buffer)
835 (faq . gnus-faq-buffer)
836 (draft . gnus-draft-buffer))
837 "Mapping from short symbols to buffer names or buffer variables.")
839 (defvar gnus-carpal nil
840 "*If non-nil, display clickable icons.")
842 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
843 "*Function called with a group name when new group is detected.
844 A few pre-made functions are supplied: `gnus-subscribe-randomly'
845 inserts new groups at the beginning of the list of groups;
846 `gnus-subscribe-alphabetically' inserts new groups in strict
847 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
848 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
851 ;; Suggested by a bug report by Hallvard B Furuseth.
852 ;; <h.b.furuseth@usit.uio.no>.
853 (defvar gnus-subscribe-options-newsgroup-method
854 (function gnus-subscribe-alphabetically)
855 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
856 If, for instance, you want to subscribe to all newsgroups in the
857 \"no\" and \"alt\" hierarchies, you'd put the following in your
860 options -n no.all alt.all
862 Gnus will the subscribe all new newsgroups in these hierarchies with
863 the subscription method in this variable.")
865 (defvar gnus-subscribe-hierarchical-interactive nil
866 "*If non-nil, Gnus will offer to subscribe hierarchically.
867 When a new hierarchy appears, Gnus will ask the user:
869 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
871 If the user pressed `d', Gnus will descend the hierarchy, `y' will
872 subscribe to all newsgroups in the hierarchy and `s' will skip this
873 hierarchy in its entirety.")
875 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
876 "*Function used for sorting the group buffer.
877 This function will be called with group info entries as the arguments
878 for the groups to be sorted. Pre-made functions include
879 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread' and
880 `gnus-group-sort-by-level'.
882 This variable can also be a list of sorting functions. In that case,
883 the most significant sort function should be the last function in the
886 ;; Mark variables suggested by Thomas Michanek
887 ;; <Thomas.Michanek@telelogic.se>.
888 (defvar gnus-unread-mark ?
889 "*Mark used for unread articles.")
890 (defvar gnus-ticked-mark ?!
891 "*Mark used for ticked articles.")
892 (defvar gnus-dormant-mark ??
893 "*Mark used for dormant articles.")
894 (defvar gnus-del-mark ?r
895 "*Mark used for del'd articles.")
896 (defvar gnus-read-mark ?R
897 "*Mark used for read articles.")
898 (defvar gnus-expirable-mark ?E
899 "*Mark used for expirable articles.")
900 (defvar gnus-killed-mark ?K
901 "*Mark used for killed articles.")
902 (defvar gnus-kill-file-mark ?X
903 "*Mark used for articles killed by kill files.")
904 (defvar gnus-low-score-mark ?Y
905 "*Mark used for articles with a low score.")
906 (defvar gnus-catchup-mark ?C
907 "*Mark used for articles that are caught up.")
908 (defvar gnus-replied-mark ?A
909 "*Mark used for articles that have been replied to.")
910 (defvar gnus-process-mark ?#
912 (defvar gnus-ancient-mark ?O
913 "*Mark used for ancient articles.")
914 (defvar gnus-canceled-mark ?G
915 "*Mark used for canceled articles.")
916 (defvar gnus-score-over-mark ?+
917 "*Score mark used for articles with high scores.")
918 (defvar gnus-score-below-mark ?-
919 "*Score mark used for articles with low scores.")
920 (defvar gnus-empty-thread-mark ?
921 "*There is no thread under the article.")
922 (defvar gnus-not-empty-thread-mark ?=
923 "*There is a thread under the article.")
924 (defvar gnus-dummy-mark ?Z
925 "*This is a dummy article.")
927 (defvar gnus-view-pseudo-asynchronously nil
928 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
930 (defvar gnus-view-pseudos nil
931 "*If `automatic', pseudo-articles will be viewed automatically.
932 If `not-confirm', pseudos will be viewed automatically, and the user
933 will not be asked to confirm the command.")
935 (defvar gnus-view-pseudos-separately t
936 "*If non-nil, one pseudo-article will be created for each file to be viewed.
937 If nil, all files that use the same viewing command will be given as a
938 list of parameters to that command.")
940 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
941 "*Format of group lines.
942 It works along the same lines as a normal formatting string,
943 with some simple extensions.
945 %M Only marked articles (character, \"*\" or \" \")
946 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
947 %L Level of subscribedness (integer)
948 %N Number of unread articles (integer)
949 %I Number of dormant articles (integer)
950 %i Number of ticked and dormant (integer)
951 %T Number of ticked articles (integer)
952 %R Number of read articles (integer)
953 %t Total number of articles (integer)
954 %y Number of unread, unticked articles (integer)
955 %G Group name (string)
956 %g Qualified group name (string)
957 %D Group description (string)
958 %s Select method (string)
959 %o Moderated group (char, \"m\")
960 %p Process mark (char)
961 %O Moderated group (string, \"(m)\" or \"\")
962 %n Select from where (string)
963 %z A string that look like `<%s:%n>' if a foreign select method is used
964 %u User defined specifier. The next character in the format string should
965 be a letter. Gnus will call the function gnus-user-format-function-X,
966 where X is the letter following %u. The function will be passed the
967 current header as argument. The function should return a string, which
968 will be inserted into the buffer just like information from any other
971 Text between %( and %) will be highlighted with `gnus-mouse-face' when
972 the mouse point move inside the area. There can only be one such area.
974 Note that this format specification is not always respected. For
975 reasons of efficiency, when listing killed groups, this specification
976 is ignored altogether. If the spec is changed considerably, your
977 output may end up looking strange when listing both alive and killed
980 If you use %o or %O, reading the active file will be slower and quite
981 a bit of extra memory will be used. %D will also worsen performance.
982 Also note that if you change the format specification to include any
983 of these specs, you must probably re-start Gnus to see them go into
986 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
987 "*The format specification of the lines in the summary buffer.
989 It works along the same lines as a normal formatting string,
990 with some simple extensions.
992 %N Article number, left padded with spaces (string)
994 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
995 %n Name of the poster (string)
996 %a Extracted name of the poster (string)
997 %A Extracted address of the poster (string)
998 %F Contents of the From: header (string)
999 %x Contents of the Xref: header (string)
1000 %D Date of the article (string)
1001 %d Date of the article (string) in DD-MMM format
1002 %M Message-id of the article (string)
1003 %r References of the article (string)
1004 %c Number of characters in the article (integer)
1005 %L Number of lines in the article (integer)
1006 %I Indentation based on thread level (a string of spaces)
1007 %T A string with two possible values: 80 spaces if the article
1008 is on thread level two or larger and 0 spaces on level one
1009 %R \"R\" if this article has been replied to, \" \" otherwise (character)
1010 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
1011 %[ Opening bracket (character, \"[\" or \"<\")
1012 %] Closing bracket (character, \"]\" or \">\")
1013 %> Spaces of length thread-level (string)
1014 %< Spaces of length (- 20 thread-level) (string)
1015 %i Article score (number)
1016 %z Article zcore (character)
1017 %t Number of articles under the current thread (number).
1018 %e Whether the thread is empty or not (character).
1019 %u User defined specifier. The next character in the format string should
1020 be a letter. Gnus will call the function gnus-user-format-function-X,
1021 where X is the letter following %u. The function will be passed the
1022 current header as argument. The function should return a string, which
1023 will be inserted into the summary just like information from any other
1026 Text between %( and %) will be highlighted with `gnus-mouse-face'
1027 when the mouse point is placed inside the area. There can only be one
1030 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1031 with care. For reasons of efficiency, Gnus will compute what column
1032 these characters will end up in, and \"hard-code\" that. This means that
1033 it is illegal to have these specs after a variable-length spec. Well,
1034 you might not be arrested, but your summary buffer will look strange,
1035 which is bad enough.
1037 The smart choice is to have these specs as for to the left as
1040 This restriction may disappear in later versions of Gnus.")
1042 (defvar gnus-summary-dummy-line-format "* : : %S\n"
1043 "*The format specification for the dummy roots in the summary buffer.
1044 It works along the same lines as a normal formatting string,
1045 with some simple extensions.
1049 (defvar gnus-summary-mode-line-format "Gnus %G/%A %Z"
1050 "*The format specification for the summary mode line.")
1052 (defvar gnus-article-mode-line-format "Gnus %G/%A %S"
1053 "*The format specification for the article mode line.")
1055 (defvar gnus-group-mode-line-format "Gnus List of groups {%M:%S} "
1056 "*The format specification for the group mode line.")
1058 (defvar gnus-valid-select-methods
1059 '(("nntp" post address prompt-address)
1061 ("nnvirtual" none virtual prompt-address)
1062 ("nnmbox" mail respool)
1063 ("nnml" mail respool)
1064 ("nnmh" mail respool)
1065 ("nndir" none prompt-address address)
1066 ("nneething" none prompt-address)
1068 ("nndoc" none prompt-address)
1069 ("nnbabyl" mail respool)
1070 ("nnkiboze" post virtual)
1072 ("nnfolder" mail respool))
1073 "An alist of valid select methods.
1074 The first element of each list lists should be a string with the name
1075 of the select method. The other elements may be be the category of
1076 this method (ie. `post', `mail', `none' or whatever) or other
1077 properties that this method has (like being respoolable).
1078 If you implement a new select method, all you should have to change is
1079 this variable. I think.")
1081 (defvar gnus-updated-mode-lines '(group article summary)
1082 "*List of buffers that should update their mode lines.
1083 The list may contain the symbols `group', `article' and `summary'. If
1084 the corresponding symbol is present, Gnus will keep that mode line
1085 updated with information that may be pertinent.
1086 If this variable is nil, screen refresh may be quicker.")
1088 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1089 (defvar gnus-mode-non-string-length 21
1090 "*Max length of mode-line non-string contents.
1091 If this is nil, Gnus will take space as is needed, leaving the rest
1092 of the modeline intact.")
1095 ;(defvar gnus-mouse-face 'highlight
1096 ; "*Face used for mouse highlighting in Gnus.
1097 ;No mouse highlights will be done if `gnus-visual' is nil.")
1099 (defvar gnus-summary-mark-below nil
1100 "*Mark all articles with a score below this variable as read.
1101 This variable is local to each summary buffer and usually set by the
1104 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1105 "*List of functions used for sorting threads in the summary buffer.
1106 By default, threads are sorted by article number.
1108 Each function takes two threads and return non-nil if the first thread
1109 should be sorted before the other. If you use more than one function,
1110 the primary sort function should be the last.
1112 Ready-mady functions include `gnus-thread-sort-by-number',
1113 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1114 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1115 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1117 (defvar gnus-thread-score-function '+
1118 "*Function used for calculating the total score of a thread.
1120 The function is called with the scores of the article and each
1121 subthread and should then return the score of the thread.
1123 Some functions you can use are `+', `max', or `min'.")
1125 (defvar gnus-auto-subscribed-groups
1126 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1127 "*All new groups that match this regexp will be subscribed automatically.
1128 Note that this variable only deals with new groups. It has no effect
1129 whatsoever on old groups.")
1131 (defvar gnus-options-subscribe nil
1132 "*All new groups matching this regexp will be subscribed unconditionally.
1133 Note that this variable deals only with new newsgroups. This variable
1134 does not affect old newsgroups.")
1136 (defvar gnus-options-not-subscribe nil
1137 "*All new groups matching this regexp will be ignored.
1138 Note that this variable deals only with new newsgroups. This variable
1139 does not affect old (already subscribed) newsgroups.")
1141 (defvar gnus-auto-expirable-newsgroups nil
1142 "*Groups in which to automatically mark read articles as expirable.
1143 If non-nil, this should be a regexp that should match all groups in
1144 which to perform auto-expiry. This only makes sense for mail groups.")
1146 (defvar gnus-total-expirable-newsgroups nil
1147 "*Groups in which to perform expiry of all read articles.
1148 Use with extreme caution. All groups that match this regexp will be
1149 expiring - which means that all read articles will be deleted after
1150 (say) one week. (This only goes for mail groups and the like, of
1153 (defvar gnus-hidden-properties '(invisible t intangible t)
1154 "Property list to use for hiding text.")
1156 (defvar gnus-modtime-botch nil
1157 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1158 due to the bogus appearance that .newsrc was modified on disc.")
1162 (defvar gnus-group-mode-hook nil
1163 "*A hook for Gnus group mode.")
1165 (defvar gnus-summary-mode-hook nil
1166 "*A hook for Gnus summary mode.
1167 This hook is run before any variables are set in the summary buffer.")
1169 (defvar gnus-article-mode-hook nil
1170 "*A hook for Gnus article mode.")
1172 (defun gnus-summary-prepare-exit-hook nil
1173 "*A hook called when preparing to exit from the summary buffer.
1174 It calls `gnus-summary-expire-articles' by default.")
1175 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1177 (defun gnus-summary-exit-hook nil
1178 "*A hook called on exit from the summary buffer.")
1180 (defvar gnus-open-server-hook nil
1181 "*A hook called just before opening connection to the news server.")
1183 (defvar gnus-load-hook nil
1184 "*A hook run while Gnus is loaded.")
1186 (defvar gnus-startup-hook nil
1187 "*A hook called at startup.
1188 This hook is called after Gnus is connected to the NNTP server.")
1190 (defvar gnus-get-new-news-hook nil
1191 "*A hook run just before Gnus checks for new news.")
1193 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1194 "*A function that is called to generate the group buffer.
1195 The function is called with three arguments: The first is a number;
1196 all group with a level less or equal to that number should be listed,
1197 if the second is non-nil, empty groups should also be displayed. If
1198 the third is non-nil, it is a number. No groups with a level lower
1199 than this number should be displayed.
1201 The only current function implemented are `gnus-group-prepare-flat'
1202 (which does the normal boring group display) and
1203 `gnus-group-prepare-topics' (which does a folding display accoring to
1206 (defvar gnus-group-prepare-hook nil
1207 "*A hook called after the group buffer has been generated.
1208 If you want to modify the group buffer, you can use this hook.")
1210 (defvar gnus-summary-prepare-hook nil
1211 "*A hook called after the summary buffer has been generated.
1212 If you want to modify the summary buffer, you can use this hook.")
1214 (defvar gnus-article-prepare-hook nil
1215 "*A hook called after an article has been prepared in the article buffer.
1216 If you want to run a special decoding program like nkf, use this hook.")
1218 ;(defvar gnus-article-display-hook nil
1219 ; "*A hook called after the article is displayed in the article buffer.
1220 ;The hook is designed to change the contents of the article
1221 ;buffer. Typical functions that this hook may contain are
1222 ;`gnus-article-hide-headers' (hide selected headers),
1223 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1224 ;`gnus-article-hide-signature' (hide signature) and
1225 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1226 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1227 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1228 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1230 (defvar gnus-article-x-face-command
1231 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1232 "String or function to be executed to display an X-Face header.
1233 If it is a string, the command will be executed in a sub-shell
1234 asynchronously. The compressed face will be piped to this command.")
1236 (defvar gnus-article-x-face-too-ugly nil
1237 "Regexp matching posters whose face shouldn't be shown automatically.")
1239 (defvar gnus-select-group-hook nil
1240 "*A hook called when a newsgroup is selected.
1242 If you'd like to simplify subjects like the
1243 `gnus-summary-next-same-subject' command does, you can use the
1246 (setq gnus-select-group-hook
1249 (mapcar (lambda (header)
1250 (mail-header-set-subject
1252 (gnus-simplify-subject
1253 (mail-header-subject header) 're-only)))
1254 gnus-newsgroup-headers))))")
1256 (defvar gnus-select-article-hook
1257 '(gnus-summary-show-thread)
1258 "*A hook called when an article is selected.
1259 The default hook shows conversation thread subtrees of the selected
1260 article automatically using `gnus-summary-show-thread'.")
1262 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1263 "*A hook called to apply kill files to a group.
1264 This hook is intended to apply a kill file to the selected newsgroup.
1265 The function `gnus-apply-kill-file' is called by default.
1267 Since a general kill file is too heavy to use only for a few
1268 newsgroups, I recommend you to use a lighter hook function. For
1269 example, if you'd like to apply a kill file to articles which contains
1270 a string `rmgroup' in subject in newsgroup `control', you can use the
1273 (setq gnus-apply-kill-hook
1276 (cond ((string-match \"control\" gnus-newsgroup-name)
1277 (gnus-kill \"Subject\" \"rmgroup\")
1278 (gnus-expunge \"X\"))))))")
1280 (defvar gnus-visual-mark-article-hook
1281 (list 'gnus-highlight-selected-summary)
1282 "*Hook run after selecting an article in the summary buffer.
1283 It is meant to be used for highlighting the article in some way. It
1284 is not run if `gnus-visual' is nil.")
1286 (defvar gnus-exit-group-hook nil
1287 "*A hook called when exiting (not quitting) summary mode.")
1289 (defvar gnus-suspend-gnus-hook nil
1290 "*A hook called when suspending (not exiting) Gnus.")
1292 (defvar gnus-exit-gnus-hook nil
1293 "*A hook called when exiting Gnus.")
1295 (defvar gnus-save-newsrc-hook nil
1296 "*A hook called before saving any of the newsrc files.")
1298 (defvar gnus-save-quick-newsrc-hook nil
1299 "*A hook called just before saving the quick newsrc file.
1300 Can be used to turn version control on or off.")
1302 (defvar gnus-save-standard-newsrc-hook nil
1303 "*A hook called just before saving the standard newsrc file.
1304 Can be used to turn version control on or off.")
1306 (defvar gnus-summary-update-hook
1307 (list 'gnus-summary-highlight-line)
1308 "*A hook called when a summary line is changed.
1309 The hook will not be called if `gnus-visual' is nil.
1311 The default function `gnus-summary-highlight-line' will
1312 highlight the line according to the `gnus-summary-highlight'
1315 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1316 "*A hook called when an article is selected for the first time.
1317 The hook is intended to mark an article as read (or unread)
1318 automatically when it is selected.")
1320 ;; Remove any hilit infestation.
1321 (add-hook 'gnus-startup-hook
1323 (remove-hook 'gnus-summary-prepare-hook
1324 'hilit-rehighlight-buffer-quietly)
1325 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1326 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1327 (remove-hook 'gnus-article-prepare-hook
1328 'hilit-rehighlight-buffer-quietly)))
1332 ;; Internal variables
1334 ;; Avoid highlighting in kill files.
1335 (defvar gnus-summary-inhibit-highlight nil)
1336 (defvar gnus-newsgroup-selected-overlay nil)
1338 (defvar gnus-article-mode-map nil)
1339 (defvar gnus-dribble-buffer nil)
1340 (defvar gnus-headers-retrieved-by nil)
1341 (defvar gnus-article-reply nil)
1342 (defvar gnus-override-method nil)
1343 (defvar gnus-article-check-size nil)
1345 (defvar gnus-current-score-file nil)
1346 (defvar gnus-internal-global-score-files nil)
1347 (defvar gnus-score-file-list nil)
1350 (defvar gnus-current-move-group nil)
1352 (defvar gnus-newsgroup-dependencies nil)
1353 (defvar gnus-newsgroup-async nil)
1354 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1356 (defvar gnus-newsgroup-adaptive nil)
1358 (defvar gnus-summary-display-table nil)
1360 (defconst gnus-group-line-format-alist
1361 (list (list ?M 'marked ?c)
1362 (list ?S 'subscribed ?c)
1364 (list ?N 'number ?s)
1365 (list ?I 'number-of-dormant ?d)
1366 (list ?T 'number-of-ticked ?d)
1367 (list ?R 'number-of-read ?s)
1368 (list ?t 'number-total ?d)
1369 (list ?y 'number-of-unread-unticked ?s)
1370 (list ?i 'number-of-ticked-and-dormant ?d)
1372 (list ?G 'qualified-group ?s)
1373 (list ?D 'newsgroup-description ?s)
1374 (list ?o 'moderated ?c)
1375 (list ?O 'moderated-string ?s)
1376 (list ?p 'process-marked ?c)
1377 (list ?s 'news-server ?s)
1378 (list ?n 'news-method ?s)
1379 (list ?z 'news-method-string ?s)
1380 (list ?u 'user-defined ?s)))
1382 (defconst gnus-summary-line-format-alist
1383 (list (list ?N 'number ?d)
1384 (list ?S 'subject ?s)
1385 (list ?s 'subject-or-nil ?s)
1387 (list ?A '(car (cdr (funcall gnus-extract-address-components from)))
1389 (list ?a '(or (car (funcall gnus-extract-address-components from))
1392 (list ?x (macroexpand '(mail-header-xref header)) ?s)
1393 (list ?D (macroexpand '(mail-header-date header)) ?s)
1394 (list ?d '(gnus-dd-mmm (mail-header-date header)) ?s)
1395 (list ?M (macroexpand '(mail-header-id header)) ?s)
1396 (list ?r (macroexpand '(mail-header-references header)) ?s)
1397 (list ?c '(or (mail-header-chars header) 0) ?d)
1399 (list ?I 'indentation ?s)
1400 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1401 (list ?R 'replied ?c)
1402 (list ?\[ 'opening-bracket ?c)
1403 (list ?\] 'closing-bracket ?c)
1404 (list ?\> '(make-string level ? ) ?s)
1405 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1407 (list ?z 'score-char ?c)
1408 (list ?U 'unread ?c)
1409 (list ?t '(gnus-summary-number-of-articles-in-thread
1410 (and (boundp 'thread) (car thread)))
1412 (list ?e '(gnus-summary-number-of-articles-in-thread
1413 (and (boundp 'thread) (car thread)) t)
1415 (list ?u 'user-defined ?s))
1416 "An alist of format specifications that can appear in summary lines,
1417 and what variables they correspond with, along with the type of the
1418 variable (string, integer, character, etc).")
1420 (defconst gnus-summary-dummy-line-format-alist
1421 (list (list ?S 'subject ?s)
1422 (list ?N 'number ?d)
1423 (list ?u 'user-defined ?s)))
1425 (defconst gnus-summary-mode-line-format-alist
1426 (list (list ?G 'group-name ?s)
1427 (list ?g '(gnus-short-group-name group-name) ?s)
1428 (list ?p '(gnus-group-real-name group-name) ?s)
1429 (list ?A 'article-number ?d)
1430 (list ?Z 'unread-and-unselected ?s)
1431 (list ?V 'gnus-version ?s)
1432 (list ?U 'unread ?d)
1433 (list ?S 'subject ?s)
1434 (list ?e 'unselected ?d)
1435 (list ?u 'user-defined ?s)
1436 (list ?d '(length gnus-newsgroup-dormant) ?d)
1437 (list ?t '(length gnus-newsgroup-marked) ?d)
1438 (list ?r '(length gnus-newsgroup-reads) ?d)
1439 (list ?E 'gnus-newsgroup-expunged-tally ?d)
1440 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1442 (defconst gnus-group-mode-line-format-alist
1443 (list (list ?S 'news-server ?s)
1444 (list ?M 'news-method ?s)
1445 (list ?u 'user-defined ?s)))
1447 (defvar gnus-have-read-active-file nil)
1449 (defconst gnus-maintainer
1450 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1451 "The mail address of the Gnus maintainers.")
1453 (defconst gnus-version "September Gnus v0.3"
1454 "Version number for this version of Gnus.")
1456 (defvar gnus-info-nodes
1457 '((gnus-group-mode "(gnus)The Group Buffer")
1458 (gnus-summary-mode "(gnus)The Summary Buffer")
1459 (gnus-article-mode "(gnus)The Article Buffer"))
1460 "Assoc list of major modes and related Info nodes.")
1462 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1463 "The location of the Gnus documentation group.")
1465 (defvar gnus-group-buffer "*Group*")
1466 (defvar gnus-summary-buffer "*Summary*")
1467 (defvar gnus-article-buffer "*Article*")
1468 (defvar gnus-server-buffer "*Server*")
1470 (defvar gnus-work-buffer " *gnus work*")
1472 (defvar gnus-original-article-buffer " *Original Article*")
1473 (defvar gnus-original-article nil)
1475 (defvar gnus-buffer-list nil
1476 "Gnus buffers that should be killed on exit.")
1478 (defvar gnus-server-alist nil
1479 "List of available servers.")
1481 (defvar gnus-slave nil
1482 "Whether this Gnus is a slave or not.")
1484 (defvar gnus-variable-list
1485 '(gnus-newsrc-options gnus-newsrc-options-n
1486 gnus-newsrc-last-checked-date
1487 gnus-newsrc-alist gnus-server-alist
1488 gnus-killed-list gnus-zombie-list)
1489 "Gnus variables saved in the quick startup file.")
1491 (defvar gnus-newsrc-options nil
1492 "Options line in the .newsrc file.")
1494 (defvar gnus-newsrc-options-n nil
1495 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1497 (defvar gnus-newsrc-last-checked-date nil
1498 "Date Gnus last asked server for new newsgroups.")
1500 (defvar gnus-newsrc-alist nil
1501 "Assoc list of read articles.
1502 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1504 (defvar gnus-newsrc-hashtb nil
1505 "Hashtable of gnus-newsrc-alist.")
1507 (defvar gnus-killed-list nil
1508 "List of killed newsgroups.")
1510 (defvar gnus-killed-hashtb nil
1511 "Hash table equivalent of gnus-killed-list.")
1513 (defvar gnus-zombie-list nil
1514 "List of almost dead newsgroups.")
1516 (defvar gnus-description-hashtb nil
1517 "Descriptions of newsgroups.")
1519 (defvar gnus-list-of-killed-groups nil
1520 "List of newsgroups that have recently been killed by the user.")
1522 (defvar gnus-active-hashtb nil
1523 "Hashtable of active articles.")
1525 (defvar gnus-moderated-list nil
1526 "List of moderated newsgroups.")
1528 (defvar gnus-group-marked nil)
1530 (defvar gnus-current-startup-file nil
1531 "Startup file for the current host.")
1533 (defvar gnus-last-search-regexp nil
1534 "Default regexp for article search command.")
1536 (defvar gnus-last-shell-command nil
1537 "Default shell command on article.")
1539 (defvar gnus-current-select-method nil
1540 "The current method for selecting a newsgroup.")
1542 (defvar gnus-group-list-mode nil)
1544 (defvar gnus-article-internal-prepare-hook nil)
1546 (defvar gnus-newsgroup-name nil)
1547 (defvar gnus-newsgroup-begin nil)
1548 (defvar gnus-newsgroup-end nil)
1549 (defvar gnus-newsgroup-last-rmail nil)
1550 (defvar gnus-newsgroup-last-mail nil)
1551 (defvar gnus-newsgroup-last-folder nil)
1552 (defvar gnus-newsgroup-last-file nil)
1553 (defvar gnus-newsgroup-auto-expire nil)
1554 (defvar gnus-newsgroup-active nil)
1556 (defvar gnus-newsgroup-data nil)
1557 (defvar gnus-newsgroup-data-reverse nil)
1558 (defvar gnus-newsgroup-limit nil)
1559 (defvar gnus-newsgroup-limits nil)
1561 (defvar gnus-newsgroup-unreads nil
1562 "List of unread articles in the current newsgroup.")
1564 (defvar gnus-newsgroup-unselected nil
1565 "List of unselected unread articles in the current newsgroup.")
1567 (defvar gnus-newsgroup-reads nil
1568 "Alist of read articles and article marks in the current newsgroup.")
1570 (defvar gnus-newsgroup-expunged-tally nil)
1572 (defvar gnus-newsgroup-marked nil
1573 "List of ticked articles in the current newsgroup (a subset of unread art).")
1575 (defvar gnus-newsgroup-killed nil
1576 "List of ranges of articles that have been through the scoring process.")
1578 (defvar gnus-newsgroup-kill-headers nil)
1580 (defvar gnus-newsgroup-replied nil
1581 "List of articles that have been replied to in the current newsgroup.")
1583 (defvar gnus-newsgroup-expirable nil
1584 "List of articles in the current newsgroup that can be expired.")
1586 (defvar gnus-newsgroup-processable nil
1587 "List of articles in the current newsgroup that can be processed.")
1589 (defvar gnus-newsgroup-bookmarks nil
1590 "List of articles in the current newsgroup that have bookmarks.")
1592 (defvar gnus-newsgroup-dormant nil
1593 "List of dormant articles in the current newsgroup.")
1595 (defvar gnus-newsgroup-scored nil
1596 "List of scored articles in the current newsgroup.")
1598 (defvar gnus-newsgroup-headers nil
1599 "List of article headers in the current newsgroup.")
1601 (defvar gnus-newsgroup-ancient nil
1602 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1604 (defvar gnus-current-article nil)
1605 (defvar gnus-article-current nil)
1606 (defvar gnus-current-headers nil)
1607 (defvar gnus-have-all-headers nil)
1608 (defvar gnus-last-article nil)
1609 (defvar gnus-newsgroup-history nil)
1610 (defvar gnus-current-kill-article nil)
1612 ;; Save window configuration.
1613 (defvar gnus-prev-winconf nil)
1616 (defvar gnus-summary-line-format-spec nil)
1617 (defvar gnus-summary-dummy-line-format-spec nil)
1618 (defvar gnus-group-line-format-spec nil)
1619 (defvar gnus-summary-mode-line-format-spec nil)
1620 (defvar gnus-article-mode-line-format-spec nil)
1621 (defvar gnus-group-mode-line-format-spec nil)
1622 (defvar gnus-summary-mark-positions nil)
1623 (defvar gnus-group-mark-positions nil)
1625 (defvar gnus-summary-expunge-below nil)
1626 (defvar gnus-reffed-article-number nil)
1628 ; Let the byte-compiler know that we know about this variable.
1629 (defvar rmail-default-rmail-file)
1631 (defvar gnus-cache-removeable-articles nil)
1633 (defconst gnus-summary-local-variables
1634 '(gnus-newsgroup-name
1635 gnus-newsgroup-begin gnus-newsgroup-end
1636 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1637 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1638 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1639 gnus-newsgroup-unselected gnus-newsgroup-marked
1640 gnus-newsgroup-reads
1641 gnus-newsgroup-replied gnus-newsgroup-expirable
1642 gnus-newsgroup-processable gnus-newsgroup-killed
1643 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1644 gnus-newsgroup-headers
1645 gnus-current-article gnus-current-headers gnus-have-all-headers
1646 gnus-last-article gnus-article-internal-prepare-hook
1647 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1648 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1649 gnus-newsgroup-async
1650 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1651 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1652 gnus-newsgroup-history gnus-newsgroup-ancient
1653 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1654 (gnus-newsgroup-expunged-tally . 0)
1655 gnus-cache-removeable-articles
1656 gnus-newsgroup-data gnus-newsgroup-data-reverse
1657 gnus-newsgroup-limit gnus-newsgroup-limits)
1658 "Variables that are buffer-local to the summary buffers.")
1660 (defconst gnus-bug-message
1661 "Sending a bug report to the Gnus Towers.
1662 ========================================
1664 The buffer below is a mail buffer. When you press `C-c C-c', it will
1665 be sent to the Gnus Bug Exterminators.
1667 At the bottom of the buffer you'll see lots of variable settings.
1668 Please do not delete those. They will tell the Bug People what your
1669 environment is, so that it will be easier to locate the bugs.
1671 If you have found a bug that makes Emacs go \"beep\", set
1672 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1673 and include the backtrace in your bug report.
1675 Please describe the bug in annoying, painstaking detail.
1677 Thank you for your help in stamping out bugs.
1680 ;;; End of variables.
1682 ;; Define some autoload functions Gnus might use.
1686 (autoload 'metamail-buffer "metamail")
1687 (autoload 'Info-goto-node "info")
1688 (autoload 'hexl-hex-string-to-integer "hexl")
1690 (autoload 'pp-to-string "pp")
1691 (autoload 'pp-eval-expression "pp")
1692 (autoload 'mail-extract-address-components "mail-extr")
1694 (autoload 'nnmail-split-fancy "nnmail")
1695 (autoload 'nnmail-article-group "nnmail")
1696 (autoload 'nnvirtual-catchup-group "nnvirtual")
1699 (autoload 'timezone-make-date-arpa-standard "timezone")
1700 (autoload 'timezone-fix-time "timezone")
1701 (autoload 'timezone-make-sortable-date "timezone")
1702 (autoload 'timezone-make-time-string "timezone")
1705 (autoload 'mail-position-on-field "sendmail")
1706 (autoload 'mail-setup "sendmail")
1707 (autoload 'rmail-output "rmailout")
1708 (autoload 'news-mail-other-window "rnewspost")
1709 (autoload 'news-reply-yank-original "rnewspost")
1710 (autoload 'news-caesar-buffer-body "rnewspost")
1711 (autoload 'rmail-insert-rmail-file-header "rmail")
1712 (autoload 'rmail-count-new-messages "rmail")
1713 (autoload 'rmail-show-message "rmail")
1716 (autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1717 (autoload 'gnus-brew-soup "gnus-soup" nil t)
1718 (autoload 'gnus-soup-add-article "gnus-soup" nil t)
1719 (autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1720 (autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1721 (autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1722 (autoload 'nnsoup-pack-replies "nnsoup" nil t)
1725 (autoload 'gnus-mh-mail-setup "gnus-mh")
1726 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1727 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1728 (autoload 'gnus-Folder-save-name "gnus-mh")
1729 (autoload 'gnus-folder-save-name "gnus-mh")
1732 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1733 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1734 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1735 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1736 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1737 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1738 (autoload 'gnus-summary-highlight-line "gnus-vis")
1739 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1742 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1743 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1744 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1745 (autoload 'gnus-article-highlight-some "gnus-vis" nil t)
1746 (autoload 'gnus-article-hide "gnus-vis" nil t)
1747 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1748 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1749 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1750 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1751 (autoload 'gnus-article-add-buttons-to-head "gnus-vis" nil t)
1752 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1753 (autoload 'gnus-article-add-button "gnus-vis")
1756 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1757 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1758 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1761 (autoload 'gnus-kill "gnus-kill")
1762 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1763 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1764 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1765 (autoload 'gnus-execute "gnus-kill")
1766 (autoload 'gnus-expunge "gnus-kill")
1769 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1770 (autoload 'gnus-cache-save-buffers "gnus-cache")
1771 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1772 (autoload 'gnus-cache-request-article "gnus-cache")
1773 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1774 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1775 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1776 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1779 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1780 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1781 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1782 (autoload 'gnus-score-save "gnus-score")
1783 (autoload 'gnus-score-headers "gnus-score")
1784 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1785 (autoload 'gnus-score-adaptive "gnus-score")
1786 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1787 (autoload 'gnus-score-find-trace "gnus-score")
1788 (autoload 'gnus-score-flush-cache "gnus-score" nil t)
1791 (autoload 'gnus-score-customize "gnus-edit" nil t)
1794 (autoload 'gnus-topic-fold "gnus-topic")
1797 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1798 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1799 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1800 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1801 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1802 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1803 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1804 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1805 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1806 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1807 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1808 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1809 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1810 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1811 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1812 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1813 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1814 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1815 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1816 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1817 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1818 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1821 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1822 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1823 (autoload 'gnus-group-mail "gnus-msg" nil t)
1824 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1825 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1826 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1827 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1828 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1829 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1830 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1831 (autoload 'gnus-post-news "gnus-msg" nil t)
1832 (autoload 'gnus-inews-news "gnus-msg" nil t)
1833 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1834 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1835 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1836 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1837 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1838 (autoload 'gnus-mail-yank-original "gnus-msg")
1839 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1840 (autoload 'gnus-sendmail-setup-mail "gnus-msg")
1841 (autoload 'gnus-article-mail "gnus-msg")
1842 (autoload 'gnus-bug "gnus-msg" nil t)
1843 (autoload 'gnus-inews-message-id "gnus-msg")
1846 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1847 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1848 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1849 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1850 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1851 (autoload 'gnus-yank-article "gnus-vm" nil t)
1857 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1858 ;; If you want the cursor to go somewhere else, set these two
1859 ;; functions in some startup hook to whatever you want.
1860 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
1861 (defalias 'gnus-group-position-point 'gnus-goto-colon)
1863 ;;; Various macros and substs.
1865 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1866 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1867 (` (let ((GnusStartBufferWindow (selected-window)))
1870 (pop-to-buffer (, buffer))
1872 (select-window GnusStartBufferWindow)))))
1874 (defmacro gnus-gethash (string hashtable)
1875 "Get hash value of STRING in HASHTABLE."
1876 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1877 ;;(` (abbrev-expansion (, string) (, hashtable)))
1878 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1880 (defmacro gnus-sethash (string value hashtable)
1881 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1882 ;; We cannot use define-abbrev since it only accepts string as value.
1883 ;; (set (intern string hashtable) value))
1884 (` (set (intern (, string) (, hashtable)) (, value))))
1886 (defsubst gnus-buffer-substring (beg end)
1887 (buffer-substring (match-beginning beg) (match-end end)))
1889 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1890 ;; function `substring' might cut on a middle of multi-octet
1892 (defun gnus-truncate-string (str width)
1893 (substring str 0 width))
1895 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1896 ;; to limit the length of a string. This function is necessary since
1897 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1898 (defsubst gnus-limit-string (str width)
1899 (if (> (length str) width)
1900 (substring str 0 width)
1903 (defsubst gnus-simplify-subject-re (subject)
1904 "Remove \"Re:\" from subject lines."
1905 (let ((case-fold-search t))
1906 (if (string-match "^re: *" subject)
1907 (substring subject (match-end 0))
1910 (defsubst gnus-goto-char (point)
1911 (and point (goto-char point)))
1913 (defmacro gnus-buffer-exists-p (buffer)
1915 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1918 (defmacro gnus-kill-buffer (buffer)
1919 (` (if (gnus-buffer-exists-p (, buffer))
1920 (kill-buffer (, buffer)))))
1922 (defsubst gnus-point-at-bol ()
1923 "Return point at the beginning of line."
1930 (defsubst gnus-point-at-eol ()
1931 "Return point at the beginning of line."
1938 ;; Delete the current line (and the next N lines.);
1939 (defmacro gnus-delete-line (&optional n)
1940 (` (delete-region (progn (beginning-of-line) (point))
1941 (progn (forward-line (, (or n 1))) (point)))))
1943 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1944 (defvar gnus-init-inhibit nil)
1945 (defun gnus-read-init-file (&optional inhibit-next)
1946 (if gnus-init-inhibit
1947 (setq gnus-init-inhibit nil)
1948 (setq gnus-init-inhibit inhibit-next)
1950 (or (and (file-exists-p gnus-init-file)
1951 ;; Don't try to load a directory.
1952 (not (file-directory-p gnus-init-file)))
1953 (file-exists-p (concat gnus-init-file ".el"))
1954 (file-exists-p (concat gnus-init-file ".elc")))
1955 (load gnus-init-file nil t))))
1957 ;;; Load the user startup file.
1958 ;; (eval '(gnus-read-init-file 'inhibit))
1960 ;;; Load the compatability functions.
1967 ;;; Gnus Utility Functions
1970 (defun gnus-extract-address-components (from)
1972 ;; First find the address - the thing with the @ in it. This may
1973 ;; not be accurate in mail addresses, but does the trick most of
1974 ;; the time in news messages.
1975 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1976 (setq address (substring from (match-beginning 0) (match-end 0))))
1977 ;; Then we check whether the "name <address>" format is used.
1979 (string-match (concat "<" (regexp-quote address) ">") from)
1980 (and (setq name (substring from 0 (1- (match-beginning 0))))
1981 ;; Strip any quotes from the name.
1982 (string-match "\".*\"" name)
1983 (setq name (substring name 1 (1- (match-end 0))))))
1984 ;; If not, then "address (name)" is used.
1986 (and (string-match "(.+)" from)
1987 (setq name (substring from (1+ (match-beginning 0))
1988 (1- (match-end 0)))))
1989 (and (string-match "()" from)
1990 (setq name address))
1991 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1992 ;; XOVER might not support folded From headers.
1993 (and (string-match "(.*" from)
1994 (setq name (substring from (1+ (match-beginning 0))
1996 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1997 (list (or name from) (or address from))))
1999 (defun gnus-fetch-field (field)
2000 "Return the value of the header FIELD of current article."
2003 (let ((case-fold-search t))
2004 (gnus-narrow-to-headers)
2005 (mail-fetch-field field)))))
2007 (defun gnus-goto-colon ()
2009 (search-forward ":" (gnus-point-at-eol) t))
2011 (defun gnus-narrow-to-headers ()
2015 (goto-char (point-min))
2016 (if (search-forward "\n\n" nil t)
2020 (defvar gnus-old-specs nil)
2022 (defun gnus-update-format-specifications ()
2023 (gnus-make-thread-indent-array)
2025 (let ((formats '(summary summary-dummy group
2026 summary-mode group-mode article-mode))
2027 old-format new-format)
2029 (setq new-format (symbol-value
2030 (intern (format "gnus-%s-line-format" (car formats)))))
2031 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs)))
2032 (equal old-format new-format))
2033 (set (intern (format "gnus-%s-line-format-spec" (car formats)))
2037 (intern (format "gnus-%s-line-format-alist"
2038 (if (eq (car formats) 'article-mode)
2039 'summary-mode (car formats))))))))
2040 (setq gnus-old-specs (cons (cons (car formats) new-format)
2041 (delq (car formats) gnus-old-specs)))
2042 (setq formats (cdr formats))))
2044 (gnus-update-group-mark-positions)
2045 (gnus-update-summary-mark-positions)
2047 (if (and (string-match "%D" gnus-group-line-format)
2048 (not gnus-description-hashtb)
2049 gnus-read-active-file)
2050 (gnus-read-all-descriptions-files)))
2052 (defun gnus-update-summary-mark-positions ()
2054 (let ((gnus-replied-mark 129)
2055 (gnus-score-below-mark 130)
2056 (gnus-score-over-mark 130)
2059 (gnus-set-work-buffer)
2060 (gnus-summary-insert-line
2061 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2062 (goto-char (point-min))
2063 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2065 (goto-char (point-min))
2066 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
2067 (- (point) 2))) pos))
2068 (goto-char (point-min))
2069 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
2070 (- (point) 2))) pos))
2071 (setq gnus-summary-mark-positions pos))))
2073 (defun gnus-update-group-mark-positions ()
2075 (let ((gnus-process-mark 128)
2076 (gnus-group-marked '("dummy.group")))
2077 (gnus-sethash "dummy.group" '(0 . 0) gnus-active-hashtb)
2078 (gnus-set-work-buffer)
2079 (gnus-group-insert-group-line nil "dummy.group" 0 nil 0 nil)
2080 (goto-char (point-min))
2081 (setq gnus-group-mark-positions
2082 (list (cons 'process (and (search-forward "\200" nil t)
2083 (- (point) 2))))))))
2085 (defun gnus-mouse-face-function (form)
2086 (` (let ((string (, form)))
2087 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
2090 (defun gnus-max-width-function (el max-width)
2091 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2092 (` (let* ((val (eval (, el)))
2093 (valstr (if (numberp val)
2094 (int-to-string val) val)))
2095 (if (> (length valstr) (, max-width))
2096 (substring valstr 0 (, max-width))
2099 (defun gnus-parse-format (format spec-alist)
2100 ;; This function parses the FORMAT string with the help of the
2101 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2102 ;; string. If the FORMAT string contains the specifiers %( and %)
2103 ;; the text between them will have the mouse-face text property.
2104 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
2105 (if (and gnus-visual gnus-mouse-face)
2106 (let ((pre (substring format (match-beginning 1) (match-end 1)))
2107 (button (substring format (match-beginning 2) (match-end 2)))
2108 (post (substring format (match-beginning 3) (match-end 3))))
2110 (gnus-parse-simple-format pre spec-alist)
2111 (gnus-mouse-face-function
2112 (gnus-parse-simple-format button spec-alist))
2113 (gnus-parse-simple-format post spec-alist)))
2114 (gnus-parse-simple-format
2115 (concat (substring format (match-beginning 1) (match-end 1))
2116 (substring format (match-beginning 2) (match-end 2))
2117 (substring format (match-beginning 3) (match-end 3)))
2119 (gnus-parse-simple-format format spec-alist)))
2121 (defun gnus-parse-simple-format (format spec-alist)
2122 ;; This function parses the FORMAT string with the help of the
2123 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2124 ;; string. The list will consist of the symbol `format', a format
2125 ;; specification string, and a list of forms depending on the
2128 spec flist fstring newspec elem beg)
2130 (gnus-set-work-buffer)
2132 (goto-char (point-min))
2133 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
2134 (setq spec (string-to-char (buffer-substring (match-beginning 2)
2136 ;; First check if there are any specs that look anything like
2137 ;; "%12,12A", ie. with a "max width specification". These have
2138 ;; to be treated specially.
2139 (if (setq beg (match-beginning 1))
2142 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
2144 (setq beg (match-beginning 2)))
2145 ;; Find the specification from `spec-alist'.
2146 (if (not (setq elem (cdr (assq spec spec-alist))))
2147 (setq elem '("*" ?s)))
2148 ;; Treat user defined format specifiers specially
2149 (and (eq (car elem) 'user-defined)
2152 (list (intern (concat "gnus-user-format-function-"
2158 (delete-region (match-beginning 3) (match-end 3)))
2159 (if (not (zerop max-width))
2160 (let ((el (car elem)))
2161 (cond ((= (car (cdr elem)) ?c)
2162 (setq el (list 'char-to-string el)))
2163 ((= (car (cdr elem)) ?d)
2164 (numberp el) (setq el (list 'int-to-string el))))
2165 (setq flist (cons (gnus-max-width-function el max-width)
2168 (setq flist (cons (car elem) flist))
2169 (setq newspec (car (cdr elem))))
2170 ;; Remove the old specification (and possibly a ",12" string).
2171 (delete-region beg (match-end 2))
2172 ;; Insert the new specification.
2175 (setq fstring (buffer-substring 1 (point-max))))
2176 (cons 'format (cons fstring (nreverse flist)))))
2178 (defun gnus-set-work-buffer ()
2179 (if (get-buffer gnus-work-buffer)
2181 (set-buffer gnus-work-buffer)
2183 (set-buffer (get-buffer-create gnus-work-buffer))
2184 (kill-all-local-variables)
2185 (buffer-disable-undo (current-buffer))
2186 (gnus-add-current-to-buffer-list)))
2188 ;; Article file names when saving.
2190 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2191 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2192 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2193 Otherwise, it is like ~/News/news/group/num."
2196 (concat (if (gnus-use-long-file-name 'not-save)
2197 (gnus-capitalize-newsgroup newsgroup)
2198 (gnus-newsgroup-directory-form newsgroup))
2199 "/" (int-to-string (mail-header-number headers)))
2200 (or gnus-article-save-directory "~/News"))))
2202 (string-equal (file-name-directory default)
2203 (file-name-directory last-file))
2204 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2206 (or last-file default))))
2208 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2209 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2210 If variable `gnus-use-long-file-name' is non-nil, it is
2211 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2214 (concat (if (gnus-use-long-file-name 'not-save)
2216 (gnus-newsgroup-directory-form newsgroup))
2217 "/" (int-to-string (mail-header-number headers)))
2218 (or gnus-article-save-directory "~/News"))))
2220 (string-equal (file-name-directory default)
2221 (file-name-directory last-file))
2222 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2224 (or last-file default))))
2226 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2227 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2228 If variable `gnus-use-long-file-name' is non-nil, it is
2229 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2232 (if (gnus-use-long-file-name 'not-save)
2233 (gnus-capitalize-newsgroup newsgroup)
2234 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2235 (or gnus-article-save-directory "~/News"))))
2237 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2238 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2239 If variable `gnus-use-long-file-name' is non-nil, it is
2240 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2243 (if (gnus-use-long-file-name 'not-save)
2245 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2246 (or gnus-article-save-directory "~/News"))))
2248 ;; For subscribing new newsgroup
2250 (defun gnus-subscribe-hierarchical-interactive (groups)
2251 (let ((groups (sort groups 'string<))
2252 prefixes prefix start ans group starts)
2254 (setq prefixes (list "^"))
2255 (while (and groups prefixes)
2256 (while (not (string-match (car prefixes) (car groups)))
2257 (setq prefixes (cdr prefixes)))
2258 (setq prefix (car prefixes))
2259 (setq start (1- (length prefix)))
2260 (if (and (string-match "[^\\.]\\." (car groups) start)
2263 (concat "^" (substring (car groups) 0 (match-end 0))))
2264 (string-match prefix (car (cdr groups))))
2266 (setq prefixes (cons prefix prefixes))
2267 (message "Descend hierarchy %s? ([y]nsq): "
2268 (substring prefix 1 (1- (length prefix))))
2269 (setq ans (read-char))
2272 (string-match prefix
2273 (setq group (car groups))))
2274 (setq gnus-killed-list
2275 (cons group gnus-killed-list))
2276 (gnus-sethash group group gnus-killed-hashtb)
2277 (setq groups (cdr groups)))
2278 (setq starts (cdr starts)))
2281 (string-match prefix
2282 (setq group (car groups))))
2283 (gnus-sethash group group gnus-killed-hashtb)
2284 (gnus-subscribe-alphabetically (car groups))
2285 (setq groups (cdr groups)))
2286 (setq starts (cdr starts)))
2289 (setq group (car groups))
2290 (setq gnus-killed-list (cons group gnus-killed-list))
2291 (gnus-sethash group group gnus-killed-hashtb)
2292 (setq groups (cdr groups))))
2294 (message "Subscribe %s? ([n]yq)" (car groups))
2295 (setq ans (read-char))
2296 (setq group (car groups))
2298 (gnus-subscribe-alphabetically (car groups))
2299 (gnus-sethash group group gnus-killed-hashtb))
2302 (setq group (car groups))
2303 (setq gnus-killed-list (cons group gnus-killed-list))
2304 (gnus-sethash group group gnus-killed-hashtb)
2305 (setq groups (cdr groups))))
2307 (setq gnus-killed-list (cons group gnus-killed-list))
2308 (gnus-sethash group group gnus-killed-hashtb)))
2309 (setq groups (cdr groups)))))))
2311 (defun gnus-subscribe-randomly (newsgroup)
2312 "Subscribe new NEWSGROUP by making it the first newsgroup."
2313 (gnus-subscribe-newsgroup newsgroup))
2315 (defun gnus-subscribe-alphabetically (newgroup)
2316 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2317 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2318 (let ((groups (cdr gnus-newsrc-alist))
2320 (while (and (not before) groups)
2321 (if (string< newgroup (car (car groups)))
2322 (setq before (car (car groups)))
2323 (setq groups (cdr groups))))
2324 (gnus-subscribe-newsgroup newgroup before)))
2326 (defun gnus-subscribe-hierarchically (newgroup)
2327 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2328 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2330 (set-buffer (find-file-noselect gnus-current-startup-file))
2331 (let ((groupkey newgroup)
2333 (while (and (not before) groupkey)
2334 (goto-char (point-min))
2336 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2337 (while (and (re-search-forward groupkey-re nil t)
2339 (setq before (buffer-substring
2340 (match-beginning 1) (match-end 1)))
2341 (string< before newgroup)))))
2342 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2344 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2345 (substring groupkey (match-beginning 1) (match-end 1)))))
2346 (gnus-subscribe-newsgroup newgroup before))))
2348 (defun gnus-subscribe-interactively (newsgroup)
2349 "Subscribe new NEWSGROUP interactively.
2350 It is inserted in hierarchical newsgroup order if subscribed. If not,
2352 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2353 (gnus-subscribe-hierarchically newsgroup)
2354 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2356 (defun gnus-subscribe-zombies (newsgroup)
2357 "Make new NEWSGROUP a zombie group."
2358 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2360 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2361 "Subscribe new NEWSGROUP.
2362 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2363 the first newsgroup."
2364 ;; We subscribe the group by changing its level to `subscribed'.
2365 (gnus-group-change-level
2366 newsgroup gnus-level-default-subscribed
2367 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2368 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2372 (defun gnus-newsgroup-directory-form (newsgroup)
2373 "Make hierarchical directory name from NEWSGROUP name."
2374 (let ((newsgroup (gnus-newsgroup-saveable-name newsgroup))
2375 (len (length newsgroup))
2377 ;; If this is a foreign group, we don't want to translate the
2379 (if (setq idx (string-match ":" newsgroup))
2380 (aset newsgroup idx ?/)
2382 ;; Replace all occurrences of `.' with `/'.
2384 (if (= (aref newsgroup idx) ?.)
2385 (aset newsgroup idx ?/))
2386 (setq idx (1+ idx)))
2389 (defun gnus-newsgroup-saveable-name (group)
2390 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2392 (gnus-replace-chars-in-string group ?/ ?.))
2394 (defun gnus-make-directory (dir)
2395 "Make DIRECTORY recursively."
2396 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2397 ;; of the many mysteries of the universe.
2398 (let* ((dir (expand-file-name dir default-directory))
2400 (if (string-match "/$" dir)
2401 (setq dir (substring dir 0 (match-beginning 0))))
2402 ;; First go down the path until we find a directory that exists.
2403 (while (not (file-exists-p dir))
2404 (setq dirs (cons dir dirs))
2405 (string-match "/[^/]+$" dir)
2406 (setq dir (substring dir 0 (match-beginning 0))))
2407 ;; Then create all the subdirs.
2408 (while (and dirs (not err))
2410 (make-directory (car dirs))
2411 (error (setq err t)))
2412 (setq dirs (cdr dirs)))
2413 ;; We return whether we were successful or not.
2416 (defun gnus-capitalize-newsgroup (newsgroup)
2417 "Capitalize NEWSGROUP name."
2418 (and (not (zerop (length newsgroup)))
2419 (concat (char-to-string (upcase (aref newsgroup 0)))
2420 (substring newsgroup 1))))
2424 (defun gnus-simplify-subject (subject &optional re-only)
2425 "Remove `Re:' and words in parentheses.
2426 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2427 (let ((case-fold-search t)) ;Ignore case.
2428 ;; Remove `Re:' and `Re^N:'.
2429 (if (string-match "^re:[ \t]*" subject)
2430 (setq subject (substring subject (match-end 0))))
2431 ;; Remove words in parentheses from end.
2433 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2434 (setq subject (substring subject 0 (match-beginning 0)))))
2435 ;; Return subject string.
2438 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2440 (defun gnus-simplify-subject-fuzzy (subject)
2441 (let ((case-fold-search t))
2443 (gnus-set-work-buffer)
2445 (inline (gnus-simplify-buffer-fuzzy))
2448 (defun gnus-simplify-buffer-fuzzy ()
2449 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2450 (goto-char (point-min))
2452 (looking-at "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*")
2453 (looking-at "^[[].*:[ \t].*[]]$"))
2454 (goto-char (point-min))
2455 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2457 (replace-match "" t t))
2458 (goto-char (point-min))
2459 (while (re-search-forward "^[[].*:[ \t].*[]]$" nil t)
2460 (let ((beg (match-beginning 0))
2461 (end (match-end 0)))
2462 (goto-char end) (delete-char -1)
2463 (goto-char beg) (delete-region beg (re-search-forward ":" nil t))
2465 (goto-char (point-min))
2466 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2467 (replace-match "" t t))
2468 (goto-char (point-min))
2469 (while (re-search-forward "[ \t]+" nil t)
2470 (replace-match " " t t))
2471 (goto-char (point-min))
2472 (while (re-search-forward "[ \t]+$" nil t)
2473 (replace-match "" t t))
2474 (goto-char (point-min))
2475 (while (re-search-forward "^[ \t]+" nil t)
2476 (replace-match "" t t))
2477 (goto-char (point-min))
2478 (if gnus-simplify-subject-fuzzy-regexp
2479 (if (listp gnus-simplify-subject-fuzzy-regexp)
2480 (let ((list gnus-simplify-subject-fuzzy-regexp))
2482 (goto-char (point-min))
2483 (while (re-search-forward (car list) nil t)
2484 (replace-match "" t t))
2485 (setq list (cdr list))))
2486 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2487 (replace-match "" t t))
2490 ;; Add the current buffer to the list of buffers to be killed on exit.
2491 (defun gnus-add-current-to-buffer-list ()
2492 (or (memq (current-buffer) gnus-buffer-list)
2493 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2495 (defun gnus-string> (s1 s2)
2496 (not (or (string< s1 s2)
2499 ;; Functions accessing headers.
2500 ;; Functions are more convenient than macros in some cases.
2502 (defun gnus-header-number (header)
2503 (mail-header-number header))
2505 (defun gnus-header-subject (header)
2506 (mail-header-subject header))
2508 (defun gnus-header-from (header)
2509 (mail-header-from header))
2511 (defun gnus-header-xref (header)
2512 (mail-header-xref header))
2514 (defun gnus-header-lines (header)
2515 (mail-header-lines header))
2517 (defun gnus-header-date (header)
2518 (mail-header-date header))
2520 (defun gnus-header-id (header)
2521 (mail-header-id header))
2523 (defun gnus-header-message-id (header)
2524 (mail-header-id header))
2526 (defun gnus-header-chars (header)
2527 (mail-header-chars header))
2529 (defun gnus-header-references (header)
2530 (mail-header-references header))
2532 ;;; General various misc type functions.
2534 (defun gnus-clear-system ()
2535 "Clear all variables and buffers."
2536 ;; Clear Gnus variables.
2537 (let ((variables gnus-variable-list))
2539 (set (car variables) nil)
2540 (setq variables (cdr variables))))
2541 ;; Clear other internal variables.
2542 (setq gnus-list-of-killed-groups nil
2543 gnus-have-read-active-file nil
2544 gnus-newsrc-alist nil
2545 gnus-newsrc-hashtb nil
2546 gnus-killed-list nil
2547 gnus-zombie-list nil
2548 gnus-killed-hashtb nil
2549 gnus-active-hashtb nil
2550 gnus-moderated-list nil
2551 gnus-description-hashtb nil
2552 gnus-newsgroup-headers nil
2553 gnus-newsgroup-name nil
2554 gnus-server-alist nil
2555 gnus-current-select-method nil)
2556 ;; Reset any score variables.
2557 (and (boundp 'gnus-score-cache)
2558 (set 'gnus-score-cache nil))
2559 (and (boundp 'gnus-internal-global-score-files)
2560 (set 'gnus-internal-global-score-files nil))
2561 ;; Kill the startup file.
2562 (and gnus-current-startup-file
2563 (get-file-buffer gnus-current-startup-file)
2564 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2565 ;; Save any cache buffers.
2566 (and gnus-use-cache (gnus-cache-save-buffers))
2567 ;; Clear the dribble buffer.
2568 (gnus-dribble-clear)
2569 ;; Kill global KILL file buffer.
2570 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2571 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2572 (gnus-kill-buffer nntp-server-buffer)
2573 ;; Kill Gnus buffers.
2574 (while gnus-buffer-list
2575 (gnus-kill-buffer (car gnus-buffer-list))
2576 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2578 (defun gnus-windows-old-to-new (setting)
2579 (if (symbolp setting)
2581 (cond ((eq setting 'SelectArticle)
2583 ((eq setting 'SelectSubject)
2585 ((eq setting 'SelectNewsgroup)
2588 (if (or (listp setting)
2589 (not (and gnus-window-configuration
2590 (memq setting '(group summary article)))))
2592 (let* ((setting (if (eq setting 'group)
2593 (if (assq 'newsgroup gnus-window-configuration)
2595 'newsgroups) setting))
2596 (elem (car (cdr (assq setting gnus-window-configuration))))
2597 (total (apply '+ elem))
2598 (types '(group summary article))
2599 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2604 (or (zerop (nth i elem))
2606 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2607 (setq out (cons (if (eq pbuf (nth i types))
2608 (vector (nth i types) perc 'point)
2609 (vector (nth i types) perc))
2612 (list (nreverse out)))))
2614 (defun gnus-add-configuration (conf)
2615 (setq gnus-buffer-configuration
2616 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2617 gnus-buffer-configuration))))
2619 (defun gnus-configure-windows (setting &optional force)
2620 (setq setting (gnus-windows-old-to-new setting))
2621 (let ((r (if (symbolp setting)
2622 (cdr (assq setting gnus-buffer-configuration))
2624 (in-buf (current-buffer))
2625 rule val w height hor ohor heights sub jump-buffer
2626 rel total to-buf all-visible)
2627 (or r (error "No such setting: %s" setting))
2629 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r)))
2630 ;; All the windows mentioned are already visibe, so we just
2631 ;; put point in the assigned buffer, and do not touch the
2633 (select-window (get-buffer-window all-visible))
2635 ;; Either remove all windows or just remove all Gnus windows.
2636 (if gnus-use-full-window
2637 (delete-other-windows)
2638 (gnus-remove-some-windows)
2639 (switch-to-buffer nntp-server-buffer))
2645 ;; We have to do the (possible) horizontal splitting before the
2647 (if (and (listp (car hor))
2648 (eq (car (car hor)) 'horizontal))
2652 (if (integerp (nth 1 (car hor)))
2654 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2656 (setq hor (cdr hor))))
2658 ;; Go through the rules and eval the elements that are to be
2661 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2663 ;; Expand short buffer name.
2664 (setq w (aref val 0))
2665 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2667 (setq val (apply 'vector (mapcar 'identity val)))
2669 (setq ohor (cons val ohor))))
2670 (setq hor (cdr hor)))
2671 (setq rule (cons (nreverse ohor) rule))
2673 (setq rule (nreverse rule))
2675 ;; We tally the window sizes.
2676 (setq total (window-height))
2678 (setq hor (car rule))
2679 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2680 (setq hor (cdr hor)))
2683 (setq rel (aref (car hor) 1)
2685 (cond ((and (floatp rel) (= 1.0 rel))
2690 (max (floor (* total rel)) 4)))
2692 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2694 (setq heights (nreverse heights)
2697 ;; We then go through these heighs and create windows for them.
2699 (setq height (car heights)
2700 heights (cdr heights))
2702 (setq height (- total sub)))
2704 (split-window nil height))
2705 (setq to-buf (aref (car hor) 0))
2710 (symbol-value (aref (car hor) 0)))
2712 (aref (car hor) 0))))
2713 (and (> (length (car hor)) 2)
2714 (eq (aref (car hor) 2) 'point)
2715 (setq jump-buffer (current-buffer)))
2717 (setq hor (cdr hor)))
2719 (setq rule (cdr rule)))
2721 ;; Finally, we pop to the buffer that's supposed to have point.
2722 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2724 (select-window (get-buffer-window jump-buffer))
2725 (set-buffer jump-buffer))))
2727 (defun gnus-all-windows-visible-p (rule)
2728 (let (invisible hor jump-buffer val buffer)
2729 ;; Go through the rules and eval the elements that are to be
2731 (while (and rule (not invisible))
2732 (setq hor (car rule)
2734 (while (and hor (not invisible))
2735 (if (setq val (if (vectorp (car hor))
2737 (if (not (eq (car (car hor)) 'horizontal))
2740 ;; Expand short buffer name.
2741 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer))
2743 (setq buffer (if (symbolp buffer) (symbol-value buffer)
2745 (and (> (length val) 2) (eq 'point (aref val 2))
2746 (setq jump-buffer buffer))
2747 (setq invisible (not (and buffer (get-buffer-window buffer))))))
2748 (setq hor (cdr hor))))
2749 (and (not invisible) jump-buffer)))
2751 (defun gnus-window-top-edge (&optional window)
2752 (nth 1 (window-edges window)))
2754 (defun gnus-remove-some-windows ()
2755 (let ((buffers gnus-window-to-buffer)
2756 buf bufs lowest-buf lowest)
2758 ;; Remove windows on all known Gnus buffers.
2760 (setq buf (cdr (car buffers)))
2762 (setq buf (and (boundp buf) (symbol-value buf))))
2764 (get-buffer-window buf)
2766 (setq bufs (cons buf bufs))
2768 (if (or (not lowest)
2769 (< (gnus-window-top-edge) lowest))
2771 (setq lowest (gnus-window-top-edge))
2772 (setq lowest-buf buf)))))
2773 (setq buffers (cdr buffers)))
2774 ;; Remove windows on *all* summary buffers.
2778 (let ((buf (window-buffer win)))
2779 (if (string-match "^\\*Summary" (buffer-name buf))
2781 (setq bufs (cons buf bufs))
2783 (if (or (not lowest)
2784 (< (gnus-window-top-edge) lowest))
2786 (setq lowest-buf buf)
2787 (setq lowest (gnus-window-top-edge))))))))))
2790 (pop-to-buffer lowest-buf)
2791 (switch-to-buffer nntp-server-buffer)))
2793 (and (not (eq (car bufs) lowest-buf))
2794 (delete-windows-on (car bufs)))
2795 (setq bufs (cdr bufs))))))
2797 (defun gnus-version ()
2798 "Version numbers of this version of Gnus."
2800 (let ((methods gnus-valid-select-methods)
2803 ;; Go through all the legal select methods and add their version
2804 ;; numbers to the total version string. Only the backends that are
2805 ;; currently in use will have their message numbers taken into
2808 (setq meth (intern (concat (car (car methods)) "-version")))
2810 (stringp (symbol-value meth))
2811 (setq mess (concat mess "; " (symbol-value meth))))
2812 (setq methods (cdr methods)))
2813 (gnus-message 2 mess)))
2815 (defun gnus-info-find-node ()
2816 "Find Info documentation of Gnus."
2818 ;; Enlarge info window if needed.
2819 (let ((mode major-mode))
2820 (gnus-configure-windows 'info)
2821 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2823 (defun gnus-replace-chars-in-string (string &rest pairs)
2824 "Replace characters in STRING from FROM to TO."
2825 (let ((string (substring string 0)) ;Copy string.
2826 (len (length string))
2829 (or (zerop (% (length pairs) 2))
2830 (error "Odd number of translation pairs"))
2831 (setplist 'sym pairs)
2832 ;; Replace all occurrences of FROM with TO.
2834 (if (setq to (get 'sym (aref string idx)))
2835 (aset string idx to))
2836 (setq idx (1+ idx)))
2839 (defun gnus-days-between (date1 date2)
2840 ;; Return the number of days between date1 and date2.
2841 (- (gnus-day-number date1) (gnus-day-number date2)))
2843 (defun gnus-day-number (date)
2844 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2845 (timezone-parse-date date))))
2846 (timezone-absolute-from-gregorian
2847 (nth 1 dat) (nth 2 dat) (car dat))))
2849 ;; Returns a floating point number that says how many seconds have
2850 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2851 (defun gnus-seconds-since-epoch (date)
2852 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2853 (timezone-parse-date date)))
2854 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2855 (timezone-parse-time
2856 (aref (timezone-parse-date date) 3))))
2857 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2858 (timezone-parse-date "Jan 1 12:00:00 1970")))
2859 (tday (- (timezone-absolute-from-gregorian
2860 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2861 (timezone-absolute-from-gregorian
2862 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2864 (* (nth 1 ttime) 60)
2865 (* 1.0 (nth 0 ttime) 60 60)
2866 (* 1.0 tday 60 60 24))))
2868 (defun gnus-file-newer-than (file date)
2869 (let ((fdate (nth 5 (file-attributes file))))
2870 (or (> (car fdate) (car date))
2871 (and (= (car fdate) (car date))
2872 (> (nth 1 fdate) (nth 1 date))))))
2874 (defun gnus-group-read-only-p (&optional group)
2875 "Check whether GROUP supports editing or not.
2876 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
2877 that that variable is buffer-local to the summary buffers."
2878 (let ((group (or group gnus-newsgroup-name)))
2879 (not (gnus-check-backend-function 'request-replace-article group))))
2881 (defun gnus-group-total-expirable-p (group)
2882 "Check whether GROUP is total-expirable or not."
2883 (let ((params (nth 5 (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))))
2884 (or (memq 'total-expire params)
2885 (cdr (assq 'total-expire params)) ; (total-expire . t)
2886 (and gnus-total-expirable-newsgroups ; Check var.
2887 (string-match gnus-total-expirable-newsgroups group)))))
2889 (defun gnus-group-auto-expirable-p (group)
2890 "Check whether GROUP is total-expirable or not."
2891 (let ((params (nth 5 (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))))
2892 (or (memq 'auto-expire params)
2893 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
2894 (and gnus-auto-expirable-newsgroups ; Check var.
2895 (string-match gnus-auto-expirable-newsgroups group)))))
2897 (defun gnus-subject-equal (s1 s2)
2898 "Check whether two subjects are equal."
2900 ((null gnus-summary-gather-subject-limit)
2901 (equal (gnus-simplify-subject-re s1)
2902 (gnus-simplify-subject-re s2)))
2903 ((eq gnus-summary-gather-subject-limit 'fuzzy)
2904 (equal (gnus-simplify-subject-fuzzy s1)
2905 (gnus-simplify-subject-fuzzy s2)))
2906 ((numberp gnus-summary-gather-subject-limit)
2907 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
2908 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
2912 ;; Returns a list of writable groups.
2913 (defun gnus-writable-groups ()
2914 (let ((alist gnus-newsrc-alist)
2917 (or (gnus-group-read-only-p (car (car alist)))
2918 (setq groups (cons (car (car alist)) groups)))
2919 (setq alist (cdr alist)))
2922 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2924 (defun gnus-y-or-n-p (prompt)
2929 (defun gnus-yes-or-no-p (prompt)
2931 (yes-or-no-p prompt)
2934 ;; Check whether to use long file names.
2935 (defun gnus-use-long-file-name (symbol)
2936 ;; The variable has to be set...
2937 (and gnus-use-long-file-name
2938 ;; If it isn't a list, then we return t.
2939 (or (not (listp gnus-use-long-file-name))
2940 ;; If it is a list, and the list contains `symbol', we
2942 (not (memq symbol gnus-use-long-file-name)))))
2944 ;; I suspect there's a better way, but I haven't taken the time to do
2945 ;; it yet. -erik selberg@cs.washington.edu
2946 (defun gnus-dd-mmm (messy-date)
2947 "Return a string like DD-MMM from a big messy string"
2948 (let ((datevec (timezone-parse-date messy-date)))
2950 (or (aref datevec 2) "??")
2953 (nth (1- (string-to-number (aref datevec 1)))
2954 timezone-months-assoc))
2957 ;; Make a hash table (default and minimum size is 255).
2958 ;; Optional argument HASHSIZE specifies the table size.
2959 (defun gnus-make-hashtable (&optional hashsize)
2960 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2962 ;; Make a number that is suitable for hashing; bigger than MIN and one
2964 (defun gnus-create-hash-size (min)
2970 ;; Show message if message has a lower level than `gnus-verbose'.
2971 ;; Guide-line for numbers:
2972 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2973 ;; for things that take a long time, 7 - not very important messages
2974 ;; on stuff, 9 - messages inside loops.
2975 (defun gnus-message (level &rest args)
2976 (if (<= level gnus-verbose)
2977 (apply 'message args)
2978 ;; We have to do this format thingie here even if the result isn't
2979 ;; shown - the return value has to be the same as the return value
2981 (apply 'format args)))
2983 ;; Generate a unique new group name.
2984 (defun gnus-generate-new-group-name (leaf)
2987 (while (gnus-gethash name gnus-newsrc-hashtb)
2988 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2991 ;; Find out whether the gnus-visual TYPE is wanted.
2992 (defun gnus-visual-p (&optional type class)
2993 (and gnus-visual ; Has to be non-nil, at least.
2994 (if (not type) ; We don't care about type.
2996 (if (listp gnus-visual) ; It's a list, so we check it.
2997 (or (memq type gnus-visual)
2998 (memq class gnus-visual))
3001 ;;; List and range functions
3003 (defun gnus-last-element (list)
3004 "Return last element of LIST."
3006 (setq list (cdr list)))
3009 (defun gnus-copy-sequence (list)
3010 "Do a complete, total copy of a list."
3011 (if (and (consp list) (not (consp (cdr list))))
3012 (cons (car list) (cdr list))
3013 (mapcar (lambda (elem) (if (consp elem)
3014 (if (consp (cdr elem))
3015 (gnus-copy-sequence elem)
3016 (cons (car elem) (cdr elem)))
3020 (defun gnus-set-difference (list1 list2)
3021 "Return a list of elements of LIST1 that do not appear in LIST2."
3022 (let ((list1 (copy-sequence list1)))
3024 (setq list1 (delq (car list2) list1))
3025 (setq list2 (cdr list2)))
3028 (defun gnus-sorted-complement (list1 list2)
3029 "Return a list of elements of LIST1 that do not appear in LIST2.
3030 Both lists have to be sorted over <."
3032 (if (or (null list1) (null list2))
3034 (while (and list1 list2)
3035 (cond ((= (car list1) (car list2))
3036 (setq list1 (cdr list1)
3038 ((< (car list1) (car list2))
3039 (setq out (cons (car list1) out))
3040 (setq list1 (cdr list1)))
3042 (setq out (cons (car list2) out))
3043 (setq list2 (cdr list2)))))
3044 (nconc (nreverse out) (or list1 list2)))))
3046 (defun gnus-intersection (list1 list2)
3049 (if (memq (car list2) list1)
3050 (setq result (cons (car list2) result)))
3051 (setq list2 (cdr list2)))
3054 (defun gnus-sorted-intersection (list1 list2)
3055 ;; LIST1 and LIST2 have to be sorted over <.
3057 (while (and list1 list2)
3058 (cond ((= (car list1) (car list2))
3059 (setq out (cons (car list1) out)
3062 ((< (car list1) (car list2))
3063 (setq list1 (cdr list1)))
3065 (setq list2 (cdr list2)))))
3068 (defun gnus-set-sorted-intersection (list1 list2)
3069 ;; LIST1 and LIST2 have to be sorted over <.
3070 ;; This function modifies LIST1.
3071 (let* ((top (cons nil list1))
3073 (while (and list1 list2)
3074 (cond ((= (car list1) (car list2))
3078 ((< (car list1) (car list2))
3079 (setcdr prev (cdr list1))
3080 (setq list1 (cdr list1)))
3082 (setq list2 (cdr list2)))))
3086 (defun gnus-compress-sequence (numbers &optional always-list)
3087 "Convert list of numbers to a list of ranges or a single range.
3088 If ALWAYS-LIST is non-nil, this function will always release a list of
3090 (let* ((first (car numbers))
3091 (last (car numbers))
3095 (if (not (listp (cdr numbers)))
3098 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3099 ((= (1+ last) (car numbers)) ;Still in sequence
3100 (setq last (car numbers)))
3101 (t ;End of one sequence
3103 (cons (if (= first last) first
3104 (cons first last)) result))
3105 (setq first (car numbers))
3106 (setq last (car numbers))))
3107 (setq numbers (cdr numbers)))
3108 (if (and (not always-list) (null result))
3109 (if (= first last) (list first) (cons first last))
3110 (nreverse (cons (if (= first last) first (cons first last))
3113 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3114 (defun gnus-uncompress-range (ranges)
3115 "Expand a list of ranges into a list of numbers.
3116 RANGES is either a single range on the form `(num . num)' or a list of
3118 (let (first last result)
3122 ((not (listp (cdr ranges)))
3123 (setq first (car ranges))
3124 (setq last (cdr ranges))
3125 (while (<= first last)
3126 (setq result (cons first result))
3127 (setq first (1+ first)))
3131 (if (atom (car ranges))
3132 (if (numberp (car ranges))
3133 (setq result (cons (car ranges) result)))
3134 (setq first (car (car ranges)))
3135 (setq last (cdr (car ranges)))
3136 (while (<= first last)
3137 (setq result (cons first result))
3138 (setq first (1+ first))))
3139 (setq ranges (cdr ranges)))
3140 (nreverse result)))))
3142 (defun gnus-add-to-range (ranges list)
3143 "Return a list of ranges that has all articles from both RANGES and LIST.
3144 Note: LIST has to be sorted over `<'."
3146 (gnus-compress-sequence list t)
3147 (setq list (copy-sequence list))
3148 (or (listp (cdr ranges))
3149 (setq ranges (list ranges)))
3151 ilist lowest highest temp)
3152 (while (and ranges list)
3154 (setq lowest (or (and (atom (car ranges)) (car ranges))
3155 (car (car ranges))))
3156 (while (and list (cdr list) (< (car (cdr list)) lowest))
3157 (setq list (cdr list)))
3158 (if (< (car ilist) lowest)
3161 (setq list (cdr list))
3163 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3164 (setq highest (or (and (atom (car ranges)) (car ranges))
3165 (cdr (car ranges))))
3166 (while (and list (<= (car list) highest))
3167 (setq list (cdr list)))
3168 (setq ranges (cdr ranges)))
3170 (setq out (nconc (gnus-compress-sequence list t) out)))
3171 (setq out (sort out (lambda (r1 r2)
3172 (< (or (and (atom r1) r1) (car r1))
3173 (or (and (atom r2) r2) (car r2))))))
3176 (if (atom (car ranges))
3178 (if (atom (car (cdr ranges)))
3179 (if (= (1+ (car ranges)) (car (cdr ranges)))
3181 (setcar ranges (cons (car ranges)
3182 (car (cdr ranges))))
3183 (setcdr ranges (cdr (cdr ranges)))))
3184 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
3186 (setcar (car (cdr ranges)) (car ranges))
3187 (setcar ranges (car (cdr ranges)))
3188 (setcdr ranges (cdr (cdr ranges)))))))
3190 (if (atom (car (cdr ranges)))
3191 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
3193 (setcdr (car ranges) (car (cdr ranges)))
3194 (setcdr ranges (cdr (cdr ranges)))))
3195 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
3197 (setcdr (car ranges) (cdr (car (cdr ranges))))
3198 (setcdr ranges (cdr (cdr ranges))))))))
3199 (setq ranges (cdr ranges)))
3202 (defun gnus-remove-from-range (ranges list)
3203 "Return a list of ranges that has all articles from LIST removed from RANGES.
3204 Note: LIST has to be sorted over `<'."
3205 ;; !!! This function shouldn't look like this, but I've got a headache.
3206 (gnus-compress-sequence
3207 (gnus-sorted-complement
3208 (gnus-uncompress-range ranges) list)))
3210 (defun gnus-member-of-range (number ranges)
3211 (if (not (listp (cdr ranges)))
3212 (and (>= number (car ranges))
3213 (<= number (cdr ranges)))
3216 (if (numberp (car ranges))
3217 (>= number (car ranges))
3218 (>= number (car (car ranges))))
3220 (if (if (numberp (car ranges))
3221 (= number (car ranges))
3222 (and (>= number (car (car ranges)))
3223 (<= number (cdr (car ranges)))))
3224 (setq not-stop nil))
3225 (setq ranges (cdr ranges)))
3233 (defvar gnus-group-mode-map nil)
3234 (defvar gnus-group-group-map nil)
3235 (defvar gnus-group-mark-map nil)
3236 (defvar gnus-group-list-map nil)
3237 (defvar gnus-group-sub-map nil)
3238 (defvar gnus-group-score-map nil)
3239 (put 'gnus-group-mode 'mode-class 'special)
3241 (if gnus-group-mode-map
3243 (setq gnus-group-mode-map (make-keymap))
3244 (suppress-keymap gnus-group-mode-map)
3245 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
3246 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
3247 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
3248 (define-key gnus-group-mode-map "\M-\r" 'gnus-group-quick-select-group)
3249 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
3250 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
3251 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
3252 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
3253 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
3254 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
3255 (define-key gnus-group-mode-map
3256 "\M-n" 'gnus-group-next-unread-group-same-level)
3257 (define-key gnus-group-mode-map
3258 "\M-p" 'gnus-group-prev-unread-group-same-level)
3259 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
3260 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
3261 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3262 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3263 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3264 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3265 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3266 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3267 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3268 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3269 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3270 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3271 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3272 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3273 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3274 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3275 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3276 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3277 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3278 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
3279 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3280 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3281 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3282 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3283 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3284 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3285 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3286 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3287 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3288 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3289 (define-key gnus-group-mode-map "V" 'gnus-version)
3290 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3291 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3292 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3293 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3294 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3295 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3296 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3297 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3298 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3299 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3300 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3301 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3302 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3303 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3304 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3306 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3307 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3308 (define-prefix-command 'gnus-group-mark-map)
3309 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3310 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3311 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3312 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3314 (define-prefix-command 'gnus-group-group-map)
3315 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3316 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3317 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3318 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3319 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3320 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3321 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3322 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3323 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3324 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3325 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3326 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3327 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3328 (define-key gnus-group-group-map "r" 'gnus-group-rename-group)
3329 (define-key gnus-group-group-map "\177" 'gnus-group-delete-group)
3330 (define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3331 (define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3332 (define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3333 (define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3334 (define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3336 (define-prefix-command 'gnus-group-list-map)
3337 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3338 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3339 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3340 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3341 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3342 (define-key gnus-group-list-map "A" 'gnus-group-list-active)
3343 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3344 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3345 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3346 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3348 (define-prefix-command 'gnus-group-score-map)
3349 (define-key gnus-group-mode-map "W" 'gnus-group-score-map)
3350 (define-key gnus-group-score-map "f" 'gnus-score-flush-cache)
3352 (define-prefix-command 'gnus-group-sub-map)
3353 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3354 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3355 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3356 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3357 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3358 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3359 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3360 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3362 (defun gnus-group-mode ()
3363 "Major mode for reading news.
3365 All normal editing commands are switched off.
3366 \\<gnus-group-mode-map>
3367 The group buffer lists (some of) the groups available. For instance,
3368 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3369 lists all zombie groups.
3371 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3372 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3374 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3376 The following commands are available:
3378 \\{gnus-group-mode-map}"
3380 (if (gnus-visual-p 'group-menu 'menu) (gnus-group-make-menu-bar))
3381 (kill-all-local-variables)
3382 (setq mode-line-modified "-- ")
3383 (make-local-variable 'mode-line-format)
3384 (setq mode-line-format (copy-sequence mode-line-format))
3385 (and (equal (nth 3 mode-line-format) " ")
3386 (setcar (nthcdr 3 mode-line-format) ""))
3387 (setq major-mode 'gnus-group-mode)
3388 (setq mode-name "Group")
3389 (gnus-group-set-mode-line)
3390 (setq mode-line-process nil)
3391 (use-local-map gnus-group-mode-map)
3392 (buffer-disable-undo (current-buffer))
3393 (setq truncate-lines t)
3394 (setq buffer-read-only t)
3395 (run-hooks 'gnus-group-mode-hook))
3397 (defun gnus-mouse-pick-group (e)
3400 (gnus-group-read-group nil))
3402 ;; Look at LEVEL and find out what the level is really supposed to be.
3403 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
3404 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
3405 (defun gnus-group-default-level (&optional level number-or-nil)
3407 (gnus-group-use-permanent-levels
3408 (setq gnus-group-default-list-level
3409 (or level gnus-group-default-list-level))
3410 (or gnus-group-default-list-level gnus-level-subscribed))
3414 (or level gnus-group-default-list-level gnus-level-subscribed))))
3418 (defun gnus-no-server (&optional arg)
3420 If ARG is a positive number, Gnus will use that as the
3421 startup level. If ARG is nil, Gnus will be started at level 2.
3422 If ARG is non-nil and not a positive number, Gnus will
3423 prompt the user for the name of an NNTP server to use.
3424 As opposed to `gnus', this command will not connect to the local server."
3426 (setq gnus-group-use-permanent-levels t)
3427 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3430 (defun gnus-slave (&optional arg)
3431 "Read news as a slave."
3433 (gnus arg nil 'slave))
3436 (defun gnus (&optional arg dont-connect slave)
3438 If ARG is non-nil and a positive number, Gnus will use that as the
3439 startup level. If ARG is non-nil and not a positive number, Gnus will
3440 prompt the user for the name of an NNTP server to use."
3442 (if (get-buffer gnus-group-buffer)
3444 (switch-to-buffer gnus-group-buffer)
3445 (gnus-group-get-new-news))
3449 (nnheader-init-server-buffer)
3450 (gnus-read-init-file)
3452 (setq gnus-slave slave)
3454 (gnus-group-setup-buffer)
3455 (let ((buffer-read-only nil))
3457 (if (not gnus-inhibit-startup-message)
3459 (gnus-group-startup-message)
3462 (let ((level (and arg (numberp arg) (> arg 0) arg))
3468 (gnus-start-news-server (and arg (not level))))))
3469 (if (and (not dont-connect)
3472 (run-hooks 'gnus-startup-hook)
3473 ;; NNTP server is successfully open.
3475 ;; Find the current startup file name.
3476 (setq gnus-current-startup-file
3477 (gnus-make-newsrc-file gnus-startup-file))
3479 ;; Read the dribble file.
3480 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
3482 (gnus-summary-make-display-table)
3483 (gnus-setup-news nil level)
3484 (gnus-group-list-groups level)
3485 (gnus-configure-windows 'group))))))
3487 (defun gnus-unload ()
3488 "Unload all Gnus features."
3490 (or (boundp 'load-history)
3491 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
3492 (let ((history load-history)
3495 (and (string-match "^gnus" (car (car history)))
3496 (setq feature (cdr (assq 'provide (car history))))
3497 (unload-feature feature 'force))
3498 (setq history (cdr history)))))
3500 (defun gnus-group-startup-message (&optional x y)
3501 "Insert startup message in current buffer."
3502 ;; Insert the message.
3507 _ ___ __ ___ __ _ ___
3525 Gnus * A newsreader for Emacsen
3526 A Praxis release * larsi@ifi.uio.no
3529 ;; And then hack it.
3530 ;; 18 is the longest line.
3531 (indent-rigidly (point-min) (point-max)
3532 (/ (max (- (window-width) (or x 46)) 0) 2))
3533 (goto-char (point-min))
3534 (let* ((pheight (count-lines (point-min) (point-max)))
3535 (wheight (window-height))
3536 (rest (- wheight pheight)))
3537 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
3542 (goto-char (point-min))
3543 (search-forward "Praxis")
3544 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3545 (goto-char (point-min)))
3547 (defun gnus-group-startup-message-old (&optional x y)
3548 "Insert startup message in current buffer."
3549 ;; Insert the message.
3565 ;; And then hack it.
3566 ;; 18 is the longest line.
3567 (indent-rigidly (point-min) (point-max)
3568 (/ (max (- (window-width) (or x 28)) 0) 2))
3569 (goto-char (point-min))
3570 ;; +4 is fuzzy factor.
3571 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3574 (goto-char (point-min))
3575 (search-forward "Praxis")
3576 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3577 (goto-char (point-min)))
3579 (defun gnus-group-setup-buffer ()
3580 (or (get-buffer gnus-group-buffer)
3582 (switch-to-buffer gnus-group-buffer)
3583 (gnus-add-current-to-buffer-list)
3585 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3587 (defun gnus-group-list-groups (&optional level unread)
3588 "List newsgroups with level LEVEL or lower that have unread articles.
3589 Default is all subscribed groups.
3590 If argument UNREAD is non-nil, groups with no unread articles are also
3592 (interactive (list (if current-prefix-arg
3593 (prefix-numeric-value current-prefix-arg)
3595 (gnus-group-default-level nil t)
3596 gnus-group-default-list-level
3597 gnus-level-subscribed))))
3599 (setq level (car gnus-group-list-mode)
3600 unread (cdr gnus-group-list-mode)))
3601 (setq level (gnus-group-default-level level))
3602 (gnus-group-setup-buffer) ;May call from out of group buffer
3603 (let ((case-fold-search nil)
3604 (group (gnus-group-group-name)))
3605 (funcall gnus-group-prepare-function level unread nil)
3606 (if (zerop (buffer-size))
3607 (gnus-message 5 gnus-no-groups-message)
3608 (goto-char (point-min))
3610 ;; Go to the first group with unread articles.
3611 (gnus-group-search-forward nil nil nil t)
3612 ;; Find the right group to put point on. If the current group
3613 ;; has disapeared in the new listing, try to find the next
3614 ;; one. If no next one can be found, just leave point at the
3615 ;; first newsgroup in the buffer.
3616 (if (not (gnus-goto-char
3617 (text-property-any (point-min) (point-max)
3618 'gnus-group (intern group))))
3619 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3621 (not (gnus-goto-char
3623 (point-min) (point-max) 'gnus-group
3624 (intern (car (car newsrc)))))))
3625 (setq newsrc (cdr newsrc)))
3626 (or newsrc (progn (goto-char (point-max))
3627 (forward-line -1))))))
3628 ;; Adjust cursor point.
3629 (gnus-group-position-point))))
3631 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3632 "List all newsgroups with unread articles of level LEVEL or lower.
3633 If ALL is non-nil, list groups that have no unread articles.
3634 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3635 If REGEXP, only list groups matching REGEXP."
3636 (set-buffer gnus-group-buffer)
3637 (let ((buffer-read-only nil)
3638 (newsrc (cdr gnus-newsrc-alist))
3639 (lowest (or lowest 1))
3640 info clevel unread group)
3642 (if (< lowest gnus-level-zombie)
3643 ;; List living groups.
3645 (setq info (car newsrc)
3648 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3649 (and unread ; This group might be bogus
3651 (string-match regexp group))
3652 (<= (setq clevel (car (cdr info))) level)
3654 (or all ; We list all groups?
3655 (eq unread t) ; We list unactivated groups
3656 (> unread 0) ; We list groups with unread articles
3657 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3658 (gnus-group-insert-group-line
3659 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3661 ;; List dead groups.
3662 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3663 (gnus-group-prepare-flat-list-dead
3664 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3665 gnus-level-zombie ?Z
3667 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3668 (gnus-group-prepare-flat-list-dead
3669 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3670 gnus-level-killed ?K regexp))
3672 (gnus-group-set-mode-line)
3673 (setq gnus-group-list-mode (cons level all))
3674 (run-hooks 'gnus-group-prepare-hook)))
3676 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3677 ;; List zombies and killed lists somehwat faster, which was
3678 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3679 ;; this by ignoring the group format specification altogether.
3682 (setq group (car groups)
3683 groups (cdr groups))
3684 (if (or (not regexp)
3685 (string-match regexp group))
3688 (insert (format " %c *: %s\n" mark group))
3689 (add-text-properties
3691 (list 'gnus-group (intern group)
3693 'gnus-level level)))))))
3695 (defun gnus-group-real-name (group)
3696 "Find the real name of a foreign newsgroup."
3697 (if (string-match ":[^:]+$" group)
3698 (substring group (1+ (match-beginning 0)))
3701 (defun gnus-group-prefixed-name (group method)
3702 "Return the whole name from GROUP and METHOD."
3703 (and (stringp method) (setq method (gnus-server-to-method method)))
3704 (concat (format "%s" (car method))
3706 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3707 (not (string= (nth 1 method) "")))
3708 (concat "+" (nth 1 method)))
3711 (defun gnus-group-real-prefix (group)
3712 "Return the prefix of the current group name."
3713 (if (string-match "^[^:]+:" group)
3714 (substring group 0 (match-end 0))
3717 (defun gnus-group-method-name (group)
3718 "Return the method used for selecting GROUP."
3719 (let ((prefix (gnus-group-real-prefix group)))
3720 (if (equal prefix "")
3722 (if (string-match "^[^\\+]+\\+" prefix)
3723 (list (intern (substring prefix 0 (1- (match-end 0))))
3724 (substring prefix (match-end 0) (1- (length prefix))))
3725 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3727 (defun gnus-group-foreign-p (group)
3728 "Return nil if GROUP is native, non-nil if it is foreign."
3729 (string-match ":" group))
3731 (defun gnus-group-topic-p ()
3732 "Return non-nil if the current line is a topic."
3733 (get-text-property (gnus-point-at-bol) 'gnus-topic))
3735 (defun gnus-group-add-parameter (group param)
3736 "Add parameter PARAM to GROUP."
3737 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
3739 () ; This is a dead group. We just ignore it.
3740 ;; Cons the new param to the old one and update.
3741 (gnus-group-set-info (cons param (nth 5 info)) group 'params))))
3743 (defun gnus-group-set-info (info &optional method-only-group part)
3744 (let* ((entry (gnus-gethash
3745 (or method-only-group (car info)) gnus-newsrc-hashtb))
3747 (info (if method-only-group (nth 2 entry) info)))
3748 (if (not method-only-group)
3751 (error "Trying to change non-existent group %s" method-only-group))
3752 ;; We have recevied parts of the actual group info - either the
3753 ;; select method or the group parameters. We first check
3754 ;; whether we have to extend the info, and if so, do that.
3755 (let ((len (length info))
3756 (total (if (eq part 'method) 5 6)))
3758 (setcdr (nthcdr (1- len) info)
3759 (make-list (- total len) nil)))
3760 ;; Then we enter the new info.
3761 (setcar (nthcdr (1- total) info) part-info)))
3762 ;; We uncompress some lists of marked articles.
3764 (if (not (setq marked (nth 3 info)))
3767 (or (eq 'score (car (car marked)))
3768 (eq 'bookmark (car (car marked)))
3769 (eq 'killed (car (car marked)))
3770 (setcdr (car marked)
3771 (gnus-uncompress-range (cdr (car marked)))))
3772 (setq marked (cdr marked)))))
3775 ;; This is a new group, so we just create it.
3777 (set-buffer gnus-group-buffer)
3779 ;; It's a foreign group...
3780 (gnus-group-make-group
3781 (gnus-group-real-name (car info))
3782 (prin1-to-string (car (nth 4 info)))
3783 (nth 1 (nth 4 info)))
3784 ;; It's a native group.
3785 (gnus-group-make-group (car info)))
3786 (gnus-message 6 "Note: New group created")
3788 (gnus-gethash (gnus-group-prefixed-name
3789 (gnus-group-real-name (car info))
3790 (or (nth 4 info) gnus-select-method))
3791 gnus-newsrc-hashtb))))
3792 ;; Whether it was a new group or not, we now have the entry, so we
3793 ;; can do the update.
3796 (setcar (nthcdr 2 entry) info)
3797 (if (and (not (eq (car entry) t))
3798 (gnus-gethash (car info) gnus-active-hashtb))
3799 (let ((marked (nth 3 info)))
3801 (max 0 (- (length (gnus-list-of-unread-articles
3803 (length (cdr (assq 'tick marked)))
3804 (length (cdr (assq 'dormant marked)))))))))
3805 (error "No such group: %s" (car info)))))
3807 (defun gnus-group-set-method-info (group select-method)
3808 (gnus-group-set-info select-method group 'method))
3810 (defun gnus-group-set-params-info (group params)
3811 (gnus-group-set-info params group 'params))
3813 (defun gnus-group-update-group-line ()
3814 "This function updates the current line in the newsgroup buffer and
3815 moves the point to the colon."
3816 (let* ((buffer-read-only nil)
3817 (group (gnus-group-group-name))
3818 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3821 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3824 (delete-region (point) (progn (forward-line 1) (point)))
3825 (gnus-group-insert-group-line-info group)
3827 (gnus-group-position-point)))
3829 (defun gnus-group-insert-group-line-info (group)
3830 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3834 (setq info (nth 2 entry))
3835 (gnus-group-insert-group-line
3836 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3837 (setq active (gnus-gethash group gnus-active-hashtb))
3838 (gnus-group-insert-group-line
3840 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3841 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3843 (defun gnus-group-insert-group-line (gformat group level marked number method)
3844 (let* ((gformat (or gformat gnus-group-line-format-spec))
3845 (active (gnus-gethash group gnus-active-hashtb))
3846 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3847 (number-of-dormant (length (cdr (assq 'dormant marked))))
3848 (number-of-ticked (length (cdr (assq 'tick marked))))
3849 (number-of-ticked-and-dormant
3850 (+ number-of-ticked number-of-dormant))
3851 (number-of-unread-unticked
3852 (if (numberp number) (int-to-string (max 0 number))
3855 (if (numberp number)
3856 (max 0 (- number-total number))
3858 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3859 ((<= level gnus-level-unsubscribed) ?U)
3860 ((= level gnus-level-zombie) ?Z)
3862 (qualified-group (gnus-group-real-name group))
3863 (newsgroup-description
3864 (if gnus-description-hashtb
3865 (or (gnus-gethash group gnus-description-hashtb) "")
3867 (moderated (if (member group gnus-moderated-list) ?m ? ))
3868 (moderated-string (if (eq moderated ?m) "(m)" ""))
3869 (method (gnus-server-get-method group method))
3870 (news-server (or (car (cdr method)) ""))
3871 (news-method (or (car method) ""))
3873 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3877 (> number-of-ticked 0))
3879 (number (if (eq number t) "*" (+ number number-of-dormant
3881 (process-marked (if (member group gnus-group-marked)
3882 gnus-process-mark ? ))
3883 (buffer-read-only nil)
3884 header ; passed as parameter to user-funcs.
3889 (insert (eval gformat))
3891 (add-text-properties
3892 b (1+ b) (list 'gnus-group (intern group)
3893 'gnus-unread (if (numberp number)
3894 (string-to-int number-of-unread-unticked)
3897 'gnus-level level))))
3899 (defun gnus-group-update-group (group &optional visible-only)
3900 "Update newsgroup info of GROUP.
3901 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3903 (set-buffer gnus-group-buffer)
3904 (let ((buffer-read-only nil)
3906 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3909 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3911 ;; Buffer may be narrowed.
3914 ;; Search a line to modify. If the buffer is large, the search
3915 ;; takes long time. In most cases, current point is on the line
3916 ;; we are looking for. So, first of all, check current line.
3919 (eq (get-text-property (point) 'gnus-group)
3924 (point-min) (point-max) 'gnus-group (intern group)))))
3925 ;; GROUP is listed in current buffer. So, delete old line.
3929 (delete-region (point) (progn (forward-line 1) (point))))
3930 ;; No such line in the buffer, find out where it's supposed to
3931 ;; go, and insert it there (or at the end of the buffer).
3932 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3935 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3941 (point-min) (point-max)
3942 'gnus-group (intern (car (car entry)))))))
3943 (setq entry (cdr entry)))
3944 (or entry (goto-char (point-max)))))))
3945 (if (or visible (not visible-only))
3946 (gnus-group-insert-group-line-info group))
3947 (gnus-group-set-mode-line))))
3949 (defun gnus-group-set-mode-line ()
3950 (if (memq 'group gnus-updated-mode-lines)
3951 (let* ((gformat (or gnus-group-mode-line-format-spec
3952 (setq gnus-group-mode-line-format-spec
3954 gnus-group-mode-line-format
3955 gnus-group-mode-line-format-alist))))
3956 (news-server (car (cdr gnus-select-method)))
3957 (news-method (car gnus-select-method))
3959 (mode-string (eval gformat)))
3960 (setq mode-string (eval gformat))
3961 (if (> (length mode-string) max-len)
3962 (setq mode-string (substring mode-string 0 (- max-len 4))))
3963 (setq mode-line-buffer-identification mode-string)
3964 (set-buffer-modified-p t))))
3966 (defun gnus-group-group-name ()
3967 "Get the name of the newsgroup on the current line."
3968 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3969 (and group (symbol-name group))))
3971 (defun gnus-group-group-level ()
3972 "Get the level of the newsgroup on the current line."
3973 (get-text-property (gnus-point-at-bol) 'gnus-level))
3975 (defun gnus-group-group-unread ()
3976 "Get the number of unread articles of the newsgroup on the current line."
3977 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3979 (defun gnus-group-search-forward (&optional backward all level first-too)
3980 "Find the next newsgroup with unread articles.
3981 If BACKWARD is non-nil, find the previous newsgroup instead.
3982 If ALL is non-nil, just find any newsgroup.
3983 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3985 If FIRST-TOO, the current line is also eligible as a target."
3986 (let ((way (if backward -1 1))
3987 (low gnus-level-killed)
3990 (if (and backward (progn (beginning-of-line)) (bobp))
3992 (or first-too (forward-line way))
4000 (get-text-property (point) 'gnus-unread)))
4001 (or (eq unread t) (and unread (> unread 0))))
4002 (setq lev (get-text-property (point)
4004 (<= lev gnus-level-subscribed)))
4006 (and (setq lev (get-text-property (point)
4015 (zerop (forward-line way)))))
4017 (progn (gnus-group-position-point) t)
4018 (goto-char (or pos beg))
4021 ;;; Gnus group mode commands
4025 (defun gnus-group-mark-group (n &optional unmark no-advance)
4026 "Mark the current group."
4028 (let ((buffer-read-only nil)
4032 (setq group (gnus-group-group-name))
4036 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
4041 (setq gnus-group-marked (delete group gnus-group-marked)))
4043 (setq gnus-group-marked
4044 (cons group (delete group gnus-group-marked))))
4046 (or no-advance (zerop (gnus-group-next-group 1))))
4048 (gnus-summary-position-point)
4051 (defun gnus-group-unmark-group (n)
4052 "Remove the mark from the current group."
4054 (gnus-group-mark-group n 'unmark))
4056 (defun gnus-group-mark-region (unmark beg end)
4057 "Mark all groups between point and mark.
4058 If UNMARK, remove the mark instead."
4059 (interactive "P\nr")
4060 (let ((num (count-lines beg end)))
4063 (- num (gnus-group-mark-group num unmark)))))
4065 (defun gnus-group-remove-mark (group)
4066 (and (gnus-group-goto-group group)
4068 (gnus-group-mark-group 1 'unmark t))))
4070 ;; Return a list of groups to work on. Take into consideration N (the
4071 ;; prefix) and the list of marked groups.
4072 (defun gnus-group-process-prefix (n)
4074 (setq n (prefix-numeric-value n))
4075 ;; There is a prefix, so we return a list of the N next
4077 (let ((way (if (< n 0) -1 1))
4082 (setq group (gnus-group-group-name)))
4083 (setq groups (cons group groups))
4085 (forward-line way)))
4088 ;; No prefix, but a list of marked articles.
4089 (reverse gnus-group-marked))
4091 ;; Neither marked articles or a prefix, so we return the
4093 (let ((group (gnus-group-group-name)))
4094 (and group (list group))))))
4096 ;; Selecting groups.
4098 (defun gnus-group-read-group (&optional all no-article group)
4099 "Read news in this newsgroup.
4100 If the prefix argument ALL is non-nil, already read articles become
4101 readable. If the optional argument NO-ARTICLE is non-nil, no article
4102 will be auto-selected upon group entry."
4104 (if (gnus-group-topic-p)
4105 (gnus-topic-fold) ; This is a topic line.
4106 ;; And this is a real group.
4107 (let ((group (or group (gnus-group-group-name)))
4108 number active marked entry)
4109 (or group (error "No group on current line"))
4111 (nth 3 (nth 2 (setq entry (gnus-gethash
4112 group gnus-newsrc-hashtb)))))
4113 ;; This group might be a dead group. In that case we have to get
4114 ;; the number of unread articles from `gnus-active-hashtb'.
4116 (setq number (car entry))
4117 (if (setq active (gnus-gethash group gnus-active-hashtb))
4118 (setq number (- (1+ (cdr active)) (car active)))))
4119 (gnus-summary-read-group
4120 group (or all (and (numberp number)
4121 (zerop (+ number (length (cdr (assq 'tick marked)))
4122 (length (cdr (assq 'dormant marked)))))))
4125 (defun gnus-group-select-group (&optional all)
4126 "Select this newsgroup.
4127 No article is selected automatically.
4128 If argument ALL is non-nil, already read articles become readable."
4130 (gnus-group-read-group all t))
4132 (defun gnus-group-quick-select-group (&optional all)
4133 "Select the current group \"quickly\".
4134 This means that no highlighting or scoring will be performed."
4137 gnus-score-find-score-files-function
4138 gnus-apply-kill-hook
4139 gnus-summary-expunge-below)
4140 (gnus-group-read-group all t)))
4143 (defun gnus-fetch-group (group)
4144 "Start Gnus if necessary and enter GROUP.
4145 Returns whether the fetching was successful or not."
4146 (interactive "sGroup name: ")
4147 (or (get-buffer gnus-group-buffer)
4149 (gnus-group-select-group))
4151 (defun gnus-group-select-group-all ()
4152 "Select the current group and display all articles in it."
4154 (gnus-group-select-group 'all))
4156 ;; Enter a group that is not in the group buffer. Non-nil is returned
4157 ;; if selection was successful.
4158 (defun gnus-group-read-ephemeral-group
4159 (group method &optional activate quit-config)
4160 (let ((group (if (gnus-group-foreign-p group) group
4161 (gnus-group-prefixed-name group method))))
4164 (list t nil (list group gnus-level-default-subscribed nil nil
4168 (if quit-config quit-config
4169 (cons (current-buffer) 'summary)))))))
4171 (set-buffer gnus-group-buffer)
4172 (or (gnus-check-server method)
4173 (error "Unable to contact server: %s" (gnus-status-message method)))
4174 (if activate (or (gnus-request-group group)
4175 (error "Couldn't request group")))
4177 (gnus-group-read-group t t group)
4180 (not (equal major-mode 'gnus-group-mode))))
4182 (defun gnus-group-jump-to-group (group)
4183 "Jump to newsgroup GROUP."
4185 (list (completing-read
4186 "Group: " gnus-active-hashtb nil
4187 (memq gnus-select-method gnus-have-read-active-file))))
4189 (if (equal group "")
4190 (error "Empty group name"))
4192 (let ((b (text-property-any
4193 (point-min) (point-max) 'gnus-group (intern group))))
4195 ;; Either go to the line in the group buffer...
4197 ;; ... or insert the line.
4199 (gnus-gethash group gnus-active-hashtb)
4200 (gnus-activate-group group)
4201 (error "%s error: %s" group (gnus-status-message group)))
4203 (gnus-group-update-group group)
4204 (goto-char (text-property-any
4205 (point-min) (point-max) 'gnus-group (intern group)))))
4206 ;; Adjust cursor point.
4207 (gnus-group-position-point))
4209 (defun gnus-group-goto-group (group)
4210 "Goto to newsgroup GROUP."
4211 (let ((b (text-property-any (point-min) (point-max)
4212 'gnus-group (intern group))))
4213 (and b (goto-char b))))
4215 (defun gnus-group-next-group (n)
4216 "Go to next N'th newsgroup.
4217 If N is negative, search backward instead.
4218 Returns the difference between N and the number of skips actually
4221 (gnus-group-next-unread-group n t))
4223 (defun gnus-group-next-unread-group (n &optional all level)
4224 "Go to next N'th unread newsgroup.
4225 If N is negative, search backward instead.
4226 If ALL is non-nil, choose any newsgroup, unread or not.
4227 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
4228 such group can be found, the next group with a level higher than
4230 Returns the difference between N and the number of skips actually
4233 (let ((backward (< n 0))
4236 (gnus-group-search-forward
4237 backward (or (not gnus-group-goto-unread) all) level))
4239 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
4240 (if level " on this level or higher" "")))
4243 (defun gnus-group-prev-group (n)
4244 "Go to previous N'th newsgroup.
4245 Returns the difference between N and the number of skips actually
4248 (gnus-group-next-unread-group (- n) t))
4250 (defun gnus-group-prev-unread-group (n)
4251 "Go to previous N'th unread newsgroup.
4252 Returns the difference between N and the number of skips actually
4255 (gnus-group-next-unread-group (- n)))
4257 (defun gnus-group-next-unread-group-same-level (n)
4258 "Go to next N'th unread newsgroup on the same level.
4259 If N is negative, search backward instead.
4260 Returns the difference between N and the number of skips actually
4263 (gnus-group-next-unread-group n t (gnus-group-group-level))
4264 (gnus-group-position-point))
4266 (defun gnus-group-prev-unread-group-same-level (n)
4267 "Go to next N'th unread newsgroup on the same level.
4268 Returns the difference between N and the number of skips actually
4271 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
4272 (gnus-group-position-point))
4274 (defun gnus-group-best-unread-group (&optional exclude-group)
4275 "Go to the group with the highest level.
4276 If EXCLUDE-GROUP, do not go to that group."
4278 (goto-char (point-min))
4281 (while (setq unread (get-text-property (point) 'gnus-unread))
4282 (if (and (numberp unread) (> unread 0))
4284 (if (and (< (get-text-property (point) 'gnus-level) best)
4285 (or (not exclude-group)
4286 (not (equal exclude-group (gnus-group-group-name)))))
4288 (setq best (get-text-property (point) 'gnus-level))
4289 (setq best-point (point))))))
4291 (if best-point (goto-char best-point))
4292 (gnus-summary-position-point)
4293 (and best-point (gnus-group-group-name))))
4295 (defun gnus-group-first-unread-group ()
4296 "Go to the first group with unread articles."
4299 (let ((opoint (point))
4301 (goto-char (point-min))
4302 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
4303 (not (zerop unread)) ; Has unread articles.
4304 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
4307 nil)) ; Not success.
4308 (gnus-group-position-point)))
4310 (defun gnus-group-enter-server-mode ()
4311 "Jump to the server buffer."
4313 (gnus-server-setup-buffer)
4314 (gnus-configure-windows 'server)
4315 (gnus-server-prepare))
4317 (defun gnus-group-make-group (name &optional method address)
4318 "Add a new newsgroup.
4319 The user will be prompted for a NAME, for a select METHOD, and an
4323 (read-string "Group name: ")
4326 "Method: " (append gnus-valid-select-methods gnus-server-alist)
4328 (if (assoc method gnus-valid-select-methods)
4330 (if (memq 'prompt-address
4331 (assoc method gnus-valid-select-methods))
4332 (read-string "Address: ")
4334 (list method nil)))))
4337 (set-buffer gnus-group-buffer)
4338 (let* ((meth (and method (if address (list (intern method) address)
4340 (nname (if method (gnus-group-prefixed-name name meth) name))
4342 (and (gnus-gethash nname gnus-newsrc-hashtb)
4343 (error "Group %s already exists" nname))
4344 (gnus-group-change-level
4345 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
4346 gnus-level-default-subscribed gnus-level-killed
4347 (and (gnus-group-group-name)
4348 (gnus-gethash (gnus-group-group-name)
4349 gnus-newsrc-hashtb))
4351 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
4353 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
4354 (gnus-group-insert-group-line-info nname)
4356 (if (assoc method gnus-valid-select-methods)
4357 (require (intern method)))
4358 (and (gnus-check-backend-function 'request-create-group nname)
4359 (gnus-request-create-group nname)))))
4361 (defun gnus-group-delete-group (group &optional force)
4362 "Delete the current group.
4363 If FORCE (the prefix) is non-nil, all the articles in the group will
4364 be deleted. This is \"deleted\" as in \"removed forever from the face
4365 of the Earth\". There is no undo."
4367 (list (gnus-group-group-name)
4368 current-prefix-arg))
4369 (or group (error "No group to rename"))
4370 (or (gnus-check-backend-function 'request-delete-group group)
4371 (error "This backend does not support group deletion"))
4373 (if (not (gnus-yes-or-no-p
4375 "Do you really want to delete %s%s? "
4376 group (if force " and all its contents" ""))))
4378 (gnus-message 6 "Deleting group %s..." group)
4379 (if (not (gnus-request-delete-group group force))
4381 (gnus-message 3 "Couldn't delete group %s" group)
4383 (gnus-message 6 "Deleting group %s...done" group)
4384 (gnus-group-goto-group group)
4385 (gnus-group-kill-group 1 t)
4387 (gnus-group-position-point)))
4389 (defun gnus-group-rename-group (group new-name)
4392 (gnus-group-group-name)
4394 (or (gnus-check-backend-function
4395 'request-rename-group (gnus-group-group-name))
4396 (error "This backend does not support renaming groups"))
4397 (read-string "New group name: "))))
4399 (or (gnus-check-backend-function 'request-rename-group group)
4400 (error "This backend does not support renaming groups"))
4402 (or group (error "No group to rename"))
4403 (and (string-match "^[ \t]*$" new-name)
4404 (error "Not a valid group name"))
4406 ;; We find the proper prefixed name.
4408 (gnus-group-prefixed-name
4409 (gnus-group-real-name new-name)
4410 (nth 4 (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))))
4412 (gnus-message 6 "Renaming group %s to %s..." group new-name)
4414 (if (not (gnus-request-rename-group group new-name))
4416 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
4418 ;; We rename the group internally by killing it...
4419 (gnus-group-goto-group group)
4420 (gnus-group-kill-group)
4421 ;; ... changing its name ...
4422 (setcar (cdr (car gnus-list-of-killed-groups))
4424 ;; ... and then yanking it. Magic!
4425 (gnus-group-yank-group)
4426 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
4428 (gnus-group-position-point)))
4431 (defun gnus-group-edit-group (group &optional part)
4432 "Edit the group on the current line."
4433 (interactive (list (gnus-group-group-name)))
4434 (let ((done-func '(lambda ()
4435 "Exit editing mode and update the information."
4437 (gnus-group-edit-group-done 'part 'group)))
4438 (part (or part 'info))
4439 (winconf (current-window-configuration))
4441 (or group (error "No group on current line"))
4442 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4443 (error "Killed group; can't be edited"))
4444 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4445 (gnus-configure-windows 'edit-group)
4446 (gnus-add-current-to-buffer-list)
4448 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4449 (use-local-map (copy-keymap emacs-lisp-mode-map))
4450 (local-set-key "\C-c\C-c" done-func)
4451 (make-local-variable 'gnus-prev-winconf)
4452 (setq gnus-prev-winconf winconf)
4453 ;; We modify the func to let it know what part it is editing.
4454 (setcar (cdr (nth 4 done-func)) (list 'quote part))
4455 (setcar (cdr (cdr (nth 4 done-func))) group)
4460 ";; Type `C-c C-c' after editing the select method.\n\n")
4462 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4464 ";; Type `C-c C-c' after editing the group info.\n\n")))
4465 (let ((cinfo (gnus-copy-sequence info))
4467 (if (not (setq marked (nth 3 cinfo)))
4470 (or (eq 'score (car (car marked)))
4471 (eq 'bookmark (car (car marked)))
4472 (eq 'killed (car (car marked)))
4473 (not (numberp (car (cdr (car marked)))))
4474 (setcdr (car marked)
4475 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4476 (setq marked (cdr marked))))
4479 (cond ((eq part 'method)
4480 (or (nth 4 info) "native"))
4487 (defun gnus-group-edit-group-method (group)
4488 "Edit the select method of GROUP."
4489 (interactive (list (gnus-group-group-name)))
4490 (gnus-group-edit-group group 'method))
4492 (defun gnus-group-edit-group-parameters (group)
4493 "Edit the group parameters of GROUP."
4494 (interactive (list (gnus-group-group-name)))
4495 (gnus-group-edit-group group 'params))
4497 (defun gnus-group-edit-group-done (part group)
4498 "Get info from buffer, update variables and jump to the group buffer."
4499 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4500 (goto-char (point-min))
4501 (let ((form (read (current-buffer)))
4502 (winconf gnus-prev-winconf))
4504 (gnus-group-set-info form)
4505 (gnus-group-set-info form group part))
4506 (kill-buffer (current-buffer))
4507 (and winconf (set-window-configuration winconf))
4508 (set-buffer gnus-group-buffer)
4509 (gnus-group-update-group (gnus-group-group-name))
4510 (gnus-group-position-point)))
4512 (defun gnus-group-make-help-group ()
4513 "Create the Gnus documentation group."
4515 (let ((path load-path)
4517 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4518 "gnus-help" '(nndoc "gnus-help")))
4520 (error "Documentation group already exists"))
4522 (not (file-exists-p (concat (file-name-as-directory (car path))
4524 (setq path (cdr path)))
4525 (or path (error "Couldn't find doc group"))
4526 (gnus-group-make-group
4527 (gnus-group-real-name name)
4529 (list 'nndoc-address
4530 (concat (file-name-as-directory (car path)) "doc.txt"))
4531 (list 'nndoc-article-type 'mbox))))
4532 (gnus-group-position-point))
4534 (defun gnus-group-make-doc-group (file type)
4535 "Create a group that uses a single file as the source."
4537 (list (read-file-name "File name: ")
4541 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4542 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4543 ((= char ?b) 'babyl)
4544 ((= char ?d) 'digest)
4545 (t (setq err (format "%c unknown. " char))
4548 (let* ((file (expand-file-name file))
4549 (name (gnus-generate-new-group-name
4550 (gnus-group-prefixed-name
4551 (file-name-nondirectory file) '(nndoc "")))))
4552 (gnus-group-make-group
4553 (gnus-group-real-name name)
4555 (list 'nndoc-address file)
4556 (list 'nndoc-article-type type)))))
4558 (defun gnus-group-make-archive-group (&optional all)
4559 "Create the (ding) Gnus archive group of the most recent articles.
4560 Given a prefix, create a full group."
4562 (let ((group (gnus-group-prefixed-name
4563 (if all "ding.archives" "ding.recent") '(nndir ""))))
4564 (and (gnus-gethash group gnus-newsrc-hashtb)
4565 (error "Archive group already exists"))
4566 (gnus-group-make-group
4567 (gnus-group-real-name group)
4569 (if all gnus-group-archive-directory
4570 gnus-group-recent-archive-directory)))
4571 (gnus-group-position-point))
4573 (defun gnus-group-make-directory-group (dir)
4574 "Create an nndir group.
4575 The user will be prompted for a directory. The contents of this
4576 directory will be used as a newsgroup. The directory should contain
4577 mail messages or news articles in files that have numeric names."
4579 (list (read-file-name "Create group from directory: ")))
4580 (or (file-exists-p dir) (error "No such directory"))
4581 (or (file-directory-p dir) (error "Not a directory"))
4582 (gnus-group-make-group dir "nndir" dir)
4583 (gnus-group-position-point))
4585 (defun gnus-group-make-kiboze-group (group address scores)
4586 "Create an nnkiboze group.
4587 The user will be prompted for a name, a regexp to match groups, and
4588 score file entries for articles to include in the group."
4591 (read-string "nnkiboze group name: ")
4592 (read-string "Source groups (regexp): ")
4593 (let ((headers (mapcar (lambda (group) (list group))
4594 '("subject" "from" "number" "date" "message-id"
4595 "references" "chars" "lines" "xref")))
4596 scores header regexp regexps)
4597 (while (not (equal "" (setq header (completing-read
4598 "Match on header: " headers nil t))))
4600 (while (not (equal "" (setq regexp (read-string
4601 (format "Match on %s (string): "
4603 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4604 (setq scores (cons (cons header regexps) scores)))
4606 (gnus-group-make-group group "nnkiboze" address)
4608 (gnus-set-work-buffer)
4609 (let (emacs-lisp-mode-hook)
4610 (pp scores (current-buffer)))
4611 (write-region (point-min) (point-max)
4612 (concat (or gnus-kill-files-directory "~/News")
4613 "nnkiboze:" group "." gnus-score-file-suffix)))
4614 (gnus-group-position-point))
4616 (defun gnus-group-add-to-virtual (n vgroup)
4617 "Add the current group to a virtual group."
4619 (list current-prefix-arg
4620 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4622 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4623 (error "%s is not an nnvirtual group" vgroup))
4624 (let* ((groups (gnus-group-process-prefix n))
4625 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4626 (setcar (cdr method)
4628 (nth 1 method) "\\|"
4631 (gnus-group-remove-mark s)
4632 (concat "\\(^" (regexp-quote s) "$\\)"))
4634 (gnus-group-position-point))
4636 (defun gnus-group-make-empty-virtual (group)
4637 "Create a new, fresh, empty virtual group."
4638 (interactive "sCreate new, empty virtual group: ")
4639 (let* ((method (list 'nnvirtual "^$"))
4640 (pgroup (gnus-group-prefixed-name group method)))
4641 ;; Check whether it exists already.
4642 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4643 (error "Group %s already exists." pgroup))
4644 ;; Subscribe the new group after the group on the current line.
4645 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4646 (gnus-group-update-group pgroup)
4648 (gnus-group-position-point)))
4650 (defun gnus-group-enter-directory (dir)
4651 "Enter an ephemeral nneething group."
4652 (interactive "DDirectory to read: ")
4653 (let* ((method (list 'nneething dir))
4654 (leaf (gnus-group-prefixed-name
4655 (file-name-nondirectory (directory-file-name dir))
4657 (name (gnus-generate-new-group-name leaf)))
4658 (let ((nneething-read-only t))
4659 (or (gnus-group-read-ephemeral-group
4661 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4663 (error "Couldn't enter %s" dir)))))
4665 ;; Group sorting commands
4666 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4668 (defun gnus-group-sort-groups ()
4669 "Sort the group buffer according to `gnus-group-sort-function'."
4671 (let ((funcs (if (listp gnus-group-sort-function) gnus-group-sort-function
4672 (list gnus-group-sort-function))))
4673 ;; We peel off the dummy group off the alist.
4674 (and (equal (car (car gnus-newsrc-alist)) "dummy.group")
4675 (setq gnus-newsrc-alist (cdr gnus-newsrc-alist)))
4678 (setq gnus-newsrc-alist
4679 (sort (cdr gnus-newsrc-alist) (car funcs)))
4680 (setq funcs (cdr funcs))))
4681 (gnus-make-hashtable-from-newsrc-alist)
4682 (gnus-group-list-groups))
4684 (defun gnus-group-sort-by-alphabet (info1 info2)
4685 (string< (car info1) (car info2)))
4687 (defun gnus-group-sort-by-unread (info1 info2)
4688 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4689 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4690 (< (or (and (numberp n1) n1) 0)
4691 (or (and (numberp n2) n2) 0))))
4693 (defun gnus-group-sort-by-level (info1 info2)
4694 (< (nth 1 info1) (nth 1 info2)))
4696 (defun gnus-group-sort-by-method (info1 info2)
4697 (string< (symbol-name (car (gnus-find-method-for-group (car info1))))
4698 (symbol-name (car (gnus-find-method-for-group (car info2))))))
4700 ;; Group catching up.
4702 (defun gnus-group-catchup-current (&optional n all)
4703 "Mark all articles not marked as unread in current newsgroup as read.
4704 If prefix argument N is numeric, the ARG next newsgroups will be
4705 caught up. If ALL is non-nil, marked articles will also be marked as
4706 read. Cross references (Xref: header) of articles are ignored.
4707 The difference between N and actual number of newsgroups that were
4708 caught up is returned."
4710 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4714 "Do you really want to mark all articles as read? "
4715 "Mark all unread articles as read? "))))
4717 (let ((groups (gnus-group-process-prefix n))
4720 ;; Virtual groups have to be given special treatment.
4721 (let ((method (gnus-find-method-for-group (car groups))))
4722 (if (eq 'nnvirtual (car method))
4723 (nnvirtual-catchup-group
4724 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4725 (gnus-group-remove-mark (car groups))
4727 (gnus-group-goto-group (car groups))
4728 (gnus-group-catchup (car groups) all))
4729 (gnus-group-update-group-line)
4730 (setq ret (1+ ret)))
4731 (setq groups (cdr groups)))
4732 (gnus-group-next-unread-group 1)
4735 (defun gnus-group-catchup-current-all (&optional n)
4736 "Mark all articles in current newsgroup as read.
4737 Cross references (Xref: header) of articles are ignored."
4739 (gnus-group-catchup-current n 'all))
4741 (defun gnus-group-catchup (group &optional all)
4742 "Mark all articles in GROUP as read.
4743 If ALL is non-nil, all articles are marked as read.
4744 The return value is the number of articles that were marked as read,
4745 or nil if no action could be taken."
4746 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4748 (marked (nth 3 (nth 2 entry))))
4749 (if (not (numberp (car entry)))
4750 (gnus-message 1 "Can't catch up; non-active group")
4751 ;; Do the updating only if the newsgroup isn't killed.
4754 (gnus-update-read-articles
4755 group (and (not all) (append (cdr (assq 'tick marked))
4756 (cdr (assq 'dormant marked))))
4757 nil (and (not all) (cdr (assq 'tick marked))))
4759 (setq marked (nth 3 (nth 2 entry)))
4760 (setcar (nthcdr 3 (nth 2 entry))
4761 (delq (assq 'dormant marked)
4762 (nth 3 (nth 2 entry)))))))
4765 (defun gnus-group-expire-articles (&optional n)
4766 "Expire all expirable articles in the current newsgroup."
4768 (let ((groups (gnus-group-process-prefix n))
4770 (or groups (error "No groups to expire"))
4772 (setq group (car groups)
4773 groups (cdr groups))
4774 (gnus-group-remove-mark group)
4775 (if (not (gnus-check-backend-function 'request-expire-articles group))
4777 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4778 (expirable (if (gnus-group-total-expirable-p group)
4779 (cons nil (gnus-list-of-read-articles group))
4780 (assq 'expire (nth 3 info)))))
4783 (gnus-request-expire-articles
4784 (cdr expirable) group))))))))
4786 (defun gnus-group-expire-all-groups ()
4787 "Expire all expirable articles in all newsgroups."
4790 (gnus-message 5 "Expiring...")
4791 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4792 (cdr gnus-newsrc-alist))))
4793 (gnus-group-expire-articles nil)))
4794 (gnus-group-position-point)
4795 (gnus-message 5 "Expiring...done"))
4797 (defun gnus-group-set-current-level (n level)
4798 "Set the level of the next N groups to LEVEL."
4801 (prefix-numeric-value current-prefix-arg)
4803 (read-string (format "Level (default %s): " (gnus-group-group-level))
4804 (int-to-string (gnus-group-group-level))))))
4805 (or (and (>= level 1) (<= level gnus-level-killed))
4806 (error "Illegal level: %d" level))
4807 (let ((groups (gnus-group-process-prefix n))
4810 (setq group (car groups)
4811 groups (cdr groups))
4812 (gnus-group-remove-mark group)
4813 (gnus-message 6 "Changed level of %s from %d to %d"
4814 group (gnus-group-group-level) level)
4815 (gnus-group-change-level group level
4816 (gnus-group-group-level))
4817 (gnus-group-update-group-line)))
4818 (gnus-group-position-point))
4820 (defun gnus-group-unsubscribe-current-group (&optional n)
4821 "Toggle subscription of the current group.
4822 If given numerical prefix, toggle the N next groups."
4824 (let ((groups (gnus-group-process-prefix n))
4827 (setq group (car groups)
4828 groups (cdr groups))
4829 (gnus-group-remove-mark group)
4830 (gnus-group-unsubscribe-group
4831 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4832 gnus-level-default-unsubscribed
4833 gnus-level-default-subscribed))
4834 (gnus-group-update-group-line))
4835 (gnus-group-next-group 1)))
4837 (defun gnus-group-unsubscribe-group (group &optional level)
4838 "Toggle subscribe from/to unsubscribe GROUP.
4839 New newsgroup is added to .newsrc automatically."
4841 (list (completing-read
4842 "Group: " gnus-active-hashtb nil
4843 (memq gnus-select-method gnus-have-read-active-file))))
4844 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4846 ((string-match "^[ \t]$" group)
4847 (error "Empty group name"))
4849 ;; Toggle subscription flag.
4850 (gnus-group-change-level
4851 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4852 gnus-level-subscribed)
4853 (1+ gnus-level-subscribed)
4854 gnus-level-default-subscribed)))
4855 (gnus-group-update-group group))
4856 ((and (stringp group)
4857 (or (not (memq gnus-select-method gnus-have-read-active-file))
4858 (gnus-gethash group gnus-active-hashtb)))
4859 ;; Add new newsgroup.
4860 (gnus-group-change-level
4862 (if level level gnus-level-default-subscribed)
4863 (or (and (member group gnus-zombie-list)
4866 (and (gnus-group-group-name)
4867 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4868 (gnus-group-update-group group))
4869 (t (error "No such newsgroup: %s" group)))
4870 (gnus-group-position-point)))
4872 (defun gnus-group-transpose-groups (n)
4873 "Move the current newsgroup up N places.
4874 If given a negative prefix, move down instead. The difference between
4875 N and the number of steps taken is returned."
4877 (or (gnus-group-group-name)
4878 (error "No group on current line"))
4879 (gnus-group-kill-group 1)
4881 (forward-line (- n))
4882 (gnus-group-yank-group)
4883 (gnus-group-position-point)))
4885 (defun gnus-group-kill-all-zombies ()
4886 "Kill all zombie newsgroups."
4888 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4889 (setq gnus-zombie-list nil)
4890 (gnus-group-list-groups))
4892 (defun gnus-group-kill-region (begin end)
4893 "Kill newsgroups in current region (excluding current point).
4894 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4909 (beginning-of-line) ;Important when LINES < 1
4910 (gnus-group-kill-group lines)))
4912 (defun gnus-group-kill-group (&optional n discard)
4913 "The the next N groups.
4914 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4915 However, only groups that were alive can be yanked; already killed
4916 groups or zombie groups can't be yanked.
4917 The return value is the name of the (last) group that was killed."
4919 (let ((buffer-read-only nil)
4920 (groups (gnus-group-process-prefix n))
4922 (if (or t (< (length groups) 10))
4923 ;; This is faster when there are few groups.
4925 (setq group (car groups)
4926 groups (cdr groups))
4927 (gnus-group-remove-mark group)
4928 (setq level (gnus-group-group-level))
4930 (if (and (not discard)
4931 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
4932 (setq gnus-list-of-killed-groups
4933 (cons (cons (car entry) (nth 2 entry))
4934 gnus-list-of-killed-groups)))
4935 (gnus-group-change-level
4936 (if entry entry group) gnus-level-killed (if entry nil level)))
4937 ;; If there are lots and lots of groups to be killed, we use
4938 ;; this thing instead.
4942 (gnus-group-position-point)
4945 (defun gnus-group-yank-group (&optional arg)
4946 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4947 inserting it before the current newsgroup. The numeric ARG specifies
4948 how many newsgroups are to be yanked. The name of the (last)
4949 newsgroup yanked is returned."
4951 (if (not arg) (setq arg 1))
4952 (let (info group prev)
4953 (while (>= (setq arg (1- arg)) 0)
4954 (if (not (setq info (car gnus-list-of-killed-groups)))
4955 (error "No more newsgroups to yank"))
4956 (setq group (nth 2 info))
4957 ;; Find which newsgroup to insert this one before - search
4958 ;; backward until something suitable is found. If there are no
4959 ;; other newsgroups in this buffer, just make this newsgroup the
4961 (setq prev (gnus-group-group-name))
4962 (gnus-group-change-level
4963 info (nth 2 info) gnus-level-killed
4964 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4966 (gnus-group-insert-group-line-info (nth 1 info))
4967 (setq gnus-list-of-killed-groups
4968 (cdr gnus-list-of-killed-groups)))
4970 (gnus-group-position-point)
4973 (defun gnus-group-list-all-groups (&optional arg)
4974 "List all newsgroups with level ARG or lower.
4975 Default is gnus-level-unsubscribed, which lists all subscribed and most
4976 unsubscribed groups."
4978 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
4980 (defun gnus-group-list-killed ()
4981 "List all killed newsgroups in the group buffer."
4983 (if (not gnus-killed-list)
4984 (gnus-message 6 "No killed groups")
4985 (let (gnus-group-list-mode)
4986 (funcall gnus-group-prepare-function
4987 gnus-level-killed t gnus-level-killed))
4988 (goto-char (point-min)))
4989 (gnus-group-position-point))
4991 (defun gnus-group-list-zombies ()
4992 "List all zombie newsgroups in the group buffer."
4994 (if (not gnus-zombie-list)
4995 (gnus-message 6 "No zombie groups")
4996 (let (gnus-group-list-mode)
4997 (funcall gnus-group-prepare-function
4998 gnus-level-zombie t gnus-level-zombie))
4999 (goto-char (point-min)))
5000 (gnus-group-position-point))
5002 (defun gnus-group-list-active ()
5003 "List all groups that are available from the server(s)."
5005 ;; First we make sure that we have really read the active file.
5006 (or gnus-have-read-active-file
5007 (gnus-read-active-file))
5008 ;; Find all groups and sort them.
5014 (and (symbol-value sym)
5015 (setq list (cons (symbol-name sym) list))))
5019 (buffer-read-only nil))
5022 (gnus-group-insert-group-line-info (car groups))
5023 (setq groups (cdr groups)))
5024 (goto-char (point-min))))
5026 (defun gnus-group-get-new-news (&optional arg)
5027 "Get newly arrived articles.
5028 If ARG is a number, it specifies which levels you are interested in
5029 re-scanning. If ARG is non-nil and not a number, this will force
5030 \"hard\" re-reading of the active files from all servers."
5032 (run-hooks 'gnus-get-new-news-hook)
5033 ;; If ARG is not a number, then we read the active file.
5037 (let ((gnus-read-active-file t))
5038 (gnus-read-active-file))
5041 (setq arg (gnus-group-default-level arg t))
5042 (if (and gnus-read-active-file (not arg))
5044 (gnus-read-active-file)
5045 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
5046 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
5047 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
5048 (gnus-group-list-groups))
5050 (defun gnus-group-get-new-news-this-group (&optional n)
5051 "Check for newly arrived news in the current group (and the N-1 next groups).
5052 The difference between N and the number of newsgroup checked is returned.
5053 If N is negative, this group and the N-1 previous groups will be checked."
5055 (let* ((groups (gnus-group-process-prefix n))
5056 (ret (if (numberp n) (- n (length groups)) 0))
5059 (setq group (car groups)
5060 groups (cdr groups))
5061 (gnus-group-remove-mark group)
5062 (or (gnus-get-new-news-in-group group)
5065 (message "%s error: %s" group (gnus-status-message group))
5067 (gnus-group-next-unread-group 1 t)
5068 (gnus-summary-position-point)
5071 (defun gnus-get-new-news-in-group (group)
5073 (gnus-activate-group group 'scan)
5075 (gnus-get-unread-articles-in-group
5076 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
5077 (gnus-gethash group gnus-active-hashtb))
5078 (gnus-group-update-group-line)
5081 (defun gnus-group-fetch-faq (group &optional faq-dir)
5082 "Fetch the FAQ for the current group."
5085 (gnus-group-real-name (gnus-group-group-name))
5086 (cond (current-prefix-arg
5088 "Faq dir: " (and (listp gnus-group-faq-directory)
5089 gnus-group-faq-directory))))))
5091 (if (listp gnus-group-faq-directory)
5092 (car gnus-group-faq-directory)
5093 gnus-group-faq-directory))
5094 (or group (error "No group name given"))
5095 (let ((file (concat (file-name-as-directory faq-dir)
5096 (gnus-group-real-name group))))
5097 (if (not (file-exists-p file))
5098 (error "No such file: %s" file)
5101 (defun gnus-group-describe-group (force &optional group)
5102 "Display a description of the current newsgroup."
5103 (interactive (list current-prefix-arg (gnus-group-group-name)))
5104 (and force (setq gnus-description-hashtb nil))
5105 (let ((method (gnus-find-method-for-group group))
5107 (or group (error "No group name given"))
5108 (and (or (and gnus-description-hashtb
5109 ;; We check whether this group's method has been
5110 ;; queried for a description file.
5112 (gnus-group-prefixed-name "" method)
5113 gnus-description-hashtb))
5114 (setq desc (gnus-group-get-description group))
5115 (gnus-read-descriptions-file method))
5117 (or desc (gnus-gethash group gnus-description-hashtb)
5118 "No description available")))))
5120 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5121 (defun gnus-group-describe-all-groups (&optional force)
5122 "Pop up a buffer with descriptions of all newsgroups."
5124 (and force (setq gnus-description-hashtb nil))
5125 (if (not (or gnus-description-hashtb
5126 (gnus-read-all-descriptions-files)))
5127 (error "Couldn't request descriptions file"))
5128 (let ((buffer-read-only nil)
5134 (insert (format " *: %-20s %s\n" (symbol-name group)
5135 (symbol-value group)))
5136 (add-text-properties
5137 b (1+ b) (list 'gnus-group group
5138 'gnus-unread t 'gnus-marked nil
5139 'gnus-level (1+ gnus-level-subscribed))))
5140 gnus-description-hashtb)
5141 (goto-char (point-min))
5142 (gnus-group-position-point)))
5144 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
5145 (defun gnus-group-apropos (regexp &optional search-description)
5146 "List all newsgroups that have names that match a regexp."
5147 (interactive "sGnus apropos (regexp): ")
5149 (obuf (current-buffer))
5151 ;; Go through all newsgroups that are known to Gnus.
5154 (and (symbol-name group)
5155 (string-match regexp (symbol-name group))
5156 (setq groups (cons (symbol-name group) groups))))
5158 ;; Go through all descriptions that are known to Gnus.
5159 (if search-description
5162 (and (string-match regexp (symbol-value group))
5163 (gnus-gethash (symbol-name group) gnus-active-hashtb)
5164 (setq groups (cons (symbol-name group) groups))))
5165 gnus-description-hashtb))
5167 (gnus-message 3 "No groups matched \"%s\"." regexp)
5168 ;; Print out all the groups.
5170 (pop-to-buffer "*Gnus Help*")
5171 (buffer-disable-undo (current-buffer))
5173 (setq groups (sort groups 'string<))
5175 ;; Groups may be entered twice into the list of groups.
5176 (if (not (string= (car groups) prev))
5178 (insert (setq prev (car groups)) "\n")
5179 (if (and gnus-description-hashtb
5180 (setq des (gnus-gethash (car groups)
5181 gnus-description-hashtb)))
5182 (insert " " des "\n"))))
5183 (setq groups (cdr groups)))
5184 (goto-char (point-min))))
5185 (pop-to-buffer obuf)))
5187 (defun gnus-group-description-apropos (regexp)
5188 "List all newsgroups that have names or descriptions that match a regexp."
5189 (interactive "sGnus description apropos (regexp): ")
5190 (if (not (or gnus-description-hashtb
5191 (gnus-read-all-descriptions-files)))
5192 (error "Couldn't request descriptions file"))
5193 (gnus-group-apropos regexp t))
5195 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5196 (defun gnus-group-list-matching (level regexp &optional all lowest)
5197 "List all groups with unread articles that match REGEXP.
5198 If the prefix LEVEL is non-nil, it should be a number that says which
5199 level to cut off listing groups.
5200 If ALL, also list groups with no unread articles.
5201 If LOWEST, don't list groups with level lower than LOWEST."
5202 (interactive "P\nsList newsgroups matching: ")
5203 (gnus-group-prepare-flat (or level gnus-level-subscribed)
5204 all (or lowest 1) regexp)
5205 (goto-char (point-min))
5206 (gnus-group-position-point))
5208 (defun gnus-group-list-all-matching (level regexp &optional lowest)
5209 "List all groups that match REGEXP.
5210 If the prefix LEVEL is non-nil, it should be a number that says which
5211 level to cut off listing groups.
5212 If LOWEST, don't list groups with level lower than LOWEST."
5213 (interactive "P\nsList newsgroups matching: ")
5214 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
5216 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
5217 (defun gnus-group-save-newsrc ()
5218 "Save the Gnus startup files."
5220 (gnus-save-newsrc-file))
5222 (defun gnus-group-restart (&optional arg)
5223 "Force Gnus to read the .newsrc file."
5225 (gnus-save-newsrc-file)
5226 (gnus-setup-news 'force)
5227 (gnus-group-list-groups arg))
5229 (defun gnus-group-read-init-file ()
5230 "Read the Gnus elisp init file."
5232 (gnus-read-init-file))
5234 (defun gnus-group-check-bogus-groups (&optional silent)
5235 "Check bogus newsgroups.
5236 If given a prefix, don't ask for confirmation before removing a bogus
5239 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
5240 (gnus-group-list-groups))
5242 (defun gnus-group-edit-global-kill (&optional article group)
5243 "Edit the global kill file.
5244 If GROUP, edit that local kill file instead."
5246 (setq gnus-current-kill-article article)
5247 (gnus-kill-file-edit-file group)
5250 (substitute-command-keys
5251 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
5253 (defun gnus-group-edit-local-kill (article group)
5254 "Edit a local kill file."
5255 (interactive (list nil (gnus-group-group-name)))
5256 (gnus-group-edit-global-kill article group))
5258 (defun gnus-group-force-update ()
5259 "Update `.newsrc' file."
5261 (gnus-save-newsrc-file))
5263 (defun gnus-group-suspend ()
5264 "Suspend the current Gnus session.
5265 In fact, cleanup buffers except for group mode buffer.
5266 The hook gnus-suspend-gnus-hook is called before actually suspending."
5268 (run-hooks 'gnus-suspend-gnus-hook)
5269 ;; Kill Gnus buffers except for group mode buffer.
5270 (let ((group-buf (get-buffer gnus-group-buffer)))
5271 ;; Do this on a separate list in case the user does a ^G before we finish
5272 (let ((gnus-buffer-list
5273 (delq group-buf (delq gnus-dribble-buffer
5274 (append gnus-buffer-list nil)))))
5275 (while gnus-buffer-list
5276 (gnus-kill-buffer (car gnus-buffer-list))
5277 (setq gnus-buffer-list (cdr gnus-buffer-list))))
5280 (setq gnus-buffer-list (list group-buf))
5281 (bury-buffer group-buf)
5282 (delete-windows-on group-buf t)))))
5284 (defun gnus-group-clear-dribble ()
5285 "Clear all information from the dribble buffer."
5287 (gnus-dribble-clear))
5289 (defun gnus-group-exit ()
5290 "Quit reading news after updating .newsrc.eld and .newsrc.
5291 The hook `gnus-exit-gnus-hook' is called before actually exiting."
5293 (if (or noninteractive ;For gnus-batch-kill
5294 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
5295 (not gnus-interactive-exit) ;Without confirmation
5297 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
5299 (run-hooks 'gnus-exit-gnus-hook)
5300 ;; Offer to save data from non-quitted summary buffers.
5301 (gnus-offer-save-summaries)
5302 ;; Save the newsrc file(s).
5303 (gnus-save-newsrc-file)
5305 (gnus-close-backends)
5306 ;; Reset everything.
5307 (gnus-clear-system))))
5309 (defun gnus-close-backends ()
5310 ;; Send a close request to all backends that support such a request.
5311 (let ((methods gnus-valid-select-methods)
5314 (if (fboundp (setq func (intern (concat (car (car methods))
5315 "-request-close"))))
5317 (setq methods (cdr methods)))))
5319 (defun gnus-group-quit ()
5320 "Quit reading news without updating .newsrc.eld or .newsrc.
5321 The hook `gnus-exit-gnus-hook' is called before actually exiting."
5323 (if (or noninteractive ;For gnus-batch-kill
5324 (zerop (buffer-size))
5325 (not (gnus-server-opened gnus-select-method))
5327 (not gnus-current-startup-file)
5329 (format "Quit reading news without saving %s? "
5330 (file-name-nondirectory gnus-current-startup-file))))
5332 (run-hooks 'gnus-exit-gnus-hook)
5333 (if gnus-use-full-window
5334 (delete-other-windows)
5335 (gnus-remove-some-windows))
5337 (gnus-close-backends)
5338 (gnus-clear-system))))
5340 (defun gnus-offer-save-summaries ()
5342 (let ((buflist (buffer-list))
5345 (and (setq bufname (buffer-name (car buflist)))
5346 (string-match "Summary" bufname)
5348 (set-buffer bufname)
5349 ;; We check that this is, indeed, a summary buffer.
5350 (eq major-mode 'gnus-summary-mode))
5351 (setq buffers (cons bufname buffers)))
5352 (setq buflist (cdr buflist)))
5355 "Update summary buffer %s? "
5358 (gnus-summary-exit))
5361 (defun gnus-group-describe-briefly ()
5362 "Give a one line description of the group mode commands."
5364 (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")))
5366 (defun gnus-group-browse-foreign-server (method)
5367 "Browse a foreign news server.
5368 If called interactively, this function will ask for a select method
5369 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
5370 If not, METHOD should be a list where the first element is the method
5371 and the second element is the address."
5373 (list (let ((how (completing-read
5375 (append gnus-valid-select-methods gnus-server-alist)
5377 ;; We either got a backend name or a virtual server name.
5378 ;; If the first, we also need an address.
5379 (if (assoc how gnus-valid-select-methods)
5381 ;; Suggested by mapjph@bath.ac.uk.
5384 (mapcar (lambda (server) (list server))
5385 gnus-secondary-servers)))
5386 ;; We got a server name, so we find the method.
5387 (gnus-server-to-method how)))))
5388 (gnus-browse-foreign-server method))
5392 ;;; Browse Server Mode
5395 (defvar gnus-browse-mode-hook nil)
5396 (defvar gnus-browse-mode-map nil)
5397 (put 'gnus-browse-mode 'mode-class 'special)
5399 (if gnus-browse-mode-map
5401 (setq gnus-browse-mode-map (make-keymap))
5402 (suppress-keymap gnus-browse-mode-map)
5403 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
5404 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
5405 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
5406 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
5407 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
5408 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
5409 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
5410 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
5411 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
5412 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
5413 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
5414 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
5415 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
5416 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
5417 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
5418 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
5419 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
5420 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
5423 (defvar gnus-browse-current-method nil)
5424 (defvar gnus-browse-return-buffer nil)
5426 (defvar gnus-browse-buffer "*Gnus Browse Server*")
5428 (defun gnus-browse-foreign-server (method &optional return-buffer)
5429 (setq gnus-browse-current-method method)
5430 (setq gnus-browse-return-buffer return-buffer)
5431 (let ((gnus-select-method method)
5433 (gnus-message 5 "Connecting to %s..." (nth 1 method))
5434 (or (gnus-check-server method)
5435 (error "Unable to contact server: %s" (gnus-status-message method)))
5436 (or (gnus-request-list method)
5437 (error "Couldn't request list: %s" (gnus-status-message method)))
5438 (get-buffer-create gnus-browse-buffer)
5439 (gnus-add-current-to-buffer-list)
5440 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
5441 (gnus-configure-windows 'browse)
5442 (buffer-disable-undo (current-buffer))
5443 (let ((buffer-read-only nil))
5446 (setq mode-line-buffer-identification
5448 "Gnus Browse Server {%s:%s}" (car method) (car (cdr method))))
5450 (set-buffer nntp-server-buffer)
5451 (let ((cur (current-buffer)))
5452 (goto-char (point-min))
5453 (or (string= gnus-ignored-newsgroups "")
5454 (delete-matching-lines gnus-ignored-newsgroups))
5455 (while (re-search-forward
5456 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
5457 (goto-char (match-end 1))
5458 (setq groups (cons (cons (buffer-substring (match-beginning 1)
5460 (max 0 (- (1+ (read cur)) (read cur))))
5462 (setq groups (sort groups
5464 (string< (car l1) (car l2)))))
5465 (let ((buffer-read-only nil))
5467 (setq group (car groups))
5469 (format "K%7d: %s\n" (cdr group) (car group)))
5470 (setq groups (cdr groups))))
5471 (switch-to-buffer (current-buffer))
5472 (goto-char (point-min))
5473 (gnus-group-position-point)))
5475 (defun gnus-browse-mode ()
5476 "Major mode for browsing a foreign server.
5478 All normal editing commands are switched off.
5480 \\<gnus-browse-mode-map>
5481 The only things you can do in this buffer is
5483 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
5484 The group will be inserted into the group buffer upon exit from this
5487 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
5489 3) `\\[gnus-browse-exit]' to return to the group buffer."
5491 (kill-all-local-variables)
5492 (if (gnus-visual-p 'browse-menu 'menu) (gnus-browse-make-menu-bar))
5493 (setq mode-line-modified "-- ")
5494 (make-local-variable 'mode-line-format)
5495 (setq mode-line-format (copy-sequence mode-line-format))
5496 (and (equal (nth 3 mode-line-format) " ")
5497 (setcar (nthcdr 3 mode-line-format) ""))
5498 (setq major-mode 'gnus-browse-mode)
5499 (setq mode-name "Browse Server")
5500 (setq mode-line-process nil)
5501 (use-local-map gnus-browse-mode-map)
5502 (buffer-disable-undo (current-buffer))
5503 (setq truncate-lines t)
5504 (setq buffer-read-only t)
5505 (run-hooks 'gnus-browse-mode-hook))
5507 (defun gnus-browse-read-group (&optional no-article)
5508 "Enter the group at the current line."
5510 (let ((group (gnus-browse-group-name)))
5511 (or (gnus-group-read-ephemeral-group
5512 group gnus-browse-current-method nil
5513 (cons (current-buffer) 'browse))
5514 (error "Couldn't enter %s" group))))
5516 (defun gnus-browse-select-group ()
5517 "Select the current group."
5519 (gnus-browse-read-group 'no))
5521 (defun gnus-browse-next-group (n)
5522 "Go to the next group."
5526 (gnus-group-position-point)))
5528 (defun gnus-browse-prev-group (n)
5529 "Go to the next group."
5531 (gnus-browse-next-group (- n)))
5533 (defun gnus-browse-unsubscribe-current-group (arg)
5534 "(Un)subscribe to the next ARG groups."
5537 (error "No group at current line."))
5538 (let ((ward (if (< arg 0) -1 1))
5540 (while (and (> arg 0)
5542 (gnus-browse-unsubscribe-group)
5543 (zerop (gnus-browse-next-group ward)))
5544 (setq arg (1- arg)))
5545 (gnus-group-position-point)
5546 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5549 (defun gnus-browse-group-name ()
5552 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5554 (gnus-group-prefixed-name
5555 (buffer-substring (match-beginning 1) (match-end 1))
5556 gnus-browse-current-method))))
5558 (defun gnus-browse-unsubscribe-group ()
5560 (buffer-read-only nil)
5564 (if (= (following-char) ?K) (setq sub t))
5565 (setq group (gnus-browse-group-name))
5570 (gnus-group-change-level
5571 (list t group gnus-level-default-subscribed
5572 nil nil gnus-browse-current-method)
5573 gnus-level-default-subscribed gnus-level-killed
5574 (and (car (nth 1 gnus-newsrc-alist))
5575 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5576 gnus-newsrc-hashtb))
5579 (gnus-group-change-level
5580 group gnus-level-killed gnus-level-default-subscribed)
5584 (defun gnus-browse-exit ()
5585 "Quit browsing and return to the group buffer."
5587 (if (eq major-mode 'gnus-browse-mode)
5588 (kill-buffer (current-buffer)))
5589 (if gnus-browse-return-buffer
5590 (gnus-configure-windows 'server 'force)
5591 (gnus-configure-windows 'group 'force)
5592 (gnus-group-list-groups nil)))
5594 (defun gnus-browse-describe-briefly ()
5595 "Give a one line description of the group mode commands."
5598 (substitute-command-keys "\\<gnus-browse-mode-map>\\[gnus-group-next-group]:Forward \\[gnus-group-prev-group]:Backward \\[gnus-browse-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-browse-describe-briefly]:This help")))
5602 ;;; Gnus summary mode
5605 (defvar gnus-summary-mode-map nil)
5606 (defvar gnus-summary-mark-map nil)
5607 (defvar gnus-summary-mscore-map nil)
5608 (defvar gnus-summary-article-map nil)
5609 (defvar gnus-summary-thread-map nil)
5610 (defvar gnus-summary-goto-map nil)
5611 (defvar gnus-summary-exit-map nil)
5612 (defvar gnus-summary-interest-map nil)
5613 (defvar gnus-summary-sort-map nil)
5614 (defvar gnus-summary-backend-map nil)
5615 (defvar gnus-summary-save-map nil)
5616 (defvar gnus-summary-wash-map nil)
5617 (defvar gnus-summary-wash-hide-map nil)
5618 (defvar gnus-summary-wash-highlight-map nil)
5619 (defvar gnus-summary-wash-time-map nil)
5620 (defvar gnus-summary-help-map nil)
5621 (defvar gnus-summary-limit-map nil)
5623 (put 'gnus-summary-mode 'mode-class 'special)
5625 (if gnus-summary-mode-map
5627 (setq gnus-summary-mode-map (make-keymap))
5628 (suppress-keymap gnus-summary-mode-map)
5630 ;; Non-orthogonal keys
5632 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5633 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5634 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5635 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5636 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5637 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5638 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5639 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5640 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5641 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5642 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5643 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5644 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5645 (define-key gnus-summary-mode-map
5646 "\M-s" 'gnus-summary-search-article-forward)
5647 (define-key gnus-summary-mode-map
5648 "\M-r" 'gnus-summary-search-article-backward)
5649 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5650 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5651 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5652 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5653 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5654 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5655 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5656 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5657 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5658 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5659 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5660 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5661 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5662 (define-key gnus-summary-mode-map
5663 "k" 'gnus-summary-kill-same-subject-and-select)
5664 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5665 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5666 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5667 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5668 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5669 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5670 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5671 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5672 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5673 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5674 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5675 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5676 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5677 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5678 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5679 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5680 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5681 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5682 (define-key gnus-summary-mode-map
5683 "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5684 (define-key gnus-summary-mode-map
5685 "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5686 (define-key gnus-summary-mode-map
5687 "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5688 (define-key gnus-summary-mode-map
5689 "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5690 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5691 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5692 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5693 (define-key gnus-summary-mode-map
5694 "\C-x\C-s" 'gnus-summary-reselect-current-group)
5695 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5696 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5697 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5698 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5699 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5700 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5701 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5702 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5703 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5704 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5705 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5706 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5707 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5708 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5709 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5710 (define-key gnus-summary-mode-map "V" 'gnus-version)
5711 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5712 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5713 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5714 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5715 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5716 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5717 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5718 (define-key gnus-summary-mode-map "x" 'gnus-summary-limit-to-unread)
5719 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5720 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5721 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5722 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5723 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5724 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5725 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5726 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5727 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5728 (define-key gnus-summary-mode-map "/" 'gnus-summary-limit-to-subject)
5731 ;; Sort of orthogonal keymap
5732 (define-prefix-command 'gnus-summary-mark-map)
5733 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5734 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5735 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5736 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5737 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5738 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5739 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5740 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5741 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5742 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5743 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5744 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5745 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5746 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5747 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5748 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5749 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5750 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5751 (define-key gnus-summary-mark-map
5752 "k" 'gnus-summary-kill-same-subject-and-select)
5753 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5755 (define-prefix-command 'gnus-summary-mscore-map)
5756 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map)
5757 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5758 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5759 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5760 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5762 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map)
5764 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5766 (define-prefix-command 'gnus-summary-limit-map)
5767 (define-key gnus-summary-mark-map "N" 'gnus-summary-limit-map)
5768 (define-key gnus-summary-limit-map "n" 'gnus-summary-limit-to-articles)
5769 (define-key gnus-summary-limit-map "w" 'gnus-summary-pop-limit)
5770 (define-key gnus-summary-limit-map "s" 'gnus-summary-limit-to-subject)
5771 (define-key gnus-summary-limit-map "u" 'gnus-summary-limit-to-unread)
5772 (define-key gnus-summary-limit-map "m" 'gnus-summary-limit-to-marks)
5773 (define-key gnus-summary-limit-map "v" 'gnus-summary-limit-to-score)
5774 (define-key gnus-summary-limit-map "D" 'gnus-summary-limit-include-dormant)
5775 (define-key gnus-summary-limit-map "d" 'gnus-summary-limit-exclude-dormant)
5776 (define-key gnus-summary-limit-map "c"
5777 'gnus-summary-limit-exclude-childless-dormant)
5779 (define-prefix-command 'gnus-summary-goto-map)
5780 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5781 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5782 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5783 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5784 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5785 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5786 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5787 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5788 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5789 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5790 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5791 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5792 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5793 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5796 (define-prefix-command 'gnus-summary-thread-map)
5797 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5798 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5799 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5800 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5801 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5802 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5803 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5804 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5805 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5806 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5807 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5808 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5809 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5810 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5811 (define-key gnus-summary-thread-map "\M-#" 'gnus-uu-unmark-thread)
5814 (define-prefix-command 'gnus-summary-exit-map)
5815 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5816 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5817 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5818 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5819 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5820 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5821 (define-key gnus-summary-exit-map
5822 "n" 'gnus-summary-catchup-and-goto-next-group)
5823 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5824 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5825 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5826 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5829 (define-prefix-command 'gnus-summary-article-map)
5830 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5831 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5832 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5833 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5834 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5835 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5836 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5837 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5838 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5839 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5840 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5841 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5842 (define-key gnus-summary-article-map "R" 'gnus-summary-refer-references)
5843 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5844 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5848 (define-prefix-command 'gnus-summary-wash-map)
5849 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5851 (define-prefix-command 'gnus-summary-wash-hide-map)
5852 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map)
5853 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide)
5854 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers)
5855 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature)
5856 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation)
5857 (define-key gnus-summary-wash-hide-map
5858 "\C-c" 'gnus-article-hide-citation-maybe)
5860 (define-prefix-command 'gnus-summary-wash-highlight-map)
5861 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map)
5862 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight)
5863 (define-key gnus-summary-wash-highlight-map
5864 "h" 'gnus-article-highlight-headers)
5865 (define-key gnus-summary-wash-highlight-map
5866 "c" 'gnus-article-highlight-citation)
5867 (define-key gnus-summary-wash-highlight-map
5868 "s" 'gnus-article-highlight-signature)
5870 (define-prefix-command 'gnus-summary-wash-time-map)
5871 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map)
5872 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut)
5873 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut)
5874 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local)
5875 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed)
5876 (define-key gnus-summary-wash-time-map "o" 'gnus-article-date-original)
5878 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5879 (define-key gnus-summary-wash-map "B" 'gnus-article-add-buttons-to-head)
5880 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5881 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5882 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr)
5883 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5884 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5885 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
5886 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
5887 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header)
5888 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
5891 (define-prefix-command 'gnus-summary-help-map)
5892 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5893 (define-key gnus-summary-help-map "v" 'gnus-version)
5894 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5895 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5896 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5897 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5900 (define-prefix-command 'gnus-summary-backend-map)
5901 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5902 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5903 (define-key gnus-summary-backend-map "\M-\C-e"
5904 'gnus-summary-expire-articles-now)
5905 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5906 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5907 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5908 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5909 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5910 (define-key gnus-summary-backend-map "q" 'gnus-summary-respool-query)
5911 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5914 (define-prefix-command 'gnus-summary-save-map)
5915 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5916 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5917 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5918 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5919 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5920 (define-key gnus-summary-save-map "b" 'gnus-summary-save-article-body-file)
5921 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5922 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5923 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5924 (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5926 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5928 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
5929 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
5931 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map)
5933 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5934 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5940 (defun gnus-summary-mode (&optional group)
5941 "Major mode for reading articles.
5943 All normal editing commands are switched off.
5944 \\<gnus-summary-mode-map>
5945 Each line in this buffer represents one article. To read an
5946 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5947 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5950 You can also post articles and send mail from this buffer. To
5951 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5952 of an article, type `\\[gnus-summary-reply]'.
5954 There are approx. one gazillion commands you can execute in this
5955 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5957 The following commands are available:
5959 \\{gnus-summary-mode-map}"
5961 (if (gnus-visual-p 'summary-menu 'menu) (gnus-summary-make-menu-bar))
5962 (kill-all-local-variables)
5963 (let ((locals gnus-summary-local-variables))
5965 (if (consp (car locals))
5967 (make-local-variable (car (car locals)))
5968 (set (car (car locals)) (eval (cdr (car locals)))))
5969 (make-local-variable (car locals))
5970 (set (car locals) nil))
5971 (setq locals (cdr locals))))
5972 (gnus-make-thread-indent-array)
5973 (setq mode-line-modified "-- ")
5974 (make-local-variable 'mode-line-format)
5975 (setq mode-line-format (copy-sequence mode-line-format))
5976 (and (equal (nth 3 mode-line-format) " ")
5977 (setcar (nthcdr 3 mode-line-format) ""))
5978 (setq major-mode 'gnus-summary-mode)
5979 (setq mode-name "Summary")
5980 (make-local-variable 'minor-mode-alist)
5981 (use-local-map gnus-summary-mode-map)
5982 (buffer-disable-undo (current-buffer))
5983 (setq buffer-read-only t) ;Disable modification
5984 (setq truncate-lines t)
5985 (setq selective-display t)
5986 (setq selective-display-ellipses t) ;Display `...'
5987 (setq buffer-display-table gnus-summary-display-table)
5988 (setq gnus-newsgroup-name group)
5989 (run-hooks 'gnus-summary-mode-hook))
5991 (defun gnus-summary-make-display-table ()
5992 ;; Change the display table. Odd characters have a tendency to mess
5993 ;; up nicely formatted displays - we make all possible glyphs
5994 ;; display only a single character.
5996 ;; We start from the standard display table, if any.
5997 (setq gnus-summary-display-table
5998 (or (copy-sequence standard-display-table)
5999 (make-display-table)))
6000 ;; Nix out all the control chars...
6002 (while (>= (setq i (1- i)) 0)
6003 (aset gnus-summary-display-table i [??])))
6004 ;; ... but not newline and cr, of course. (cr is necessary for the
6005 ;; selective display).
6006 (aset gnus-summary-display-table ?\n nil)
6007 (aset gnus-summary-display-table ?\r nil)
6008 ;; We nix out any glyphs over 126 that are not set already.
6010 (while (>= (setq i (1- i)) 127)
6011 ;; Only modify if the entry is nil.
6012 (or (aref gnus-summary-display-table i)
6013 (aset gnus-summary-display-table i [??])))))
6015 (defun gnus-summary-clear-local-variables ()
6016 (let ((locals gnus-summary-local-variables))
6018 (if (consp (car locals))
6019 (and (vectorp (car (car locals)))
6020 (set (car (car locals)) nil))
6021 (and (vectorp (car locals))
6022 (set (car locals) nil)))
6023 (setq locals (cdr locals)))))
6025 ;; Summary data functions.
6027 (defmacro gnus-data-number (data)
6030 (defmacro gnus-data-mark (data)
6031 (` (nth 1 (, data))))
6033 (defmacro gnus-data-set-mark (data mark)
6034 (` (setcar (nthcdr 1 (, data)) (, mark))))
6036 (defmacro gnus-data-pos (data)
6037 (` (nth 2 (, data))))
6039 (defmacro gnus-data-header (data)
6040 (` (nth 3 (, data))))
6042 (defmacro gnus-data-level (data)
6043 (` (nth 4 (, data))))
6045 (defmacro gnus-data-unread-p (data)
6046 (` (= (nth 1 (, data)) gnus-unread-mark)))
6048 (defmacro gnus-data-find (number)
6049 (` (assq (, number) gnus-newsgroup-data)))
6051 (defmacro gnus-data-find-list (number &optional data)
6052 (` (memq (assq (, number) (, (or data 'gnus-newsgroup-data)))
6053 (, (or data 'gnus-newsgroup-data)))))
6055 (defmacro gnus-data-make (number mark pos header level)
6056 (` (list (, number) (, mark) (set-marker (make-marker) (, pos)) (, header)
6059 (defun gnus-data-enter (after-article number mark pos header level)
6060 (let ((data (gnus-data-find-list after-article)))
6061 (or data (error "No such article: %d" after-article))
6062 (setcdr data (cons (gnus-data-make number mark pos header level)
6065 (defun gnus-data-enter-list (after-article list)
6068 (let ((data (gnus-data-find-list after-article))
6070 (or data (error "No such article: %d" after-article))
6071 ;; Find the last element in the list to be spliced into the main
6074 (setq list (cdr list)))
6075 (setcdr list (cdr data))
6076 (setcdr data ilist))))
6078 (defun gnus-data-remove (article)
6079 (let ((data gnus-newsgroup-data))
6080 (if (= (gnus-data-number (car data)) article)
6081 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
6082 gnus-newsgroup-data-reverse nil)
6084 (and (= (gnus-data-number (car (cdr data))) article)
6086 (set-marker (gnus-data-pos (car (cdr data))) nil)
6087 (setcdr data (cdr (cdr data)))
6089 gnus-newsgroup-data-reverse nil)))
6090 (setq data (cdr data))))))
6092 (defmacro gnus-data-list (backward)
6094 (or gnus-newsgroup-data-reverse
6095 (setq gnus-newsgroup-data-reverse
6096 (reverse gnus-newsgroup-data)))
6097 gnus-newsgroup-data)))
6099 (defun gnus-summary-article-pseudo-p (article)
6100 (not (vectorp (gnus-data-header (gnus-data-find article)))))
6102 (defun gnus-article-parent-p (number)
6103 (let* ((data (gnus-data-find-list number)))
6104 (and (cdr data) ; There has to be an article after...
6105 (< (gnus-data-level (car data)) ; And it has to have a higher level.
6106 (gnus-data-level (nth 1 data))))))
6108 ;; Some summary mode macros.
6110 (defmacro gnus-summary-article-number (&optional number-or-nil)
6111 "The article number of the article on the current line.
6112 If there isn's an article number here, then we return the current
6115 '(get-text-property (point) 'gnus-number)
6116 '(or (get-text-property (point) 'gnus-number)
6117 gnus-current-article)))
6119 (defmacro gnus-summary-article-header (&optional number)
6120 (` (gnus-data-header (gnus-data-find
6121 (, (or number '(gnus-summary-article-number)))))))
6123 (defmacro gnus-summary-thread-level (&optional number)
6124 (` (gnus-data-level (gnus-data-find
6125 (, (or number '(gnus-summary-article-number)))))))
6127 (defmacro gnus-summary-article-mark (&optional number)
6128 (` (gnus-data-mark (gnus-data-find
6129 (, (or number '(gnus-summary-article-number)))))))
6131 (defmacro gnus-summary-article-pos (&optional number)
6132 (` (gnus-data-pos (gnus-data-find
6133 (, (or number '(gnus-summary-article-number)))))))
6135 (defmacro gnus-summary-article-subject (&optional number)
6136 "Return current subject string or nil if nothing."
6139 (` (gnus-data-header (assq (, number) gnus-newsgroup-data)))
6140 '(gnus-data-header (assq (gnus-summary-article-number)
6141 gnus-newsgroup-data))))))
6144 (mail-header-subject headers)))))
6146 (defmacro gnus-summary-article-score (&optional number)
6147 "Return current article score."
6148 (` (or (cdr (assq (, (or number '(gnus-summary-article-number)))
6149 gnus-newsgroup-scored))
6150 gnus-summary-default-score 0)))
6152 (defun gnus-summary-article-children (&optional number)
6153 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
6154 (level (gnus-data-level (car data)))
6156 (while (and (setq data (cdr data))
6157 (> (setq l (gnus-data-level (car data))) level))
6158 (and (= (1+ level) l)
6159 (setq children (cons (gnus-data-number (car data))
6161 (nreverse children)))
6163 (defun gnus-summary-article-parent (&optional number)
6164 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
6165 (gnus-data-list t)))
6166 (level (gnus-data-level (car data)))
6169 () ; This is a root.
6170 ;; We search until we find an article with a level less than
6171 ;; this one. That function has to be the parent.
6172 (while (and (setq data (cdr data))
6173 (not (< (gnus-data-level (car data)) level))))
6174 (and data (gnus-data-number (car data))))))
6177 ;; Various summary mode internalish functions.
6179 (defun gnus-mouse-pick-article (e)
6182 (gnus-summary-next-page nil t))
6184 (defun gnus-summary-setup-buffer (group)
6185 "Initialize summary buffer."
6186 (let ((buffer (concat "*Summary " group "*")))
6187 (if (get-buffer buffer)
6190 (not gnus-newsgroup-begin))
6191 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6192 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
6193 (gnus-add-current-to-buffer-list)
6194 (gnus-summary-mode group)
6195 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
6196 (setq gnus-newsgroup-name group)
6199 (defun gnus-set-global-variables ()
6200 ;; Set the global equivalents of the summary buffer-local variables
6201 ;; to the latest values they had. These reflect the summary buffer
6202 ;; that was in action when the last article was fetched.
6203 (if (eq major-mode 'gnus-summary-mode)
6205 (setq gnus-summary-buffer (current-buffer))
6206 (let ((name gnus-newsgroup-name)
6207 (marked gnus-newsgroup-marked)
6208 (unread gnus-newsgroup-unreads)
6209 (headers gnus-current-headers)
6210 (data gnus-newsgroup-data)
6211 (score-file gnus-current-score-file))
6213 (set-buffer gnus-group-buffer)
6214 (setq gnus-newsgroup-name name)
6215 (setq gnus-newsgroup-marked marked)
6216 (setq gnus-newsgroup-unreads unread)
6217 (setq gnus-current-headers headers)
6218 (setq gnus-newsgroup-data data)
6219 (setq gnus-current-score-file score-file))))))
6221 (defun gnus-summary-last-article-p (&optional article)
6222 "Return whether ARTICLE is the last article in the buffer."
6223 (if (not (setq article (or article (gnus-summary-article-number))))
6224 t ; All non-existant numbers are the last article. :-)
6225 (cdr (gnus-data-find-list article))))
6227 (defun gnus-summary-insert-dummy-line (sformat subject number)
6229 (setq sformat gnus-summary-dummy-line-format-spec))
6232 (point) (progn (insert (eval sformat)) (point))
6233 'gnus-number number))
6235 (defvar gnus-thread-indent-array nil)
6236 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
6237 (defun gnus-make-thread-indent-array ()
6239 (if (and gnus-thread-indent-array
6240 (= gnus-thread-indent-level gnus-thread-indent-array-level))
6242 (setq gnus-thread-indent-array (make-vector 201 "")
6243 gnus-thread-indent-array-level gnus-thread-indent-level)
6245 (aset gnus-thread-indent-array n
6246 (make-string (* n gnus-thread-indent-level) ? ))
6249 (defun gnus-summary-insert-line
6250 (sformat header level current unread replied expirable subject-or-nil
6251 &optional dummy score)
6252 (or sformat (setq sformat gnus-summary-line-format-spec))
6253 (let* ((indentation (aref gnus-thread-indent-array level))
6254 (lines (mail-header-lines header))
6255 (score (or score gnus-summary-default-score 0))
6257 (if (or (null gnus-summary-default-score)
6258 (<= (abs (- score gnus-summary-default-score))
6259 gnus-summary-zcore-fuzz)) ?
6260 (if (< score gnus-summary-default-score)
6261 gnus-score-below-mark gnus-score-over-mark)))
6262 (replied (if replied gnus-replied-mark ? ))
6263 (from (mail-header-from header))
6265 ((string-match "(.+)" from)
6266 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
6267 ((string-match "<[^>]+> *$" from)
6268 (let ((beg (match-beginning 0)))
6269 (or (and (string-match "^\"[^\"]*\"" from)
6270 (substring from (1+ (match-beginning 0))
6271 (1- (match-end 0))))
6272 (substring from 0 beg))))
6274 (subject (mail-header-subject header))
6275 (number (mail-header-number header))
6276 (opening-bracket (if dummy ?\< ?\[))
6277 (closing-bracket (if dummy ?\> ?\]))
6278 (buffer-read-only nil))
6279 (or (numberp lines) (setq lines 0))
6282 (progn (insert (eval sformat)) (point))
6283 'gnus-number number)))
6285 (defun gnus-summary-update-line (&optional dont-update)
6286 ;; Update summary line after change.
6287 (or (not gnus-summary-default-score)
6288 gnus-summary-inhibit-highlight
6289 (let ((gnus-summary-inhibit-highlight t)
6290 (article (gnus-summary-article-number)))
6293 (if (and gnus-summary-mark-below
6294 (< (gnus-summary-article-score)
6295 gnus-summary-mark-below))
6296 (and (not (memq article gnus-newsgroup-marked))
6297 (not (memq article gnus-newsgroup-dormant))
6298 (memq article gnus-newsgroup-unreads)
6299 (gnus-summary-mark-article-as-read gnus-low-score-mark))
6300 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
6301 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
6302 (and (gnus-visual-p 'summary-highlight 'highlight)
6303 (run-hooks 'gnus-summary-update-hook))))))
6305 (defun gnus-summary-update-lines (&optional beg end)
6306 ;; Mark article as read (or not) by taking into account scores.
6307 (let ((beg (or beg (point-min)))
6308 (end (or end (point-max))))
6309 (if (or (not gnus-summary-default-score)
6310 gnus-summary-inhibit-highlight)
6312 (let ((gnus-summary-inhibit-highlight t)
6315 (set-buffer gnus-summary-buffer)
6318 (while (and (not (eobp)) (< (point) end))
6319 (if (and gnus-summary-mark-below
6321 (setq article (gnus-summary-article-number))
6322 gnus-newsgroup-scored))
6323 gnus-summary-default-score 0)
6324 gnus-summary-mark-below))
6325 ;; We want to possibly mark it as read...
6326 (and (not (memq article gnus-newsgroup-marked))
6327 (not (memq article gnus-newsgroup-dormant))
6328 (memq article gnus-newsgroup-unreads)
6329 (gnus-summary-mark-article-as-read gnus-low-score-mark))
6330 ;; We want to possibly mark it as unread.
6331 (and (eq (gnus-summary-article-mark article)
6332 gnus-low-score-mark)
6333 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
6334 ;; Do the visual highlights at the same time.
6335 (and (gnus-visual-p 'summary-highlight 'highlight)
6336 (run-hooks 'gnus-summary-update-hook))
6337 (forward-line 1)))))))
6339 (defvar gnus-tmp-gathered nil)
6341 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
6342 ;; Sum up all elements (and sub-elements) in a list.
6344 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
6345 (if (and (consp thread) (cdr thread))
6348 'gnus-summary-number-of-articles-in-thread
6352 (if (> number 1) gnus-not-empty-thread-mark
6353 gnus-empty-thread-mark)
6356 ;; This function goes through the local params of GROUP and sets all
6357 ;; variable specs in that list.
6358 (defun gnus-summary-set-local-parameters (group)
6359 (let ((params (nth 5 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6362 (setq elem (car params)
6363 params (cdr params))
6366 (symbolp (car elem))
6368 (make-local-variable (car elem))
6369 (set (car elem) (eval (nth 1 elem))))))))
6371 (defun gnus-summary-read-group
6372 (group &optional show-all no-article kill-buffer no-display)
6373 "Start reading news in newsgroup GROUP.
6374 If SHOW-ALL is non-nil, already read articles are also listed.
6375 If NO-ARTICLE is non-nil, no article is selected initially.
6376 If NO-DISPLAY, don't generate a summary buffer."
6377 (gnus-message 5 "Retrieving newsgroup: %s..." group)
6378 (let* ((new-group (gnus-summary-setup-buffer group))
6379 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
6381 (did-select (and new-group (gnus-select-newsgroup group show-all))))
6384 (gnus-set-global-variables)
6385 (gnus-kill-buffer kill-buffer)
6386 (gnus-configure-windows 'summary 'force)
6387 (gnus-set-mode-line 'summary)
6388 (gnus-summary-position-point)
6392 (and (eq major-mode 'gnus-summary-mode)
6393 (not (equal (current-buffer) kill-buffer))
6395 (kill-buffer (current-buffer))
6396 (if (not quit-config)
6398 (set-buffer gnus-group-buffer)
6399 (gnus-group-jump-to-group group)
6400 (gnus-group-next-unread-group 1))
6401 (if (not (buffer-name (car quit-config)))
6402 (gnus-configure-windows 'group 'force)
6403 (set-buffer (car quit-config))
6404 (and (eq major-mode 'gnus-summary-mode)
6405 (gnus-set-global-variables))
6406 (gnus-configure-windows (cdr quit-config))))))
6407 (message "Can't select group")
6409 ((eq did-select 'quit)
6410 (and (eq major-mode 'gnus-summary-mode)
6411 (not (equal (current-buffer) kill-buffer))
6412 (kill-buffer (current-buffer)))
6413 (gnus-kill-buffer kill-buffer)
6414 (if (not quit-config)
6416 (set-buffer gnus-group-buffer)
6417 (gnus-group-jump-to-group group)
6418 (gnus-group-next-unread-group 1)
6419 (gnus-configure-windows 'group 'force))
6420 (if (not (buffer-name (car quit-config)))
6421 (gnus-configure-windows 'group 'force)
6422 (set-buffer (car quit-config))
6423 (and (eq major-mode 'gnus-summary-mode)
6424 (gnus-set-global-variables))
6425 (gnus-configure-windows (cdr quit-config))))
6428 (gnus-set-global-variables)
6429 ;; Save the active value in effect when the group was entered.
6430 (setq gnus-newsgroup-active
6432 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6433 ;; You can change the summary buffer in some way with this hook.
6434 (run-hooks 'gnus-select-group-hook)
6435 ;; Set any local variables in the group parameters.
6436 (gnus-summary-set-local-parameters gnus-newsgroup-name)
6437 ;; Do score processing.
6438 (and gnus-use-scoring (gnus-possibly-score-headers))
6439 (gnus-update-format-specifications)
6440 ;; Generate the summary buffer.
6442 (gnus-summary-prepare))
6443 (if (zerop (buffer-size))
6444 (cond (gnus-newsgroup-dormant
6445 (gnus-summary-limit-include-dormant))
6446 ((and gnus-newsgroup-scored show-all)
6447 (gnus-summary-show-all-expunged))))
6448 ;; Function `gnus-apply-kill-file' must be called in this hook.
6449 (run-hooks 'gnus-apply-kill-hook)
6450 (if (zerop (buffer-size))
6452 ;; This newsgroup is empty.
6453 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
6454 (gnus-message 6 "No unread news")
6455 (gnus-kill-buffer kill-buffer)
6459 ;; (let ((gnus-summary-buffer kill-buffer))
6460 ;; (gnus-configure-windows 'group))))
6461 ;; Hide conversation thread subtrees. We cannot do this in
6462 ;; gnus-summary-prepare-hook since kill processing may not
6463 ;; work with hidden articles.
6464 (and gnus-show-threads
6465 gnus-thread-hide-subtree
6466 (gnus-summary-hide-all-threads))
6467 ;; Show first unread article if requested.
6468 (goto-char (point-min))
6469 (if (and (not no-article)
6470 gnus-auto-select-first
6471 (gnus-summary-first-unread-article))
6473 (gnus-configure-windows 'summary 'force))
6474 (gnus-set-mode-line 'summary)
6475 (gnus-summary-position-point)
6476 ;; If in async mode, we send some info to the backend.
6477 (and gnus-newsgroup-async
6478 (gnus-request-asynchronous
6479 gnus-newsgroup-name gnus-newsgroup-data))
6480 (gnus-kill-buffer kill-buffer)
6481 (if (not (get-buffer-window gnus-group-buffer))
6483 ;; gotta use windows, because recenter does wierd stuff if
6484 ;; the current buffer ain't the displayed window.
6485 (let ((owin (selected-window)))
6486 (select-window (get-buffer-window gnus-group-buffer))
6487 (and (gnus-group-goto-group group)
6489 (select-window owin))))
6492 (defun gnus-summary-prepare ()
6493 ;; Generate the summary buffer.
6494 (let ((buffer-read-only nil))
6496 (setq gnus-newsgroup-data nil
6497 gnus-newsgroup-data-reverse nil)
6498 (gnus-summary-prepare-threads
6499 (if gnus-show-threads
6500 (gnus-gather-threads
6502 (gnus-make-threads)))
6503 gnus-newsgroup-headers)
6505 (gnus-summary-update-lines)
6506 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
6507 ;; Call hooks for modifying summary buffer.
6508 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
6509 (goto-char (point-min))
6510 (run-hooks 'gnus-summary-prepare-hook)))
6512 (defun gnus-gather-threads (threads)
6513 "Gather threads that have lost their roots."
6514 (if (not gnus-summary-make-false-root)
6516 (let ((hashtb (gnus-make-hashtable 1023))
6519 subject hthread whole-subject)
6522 (setq subject (mail-header-subject (car (car threads)))))
6523 (if (and gnus-summary-gather-exclude-subject
6524 (string-match gnus-summary-gather-exclude-subject
6526 () ; We don't want to do anything with this.
6527 (if gnus-summary-gather-subject-limit
6528 (or (and (numberp gnus-summary-gather-subject-limit)
6529 (> (length subject) gnus-summary-gather-subject-limit)
6531 (substring subject 0
6532 gnus-summary-gather-subject-limit)))
6533 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
6534 (setq subject (gnus-simplify-subject-fuzzy subject))))
6535 (setq subject (gnus-simplify-subject-re subject)))
6537 (gnus-gethash subject hashtb))
6539 (or (stringp (car (car hthread)))
6540 (setcar hthread (list whole-subject (car hthread))))
6541 (setcdr (car hthread) (nconc (cdr (car hthread))
6542 (list (car threads))))
6543 (setcdr prev (cdr threads))
6544 (setq threads prev))
6545 (gnus-sethash subject threads hashtb)))
6547 (setq threads (cdr threads)))
6550 (defun gnus-make-threads ()
6551 ;; This function takes the dependencies already made by
6552 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6553 ;; through the dependecies in the hash table and finds all the
6554 ;; roots. Roots do not refer back to any valid articles.
6556 (and gnus-fetch-old-headers
6557 (eq gnus-headers-retrieved-by 'nov)
6558 (gnus-build-old-threads))
6561 (or (car (symbol-value refs))
6562 (setq threads (append (cdr (symbol-value refs)) threads))))
6563 gnus-newsgroup-dependencies)
6566 (defun gnus-cut-thread (thread)
6567 ;; Remove leaf dormant or ancient articles from THREAD.
6568 (let ((head (car thread))
6569 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6570 (if (and (null tail)
6571 (let ((number (mail-header-number head)))
6572 (or (memq number gnus-newsgroup-ancient)
6573 (memq number gnus-newsgroup-dormant)
6574 (and gnus-summary-expunge-below
6575 (or (eq gnus-fetch-old-headers 'some)
6576 (numberp gnus-fetch-old-headers))
6577 (< (or (cdr (assq number gnus-newsgroup-scored))
6578 gnus-summary-default-score 0)
6579 gnus-summary-expunge-below)
6581 (setq gnus-newsgroup-unreads
6582 (delq number gnus-newsgroup-unreads))
6583 (setq gnus-newsgroup-reads
6584 (cons (cons number gnus-low-score-mark)
6585 gnus-newsgroup-reads))
6586 (setq gnus-newsgroup-expunged-tally
6587 (1+ gnus-newsgroup-expunged-tally))
6590 (list (cons head tail)))))
6592 (defun gnus-trim-thread (thread)
6593 ;; Remove root ancient articles with only one child from THREAD.
6594 (if (and (or (eq gnus-fetch-old-headers 'some)
6595 (numberp gnus-fetch-old-headers))
6596 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient)
6597 (= (length thread) 2))
6598 (gnus-trim-thread (nth 1 thread))
6601 (defun gnus-make-sub-thread (root)
6602 ;; This function makes a sub-tree for a node in the tree.
6603 (let ((children (reverse (cdr (gnus-gethash (downcase (mail-header-id root))
6604 gnus-newsgroup-dependencies)))))
6605 (cons root (mapcar (lambda (c) (gnus-make-sub-thread (car c))) children))))
6607 (defun gnus-build-old-threads ()
6608 ;; Look at all the articles that refer back to old articles, and
6609 ;; fetch the headers for the articles that aren't there. This will
6610 ;; build complete threads - if the roots haven't been expired by the
6615 (if (not (car (symbol-value refs)))
6617 (setq heads (cdr (symbol-value refs)))
6619 (if (not (memq (mail-header-number (car (car heads)))
6620 gnus-newsgroup-dormant))
6622 (setq id (symbol-name refs))
6623 (while (and (setq id (gnus-build-get-header id))
6624 (not (car (gnus-gethash
6625 id gnus-newsgroup-dependencies)))))
6627 (setq heads (cdr heads)))))))
6628 gnus-newsgroup-dependencies)))
6630 (defun gnus-build-get-header (id)
6631 ;; Look through the buffer of NOV lines and find the header to
6632 ;; ID. Enter this line into the dependencies hash table, and return
6633 ;; the id of the parent article (if any).
6634 (let ((deps gnus-newsgroup-dependencies)
6638 (set-buffer nntp-server-buffer)
6639 (goto-char (point-min))
6640 (while (and (not found) (search-forward id nil t))
6642 (setq found (looking-at
6643 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6644 (regexp-quote id))))
6645 (or found (beginning-of-line 2)))
6650 (setq header (gnus-nov-parse-line
6651 (read (current-buffer)) deps))
6652 (setq ref (mail-header-references header))
6653 (string-match "\\(<[^>]+>\\) *$" ref)
6654 (substring ref (match-beginning 1) (match-end 1))))))
6656 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6657 gnus-newsgroup-ancient (cons (mail-header-number header)
6658 gnus-newsgroup-ancient))))))
6660 ;; Re-build the thread containing ID.
6661 (defun gnus-rebuild-thread (id)
6662 (let ((dep gnus-newsgroup-dependencies)
6663 (buffer-read-only nil)
6664 current parent headers refs thread art data)
6665 (while (and id (setq headers
6666 (car (setq art (gnus-gethash (downcase id) dep)))))
6668 (setq id (and (setq refs (mail-header-references headers))
6669 (string-match "\\(<[^>]+>\\) *$" refs)
6670 (substring refs (match-beginning 1) (match-end 1)))))
6671 (setq thread (gnus-make-sub-thread (car parent)))
6672 (gnus-rebuild-remove-articles thread)
6673 (let ((beg (point)))
6674 (setq current (save-excursion
6676 (gnus-summary-article-number)))
6677 (let (gnus-newsgroup-data)
6678 (gnus-summary-prepare-threads (list thread))
6679 (setq data (nreverse gnus-newsgroup-data)))
6680 (gnus-data-enter-list current data)
6681 (gnus-summary-update-lines beg (point)))))
6683 ;; Delete all lines in the summary buffer that correspond to articles
6685 (defun gnus-rebuild-remove-articles (thread)
6687 (and (gnus-summary-goto-subject
6688 (setq number (mail-header-number (car thread))))
6690 (gnus-data-remove number))
6691 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6693 (defun gnus-sort-threads (threads)
6694 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6695 (let ((fun gnus-thread-sort-functions))
6697 (setq threads (sort threads (car fun))
6701 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6702 (defmacro gnus-thread-header (thread)
6703 ;; Return header of first article in THREAD.
6704 ;; Note that THREAD must never, evr be anything else than a variable -
6705 ;; using some other form will lead to serious barfage.
6706 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
6707 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6708 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6711 (defun gnus-thread-sort-by-number (h1 h2)
6712 "Sort threads by root article number."
6713 (< (mail-header-number (gnus-thread-header h1))
6714 (mail-header-number (gnus-thread-header h2))))
6716 (defun gnus-thread-sort-by-author (h1 h2)
6717 "Sort threads by root author."
6719 (let ((extract (funcall
6720 gnus-extract-address-components
6721 (mail-header-from (gnus-thread-header h1)))))
6722 (or (car extract) (cdr extract)))
6723 (let ((extract (funcall
6724 gnus-extract-address-components
6725 (mail-header-from (gnus-thread-header h2)))))
6726 (or (car extract) (cdr extract)))))
6728 (defun gnus-thread-sort-by-subject (h1 h2)
6729 "Sort threads by root subject."
6731 (downcase (gnus-simplify-subject
6732 (mail-header-subject (gnus-thread-header h1))))
6733 (downcase (gnus-simplify-subject
6734 (mail-header-subject (gnus-thread-header h2))))))
6736 (defun gnus-thread-sort-by-date (h1 h2)
6737 "Sort threads by root article date."
6739 (gnus-sortable-date (mail-header-date (gnus-thread-header h1)))
6740 (gnus-sortable-date (mail-header-date (gnus-thread-header h2)))))
6742 (defun gnus-thread-sort-by-score (h1 h2)
6743 "Sort threads by root article score.
6744 Unscored articles will be counted as having a score of zero."
6745 (> (or (cdr (assq (mail-header-number (gnus-thread-header h1))
6746 gnus-newsgroup-scored))
6747 gnus-summary-default-score 0)
6748 (or (cdr (assq (mail-header-number (gnus-thread-header h2))
6749 gnus-newsgroup-scored))
6750 gnus-summary-default-score 0)))
6752 (defun gnus-thread-sort-by-total-score (h1 h2)
6753 "Sort threads by the sum of all scores in the thread.
6754 Unscored articles will be counted as having a score of zero."
6755 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6757 (defun gnus-thread-total-score (thread)
6758 ;; This function find the total score of THREAD.
6760 (if (stringp (car thread))
6761 (apply gnus-thread-score-function 0
6762 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6763 (gnus-thread-total-score-1 thread))
6764 (gnus-thread-total-score-1 (list thread))))
6766 (defun gnus-thread-total-score-1 (root)
6767 ;; This function find the total score of the thread below ROOT.
6768 (setq root (car root))
6769 (apply gnus-thread-score-function
6770 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
6771 gnus-summary-default-score 0)
6772 (mapcar 'gnus-thread-total-score
6773 (cdr (gnus-gethash (downcase (mail-header-id root))
6774 gnus-newsgroup-dependencies)))))
6776 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6777 (defvar gnus-tmp-prev-subject nil)
6778 (defvar gnus-tmp-false-parent nil)
6779 (defvar gnus-tmp-root-expunged nil)
6781 (defun gnus-summary-prepare-threads (threads &optional cull)
6782 "Prepare summary buffer from THREADS and indentation LEVEL.
6783 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6784 or a straight list of headers."
6785 (message "Generating summary...")
6787 thread header number subject stack state gnus-tmp-gathered mark
6788 new-roots new-adopts thread-end)
6790 (setq gnus-tmp-prev-subject nil)
6792 (if (vectorp (car threads))
6793 ;; If this is a straight (sic) list of headers, then a
6794 ;; threaded summary display isn't required, so we just create
6795 ;; an unthreaded one.
6796 (gnus-summary-prepare-unthreaded threads cull)
6798 ;; Do the threaded display.
6800 (while (or threads stack new-adopts new-roots)
6802 (if (and (= level 0)
6803 (not gnus-tmp-false-parent)
6804 (or new-adopts new-roots))
6807 (setq level (if gnus-tmp-root-expunged 0 1)
6808 thread (list (car new-adopts))
6809 header (car (car thread))
6810 new-adopts (cdr new-adopts))
6812 (setq thread (list (car new-roots))
6813 header (car (car thread))
6814 new-roots (cdr new-roots)))))
6817 ;; If there are some threads, we do them before the
6818 ;; threads on the stack.
6819 (setq thread threads
6820 header (car (car thread)))
6821 ;; There were no current threads, so we pop something off
6823 (setq state (car stack)
6827 header (car (car thread)))))
6829 (setq gnus-tmp-false-parent nil)
6830 (setq gnus-tmp-root-expunged nil)
6831 (setq thread-end nil)
6833 (if (stringp header)
6835 ;; The header is a dummy root.
6837 ((eq gnus-summary-make-false-root 'adopt)
6838 ;; We let the first article adopt the rest.
6839 (let ((th (car (cdr (car thread)))))
6842 ;(setcdr th (cdr (cdr (car thread))))
6843 (setq new-adopts (nconc new-adopts
6844 (cdr (cdr (car thread)))))
6845 (setq gnus-tmp-gathered
6847 (lambda (h) (mail-header-number (car h)))
6848 (cdr (cdr (car thread))))
6850 (setcdr (cdr (car thread)) nil))
6852 gnus-tmp-false-parent t))
6853 ((eq gnus-summary-make-false-root 'empty)
6854 ;; We print adopted articles with empty subject fields.
6855 (setq gnus-tmp-gathered
6857 (lambda (h) (mail-header-number (car h)))
6858 (cdr (cdr (car thread))))
6861 ((eq gnus-summary-make-false-root 'dummy)
6862 ;; We output a dummy root.
6863 (gnus-summary-insert-dummy-line
6864 nil header (mail-header-number
6865 (car (car (cdr (car thread)))))))
6867 ;; We do not make a root for the gathered
6868 ;; sub-threads at all.
6871 (setq number (mail-header-number header)
6872 subject (mail-header-subject header))
6875 ((and (null gnus-thread-ignore-subject)
6877 gnus-tmp-prev-subject
6878 (not (gnus-subject-equal gnus-tmp-prev-subject subject)))
6879 (setq new-roots (if (cdr (car thread))
6880 (nconc new-roots (list (car thread)))
6884 ((and gnus-newsgroup-limit
6885 (not (memq number gnus-newsgroup-limit)))
6886 (setq gnus-tmp-gathered
6888 (lambda (h) (mail-header-number (car h)))
6891 (setq new-adopts (if (cdr (car thread))
6898 (setq gnus-tmp-root-expunged t)))
6899 ((and (memq number gnus-newsgroup-dormant)
6902 ((and gnus-summary-expunge-below
6903 (< (or (cdr (assq number gnus-newsgroup-scored))
6904 gnus-summary-default-score 0)
6905 gnus-summary-expunge-below))
6907 gnus-newsgroup-expunged-tally
6908 (1+ gnus-newsgroup-expunged-tally)
6909 gnus-newsgroup-unreads
6910 (delq number gnus-newsgroup-unreads)
6911 gnus-newsgroup-reads
6912 (cons (cons number gnus-low-score-mark)
6913 gnus-newsgroup-reads))))
6921 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6922 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6923 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6924 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6925 (t (or (cdr (assq number gnus-newsgroup-reads))
6926 gnus-ancient-mark))))
6928 (gnus-summary-insert-line
6929 nil header level nil mark
6930 (memq number gnus-newsgroup-replied)
6931 (memq number gnus-newsgroup-expirable)
6933 ((and gnus-thread-ignore-subject
6934 gnus-tmp-prev-subject
6935 (not (gnus-subject-equal
6936 gnus-tmp-prev-subject subject)))
6939 (if (and (eq gnus-summary-make-false-root 'empty)
6940 (memq number gnus-tmp-gathered))
6941 gnus-summary-same-subject
6943 (t gnus-summary-same-subject))
6944 (and (eq gnus-summary-make-false-root 'adopt)
6946 (memq number gnus-tmp-gathered))
6947 (cdr (assq number gnus-newsgroup-scored))))
6949 (setq gnus-newsgroup-data
6950 (cons (gnus-data-make number mark (- (point) 4)
6952 gnus-newsgroup-data))
6954 (setq gnus-tmp-prev-subject
6955 (gnus-simplify-subject-re subject)))))
6958 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6959 (setq level (1+ level))
6960 (setq threads (if thread-end nil (cdr (car thread))))
6961 (or threads (setq level 0)))))
6962 (message "Generating summary...done"))
6964 (defun gnus-summary-prepare-unthreaded (headers &optional cull)
6965 (let (header number mark)
6968 (setq header (car headers)
6969 headers (cdr headers)
6970 number (mail-header-number header))
6972 ;; We may have to root out some bad articles...
6974 ((memq (setq number (mail-header-number header))
6975 gnus-newsgroup-dormant))
6976 ((and gnus-summary-expunge-below
6977 (< (or (cdr (assq number gnus-newsgroup-scored))
6978 gnus-summary-default-score 0)
6979 gnus-summary-expunge-below))
6980 (setq gnus-newsgroup-unreads
6981 (delq number gnus-newsgroup-unreads))
6982 (setq gnus-newsgroup-reads
6983 (cons (cons number gnus-low-score-mark)
6984 gnus-newsgroup-reads))
6985 (setq gnus-newsgroup-expunged-tally
6986 (1+ gnus-newsgroup-expunged-tally)))
6987 ((and gnus-newsgroup-limit
6988 (not (memq number gnus-newsgroup-limit)))
6989 ;; Don't print this article - it's not in the limit.
6994 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6995 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6996 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6997 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6998 (t (or (cdr (assq number gnus-newsgroup-reads))
6999 gnus-ancient-mark))))
7000 (setq gnus-newsgroup-data
7001 (cons (gnus-data-make number mark (1+ (point)) header 0)
7002 gnus-newsgroup-data))
7003 (gnus-summary-insert-line
7004 nil header 0 nil mark (memq number gnus-newsgroup-replied)
7005 (memq number gnus-newsgroup-expirable)
7006 (mail-header-subject header) nil
7007 (cdr (assq number gnus-newsgroup-scored))))))))
7009 (defun gnus-select-newsgroup (group &optional read-all)
7010 "Select newsgroup GROUP.
7011 If READ-ALL is non-nil, all articles in the group are selected."
7012 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
7013 (info (nth 2 entry))
7016 (or (gnus-check-server
7017 (setq gnus-current-select-method (gnus-find-method-for-group group)))
7018 (error "Couldn't open server"))
7020 (or (and entry (not (eq (car entry) t))) ; Either it's active...
7021 (gnus-activate-group group) ; Or we can activate it...
7022 (progn ; Or we bug out.
7023 (kill-buffer (current-buffer))
7024 (error "Couldn't request group %s: %s"
7025 group (gnus-status-message group))))
7027 (setq gnus-newsgroup-name group)
7028 (setq gnus-newsgroup-unselected nil)
7029 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
7031 (and gnus-asynchronous
7032 (gnus-check-backend-function
7033 'request-asynchronous gnus-newsgroup-name)
7034 (setq gnus-newsgroup-async
7035 (gnus-request-asynchronous gnus-newsgroup-name)))
7037 (setq articles (gnus-articles-to-read group read-all))
7041 (gnus-message 3 "Couldn't select newsgroup")
7043 ((eq articles 0) nil)
7045 ;; Init the dependencies hash table.
7046 (setq gnus-newsgroup-dependencies
7047 (gnus-make-hashtable (length articles)))
7048 ;; Retrieve the headers and read them in.
7049 (gnus-message 5 "Fetching headers...")
7050 (setq gnus-newsgroup-headers
7052 (setq gnus-headers-retrieved-by
7053 (gnus-retrieve-headers
7054 articles gnus-newsgroup-name
7055 ;; We might want to fetch old headers, but
7056 ;; not if there is only 1 article.
7057 (and gnus-fetch-old-headers
7059 (not (eq gnus-fetch-old-headers 'some))
7060 (not (numberp gnus-fetch-old-headers)))
7061 (> (length articles) 1))))))
7062 (gnus-get-newsgroup-headers-xover articles)
7063 (gnus-get-newsgroup-headers)))
7064 (gnus-message 5 "Fetching headers...done")
7065 ;; Remove canceled articles from the list of unread articles.
7066 (setq gnus-newsgroup-unreads
7067 (gnus-set-sorted-intersection
7068 gnus-newsgroup-unreads
7069 (mapcar (lambda (headers) (mail-header-number headers))
7070 gnus-newsgroup-headers)))
7071 ;; Adjust and set lists of article marks.
7074 (gnus-adjust-marked-articles info)
7075 (setq gnus-newsgroup-marked
7077 (cdr (assq 'tick (setq marked (nth 3 info))))))
7078 (setq gnus-newsgroup-replied
7079 (copy-sequence (cdr (assq 'reply marked))))
7080 (setq gnus-newsgroup-expirable
7081 (copy-sequence (cdr (assq 'expire marked))))
7082 (setq gnus-newsgroup-killed
7083 (copy-sequence (cdr (assq 'killed marked))))
7084 (setq gnus-newsgroup-bookmarks
7085 (copy-sequence (cdr (assq 'bookmark marked))))
7086 (setq gnus-newsgroup-dormant
7087 (copy-sequence (cdr (assq 'dormant marked))))
7088 (setq gnus-newsgroup-scored
7089 (copy-sequence (cdr (assq 'score marked))))
7090 (setq gnus-newsgroup-processable nil)))
7091 ;; Check whether auto-expire is to be done in this group.
7092 (setq gnus-newsgroup-auto-expire
7093 (gnus-group-auto-expirable-p group))
7094 ;; First and last article in this newsgroup.
7095 (and gnus-newsgroup-headers
7096 (setq gnus-newsgroup-begin
7097 (mail-header-number (car gnus-newsgroup-headers)))
7098 (setq gnus-newsgroup-end
7100 (gnus-last-element gnus-newsgroup-headers))))
7101 (setq gnus-reffed-article-number -1)
7102 ;; GROUP is successfully selected.
7103 (or gnus-newsgroup-headers t)))))
7105 (defun gnus-articles-to-read (group read-all)
7106 ;; Find out what articles the user wants to read.
7108 ;; Select all articles if `read-all' is non-nil, or if all the
7109 ;; unread articles are dormant articles.
7110 (if (or (and read-all (not (numberp read-all)))
7111 (= (length gnus-newsgroup-unreads)
7112 (length gnus-newsgroup-dormant)))
7113 (gnus-uncompress-range
7114 (gnus-gethash group gnus-active-hashtb))
7115 gnus-newsgroup-unreads))
7116 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
7117 (scored (length scored-list))
7118 (number (length articles))
7119 (marked (+ (length gnus-newsgroup-marked)
7120 (length gnus-newsgroup-dormant)))
7127 (cond ((and (or (<= scored marked)
7129 (numberp gnus-large-newsgroup)
7130 (> number gnus-large-newsgroup))
7134 "How many articles from %s (default %d): "
7135 gnus-newsgroup-name number))))
7136 (if (string-match "^[ \t]*$" input)
7138 ((and (> scored marked) (< scored number))
7142 "%s %s (%d scored, %d total): "
7143 "How many articles from"
7144 group scored number))))
7145 (if (string-match "^[ \t]*$" input)
7149 (setq select (if (stringp select) (string-to-number select) select))
7150 (if (or (null select) (zerop select))
7152 (if (and (not (zerop scored)) (<= (abs select) scored))
7154 (setq articles (sort scored-list '<))
7155 (setq number (length articles)))
7156 (setq articles (copy-sequence articles)))
7158 (if (< (abs select) number)
7160 ;; Select the N oldest articles.
7161 (setcdr (nthcdr (1- (abs select)) articles) nil)
7162 ;; Select the N most recent articles.
7163 (setq articles (nthcdr (- number select) articles))))
7164 (setq gnus-newsgroup-unselected
7165 (gnus-sorted-intersection
7166 gnus-newsgroup-unreads
7167 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
7170 (defun gnus-killed-articles (killed articles)
7173 (if (inline (gnus-member-of-range (car articles) killed))
7174 (setq out (cons (car articles) out)))
7175 (setq articles (cdr articles)))
7178 (defun gnus-adjust-marked-articles (info &optional active)
7179 "Remove all marked articles that are no longer legal."
7180 (let ((marked-lists (nth 3 info))
7181 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
7183 ;; There are many types of marked articles.
7185 (setq m (cdr (setq prev (car marked-lists))))
7186 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
7187 ;; Make sure that all ticked articles are a subset of the
7188 ;; unread/unselected articles.
7190 (if (or (memq (car m) gnus-newsgroup-unreads)
7191 (memq (car m) gnus-newsgroup-unselected))
7193 (setcdr prev (cdr m)))
7195 ((eq 'score (car prev))
7196 ;; Scored articles should be a subset of
7197 ;; unread/unselected articles.
7199 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
7200 (memq (car (car m)) gnus-newsgroup-unreads))
7202 (setcdr prev (cdr m)))
7204 ((eq 'bookmark (car prev))
7205 ;; Bookmarks should be a subset of active articles.
7207 (if (< (car (car m)) (car active))
7208 (setcdr prev (cdr m))
7211 ((eq 'killed (car prev))
7212 ;; Articles that have been through the kill process are
7213 ;; to be a subset of active articles.
7214 (while (and m (< (or (and (numberp (car m)) (car m))
7217 (setcdr prev (cdr m))
7219 (if (and m (< (or (and (numberp (car m)) (car m))
7222 (setcar (if (numberp (car m)) m (car m)) (car active))))
7223 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
7224 ;; The replied and expirable articles have to be articles
7227 (if (< (car m) (car active))
7228 (setcdr prev (cdr m))
7231 (setq marked-lists (cdr marked-lists)))
7232 ;; Remove all lists that are empty.
7233 (setq marked-lists (nth 3 info))
7236 (while (= 1 (length (car marked-lists)))
7237 (setq marked-lists (cdr marked-lists)))
7238 (setq m (cdr (setq prev marked-lists)))
7240 (if (= 1 (length (car m)))
7241 (setcdr prev (cdr m))
7244 (setcar (nthcdr 3 info) marked-lists)))
7245 ;; Finally, if there are no marked lists at all left, and if there
7246 ;; are no elements after the lists in the info list, we just chop
7247 ;; the info list off before the marked lists.
7248 (and (null marked-lists)
7249 (not (nthcdr 4 info))
7250 (setcdr (nthcdr 2 info) nil)))
7253 (defun gnus-set-marked-articles
7254 (info ticked replied expirable killed dormant bookmark score)
7255 "Enter the various lists of marked articles into the newsgroup info list."
7257 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
7258 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
7259 (and expirable (setq newmarked (cons (cons 'expire expirable)
7261 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
7262 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
7263 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
7265 (and score (setq newmarked (cons (cons 'score score) newmarked)))
7268 (setcar (nthcdr 3 info) newmarked)
7269 (and (not newmarked)
7270 (not (nthcdr 4 info))
7271 (setcdr (nthcdr 2 info) nil)))
7273 (setcdr (nthcdr 2 info) (list newmarked))))))
7275 (defun gnus-add-marked-articles (group type articles &optional info force)
7276 ;; Add ARTICLES of TYPE to the info of GROUP.
7277 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
7278 ;; add, but replace marked articles of TYPE with ARTICLES.
7279 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7282 (and (not (setq marked (nthcdr 3 info)))
7283 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
7284 (and (not (setq m (assq type (car marked))))
7285 (setcar marked (cons (cons type articles) (car marked))))
7288 (nconc m articles)))))
7290 (defun gnus-set-mode-line (where)
7291 "This function sets the mode line of the article or summary buffers.
7292 If WHERE is `summary', the summary mode line format will be used."
7293 (if (memq where gnus-updated-mode-lines)
7296 (set-buffer gnus-summary-buffer)
7297 (let* ((mformat (if (eq where 'article)
7298 gnus-article-mode-line-format-spec
7299 gnus-summary-mode-line-format-spec))
7300 (group-name gnus-newsgroup-name)
7301 (article-number (or gnus-current-article 0))
7302 (unread (- (length gnus-newsgroup-unreads)
7303 (length gnus-newsgroup-dormant)))
7304 (unread-and-unticked
7305 (- unread (length gnus-newsgroup-marked)))
7306 (unselected (length gnus-newsgroup-unselected))
7307 (unread-and-unselected
7308 (cond ((and (zerop unread-and-unticked)
7309 (zerop unselected)) "")
7311 (format "{%d more}" unread-and-unticked))
7312 (t (format "{%d(+%d) more}"
7313 unread-and-unticked unselected))))
7315 (if gnus-current-headers
7316 (mail-header-subject gnus-current-headers) ""))
7317 (max-len (and gnus-mode-non-string-length
7318 (- (frame-width) gnus-mode-non-string-length)))
7319 header);; passed as argument to any user-format-funcs
7320 (setq mode-string (eval mformat))
7321 (or (numberp max-len)
7322 (setq max-len (length mode-string)))
7323 (if (< max-len 4) (setq max-len 4))
7324 (if (> (length mode-string) max-len)
7325 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
7326 ;; function `substring' might cut on a middle
7327 ;; of multi-octet character.
7329 (concat (gnus-truncate-string mode-string (- max-len 3))
7331 (setq mode-string (format (format "%%-%ds" max-len)
7333 (setq mode-line-buffer-identification mode-string)
7334 (set-buffer-modified-p t))))
7336 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads ticked dormant)
7337 "Go through the HEADERS list and add all Xrefs to a hash table.
7338 The resulting hash table is returned, or nil if no Xrefs were found."
7339 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
7341 (gnus-group-foreign-p from-newsgroup)
7343 (assoc (symbol-name (car from-method))
7344 gnus-valid-select-methods))))
7345 (gnus-group-real-prefix from-newsgroup)))
7346 (xref-hashtb (make-vector 63 0))
7347 start group entry number xrefs header)
7349 (setq header (car headers))
7350 (if (and (setq xrefs (mail-header-xref header))
7351 (not (memq (setq number (mail-header-number header)) unreads))
7352 (not (memq number ticked))
7353 (not (memq number dormant)))
7356 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
7357 (setq start (match-end 0))
7358 (setq group (concat prefix (substring xrefs (match-beginning 1)
7361 (string-to-int (substring xrefs (match-beginning 2)
7363 (if (setq entry (gnus-gethash group xref-hashtb))
7364 (setcdr entry (cons number (cdr entry)))
7365 (gnus-sethash group (cons number nil) xref-hashtb)))))
7366 (setq headers (cdr headers)))
7367 (if start xref-hashtb nil)))
7369 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable
7371 "Look through all the headers and mark the Xrefs as read."
7372 (let ((virtual (memq 'virtual
7373 (assoc (symbol-name (car (gnus-find-method-for-group
7375 gnus-valid-select-methods)))
7376 name entry info xref-hashtb idlist method
7379 (set-buffer gnus-group-buffer)
7380 (if (setq xref-hashtb
7381 (gnus-create-xref-hashtb
7382 from-newsgroup headers unreads ticked dormant))
7385 (if (string= from-newsgroup (setq name (symbol-name group)))
7387 (setq idlist (symbol-value group))
7388 ;; Dead groups are not updated.
7390 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
7392 (if (stringp (setq nth4 (nth 4 info)))
7393 (setq nth4 (gnus-server-to-method nth4))))
7394 ;; Only do the xrefs if the group has the same
7395 ;; select method as the group we have just read.
7396 (or (gnus-methods-equal-p
7397 nth4 (gnus-find-method-for-group from-newsgroup))
7400 (setq method (gnus-find-method-for-group
7402 (and (equal (car nth4) (car method))
7403 (equal (nth 1 nth4) (nth 1 method))))
7404 gnus-use-cross-reference
7405 (or (not (eq gnus-use-cross-reference t))
7407 ;; Only do cross-references on subscribed
7408 ;; groups, if that is what is wanted.
7409 (<= (nth 1 info) gnus-level-subscribed)))
7410 (gnus-group-make-articles-read name idlist expirable))))
7413 (defun gnus-group-make-articles-read (group articles expirable)
7415 (entry (gnus-gethash group gnus-newsrc-hashtb))
7416 (info (nth 2 entry))
7417 (active (gnus-gethash group gnus-active-hashtb))
7418 exps expirable range)
7419 ;; First peel off all illegal article numbers.
7421 (let ((ids articles)
7422 (ticked (cdr (assq 'tick (nth 3 info))))
7423 (dormant (cdr (assq 'dormant (nth 3 info))))
7428 (if (and first (> id (cdr active)))
7430 ;; We'll end up in this situation in one particular
7431 ;; obscure situation. If you re-scan a group and get
7432 ;; a new article that is cross-posted to a different
7433 ;; group that has not been re-scanned, you might get
7434 ;; crossposted article that has a higher number than
7435 ;; Gnus believes possible. So we re-activate this
7436 ;; group as well. This might mean doing the
7437 ;; crossposting thingie will *increase* the number
7438 ;; of articles in some groups. Tsk, tsk.
7439 (setq active (or (gnus-activate-group group) active))))
7440 (if (or (> id (cdr active))
7444 (setq articles (delq id articles)))
7445 (and (memq id expirable)
7446 (setq exps (cons id exps)))
7447 (setq ids (cdr ids)))))
7448 ;; Update expirable articles.
7449 (gnus-add-marked-articles nil 'expirable exps info)
7453 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
7454 (setcar (nthcdr 2 info)
7458 (setq articles (sort articles '<)))))
7459 ;; Then we have to re-compute how many unread
7460 ;; articles there are in this group.
7465 (setq num (- (1+ (cdr active)) (car active))))
7466 ((not (listp (cdr range)))
7467 (setq num (- (cdr active) (- (1+ (cdr range))
7471 (if (numberp (car range))
7473 (setq num (+ num (- (1+ (cdr (car range)))
7474 (car (car range))))))
7475 (setq range (cdr range)))
7476 (setq num (- (cdr active) num))))
7477 ;; Update the number of unread articles.
7481 (length (cdr (assq 'tick (nth 3 info))))
7483 (cdr (assq 'dormant (nth 3 info)))))))
7484 ;; Update the group buffer.
7485 (gnus-group-update-group group t)))))
7487 (defun gnus-methods-equal-p (m1 m2)
7488 (let ((m1 (or m1 gnus-select-method))
7489 (m2 (or m2 gnus-select-method)))
7491 (and (eq (car m1) (car m2))
7492 (or (not (memq 'address (assoc (symbol-name (car m1))
7493 gnus-valid-select-methods)))
7494 (equal (nth 1 m1) (nth 1 m2)))))))
7496 (defsubst gnus-header-value ()
7497 (buffer-substring (match-end 0) (gnus-point-at-eol)))
7499 (defvar gnus-newsgroup-none-id 0)
7501 (defun gnus-get-newsgroup-headers ()
7502 (setq gnus-article-internal-prepare-hook nil)
7503 (let ((cur nntp-server-buffer)
7504 (dependencies (save-excursion (set-buffer gnus-summary-buffer)
7505 gnus-newsgroup-dependencies))
7506 headers id id-dep ref-dep end ref)
7508 (set-buffer nntp-server-buffer)
7509 (let ((case-fold-search t)
7510 in-reply-to header number p lines)
7511 (goto-char (point-min))
7512 ;; Search to the beginning of the next header. Error messages
7513 ;; do not begin with 2 or 3.
7514 (while (re-search-forward "^[23][0-9]+ " nil t)
7517 ;; This implementation of this function, with nine
7518 ;; search-forwards instead of the one re-search-forward and
7519 ;; a case (which basically was the old function) is actually
7520 ;; about twice as fast, even though it looks messier. You
7521 ;; can't have everything, I guess. Speed and elegance
7522 ;; doesn't always go hand in hand.
7531 (narrow-to-region (point)
7532 (or (and (search-forward "\n.\n" nil t)
7538 (if (search-forward "\nsubject: " nil t)
7539 (gnus-header-value) "(none)"))
7543 (if (search-forward "\nfrom: " nil t)
7544 (gnus-header-value) "(nobody)"))
7548 (if (search-forward "\ndate: " nil t)
7549 (gnus-header-value) ""))
7553 (if (search-forward "\nmessage-id: " nil t)
7554 (setq id (gnus-header-value))
7555 ;; If there was no message-id, we just fake one to make
7556 ;; subsequent routines simpler.
7557 (setq id (concat "none+"
7559 (setq gnus-newsgroup-none-id
7560 (1+ gnus-newsgroup-none-id)))))))
7564 (if (search-forward "\nreferences: " nil t)
7567 (setq end (match-end 0))
7574 (search-backward ">" end t)
7577 (search-backward "<" end t)
7579 ;; Get the references from the in-reply-to header if there
7580 ;; were no references and the in-reply-to header looks
7582 (if (and (search-forward "\nin-reply-to: " nil t)
7583 (setq in-reply-to (gnus-header-value))
7584 (string-match "<[^>]+>" in-reply-to))
7586 (setq ref (substring in-reply-to (match-beginning 0)
7588 (setq ref (downcase ref))))
7595 (if (search-forward "\nlines: " nil t)
7596 (if (numberp (setq lines (read cur)))
7602 (and (search-forward "\nxref: " nil t)
7603 (gnus-header-value)))))
7604 ;; We do the threading while we read the headers. The
7605 ;; message-id and the last reference are both entered into
7606 ;; the same hash table. Some tippy-toeing around has to be
7607 ;; done in case an article has arrived before the article
7608 ;; which it refers to.
7609 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
7610 (if (car (symbol-value id-dep))
7611 ;; An article with this Message-ID has already
7612 ;; been seen, so we ignore this one, except we add
7613 ;; any additional Xrefs (in case the two articles
7614 ;; came from different servers).
7616 (mail-header-set-xref
7617 (car (symbol-value id-dep))
7618 (concat (or (mail-header-xref
7619 (car (symbol-value id-dep))) "")
7620 (or (mail-header-xref header) "")))
7622 (setcar (symbol-value id-dep) header))
7623 (set id-dep (list header)))
7626 (if (boundp (setq ref-dep (intern ref dependencies)))
7627 (setcdr (symbol-value ref-dep)
7628 (nconc (cdr (symbol-value ref-dep))
7629 (list (symbol-value id-dep))))
7630 (set ref-dep (list nil (symbol-value id-dep))))
7631 (setq headers (cons header headers))))
7632 (goto-char (point-max))
7634 (nreverse headers)))))
7636 ;; The following macros and functions were written by Felix Lee
7637 ;; <flee@cse.psu.edu>.
7639 (defmacro gnus-nov-read-integer ()
7641 (if (= (following-char) ?\t)
7643 (let ((num (condition-case nil (read buffer) (error nil))))
7644 (if (numberp num) num 0)))
7645 (or (eobp) (forward-char 1))))
7647 (defmacro gnus-nov-skip-field ()
7648 '(search-forward "\t" eol 'move))
7650 (defmacro gnus-nov-field ()
7651 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
7653 ;; Goes through the xover lines and returns a list of vectors
7654 (defun gnus-get-newsgroup-headers-xover (sequence)
7655 "Parse the news overview data in the server buffer, and return a
7656 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7657 ;; Get the Xref when the users reads the articles since most/some
7658 ;; NNTP servers do not include Xrefs when using XOVER.
7659 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
7660 (let ((cur nntp-server-buffer)
7661 (dependencies gnus-newsgroup-dependencies)
7662 number headers header)
7664 (set-buffer nntp-server-buffer)
7665 (goto-char (point-min))
7666 (while (and sequence (not (eobp)))
7667 (setq number (read cur))
7668 (while (and sequence (< (car sequence) number))
7669 (setq sequence (cdr sequence)))
7671 (eq number (car sequence))
7673 (setq sequence (cdr sequence))
7675 (inline (gnus-nov-parse-line number dependencies)))
7676 (setq headers (cons header headers)))))
7678 (setq headers (nreverse headers)))
7681 ;; This function has to be called with point after the article number
7682 ;; on the beginning of the line.
7683 (defun gnus-nov-parse-line (number dependencies)
7685 (eol (gnus-point-at-eol))
7686 (buffer (current-buffer))
7687 header ref id id-dep ref-dep)
7689 ;; overview: [num subject from date id refs chars lines misc]
7690 (narrow-to-region (point) eol)
7697 (gnus-nov-field) ; subject
7698 (gnus-nov-field) ; from
7699 (gnus-nov-field) ; date
7700 (setq id (or (gnus-nov-field)
7703 (setq none (1+ none)))))) ; id
7706 (let ((beg (point)))
7707 (search-forward "\t" eol)
7708 (if (search-backward ">" beg t)
7714 (search-backward "<" beg t)
7717 (gnus-nov-field)) ; refs
7718 (gnus-nov-read-integer) ; chars
7719 (gnus-nov-read-integer) ; lines
7720 (if (= (following-char) ?\n)
7722 (gnus-nov-field)) ; misc
7726 (message "Strange nov line.")
7732 ;; We build the thread tree.
7734 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
7735 (if (car (symbol-value id-dep))
7736 ;; An article with this Message-ID has already been seen,
7737 ;; so we ignore this one, except we add any additional
7738 ;; Xrefs (in case the two articles came from different
7741 (mail-header-set-xref
7742 (car (symbol-value id-dep))
7743 (concat (or (mail-header-xref
7744 (car (symbol-value id-dep))) "")
7745 (or (mail-header-xref header) "")))
7747 (setcar (symbol-value id-dep) header))
7748 (set id-dep (list header))))
7751 (if (boundp (setq ref-dep (intern (or ref "none")
7753 (setcdr (symbol-value ref-dep)
7754 (nconc (cdr (symbol-value ref-dep))
7755 (list (symbol-value id-dep))))
7756 (set ref-dep (list nil (symbol-value id-dep))))))
7759 (defun gnus-article-get-xrefs ()
7760 "Fill in the Xref value in `gnus-current-headers', if necessary.
7761 This is meant to be called in `gnus-article-internal-prepare-hook'."
7762 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7763 gnus-current-headers)))
7764 (or (not gnus-use-cross-reference)
7766 (and (mail-header-xref headers)
7767 (not (string= (mail-header-xref headers) "")))
7768 (let ((case-fold-search t)
7771 (gnus-narrow-to-headers)
7772 (goto-char (point-min))
7773 (if (or (and (eq (downcase (following-char)) ?x)
7774 (looking-at "Xref:"))
7775 (search-forward "\nXref:" nil t))
7777 (goto-char (1+ (match-end 0)))
7778 (setq xref (buffer-substring (point)
7779 (progn (end-of-line) (point))))
7780 (mail-header-set-xref headers xref))))))))
7782 ;; Insert article ID in the summary buffer and select it as well.
7783 (defun gnus-summary-insert-article (id)
7784 (let ((header (gnus-read-header id))
7787 () ; We couldn't fetch ID.
7788 (gnus-rebuild-thread (mail-header-id header))
7789 (gnus-summary-goto-subject (setq number (mail-header-number header)))
7792 ;; We have to update the boundaries, possibly.
7793 (and (> number gnus-newsgroup-end)
7794 (setq gnus-newsgroup-end number))
7795 (and (< number gnus-newsgroup-begin)
7796 (setq gnus-newsgroup-begin number))
7797 (setq gnus-newsgroup-unselected
7798 (delq number gnus-newsgroup-unselected))))
7799 (gnus-summary-show-article))))
7801 (defun gnus-summary-work-articles (n)
7802 "Return a list of articles to be worked upon. The prefix argument,
7803 the list of process marked articles, and the current article will be
7804 taken into consideration."
7805 (let (articles article)
7806 (if (and n (numberp n))
7807 (let ((backward (< n 0))
7813 (cons (setq article (gnus-summary-article-number))
7816 (gnus-summary-find-prev nil article)
7817 (gnus-summary-find-next nil article)))
7819 (sort articles (function <)))
7820 (or (reverse gnus-newsgroup-processable)
7821 (list (gnus-summary-article-number))))))
7823 (defun gnus-summary-search-group (&optional backward use-level)
7824 "Search for next unread newsgroup.
7825 If optional argument BACKWARD is non-nil, search backward instead."
7827 (set-buffer gnus-group-buffer)
7828 (if (gnus-group-search-forward
7829 backward nil (if use-level (gnus-group-group-level) nil))
7830 (gnus-group-group-name))))
7832 (defun gnus-summary-best-group (&optional exclude-group)
7833 "Find the name of the best unread group.
7834 If EXCLUDE-GROUP, do not go to this group."
7836 (set-buffer gnus-group-buffer)
7838 (gnus-group-best-unread-group exclude-group))))
7840 (defun gnus-summary-find-next (&optional unread article backward)
7841 (if backward (gnus-summary-find-prev)
7842 (let* ((article (or article (gnus-summary-article-number)))
7843 (arts (cdr (gnus-data-find-list article)))
7849 (and (gnus-data-unread-p (car arts))
7850 (setq result (car arts)
7852 (setq arts (cdr arts)))
7856 (goto-char (gnus-data-pos result))
7857 (gnus-data-number result))))))
7859 (defun gnus-summary-find-prev (&optional unread article)
7860 (let* ((article (or article (gnus-summary-article-number)))
7862 (setq arts (cdr (gnus-data-find-list article (gnus-data-list 'rev))))
7867 (and (gnus-data-unread-p (car arts))
7868 (setq result (car arts)
7870 (setq arts (cdr arts)))
7874 (goto-char (gnus-data-pos result))
7875 (gnus-data-number result)))))
7877 (defun gnus-summary-find-subject (subject &optional unread backward article)
7878 (let* ((article (or article (gnus-summary-article-number)))
7879 (articles (gnus-data-list backward))
7880 (arts (cdr (gnus-data-find-list article articles)))
7883 (and (or (not unread)
7884 (gnus-data-unread-p (car arts)))
7885 (vectorp (gnus-data-header (car arts)))
7887 subject (mail-header-subject (gnus-data-header (car arts))))
7888 (setq result (car arts)
7890 (setq arts (cdr arts)))
7892 (goto-char (gnus-data-pos result))
7893 (gnus-data-number result))))
7895 (defun gnus-summary-search-forward (&optional unread subject backward)
7897 (gnus-summary-find-subject subject unread backward))
7899 (gnus-summary-find-prev unread))
7901 (gnus-summary-find-next unread))))
7903 (defun gnus-summary-recenter ()
7904 "Center point in the summary window.
7905 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7906 displayed, no centering will be performed."
7907 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7908 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7909 (let* ((top (cond ((< (window-height) 4) 0)
7910 ((< (window-height) 7) 1)
7912 (height (1- (window-height)))
7913 (bottom (save-excursion (goto-char (point-max))
7914 (forward-line (- height))
7916 (window (get-buffer-window (current-buffer))))
7918 ;; The user has to want it,
7919 gnus-auto-center-summary
7920 ;; the article buffer must be displayed,
7921 (get-buffer-window gnus-article-buffer)
7922 ;; Set the window start to either `bottom', which is the biggest
7923 ;; possible valid number, or the second line from the top,
7924 ;; whichever is the least.
7926 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7928 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7929 (defun gnus-short-group-name (group &optional levels)
7930 "Collapse GROUP name LEVELS."
7931 (let* ((name "") (foreign "") (depth -1) (skip 1)
7934 (while (string-match "\\." group skip)
7935 (setq skip (match-end 0)
7938 (if (string-match ":" group)
7939 (setq foreign (substring group 0 (match-end 0))
7940 group (substring group (match-end 0))))
7942 (if (and (string-match "\\." group) (> levels 0))
7943 (setq name (concat name (substring group 0 1))
7944 group (substring group (match-end 0))
7946 name (concat name "."))
7947 (setq name (concat foreign name group)
7951 (defun gnus-summary-jump-to-group (newsgroup)
7952 "Move point to NEWSGROUP in group mode buffer."
7953 ;; Keep update point of group mode buffer if visible.
7954 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7955 (save-window-excursion
7956 ;; Take care of tree window mode.
7957 (if (get-buffer-window gnus-group-buffer)
7958 (pop-to-buffer gnus-group-buffer))
7959 (gnus-group-jump-to-group newsgroup))
7961 ;; Take care of tree window mode.
7962 (if (get-buffer-window gnus-group-buffer)
7963 (pop-to-buffer gnus-group-buffer)
7964 (set-buffer gnus-group-buffer))
7965 (gnus-group-jump-to-group newsgroup))))
7967 ;; This function returns a list of article numbers based on the
7968 ;; difference between the ranges of read articles in this group and
7969 ;; the range of active articles.
7970 (defun gnus-list-of-unread-articles (group)
7971 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7972 (active (gnus-gethash group gnus-active-hashtb))
7975 ;; If none are read, then all are unread.
7977 (setq first (car active))
7978 ;; If the range of read articles is a single range, then the
7979 ;; first unread article is the article after the last read
7980 ;; article. Sounds logical, doesn't it?
7981 (if (not (listp (cdr read)))
7982 (setq first (1+ (cdr read)))
7983 ;; `read' is a list of ranges.
7984 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7985 (car (car read)))) 1)
7989 (while (< first nlast)
7990 (setq unread (cons first unread))
7991 (setq first (1+ first))))
7992 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7993 (setq nlast (if (atom (car (cdr read)))
7995 (car (car (cdr read)))))
7996 (setq read (cdr read)))))
7997 ;; And add the last unread articles.
7998 (while (<= first last)
7999 (setq unread (cons first unread))
8000 (setq first (1+ first)))
8001 ;; Return the list of unread articles.
8004 (defun gnus-list-of-read-articles (group)
8005 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
8006 (active (gnus-gethash group gnus-active-hashtb)))
8008 (gnus-sorted-complement
8009 (gnus-uncompress-range active)
8010 (gnus-list-of-unread-articles group)))))
8012 ;; Various summary commands
8014 (defun gnus-summary-universal-argument ()
8015 "Perform any operation on all articles marked with the process mark."
8017 (gnus-set-global-variables)
8018 (let ((articles (reverse gnus-newsgroup-processable))
8020 (or articles (error "No articles marked"))
8021 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
8022 (error "Undefined key"))
8024 (gnus-summary-goto-subject (car articles))
8025 (command-execute func)
8026 (gnus-summary-remove-process-mark (car articles))
8027 (setq articles (cdr articles)))))
8029 (defun gnus-summary-toggle-truncation (&optional arg)
8030 "Toggle truncation of summary lines.
8031 With arg, turn line truncation on iff arg is positive."
8033 (setq truncate-lines
8034 (if (null arg) (not truncate-lines)
8035 (> (prefix-numeric-value arg) 0)))
8038 (defun gnus-summary-reselect-current-group (&optional all)
8039 "Once exit and then reselect the current newsgroup.
8040 The prefix argument ALL means to select all articles."
8042 (gnus-set-global-variables)
8043 (let ((current-subject (gnus-summary-article-number))
8044 (group gnus-newsgroup-name))
8045 (setq gnus-newsgroup-begin nil)
8046 (gnus-summary-exit t)
8047 ;; We have to adjust the point of group mode buffer because the
8048 ;; current point was moved to the next unread newsgroup by
8050 (gnus-summary-jump-to-group group)
8051 (gnus-group-read-group all t)
8052 (gnus-summary-goto-subject current-subject)))
8054 (defun gnus-summary-rescan-group (&optional all)
8055 "Exit the newsgroup, ask for new articles, and select the newsgroup."
8057 (gnus-set-global-variables)
8058 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
8059 (let ((group gnus-newsgroup-name))
8061 (gnus-summary-jump-to-group group)
8063 (set-buffer gnus-group-buffer)
8064 (gnus-group-get-new-news-this-group 1))
8065 (gnus-summary-jump-to-group group)
8066 (gnus-group-read-group all)))
8068 (defun gnus-summary-update-info ()
8069 (let* ((group gnus-newsgroup-name))
8070 (if gnus-newsgroup-kill-headers
8071 (setq gnus-newsgroup-killed
8072 (gnus-compress-sequence
8074 (gnus-set-sorted-intersection
8075 (gnus-uncompress-range gnus-newsgroup-killed)
8076 (setq gnus-newsgroup-unselected
8077 (sort gnus-newsgroup-unselected '<)))
8078 (setq gnus-newsgroup-unreads
8079 (sort gnus-newsgroup-unreads '<))) t)))
8080 (or (listp (cdr gnus-newsgroup-killed))
8081 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
8082 (let ((headers gnus-newsgroup-headers))
8083 (gnus-close-group group)
8084 (run-hooks 'gnus-exit-group-hook)
8085 (gnus-update-read-articles
8086 group gnus-newsgroup-unreads gnus-newsgroup-unselected
8087 gnus-newsgroup-marked
8088 t gnus-newsgroup-replied gnus-newsgroup-expirable
8089 gnus-newsgroup-killed gnus-newsgroup-dormant
8090 gnus-newsgroup-bookmarks
8091 (and gnus-save-score gnus-newsgroup-scored))
8092 (and gnus-use-cross-reference
8093 (gnus-mark-xrefs-as-read
8094 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable
8095 gnus-newsgroup-marked gnus-newsgroup-dormant))
8096 ;; Do adaptive scoring, and possibly save score files.
8097 (and gnus-newsgroup-adaptive
8098 (gnus-score-adaptive))
8099 (and gnus-use-scoring
8100 (fboundp 'gnus-score-save)
8101 (funcall 'gnus-score-save))
8102 ;; Do not switch windows but change the buffer to work.
8103 (set-buffer gnus-group-buffer)
8104 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
8105 (gnus-group-update-group group)))))
8107 (defun gnus-summary-exit (&optional temporary)
8108 "Exit reading current newsgroup, and then return to group selection mode.
8109 gnus-exit-group-hook is called with no arguments if that value is non-nil."
8111 (gnus-set-global-variables)
8112 (gnus-kill-save-kill-buffer)
8113 (let* ((group gnus-newsgroup-name)
8114 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
8115 gnus-newsgroup-name))))
8117 (buf (current-buffer)))
8118 (run-hooks 'gnus-summary-prepare-exit-hook)
8119 ;; Make all changes in this group permanent.
8120 (gnus-summary-update-info)
8122 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
8123 ;; Make sure where I was, and go to next newsgroup.
8124 (set-buffer gnus-group-buffer)
8127 (gnus-group-jump-to-group group)
8128 (gnus-group-next-unread-group 1)))
8131 ;; We set all buffer-local variables to nil. It is unclear why
8132 ;; this is needed, but if we don't, buffer-local variables are
8133 ;; not garbage-collected, it seems. This would the lead to en
8134 ;; ever-growing Emacs.
8136 (gnus-summary-clear-local-variables)
8137 ;; We clear the global counterparts of the buffer-local
8138 ;; variables as well, just to be on the safe side.
8139 (gnus-configure-windows 'group 'force)
8140 (gnus-summary-clear-local-variables)
8141 ;; Return to group mode buffer.
8142 (if (eq mode 'gnus-summary-mode)
8143 (gnus-kill-buffer buf))
8144 (if (get-buffer gnus-article-buffer)
8145 (bury-buffer gnus-article-buffer))
8146 (setq gnus-current-select-method gnus-select-method)
8147 (pop-to-buffer gnus-group-buffer)
8148 (if (not quit-config)
8150 (gnus-group-jump-to-group group)
8151 (gnus-group-next-unread-group 1))
8152 (if (not (buffer-name (car quit-config)))
8153 (gnus-configure-windows 'group 'force)
8154 (set-buffer (car quit-config))
8155 (and (eq major-mode 'gnus-summary-mode)
8156 (gnus-set-global-variables))
8157 (gnus-configure-windows (cdr quit-config))))
8158 (run-hooks 'gnus-summary-exit-hook))))
8160 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
8161 (defun gnus-summary-exit-no-update (&optional no-questions)
8162 "Quit reading current newsgroup without updating read article info."
8164 (gnus-set-global-variables)
8165 (let* ((group gnus-newsgroup-name)
8166 (quit-config (nth 1 (assoc 'quit-config
8167 (gnus-find-method-for-group group)))))
8168 (if (or no-questions
8170 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
8172 (gnus-close-group group)
8173 (gnus-summary-clear-local-variables)
8174 (set-buffer gnus-group-buffer)
8175 (gnus-summary-clear-local-variables)
8176 ;; Return to group selection mode.
8177 (gnus-configure-windows 'group 'force)
8178 (if (get-buffer gnus-summary-buffer)
8179 (kill-buffer gnus-summary-buffer))
8180 (if (get-buffer gnus-article-buffer)
8181 (bury-buffer gnus-article-buffer))
8182 (if (equal (gnus-group-group-name) group)
8183 (gnus-group-next-unread-group 1))
8186 (if (not (buffer-name (car quit-config)))
8187 (gnus-configure-windows 'group 'force)
8188 (set-buffer (car quit-config))
8189 (and (eq major-mode 'gnus-summary-mode)
8190 (gnus-set-global-variables))
8191 (gnus-configure-windows (cdr quit-config)))))))))
8193 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
8194 (defun gnus-summary-fetch-faq (&optional faq-dir)
8195 "Fetch the FAQ for the current group.
8196 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
8200 (if current-prefix-arg
8202 "Faq dir: " (and (listp gnus-group-faq-directory)
8203 gnus-group-faq-directory)))))
8204 (let (gnus-faq-buffer)
8205 (and (setq gnus-faq-buffer
8206 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
8207 (gnus-configure-windows 'summary-faq))))
8209 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
8210 (defun gnus-summary-describe-group (&optional force)
8211 "Describe the current newsgroup."
8213 (gnus-group-describe-group force gnus-newsgroup-name))
8215 (defun gnus-summary-describe-briefly ()
8216 "Describe summary mode commands briefly."
8219 (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")))
8221 ;; Walking around group mode buffer from summary mode.
8223 (defun gnus-summary-next-group (&optional no-article target-group backward)
8224 "Exit current newsgroup and then select next unread newsgroup.
8225 If prefix argument NO-ARTICLE is non-nil, no article is selected
8226 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
8227 previous group instead."
8229 (gnus-set-global-variables)
8230 (let ((current-group gnus-newsgroup-name)
8231 (current-buffer (current-buffer))
8233 ;; First we semi-exit this group to update Xrefs and all variables.
8234 ;; We can't do a real exit, because the window conf must remain
8235 ;; the same in case the user is prompted for info, and we don't
8236 ;; want the window conf to change before that...
8237 (gnus-summary-exit t)
8238 (while (not entered)
8239 ;; Then we find what group we are supposed to enter.
8240 (set-buffer gnus-group-buffer)
8241 (gnus-group-jump-to-group current-group)
8244 (if (eq gnus-keep-same-level 'best)
8245 (gnus-summary-best-group gnus-newsgroup-name)
8246 (gnus-summary-search-group backward gnus-keep-same-level))))
8247 (if (not target-group)
8248 ;; There are no further groups, so we return to the group
8251 (gnus-message 5 "Returning to the group buffer")
8253 (set-buffer current-buffer)
8254 (gnus-summary-exit))
8255 ;; We try to enter the target group.
8256 (gnus-group-jump-to-group target-group)
8257 (let ((unreads (gnus-group-group-unread)))
8258 (if (and (or (eq t unreads)
8259 (and unreads (not (zerop unreads))))
8260 (gnus-summary-read-group
8261 target-group nil no-article current-buffer))
8263 (setq current-group target-group
8264 target-group nil)))))))
8266 (defun gnus-summary-prev-group (&optional no-article)
8267 "Exit current newsgroup and then select previous unread newsgroup.
8268 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
8270 (gnus-summary-next-group no-article nil t))
8272 ;; Walking around summary lines.
8274 (defun gnus-summary-first-subject (&optional unread)
8275 "Go to the first unread subject.
8276 If UNREAD is non-nil, go to the first unread article.
8277 Returns the article selected or nil if there are no unread articles."
8282 ((null gnus-newsgroup-data)
8283 (gnus-message 3 "No articles in the group")
8285 ;; Pick the first article.
8287 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
8288 (gnus-data-number (car gnus-newsgroup-data)))
8289 ;; No unread articles.
8290 ((null gnus-newsgroup-unreads)
8291 (gnus-message 3 "No more unread articles")
8293 ;; Find the first unread article.
8295 (let ((data gnus-newsgroup-data))
8297 (not (gnus-data-unread-p (car data))))
8298 (setq data (cdr data)))
8301 (goto-char (gnus-data-pos (car data)))
8302 (gnus-data-number (car data)))))))
8303 (gnus-summary-position-point)))
8305 (defun gnus-summary-next-subject (n &optional unread dont-display)
8306 "Go to next N'th summary line.
8307 If N is negative, go to the previous N'th subject line.
8308 If UNREAD is non-nil, only unread articles are selected.
8309 The difference between N and the actual number of steps taken is
8312 (let ((backward (< n 0))
8316 (gnus-summary-find-prev unread)
8317 (gnus-summary-find-next unread)))
8319 (if (/= 0 n) (gnus-message 7 "No more%s articles"
8320 (if unread " unread" "")))
8323 (gnus-summary-recenter)
8324 (gnus-summary-position-point)))
8327 (defun gnus-summary-next-unread-subject (n)
8328 "Go to next N'th unread summary line."
8330 (gnus-summary-next-subject n t))
8332 (defun gnus-summary-prev-subject (n &optional unread)
8333 "Go to previous N'th summary line.
8334 If optional argument UNREAD is non-nil, only unread article is selected."
8336 (gnus-summary-next-subject (- n) unread))
8338 (defun gnus-summary-prev-unread-subject (n)
8339 "Go to previous N'th unread summary line."
8341 (gnus-summary-next-subject (- n) t))
8343 (defun gnus-summary-goto-subject (article &optional force)
8344 "Go the subject line of ARTICLE."
8348 (completing-read "Article number: "
8352 (int-to-string (mail-header-number headers))))
8353 gnus-newsgroup-headers)
8354 nil 'require-match))))
8355 (or article (error "No article number"))
8357 (data (gnus-data-find article)))
8360 (and (gnus-summary-insert-article article)
8361 (setq data (gnus-data-find article))))
8363 (message "Can't find article %d" article)
8364 (goto-char (gnus-data-pos data))
8365 (gnus-summary-show-thread)
8366 ;; Skip dummy articles.
8367 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8368 (gnus-summary-find-next))
8374 (gnus-summary-position-point))))))
8376 ;; Walking around summary lines with displaying articles.
8378 (defun gnus-summary-expand-window (&optional arg)
8379 "Make the summary buffer take up the entire Emacs frame.
8380 Given a prefix, will force an `article' buffer configuration."
8382 (gnus-set-global-variables)
8384 (gnus-configure-windows 'article 'force)
8385 (gnus-configure-windows 'summary 'force)))
8387 (defun gnus-summary-display-article (article &optional all-header)
8388 "Display ARTICLE in article buffer."
8389 (gnus-set-global-variables)
8393 (gnus-article-prepare article all-header)
8394 (gnus-summary-show-thread)
8395 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8396 (gnus-summary-find-next))
8397 (run-hooks 'gnus-select-article-hook)
8398 (gnus-summary-recenter)
8399 (gnus-summary-goto-subject article)
8400 ;; Successfully display article.
8401 (gnus-summary-update-line)
8402 (gnus-article-set-window-start
8403 (cdr (assq article gnus-newsgroup-bookmarks)))
8406 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
8407 "Select the current article.
8408 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
8409 non-nil, the article will be re-fetched even if it already present in
8410 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
8412 (let ((article (or article (gnus-summary-article-number)))
8413 (all-headers (not (not all-headers))) ;Must be T or NIL.
8416 (gnus-summary-article-pseudo-p article)
8417 (error "This is a pseudo-article."))
8420 (set-buffer gnus-summary-buffer)
8421 (if (or (null gnus-current-article)
8422 (null gnus-article-current)
8423 (null (get-buffer gnus-article-buffer))
8424 (not (eq article (cdr gnus-article-current)))
8425 (not (equal (car gnus-article-current) gnus-newsgroup-name))
8427 ;; The requested article is different from the current article.
8429 (gnus-summary-display-article article all-headers)
8431 (if (or all-headers gnus-show-all-headers)
8432 (gnus-article-show-all-headers))
8435 (gnus-article-set-window-start
8436 (cdr (assq article gnus-newsgroup-bookmarks)))))))
8438 (defun gnus-summary-set-current-mark (&optional current-mark)
8439 "Obsolete function."
8442 (defun gnus-summary-next-article (&optional unread subject backward)
8443 "Select the next article.
8444 If UNREAD, only unread articles are selected.
8445 If SUBJECT, only articles with SUBJECT are selected.
8446 If BACKWARD, the previous article is selected instead of the next."
8448 (gnus-set-global-variables)
8451 ;; Is there such an article?
8452 ((and (gnus-summary-search-forward unread subject backward)
8453 (or (gnus-summary-display-article (gnus-summary-article-number))
8454 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8455 (gnus-summary-position-point))
8456 ;; If not, we try the first unread, if that is wanted.
8458 gnus-auto-select-same
8459 (or (gnus-summary-first-unread-article)
8460 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8461 (gnus-summary-position-point)
8462 (gnus-message 6 "Wrapped"))
8463 ;; Try to get next/previous article not displayed in this group.
8464 ((and gnus-auto-extend-newsgroup
8465 (not unread) (not subject))
8466 (gnus-summary-goto-article
8467 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
8469 ;; Go to next/previous group.
8471 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
8472 (gnus-summary-jump-to-group gnus-newsgroup-name))
8473 (let ((cmd last-command-char)
8475 (if (eq gnus-keep-same-level 'best)
8476 (gnus-summary-best-group gnus-newsgroup-name)
8477 (gnus-summary-search-group backward gnus-keep-same-level))))
8478 ;; For some reason, the group window gets selected. We change
8480 (select-window (get-buffer-window (current-buffer)))
8481 ;; Keep just the event type of CMD.
8482 ;(and (listp cmd) (setq cmd (car cmd)))
8483 ;; Select next unread newsgroup automagically.
8485 ((not gnus-auto-select-next)
8486 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
8487 ((or (eq gnus-auto-select-next 'quietly)
8488 (and (eq gnus-auto-select-next 'almost-quietly)
8489 (gnus-summary-last-article-p)))
8491 (if (assoc 'quit-config (gnus-find-method-for-group
8492 gnus-newsgroup-name))
8494 (gnus-message 7 "No more%s articles (%s)..."
8495 (if unread " unread" "")
8496 (if group (concat "selecting " group)
8498 (gnus-summary-next-group nil group backward)))
8500 (let ((keystrokes '(?\C-n ?\C-p))
8502 (while (or (null key) (memq key keystrokes))
8504 7 "No more%s articles%s" (if unread " unread" "")
8505 (if (and group (not (assoc 'quit-config
8506 (gnus-find-method-for-group
8507 gnus-newsgroup-name))))
8508 (format " (Type %s for %s [%s])"
8509 (single-key-description cmd) group
8510 (car (gnus-gethash group gnus-newsrc-hashtb)))
8511 (format " (Type %s to exit %s)"
8512 (single-key-description cmd)
8513 gnus-newsgroup-name)))
8514 ;; Confirm auto selection.
8515 (let* ((event (read-char-exclusive)))
8516 (setq key (if (listp event) (car event) event))
8517 (if (memq key keystrokes)
8518 (let ((obuf (current-buffer)))
8519 (switch-to-buffer gnus-group-buffer)
8521 (gnus-group-jump-to-group group))
8523 (execute-kbd-macro (char-to-string key))
8525 (setq group (gnus-group-group-name))
8526 (switch-to-buffer obuf)))))
8528 (if (or (not group) (assoc 'quit-config
8529 (gnus-find-method-for-group
8530 gnus-newsgroup-name)))
8532 (gnus-summary-next-group nil group backward))
8533 (execute-kbd-macro (char-to-string key)))))))))))
8535 (defun gnus-summary-next-unread-article ()
8536 "Select unread article after current one."
8538 (gnus-summary-next-article t (and gnus-auto-select-same
8539 (gnus-summary-article-subject))))
8541 (defun gnus-summary-prev-article (&optional unread subject)
8542 "Select the article after the current one.
8543 If UNREAD is non-nil, only unread articles are selected."
8545 (gnus-summary-next-article unread subject t))
8547 (defun gnus-summary-prev-unread-article ()
8548 "Select unred article before current one."
8550 (gnus-summary-prev-article t (and gnus-auto-select-same
8551 (gnus-summary-article-subject))))
8553 (defun gnus-summary-next-page (&optional lines circular)
8554 "Show next page of selected article.
8555 If end of article, select next article.
8556 Argument LINES specifies lines to be scrolled up.
8557 If CIRCULAR is non-nil, go to the start of the article instead of
8558 instead of selecting the next article when reaching the end of the
8561 (setq gnus-summary-buffer (current-buffer))
8562 (gnus-set-global-variables)
8563 (let ((article (gnus-summary-article-number))
8565 (gnus-configure-windows 'article)
8566 (if (or (null gnus-current-article)
8567 (null gnus-article-current)
8568 (/= article (cdr gnus-article-current))
8569 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8570 ;; Selected subject is different from current article's.
8571 (gnus-summary-display-article article)
8572 (gnus-eval-in-buffer-window
8574 (setq endp (gnus-article-next-page lines)))
8577 (gnus-summary-beginning-of-article))
8579 (gnus-message 3 "End of message"))
8581 (gnus-summary-next-unread-article)))))
8582 (gnus-summary-recenter)
8583 (gnus-summary-position-point)))
8585 (defun gnus-summary-prev-page (&optional lines)
8586 "Show previous page of selected article.
8587 Argument LINES specifies lines to be scrolled down."
8589 (gnus-set-global-variables)
8590 (let ((article (gnus-summary-article-number)))
8591 (gnus-configure-windows 'article)
8592 (if (or (null gnus-current-article)
8593 (null gnus-article-current)
8594 (/= article (cdr gnus-article-current))
8595 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8596 ;; Selected subject is different from current article's.
8597 (gnus-summary-display-article article)
8598 (gnus-summary-recenter)
8599 (gnus-eval-in-buffer-window gnus-article-buffer
8600 (gnus-article-prev-page lines))))
8601 (gnus-summary-position-point))
8603 (defun gnus-summary-scroll-up (lines)
8604 "Scroll up (or down) one line current article.
8605 Argument LINES specifies lines to be scrolled up (or down if negative)."
8607 (gnus-set-global-variables)
8608 (gnus-configure-windows 'article)
8609 (or (gnus-summary-select-article nil nil 'pseudo)
8610 (gnus-eval-in-buffer-window
8613 (if (gnus-article-next-page lines)
8614 (gnus-message 3 "End of message")))
8616 (gnus-article-prev-page (- lines))))))
8617 (gnus-summary-recenter)
8618 (gnus-summary-position-point))
8620 (defun gnus-summary-next-same-subject ()
8621 "Select next article which has the same subject as current one."
8623 (gnus-set-global-variables)
8624 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8626 (defun gnus-summary-prev-same-subject ()
8627 "Select previous article which has the same subject as current one."
8629 (gnus-set-global-variables)
8630 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8632 (defun gnus-summary-next-unread-same-subject ()
8633 "Select next unread article which has the same subject as current one."
8635 (gnus-set-global-variables)
8636 (gnus-summary-next-article t (gnus-summary-article-subject)))
8638 (defun gnus-summary-prev-unread-same-subject ()
8639 "Select previous unread article which has the same subject as current one."
8641 (gnus-set-global-variables)
8642 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8644 (defun gnus-summary-first-unread-article ()
8645 "Select the first unread article.
8646 Return nil if there are no unread articles."
8648 (gnus-set-global-variables)
8650 (if (gnus-summary-first-subject t)
8652 (gnus-summary-show-thread)
8653 (gnus-summary-first-subject t)
8654 (gnus-summary-display-article (gnus-summary-article-number))))
8655 (gnus-summary-position-point)))
8657 (defun gnus-summary-best-unread-article ()
8658 "Select the unread article with the highest score."
8660 (gnus-set-global-variables)
8661 (let ((best -1000000)
8662 (data gnus-newsgroup-data)
8665 (and (gnus-data-unread-p (car data))
8667 (gnus-summary-article-score (gnus-data-number (car data))))
8670 article (gnus-data-number (car data))))
8671 (setq data (cdr data)))
8673 (gnus-summary-goto-article article)
8674 (error "No unread articles"))
8675 (gnus-summary-position-point)))
8677 (defun gnus-summary-goto-article (article &optional all-headers force)
8678 "Fetch ARTICLE and display it if it exists.
8679 If ALL-HEADERS is non-nil, no header lines are hidden."
8685 (mapcar (lambda (headers)
8686 (list (int-to-string (mail-header-number headers))))
8687 gnus-newsgroup-headers)
8688 nil 'require-match))))
8690 (and (gnus-summary-goto-subject article force)
8691 (gnus-summary-display-article article all-headers))
8692 (gnus-summary-position-point)))
8694 (defun gnus-summary-goto-last-article ()
8695 "Go to the previously read article."
8698 (and gnus-last-article
8699 (gnus-summary-goto-article gnus-last-article))
8700 (gnus-summary-position-point)))
8702 (defun gnus-summary-pop-article (number)
8703 "Pop one article off the history and go to the previous.
8704 NUMBER articles will be popped off."
8707 (setq gnus-newsgroup-history
8708 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8710 (gnus-summary-goto-article (car to))
8711 (error "Article history empty")))
8712 (gnus-summary-position-point))
8714 ;; Summary commands and functions for limiting the summary buffer.
8716 (defun gnus-summary-limit-to-articles (n)
8717 "Limit the summary buffer to the next N articles.
8718 If not given a prefix, use the process marked articles instead."
8720 (gnus-set-global-variables)
8722 (let ((articles (gnus-summary-work-articles n)))
8723 (gnus-summary-limit articles))
8724 (gnus-summary-position-point)))
8726 (defun gnus-summary-pop-limit (&optional total)
8727 "Restore the previous limit.
8728 If given a prefix, remove all limits."
8730 (gnus-set-global-variables)
8732 (if total (setq gnus-newsgroup-limits nil))
8733 (gnus-summary-limit nil 'pop))
8734 (gnus-summary-position-point))
8736 (defun gnus-summary-limit-to-subject (subject)
8737 "Limit the summary buffer to articles that have subjects that match a regexp."
8738 (interactive "sRegexp: ")
8739 (if (equal "" subject)
8742 (let ((articles (gnus-summary-find-matching "subject" subject)))
8743 (or articles (error "Found no matches for \"%s\"" subject))
8744 (gnus-summary-limit articles))
8745 (gnus-summary-position-point))))
8747 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8749 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8751 (defun gnus-summary-limit-to-unread (&optional all)
8752 "Limit the summary buffer to articles that are not marked as read.
8753 If ALL is non-nil, limit strictly to unread articles."
8756 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark) t)
8757 (gnus-summary-limit-to-marks
8758 ;; Concat all the marks that say that an article is read and have
8761 (lambda (char) (char-to-string (symbol-value char)))
8762 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
8763 gnus-killed-mark gnus-kill-file-mark
8764 gnus-low-score-mark gnus-expirable-mark
8765 gnus-canceled-mark gnus-catchup-mark)
8768 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
8769 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
8771 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8772 "Limit the summary buffer to articles that are not marked with MARKS (e.g. \"DK\").
8773 If REVERSE, limit the summary buffer to articles that are marked
8775 Returns how many articles were removed."
8776 (interactive "sMarks: ")
8777 (gnus-set-global-variables)
8779 (if gnus-newsgroup-adaptive
8780 (gnus-score-remove-lines-adaptive marks)
8781 (let ((data gnus-newsgroup-data)
8782 (marks (append marks nil)) ; Transform to list.
8785 (or (if reverse (not (memq (gnus-data-mark (car data)) marks))
8786 (memq (gnus-data-mark (car data)) marks))
8787 (setq articles (cons (gnus-data-number (car data)) articles)))
8788 (setq data (cdr data)))
8789 (gnus-summary-limit articles)))
8790 (gnus-summary-position-point)))
8792 (defun gnus-summary-limit-to-score (&optional score)
8793 "Limit to articles with score at or above SCORE."
8795 (gnus-set-global-variables)
8796 (setq score (if score
8797 (prefix-numeric-value score)
8798 (or gnus-summary-default-score 0)))
8799 (let ((data gnus-newsgroup-data)
8802 (and (>= (gnus-summary-article-score (gnus-data-number (car data)))
8804 (setq articles (cons (gnus-data-number (car data)) articles)))
8805 (setq data (cdr data))
8807 (gnus-summary-limit articles)
8808 (gnus-summary-position-point)))))
8810 (defun gnus-summary-limit-include-dormant ()
8811 "Display all the hidden articles that are marked as dormant."
8813 (gnus-set-global-variables)
8814 (or gnus-newsgroup-dormant
8815 (error "There are no dormant articles in this group"))
8817 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8818 (gnus-summary-position-point)))
8820 (defun gnus-summary-limit-exclude-dormant ()
8821 "Hide all dormant articles."
8823 (gnus-set-global-variables)
8825 (gnus-summary-limit-to-marks (char-to-string gnus-dormant-mark) 'reverse)
8826 (gnus-summary-position-point)))
8828 (defun gnus-summary-limit-exclude-childless-dormant ()
8829 "Hide all dormant articles that have no children."
8831 (gnus-set-global-variables)
8832 (let ((data gnus-newsgroup-data)
8834 ;; Find all articles that are either not dormant or have
8837 (and (or (not (= (gnus-data-mark (car data)) gnus-dormant-mark))
8838 (gnus-article-parent-p (gnus-data-number (car data))))
8839 (setq articles (cons (gnus-data-number (car data))
8841 (setq data (cdr data)))
8844 (gnus-summary-limit articles)
8845 (gnus-summary-position-point))))
8847 (defun gnus-summary-limit (articles &optional pop)
8849 ;; We pop the previous limit off the stack and use that.
8850 (setq articles (car gnus-newsgroup-limits)
8851 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8852 ;; We use the new limit, so we push the old limit on the stack.
8853 (setq gnus-newsgroup-limits
8854 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
8856 (setq gnus-newsgroup-limit articles)
8857 (let ((total (length gnus-newsgroup-data))
8858 (data (gnus-data-find-list (gnus-summary-article-number)))
8860 ;; This will do all the work of generating the new summary buffer
8861 ;; according to the new limit.
8862 (gnus-summary-prepare)
8863 ;; Try to return to the article you were at, or on in the
8866 ;; We try to find some article after the current one.
8868 (and (gnus-summary-goto-subject (gnus-data-number (car data)))
8871 (setq data (cdr data))))
8873 ;; If there is no data, that means that we were after the last
8874 ;; article. The same goes when we can't find any articles
8875 ;; after the current one.
8877 (goto-char (point-max))
8878 (gnus-summary-find-prev)))
8879 ;; We return how many articles were removed from the summary
8880 ;; buffer as a result of the new limit.
8881 (- total (length gnus-newsgroup-data))))
8883 ;; Summary article oriented commands
8885 (defun gnus-summary-refer-parent-article (n)
8886 "Refer parent article N times.
8887 The difference between N and the number of articles fetched is returned."
8889 (gnus-set-global-variables)
8893 (let ((ref (mail-header-references (gnus-summary-article-header))))
8894 (if (and ref (not (equal ref ""))
8895 (string-match "<[^<>]*>[ \t]*$" ref))
8896 (gnus-summary-refer-article
8897 (substring ref (match-beginning 0) (match-end 0)))
8898 (gnus-message 1 "No references in article %d"
8899 (gnus-summary-article-number))
8902 (gnus-summary-position-point)
8905 (defun gnus-summary-refer-references ()
8906 "Fetch all articles mentioned in the References header.
8907 Return how many articles were fetched."
8909 (gnus-set-global-variables)
8910 (let ((ref (mail-header-references (gnus-summary-article-header)))
8912 (while (string-match "<[^]*>" ref)
8914 (gnus-summary-refer-article
8915 (substring ref (match-beginning 0) (match-end 0)))
8916 (setq ref (substring ref (match-end 0))))
8919 (defun gnus-summary-refer-article (message-id)
8920 "Fetch an article specified by MESSAGE-ID."
8921 (interactive "sMessage-ID: ")
8922 (if (or (not (stringp message-id))
8923 (zerop (length message-id)))
8925 ;; Construct the correct Message-ID if necessary.
8926 ;; Suggested by tale@pawl.rpi.edu.
8927 (or (string-match "^<" message-id)
8928 (setq message-id (concat "<" message-id)))
8929 (or (string-match ">$" message-id)
8930 (setq message-id (concat message-id ">")))
8931 (let ((header (car (gnus-gethash (downcase message-id)
8932 gnus-newsgroup-dependencies))))
8934 ;; The article is present in the buffer, to we just go to it.
8935 (gnus-summary-goto-article (mail-header-number header) nil t)
8936 ;; We fetch the article
8937 (let ((gnus-override-method gnus-refer-article-method)
8938 (gnus-ancient-mark gnus-read-mark)
8939 (tmp-point (window-start
8940 (get-buffer-window gnus-article-buffer)))
8942 (and gnus-refer-article-method
8943 (gnus-check-server gnus-refer-article-method))
8944 (gnus-summary-insert-article message-id))))))
8946 (defun gnus-summary-enter-digest-group ()
8947 "Enter a digest group based on the current article."
8949 (gnus-set-global-variables)
8950 (gnus-summary-select-article)
8951 ;; We do not want a narrowed article.
8952 (gnus-summary-stop-page-breaking)
8953 (let ((name (format "%s-%d"
8954 (gnus-group-prefixed-name
8955 gnus-newsgroup-name (list 'nndoc ""))
8956 gnus-current-article))
8957 (ogroup gnus-newsgroup-name)
8958 (buf (current-buffer)))
8959 (if (gnus-group-read-ephemeral-group
8960 name (list 'nndoc name
8961 (list 'nndoc-address (get-buffer gnus-article-buffer))
8962 '(nndoc-article-type digest))
8964 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8965 (list (list (cons 'to-group ogroup))))
8966 (switch-to-buffer buf)
8967 (gnus-set-global-variables)
8968 (gnus-configure-windows 'summary)
8969 (gnus-message 3 "Article not a digest?"))))
8971 (defun gnus-summary-isearch-article ()
8972 "Do incremental search forward on current article."
8974 (gnus-set-global-variables)
8975 (gnus-summary-select-article)
8976 (gnus-eval-in-buffer-window
8977 gnus-article-buffer (isearch-forward)))
8979 (defun gnus-summary-search-article-forward (regexp &optional backward)
8980 "Search for an article containing REGEXP forward.
8981 If BACKWARD, search backward instead."
8984 (format "Search article %s (regexp%s): "
8985 (if current-prefix-arg "backward" "forward")
8986 (if gnus-last-search-regexp
8987 (concat ", default " gnus-last-search-regexp)
8989 current-prefix-arg))
8990 (gnus-set-global-variables)
8991 (if (string-equal regexp "")
8992 (setq regexp (or gnus-last-search-regexp ""))
8993 (setq gnus-last-search-regexp regexp))
8994 (if (gnus-summary-search-article regexp backward)
8995 (gnus-article-set-window-start
8996 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8997 (error "Search failed: \"%s\"" regexp)))
8999 (defun gnus-summary-search-article-backward (regexp)
9000 "Search for an article containing REGEXP backward."
9003 (format "Search article backward (regexp%s): "
9004 (if gnus-last-search-regexp
9005 (concat ", default " gnus-last-search-regexp)
9007 (gnus-summary-search-article-forward regexp 'backward))
9009 (defun gnus-summary-search-article (regexp &optional backward)
9010 "Search for an article containing REGEXP.
9011 Optional argument BACKWARD means do search for backward.
9012 gnus-select-article-hook is not called during the search."
9013 (let ((gnus-select-article-hook nil) ;Disable hook.
9014 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9017 (function re-search-backward) (function re-search-forward)))
9020 ;; Hidden thread subtrees must be searched for ,too.
9021 (gnus-summary-show-all-threads)
9022 ;; First of all, search current article.
9023 ;; We don't want to read article again from NNTP server nor reset
9025 (gnus-summary-select-article)
9026 (gnus-message 9 "Searching article: %d..." gnus-current-article)
9027 (setq last gnus-current-article)
9028 (gnus-eval-in-buffer-window
9032 ;; Begin search from current point.
9033 (setq found (funcall re-search regexp nil t))))
9034 ;; Then search next articles.
9035 (while (and (not found)
9036 (gnus-summary-display-article
9037 (if backward (gnus-summary-find-prev)
9038 (gnus-summary-find-next))))
9039 (gnus-message 9 "Searching article: %d..." gnus-current-article)
9040 (gnus-eval-in-buffer-window
9044 (goto-char (if backward (point-max) (point-min)))
9045 (setq found (funcall re-search regexp nil t)))))
9047 ;; Adjust article pointer.
9048 (or (eq last gnus-current-article)
9049 (setq gnus-last-article last))
9050 ;; Return T if found such article.
9053 (defun gnus-summary-find-matching (header regexp &optional backward unread
9055 "Return a list of all articles that match REGEXP on HEADER.
9056 The search stars on the current article and goes forwards unless
9057 BACKWARD is non-nil. If UNREAD is non-nil, only unread articles will
9058 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9059 in the comparisons."
9060 (let ((data (gnus-data-find-list (gnus-summary-article-number
9061 (gnus-data-list backward))))
9062 (func (intern (concat "gnus-header-" header)))
9063 (case-fold-search (not not-case-fold))
9065 (or (fboundp func) (error "%s is not a valid header" header))
9068 (and (or (not unread) ; We want all articles...
9069 (gnus-data-unread-p d)) ; Or just unreads.
9070 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9071 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
9072 (setq articles (cons (gnus-data-number d) articles))) ; Success!
9073 (setq data (cdr data)))
9074 (nreverse articles)))
9076 (defun gnus-summary-execute-command (header regexp command &optional backward)
9077 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9078 If HEADER is an empty string (or nil), the match is done on the entire
9079 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9081 (list (let ((completion-ignore-case t))
9084 (mapcar (lambda (string) (list string))
9085 '("Number" "Subject" "From" "Lines" "Date"
9086 "Message-ID" "Xref" "References"))
9087 nil 'require-match))
9088 (read-string "Regexp: ")
9089 (read-key-sequence "Command: ")
9090 current-prefix-arg))
9091 (gnus-set-global-variables)
9092 ;; Hidden thread subtrees must be searched as well.
9093 (gnus-summary-show-all-threads)
9094 ;; We don't want to change current point nor window configuration.
9096 (save-window-excursion
9097 (gnus-message 6 "Executing %s..." (key-description command))
9098 ;; We'd like to execute COMMAND interactively so as to give arguments.
9099 (gnus-execute header regexp
9101 (call-interactively '(, (key-binding command)))))
9103 (gnus-message 6 "Executing %s...done" (key-description command)))))
9105 (defun gnus-summary-beginning-of-article ()
9106 "Scroll the article back to the beginning."
9108 (gnus-set-global-variables)
9109 (gnus-summary-select-article)
9110 (gnus-configure-windows 'article)
9111 (gnus-eval-in-buffer-window
9114 (goto-char (point-min))
9115 (and gnus-break-pages (gnus-narrow-to-page))))
9117 (defun gnus-summary-end-of-article ()
9118 "Scroll to the end of the article."
9120 (gnus-set-global-variables)
9121 (gnus-summary-select-article)
9122 (gnus-configure-windows 'article)
9123 (gnus-eval-in-buffer-window
9126 (goto-char (point-max))
9128 (and gnus-break-pages (gnus-narrow-to-page))))
9130 (defun gnus-summary-show-article (&optional arg)
9131 "Force re-fetching of the current article.
9132 If ARG (the prefix) is non-nil, show the raw article without any
9133 article massaging functions being run."
9135 (gnus-set-global-variables)
9137 ;; Select the article the normal way.
9138 (gnus-summary-select-article nil 'force)
9139 ;; Bind the article treatment functions to nil.
9140 (let ((gnus-have-all-headers t)
9141 gnus-article-display-hook
9142 gnus-article-prepare-hook
9144 (gnus-summary-select-article nil 'force)))
9145 (gnus-configure-windows 'article)
9146 (gnus-summary-position-point))
9148 (defun gnus-summary-verbose-headers (&optional arg)
9149 "Toggle permanent full header display.
9150 If ARG is a positive number, turn header display on.
9151 If ARG is a negative number, turn header display off."
9153 (gnus-set-global-variables)
9154 (gnus-summary-toggle-header arg)
9155 (setq gnus-show-all-headers
9156 (cond ((or (not (numberp arg))
9158 (not gnus-show-all-headers))
9162 (defun gnus-summary-toggle-header (&optional arg)
9163 "Show the headers if they are hidden, or hide them if they are shown.
9164 If ARG is a positive number, show the entire header.
9165 If ARG is a negative number, hide the unwanted header lines."
9167 (gnus-set-global-variables)
9169 (set-buffer gnus-article-buffer)
9170 (let ((buffer-read-only nil))
9172 (if (> arg 0) (remove-text-properties (point-min) (point-max)
9173 gnus-hidden-properties)
9174 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
9175 (if (text-property-any (point-min) (point-max) 'invisible t)
9176 (remove-text-properties
9177 (point-min) (point-max) gnus-hidden-properties)
9178 ;; We hide the headers. This song and dance act below is
9179 ;; done because `gnus-have-all-headers' is buffer-local to
9180 ;; the summary buffer, and we only want to temporarily
9181 ;; change it in that buffer. Ugh.
9182 (let ((have gnus-have-all-headers))
9184 (set-buffer gnus-summary-buffer)
9185 (setq gnus-have-all-headers nil)
9187 (set-buffer gnus-article-buffer)
9188 (run-hooks 'gnus-article-display-hook))
9189 (setq gnus-have-all-headers have)))))
9190 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
9192 (defun gnus-summary-show-all-headers ()
9193 "Make all header lines visible."
9195 (gnus-set-global-variables)
9196 (gnus-article-show-all-headers))
9198 (defun gnus-summary-toggle-mime (&optional arg)
9199 "Toggle MIME processing.
9200 If ARG is a positive number, turn MIME processing on."
9202 (gnus-set-global-variables)
9203 (setq gnus-show-mime
9204 (if (null arg) (not gnus-show-mime)
9205 (> (prefix-numeric-value arg) 0)))
9206 (gnus-summary-select-article t 'force))
9208 (defun gnus-summary-caesar-message (&optional arg)
9209 "Caesar rotate the current article by 13.
9210 The numerical prefix specifies how manu places to rotate each letter
9213 (gnus-set-global-variables)
9214 (gnus-summary-select-article)
9215 (let ((mail-header-separator ""))
9216 (gnus-eval-in-buffer-window
9220 (let ((start (window-start)))
9221 (news-caesar-buffer-body arg)
9222 (set-window-start (get-buffer-window (current-buffer)) start))))))
9224 (defun gnus-summary-stop-page-breaking ()
9225 "Stop page breaking in the current article."
9227 (gnus-set-global-variables)
9228 (gnus-summary-select-article)
9229 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
9231 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
9233 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
9234 "Move the current article to a different newsgroup.
9235 If N is a positive number, move the N next articles.
9236 If N is a negative number, move the N previous articles.
9237 If N is nil and any articles have been marked with the process mark,
9238 move those articles instead.
9239 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9240 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
9241 re-spool using this method.
9242 For this function to work, both the current newsgroup and the
9243 newsgroup that you want to move to have to support the `request-move'
9244 and `request-accept' functions. (Ie. mail newsgroups at present.)"
9246 (gnus-set-global-variables)
9247 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
9248 (error "The current newsgroup does not support article moving"))
9249 (let ((articles (gnus-summary-work-articles n))
9250 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
9251 art-group to-method sel-met)
9252 (if (and (not to-newsgroup) (not select-method))
9255 (format "Where do you want to move %s? %s"
9256 (if (> (length articles) 1)
9257 (format "these %d articles" (length articles))
9259 (if gnus-current-move-group
9260 (format "(%s default) " gnus-current-move-group)
9262 gnus-active-hashtb nil nil prefix)))
9265 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
9266 (setq to-newsgroup (or gnus-current-move-group "")))
9267 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
9268 (gnus-activate-group to-newsgroup)
9269 (error "No such group: %s" to-newsgroup))
9270 (setq gnus-current-move-group to-newsgroup)))
9271 (setq to-method (if select-method (list select-method "")
9272 (gnus-find-method-for-group to-newsgroup)))
9273 (or (gnus-check-backend-function 'request-accept-article (car to-method))
9274 (error "%s does not support article copying" (car to-method)))
9275 (or (gnus-check-server to-method)
9276 (error "Can't open server %s" (car to-method)))
9277 (gnus-message 6 "Moving to %s: %s..."
9278 (or select-method to-newsgroup) articles)
9281 (gnus-request-move-article
9282 (car articles) ; Article to move
9283 gnus-newsgroup-name ; From newsgrouo
9284 (nth 1 (gnus-find-method-for-group
9285 gnus-newsgroup-name)) ; Server
9286 (list 'gnus-request-accept-article
9288 (list 'quote select-method)
9290 (not (cdr articles))) ; Accept form
9291 (not (cdr articles)))) ; Only save nov last time
9292 (let* ((buffer-read-only nil)
9295 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
9297 (gnus-group-prefixed-name
9299 (if select-method (list select-method "")
9300 (gnus-find-method-for-group to-newsgroup)))
9301 gnus-newsrc-hashtb)))
9302 (info (nth 2 entry))
9303 (article (car articles)))
9304 (gnus-summary-goto-subject article)
9306 (delete-region (point) (progn (forward-line 1) (point)))
9307 ;; Update the group that has been moved to.
9309 () ; This group does not exist yet.
9310 (if (not (memq article gnus-newsgroup-unreads))
9311 (setcar (cdr (cdr info))
9312 (gnus-add-to-range (nth 2 info)
9313 (list (cdr art-group)))))
9314 ;; Copy any marks over to the new group.
9315 (let ((marks '((tick . gnus-newsgroup-marked)
9316 (dormant . gnus-newsgroup-dormant)
9317 (expire . gnus-newsgroup-expirable)
9318 (bookmark . gnus-newsgroup-bookmarks)
9319 (reply . gnus-newsgroup-replied)))
9320 (to-article (cdr art-group)))
9322 (if (memq article (symbol-value (cdr (car marks))))
9323 (gnus-add-marked-articles
9324 (car info) (car (car marks)) (list to-article) info))
9325 (setq marks (cdr marks)))))
9327 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9328 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9329 (setq gnus-newsgroup-dormant
9330 (delq article gnus-newsgroup-dormant))
9331 (setq gnus-newsgroup-reads
9332 (cons (cons article gnus-canceled-mark)
9333 gnus-newsgroup-reads)))
9334 (gnus-message 1 "Couldn't move article %s" (car articles)))
9335 (gnus-summary-remove-process-mark (car articles))
9336 (setq articles (cdr articles)))))
9338 (defun gnus-summary-respool-article (&optional n respool-method)
9339 "Respool the current article.
9340 The article will be squeezed through the mail spooling process again,
9341 which means that it will be put in some mail newsgroup or other
9342 depending on `nnmail-split-methods'.
9343 If N is a positive number, respool the N next articles.
9344 If N is a negative number, respool the N previous articles.
9345 If N is nil and any articles have been marked with the process mark,
9346 respool those articles instead.
9348 Respooling can be done both from mail groups and \"real\" newsgroups.
9349 In the former case, the articles in question will be moved from the
9350 current group into whatever groups they are destined to. In the
9351 latter case, they will be copied into the relevant groups."
9353 (gnus-set-global-variables)
9354 (let ((respool-methods (gnus-methods-using 'respool))
9356 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
9358 (setq respool-method
9360 "What method do you want to use when respooling? "
9361 respool-methods nil t methname)))
9362 (or (string= respool-method "")
9363 (if (assoc (symbol-name
9364 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9366 (gnus-summary-move-article n nil (intern respool-method))
9367 (gnus-summary-copy-article n nil (intern respool-method))))))
9369 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
9370 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9371 "Move the current article to a different newsgroup.
9372 If N is a positive number, move the N next articles.
9373 If N is a negative number, move the N previous articles.
9374 If N is nil and any articles have been marked with the process mark,
9375 move those articles instead.
9376 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9377 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
9378 re-spool using this method.
9379 For this function to work, the newsgroup that you want to move to have
9380 to support the `request-move' and `request-accept'
9381 functions. (Ie. mail newsgroups at present.)"
9383 (gnus-set-global-variables)
9384 (let ((articles (gnus-summary-work-articles n))
9385 (copy-buf (get-buffer-create "*copy work*"))
9386 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
9387 art-group to-method)
9388 (buffer-disable-undo copy-buf)
9389 (if (and (not to-newsgroup) (not select-method))
9392 (format "Where do you want to copy %s? %s"
9393 (if (> (length articles) 1)
9394 (format "these %d articles" (length articles))
9396 (if gnus-current-move-group
9397 (format "(%s default) " gnus-current-move-group)
9399 gnus-active-hashtb nil nil prefix)))
9402 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
9403 (setq to-newsgroup (or gnus-current-move-group "")))
9404 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
9405 (gnus-activate-group to-newsgroup)
9406 (error "No such group: %s" to-newsgroup))
9407 (setq gnus-current-move-group to-newsgroup)))
9408 (setq to-method (if select-method (list select-method "")
9409 (gnus-find-method-for-group to-newsgroup)))
9410 (or (gnus-check-backend-function 'request-accept-article (car to-method))
9411 (error "%s does not support article copying" (car to-method)))
9412 (or (gnus-check-server to-method)
9413 (error "Can't open server %s" (car to-method)))
9415 (gnus-message 6 "Copying to %s: %s..."
9416 (or select-method to-newsgroup) articles)
9419 (set-buffer copy-buf)
9420 (gnus-request-article-this-buffer
9421 (car articles) gnus-newsgroup-name)
9422 (gnus-request-accept-article
9423 (if select-method (quote select-method) to-newsgroup)
9424 (not (cdr articles)))))
9427 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
9429 (gnus-group-prefixed-name
9431 (if select-method (list select-method "")
9432 (gnus-find-method-for-group to-newsgroup)))
9433 gnus-newsrc-hashtb)))
9434 (info (nth 2 entry))
9435 (article (car articles)))
9436 ;; We copy the info over to the new group.
9438 () ; This group does not exist (yet).
9439 (if (not (memq article gnus-newsgroup-unreads))
9440 (setcar (cdr (cdr info))
9441 (gnus-add-to-range (nth 2 info)
9442 (list (cdr art-group)))))
9443 ;; Copy any marks over to the new group.
9444 (let ((marks '((tick . gnus-newsgroup-marked)
9445 (dormant . gnus-newsgroup-dormant)
9446 (expire . gnus-newsgroup-expirable)
9447 (bookmark . gnus-newsgroup-bookmarks)
9448 (reply . gnus-newsgroup-replied)))
9449 (to-article (cdr art-group)))
9451 (if (memq article (symbol-value (cdr (car marks))))
9452 (gnus-add-marked-articles
9453 (car info) (car (car marks)) (list to-article) info))
9454 (setq marks (cdr marks))))))
9455 (gnus-message 1 "Couldn't copy article %s" (car articles)))
9456 (gnus-summary-remove-process-mark (car articles))
9457 (setq articles (cdr articles)))
9458 (kill-buffer copy-buf)))
9460 (defun gnus-summary-import-article (file)
9461 "Import a random file into a mail newsgroup."
9462 (interactive "fImport file: ")
9463 (let ((group gnus-newsgroup-name)
9465 (or (gnus-check-backend-function 'request-accept-article group)
9466 (error "%s does not support article importing" group))
9467 (or (file-readable-p file)
9468 (not (file-regular-p file))
9469 (error "Can't read %s" file))
9471 (set-buffer (get-buffer-create " *import file*"))
9472 (buffer-disable-undo (current-buffer))
9474 (insert-file-contents file)
9475 (goto-char (point-min))
9476 (if (nnheader-article-p)
9478 (setq atts (file-attributes file)
9479 lines (count-lines (point-min) (point-max)))
9480 (insert "From: " (read-string "From: ") "\n"
9481 "Subject: " (read-string "Subject: ") "\n"
9482 "Date: " (current-time-string (nth 5 atts)) "\n"
9483 "Message-ID: " (gnus-inews-message-id) "\n"
9484 "Lines: " (int-to-string lines) "\n"
9485 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9486 (gnus-request-accept-article group t)
9487 (kill-buffer (current-buffer)))))
9489 (defun gnus-summary-expire-articles ()
9490 "Expire all articles that are marked as expirable in the current group."
9492 (if (not (gnus-check-backend-function
9493 'request-expire-articles gnus-newsgroup-name))
9495 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
9496 gnus-newsrc-hashtb)))
9497 (total (gnus-group-total-expirable-p gnus-newsgroup-name))
9498 (expirable (if total
9499 (gnus-list-of-read-articles gnus-newsgroup-name)
9500 (setq gnus-newsgroup-expirable
9501 (sort gnus-newsgroup-expirable '<))))
9505 (gnus-message 6 "Expiring articles...")
9506 ;; The list of articles that weren't expired is returned.
9507 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
9508 (or total (setq gnus-newsgroup-expirable es))
9509 ;; We go through the old list of expirable, and mark all
9510 ;; really expired articles as non-existant.
9511 (or (eq es expirable) ;If nothing was expired, we don't mark.
9512 (let ((gnus-use-cache nil))
9514 (or (memq (car expirable) es)
9515 (gnus-summary-mark-article
9516 (car expirable) gnus-canceled-mark))
9517 (setq expirable (cdr expirable)))))
9518 (gnus-message 6 "Expiring articles...done")))))
9520 (defun gnus-summary-expire-articles-now ()
9521 "Expunge all expirable articles in the current group.
9522 This means that *all* articles that are marked as expirable will be
9523 deleted forever, right now."
9525 (or gnus-expert-user
9527 "Are you really, really, really sure you want to expunge? ")
9529 (let ((nnmail-expiry-wait -1)
9530 (nnmail-expiry-wait-function nil))
9531 (gnus-summary-expire-articles)))
9533 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9534 (defun gnus-summary-delete-article (&optional n)
9535 "Delete the N next (mail) articles.
9536 This command actually deletes articles. This is not a marking
9537 command. The article will disappear forever from you life, never to
9539 If N is negative, delete backwards.
9540 If N is nil and articles have been marked with the process mark,
9541 delete these instead."
9543 (or (gnus-check-backend-function 'request-expire-articles
9544 gnus-newsgroup-name)
9545 (error "The current newsgroup does not support article deletion."))
9546 ;; Compute the list of articles to delete.
9547 (let ((articles (gnus-summary-work-articles n))
9549 (if (and gnus-novice-user
9551 (format "Do you really want to delete %s forever? "
9552 (if (> (length articles) 1) "these articles"
9555 ;; Delete the articles.
9556 (setq not-deleted (gnus-request-expire-articles
9557 articles gnus-newsgroup-name 'force))
9559 (gnus-summary-remove-process-mark (car articles))
9560 ;; The backend might not have been able to delete the article
9562 (or (memq (car articles) not-deleted)
9563 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9564 (setq articles (cdr articles))))
9565 (gnus-summary-position-point)
9568 (defun gnus-summary-edit-article (&optional force)
9569 "Enter into a buffer and edit the current article.
9570 This will have permanent effect only in mail groups.
9571 If FORCE is non-nil, allow editing of articles even in read-only
9575 (not (gnus-group-read-only-p))
9576 (error "The current newsgroup does not support article editing."))
9577 (gnus-summary-select-article t)
9578 (gnus-configure-windows 'article)
9579 (select-window (get-buffer-window gnus-article-buffer))
9580 (gnus-message 6 "C-c C-c to end edits")
9581 (setq buffer-read-only nil)
9583 (use-local-map (copy-keymap (current-local-map)))
9584 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
9585 (buffer-enable-undo)
9587 (goto-char (point-min))
9588 (search-forward "\n\n" nil t))
9590 (defun gnus-summary-edit-article-done ()
9591 "Make edits to the current article permanent."
9593 (if (gnus-group-read-only-p)
9595 (gnus-summary-edit-article-postpone)
9596 (message "The current newsgroup does not support article editing.")
9598 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
9601 (if (not (gnus-request-replace-article
9602 (cdr gnus-article-current) (car gnus-article-current)
9604 (error "Couldn't replace article.")
9606 (use-local-map gnus-article-mode-map)
9607 (setq buffer-read-only t)
9608 (buffer-disable-undo (current-buffer))
9609 (gnus-configure-windows 'summary))
9610 (and (gnus-visual-p 'summary-highlight 'highlight)
9611 (run-hooks 'gnus-visual-mark-article-hook)))))
9613 (defun gnus-summary-edit-article-postpone ()
9614 "Postpone changes to the current article."
9617 (use-local-map gnus-article-mode-map)
9618 (setq buffer-read-only t)
9619 (buffer-disable-undo (current-buffer))
9620 (gnus-configure-windows 'summary)
9621 (and (gnus-visual-p 'summary-highlight 'highlight)
9622 (run-hooks 'gnus-visual-mark-article-hook)))
9624 (defun gnus-summary-respool-query ()
9625 "Query where the respool algorithm would put this article."
9627 (gnus-summary-select-article)
9629 (set-buffer gnus-article-buffer)
9631 (goto-char (point-min))
9632 (search-forward "\n\n")
9633 (narrow-to-region (point-min) (point))
9635 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
9637 ;; Summary score commands.
9639 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
9641 (defun gnus-summary-raise-score (n)
9642 "Raise the score of the current article by N."
9644 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
9646 (defun gnus-summary-set-score (n)
9647 "Set the score of the current article to N."
9649 ;; Skip dummy header line.
9651 (gnus-summary-show-thread)
9652 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
9653 (gnus-summary-find-next))
9654 (let ((buffer-read-only nil))
9656 (gnus-summary-update-mark
9657 (if (= n (or gnus-summary-default-score 0)) ?
9658 (if (< n (or gnus-summary-default-score 0))
9659 gnus-score-below-mark gnus-score-over-mark)) 'score))
9660 (let* ((article (gnus-summary-article-number))
9661 (score (assq article gnus-newsgroup-scored)))
9662 (if score (setcdr score n)
9663 (setq gnus-newsgroup-scored
9664 (cons (cons article n) gnus-newsgroup-scored))))
9665 (gnus-summary-update-line)))
9667 (defun gnus-summary-current-score ()
9668 "Return the score of the current article."
9670 (message "%s" (gnus-summary-article-score)))
9672 ;; Summary marking commands.
9674 (defun gnus-summary-raise-same-subject-and-select (score)
9675 "Raise articles which has the same subject with SCORE and select the next."
9677 (let ((subject (gnus-summary-article-subject)))
9678 (gnus-summary-raise-score score)
9679 (while (gnus-summary-find-subject subject)
9680 (gnus-summary-raise-score score))
9681 (gnus-summary-next-article t)))
9683 (defun gnus-summary-raise-same-subject (score)
9684 "Raise articles which has the same subject with SCORE."
9686 (let ((subject (gnus-summary-article-subject)))
9687 (gnus-summary-raise-score score)
9688 (while (gnus-summary-find-subject subject)
9689 (gnus-summary-raise-score score))
9690 (gnus-summary-next-subject 1 t)))
9692 (defun gnus-score-default (level)
9693 (if level (prefix-numeric-value level)
9694 gnus-score-interactive-default-score))
9696 (defun gnus-summary-raise-thread (&optional score)
9697 "Raise the score of the articles in the current thread with SCORE."
9699 (setq score (gnus-score-default score))
9702 (let ((articles (gnus-summary-articles-in-thread)))
9704 (gnus-summary-goto-subject (car articles))
9705 (gnus-summary-raise-score score)
9706 (setq articles (cdr articles))))
9708 (let ((gnus-summary-check-current t))
9709 (or (zerop (gnus-summary-next-subject 1 t))
9711 (gnus-summary-recenter)
9712 (gnus-summary-position-point)
9713 (gnus-set-mode-line 'summary))
9715 (defun gnus-summary-lower-same-subject-and-select (score)
9716 "Raise articles which has the same subject with SCORE and select the next."
9718 (gnus-summary-raise-same-subject-and-select (- score)))
9720 (defun gnus-summary-lower-same-subject (score)
9721 "Raise articles which has the same subject with SCORE."
9723 (gnus-summary-raise-same-subject (- score)))
9725 (defun gnus-summary-lower-thread (&optional score)
9726 "Lower score of articles in the current thread with SCORE."
9728 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
9730 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9731 "Mark articles which has the same subject as read, and then select the next.
9732 If UNMARK is positive, remove any kind of mark.
9733 If UNMARK is negative, tick articles."
9736 (setq unmark (prefix-numeric-value unmark)))
9738 (gnus-summary-mark-same-subject
9739 (gnus-summary-article-subject) unmark)))
9740 ;; Select next unread article. If auto-select-same mode, should
9741 ;; select the first unread article.
9742 (gnus-summary-next-article t (and gnus-auto-select-same
9743 (gnus-summary-article-subject)))
9744 (gnus-message 7 "%d article%s marked as %s"
9745 count (if (= count 1) " is" "s are")
9746 (if unmark "unread" "read"))))
9748 (defun gnus-summary-kill-same-subject (&optional unmark)
9749 "Mark articles which has the same subject as read.
9750 If UNMARK is positive, remove any kind of mark.
9751 If UNMARK is negative, tick articles."
9754 (setq unmark (prefix-numeric-value unmark)))
9756 (gnus-summary-mark-same-subject
9757 (gnus-summary-article-subject) unmark)))
9758 ;; If marked as read, go to next unread subject.
9760 ;; Go to next unread subject.
9761 (gnus-summary-next-subject 1 t))
9762 (gnus-message 7 "%d articles are marked as %s"
9763 count (if unmark "unread" "read"))))
9765 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9766 "Mark articles with same SUBJECT as read, and return marked number.
9767 If optional argument UNMARK is positive, remove any kinds of marks.
9768 If optional argument UNMARK is negative, mark articles as unread instead."
9772 ((null unmark) ; Mark as read.
9775 (gnus-summary-mark-article-as-read gnus-killed-mark)
9776 (gnus-summary-show-thread) t)
9777 (gnus-summary-find-subject subject))
9778 (setq count (1+ count))))
9779 ((> unmark 0) ; Tick.
9782 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9783 (gnus-summary-show-thread) t)
9784 (gnus-summary-find-subject subject))
9785 (setq count (1+ count))))
9786 (t ; Mark as unread.
9789 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9790 (gnus-summary-show-thread) t)
9791 (gnus-summary-find-subject subject))
9792 (setq count (1+ count)))))
9793 (gnus-set-mode-line 'summary)
9794 ;; Return the number of marked articles.
9797 (defun gnus-summary-mark-as-processable (n &optional unmark)
9798 "Set the process mark on the next N articles.
9799 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9800 the process mark instead. The difference between N and the actual
9801 number of articles marked is returned."
9803 (let ((backward (< n 0))
9808 (gnus-summary-remove-process-mark
9809 (gnus-summary-article-number))
9810 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9811 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9813 (if (/= 0 n) (gnus-message 7 "No more articles"))
9814 (gnus-summary-recenter)
9815 (gnus-summary-position-point)
9818 (defun gnus-summary-unmark-as-processable (n)
9819 "Remove the process mark from the next N articles.
9820 If N is negative, mark backward instead. The difference between N and
9821 the actual number of articles marked is returned."
9823 (gnus-summary-mark-as-processable n t))
9825 (defun gnus-summary-unmark-all-processable ()
9826 "Remove the process mark from all articles."
9829 (while gnus-newsgroup-processable
9830 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9831 (gnus-summary-position-point))
9833 (defun gnus-summary-mark-as-expirable (n)
9834 "Mark N articles forward as expirable.
9835 If N is negative, mark backward instead. The difference between N and
9836 the actual number of articles marked is returned."
9838 (gnus-summary-mark-forward n gnus-expirable-mark))
9840 (defun gnus-summary-mark-article-as-replied (article)
9841 "Mark ARTICLE replied and update the summary line."
9842 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
9843 (let ((buffer-read-only nil))
9844 (if (gnus-summary-goto-subject article)
9846 (gnus-summary-update-mark gnus-replied-mark 'replied)
9849 (defun gnus-summary-set-bookmark (article)
9850 "Set a bookmark in current article."
9851 (interactive (list (gnus-summary-article-number)))
9852 (if (or (not (get-buffer gnus-article-buffer))
9853 (not gnus-current-article)
9854 (not gnus-article-current)
9855 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9856 (error "No current article selected"))
9857 ;; Remove old bookmark, if one exists.
9858 (let ((old (assq article gnus-newsgroup-bookmarks)))
9859 (if old (setq gnus-newsgroup-bookmarks
9860 (delq old gnus-newsgroup-bookmarks))))
9861 ;; Set the new bookmark, which is on the form
9862 ;; (article-number . line-number-in-body).
9863 (setq gnus-newsgroup-bookmarks
9867 (set-buffer gnus-article-buffer)
9871 (goto-char (point-min))
9872 (search-forward "\n\n" nil t)
9875 gnus-newsgroup-bookmarks))
9876 (gnus-message 6 "A bookmark has been added to the current article."))
9878 (defun gnus-summary-remove-bookmark (article)
9879 "Remove the bookmark from the current article."
9880 (interactive (list (gnus-summary-article-number)))
9881 ;; Remove old bookmark, if one exists.
9882 (let ((old (assq article gnus-newsgroup-bookmarks)))
9885 (setq gnus-newsgroup-bookmarks
9886 (delq old gnus-newsgroup-bookmarks))
9887 (gnus-message 6 "Removed bookmark."))
9888 (gnus-message 6 "No bookmark in current article."))))
9890 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9891 (defun gnus-summary-mark-as-dormant (n)
9892 "Mark N articles forward as dormant.
9893 If N is negative, mark backward instead. The difference between N and
9894 the actual number of articles marked is returned."
9896 (gnus-summary-mark-forward n gnus-dormant-mark))
9898 (defun gnus-summary-set-process-mark (article)
9899 "Set the process mark on ARTICLE and update the summary line."
9900 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
9901 (let ((buffer-read-only nil))
9902 (if (gnus-summary-goto-subject article)
9904 (gnus-summary-show-thread)
9905 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9906 (gnus-summary-find-next))
9907 (gnus-summary-update-mark gnus-process-mark 'replied)
9910 (defun gnus-summary-remove-process-mark (article)
9911 "Remove the process mark from ARTICLE and update the summary line."
9912 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9913 (let ((buffer-read-only nil))
9914 (if (gnus-summary-goto-subject article)
9916 (gnus-summary-show-thread)
9917 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9918 (gnus-summary-find-next))
9919 (gnus-summary-update-mark ? 'replied)
9920 (if (memq article gnus-newsgroup-replied)
9921 (gnus-summary-update-mark gnus-replied-mark 'replied))
9924 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9925 "Mark N articles as read forwards.
9926 If N is negative, mark backwards instead.
9927 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9929 The difference between N and the actual number of articles marked is
9932 (gnus-set-global-variables)
9933 (let ((backward (< n 0))
9934 (gnus-summary-goto-unread
9935 (and gnus-summary-goto-unread
9936 (not (memq mark (list gnus-unread-mark
9937 gnus-ticked-mark gnus-dormant-mark)))))
9939 (mark (or mark gnus-del-mark)))
9941 (gnus-summary-mark-article nil mark no-expire)
9942 (zerop (gnus-summary-next-subject
9943 (if backward -1 1) gnus-summary-goto-unread t)))
9945 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9946 (gnus-summary-recenter)
9947 (gnus-summary-position-point)
9948 (gnus-set-mode-line 'summary)
9951 (defun gnus-summary-mark-article-as-read (mark)
9952 "Mark the current article quickly as read with MARK."
9953 (let ((article (gnus-summary-article-number)))
9954 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9955 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9956 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9957 (setq gnus-newsgroup-reads
9958 (cons (cons article mark) gnus-newsgroup-reads))
9959 ;; Possibly remove from cache, if that is used.
9960 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9961 (and gnus-newsgroup-auto-expire
9962 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9963 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9964 (= mark gnus-read-mark))
9966 (setq mark gnus-expirable-mark)
9967 (setq gnus-newsgroup-expirable
9968 (cons article gnus-newsgroup-expirable))))
9969 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9970 (gnus-summary-find-next))
9972 (gnus-summary-update-mark mark 'unread)
9975 (defun gnus-summary-mark-article-as-unread (mark)
9976 "Mark the current article quickly as unread with MARK."
9977 (let ((article (gnus-summary-article-number)))
9978 (or (memq article gnus-newsgroup-unreads)
9979 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9980 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9981 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9982 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9983 (setq gnus-newsgroup-reads
9984 (delq (assq article gnus-newsgroup-reads)
9985 gnus-newsgroup-reads))
9986 (if (= mark gnus-ticked-mark)
9987 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9988 (if (= mark gnus-dormant-mark)
9989 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
9991 ;; See whether the article is to be put in the cache.
9993 (vectorp (gnus-summary-article-header article))
9995 (gnus-cache-possibly-enter-article
9996 gnus-newsgroup-name article
9997 (gnus-summary-article-header article)
9998 (= mark gnus-ticked-mark)
9999 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10001 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
10002 (gnus-summary-find-next))
10004 (gnus-summary-update-mark mark 'unread)
10007 (defun gnus-summary-mark-article (&optional article mark no-expire)
10008 "Mark ARTICLE with MARK. MARK can be any character.
10009 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
10010 (dormant) and `?E' (expirable).
10011 If MARK is nil, then the default character `?D' is used.
10012 If ARTICLE is nil, then the article on the current line will be
10014 (and (stringp mark)
10015 (setq mark (aref mark 0)))
10016 ;; If no mark is given, then we check auto-expiring.
10017 (and (not no-expire)
10018 gnus-newsgroup-auto-expire
10020 (and (numberp mark)
10021 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
10022 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
10023 (= mark gnus-read-mark))))
10024 (setq mark gnus-expirable-mark))
10025 (let* ((mark (or mark gnus-del-mark))
10026 (article (or article (gnus-summary-article-number))))
10027 (or article (error "No article on current line"))
10028 (if (or (= mark gnus-unread-mark)
10029 (= mark gnus-ticked-mark)
10030 (= mark gnus-dormant-mark))
10031 (gnus-mark-article-as-unread article mark)
10032 (gnus-mark-article-as-read article mark))
10034 ;; See whether the article is to be put in the cache.
10035 (and gnus-use-cache
10036 (not (= mark gnus-canceled-mark))
10037 (vectorp (gnus-summary-article-header article))
10039 (gnus-cache-possibly-enter-article
10040 gnus-newsgroup-name article
10041 (gnus-summary-article-header article)
10042 (= mark gnus-ticked-mark)
10043 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10045 (if (gnus-summary-goto-subject article)
10046 (let ((buffer-read-only nil))
10047 (gnus-summary-show-thread)
10048 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
10049 (gnus-summary-find-next))
10051 (gnus-summary-update-mark mark 'unread)
10054 (defun gnus-summary-update-mark (mark type)
10055 (beginning-of-line)
10056 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10057 (buffer-read-only nil)
10061 ;; Go to the right position on the line.
10062 (forward-char forward)
10063 ;; Replace the old mark with the new mark.
10064 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
10065 ;; Optionally update the marks by some user rule.
10066 (and (eq type 'unread)
10068 (gnus-data-set-mark (gnus-data-find (gnus-summary-article-number))
10070 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10072 (defun gnus-mark-article-as-read (article &optional mark)
10073 "Enter ARTICLE in the pertinent lists and remove it from others."
10074 ;; Make the article expirable.
10075 (let ((mark (or mark gnus-del-mark)))
10076 (if (= mark gnus-expirable-mark)
10077 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
10078 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
10079 ;; Remove from unread and marked lists.
10080 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10081 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10082 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10083 (setq gnus-newsgroup-reads
10084 (cons (cons article mark) gnus-newsgroup-reads))
10085 ;; Possibly remove from cache, if that is used.
10086 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
10088 (defun gnus-mark-article-as-unread (article &optional mark)
10089 "Enter ARTICLE in the pertinent lists and remove it from others."
10090 (let ((mark (or mark gnus-ticked-mark)))
10091 ;; Add to unread list.
10092 (or (memq article gnus-newsgroup-unreads)
10093 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
10094 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10095 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10096 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10097 (setq gnus-newsgroup-reads
10098 (delq (assq article gnus-newsgroup-reads)
10099 gnus-newsgroup-reads))
10100 (if (= mark gnus-ticked-mark)
10101 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
10102 (if (= mark gnus-dormant-mark)
10103 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
10105 (defalias 'gnus-summary-mark-as-unread-forward
10106 'gnus-summary-tick-article-forward)
10107 (make-obsolete 'gnus-summary-mark-as-unread-forward
10108 'gnus-summary-tick-article-forward)
10109 (defun gnus-summary-tick-article-forward (n)
10110 "Tick N articles forwards.
10111 If N is negative, tick backwards instead.
10112 The difference between N and the number of articles ticked is returned."
10114 (gnus-summary-mark-forward n gnus-ticked-mark))
10116 (defalias 'gnus-summary-mark-as-unread-backward
10117 'gnus-summary-tick-article-backward)
10118 (make-obsolete 'gnus-summary-mark-as-unread-backward
10119 'gnus-summary-tick-article-backward)
10120 (defun gnus-summary-tick-article-backward (n)
10121 "Tick N articles backwards.
10122 The difference between N and the number of articles ticked is returned."
10124 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10126 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10127 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10128 (defun gnus-summary-tick-article (&optional article clear-mark)
10129 "Mark current article as unread.
10130 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10131 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10132 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10133 gnus-ticked-mark)))
10135 (defun gnus-summary-mark-as-read-forward (n)
10136 "Mark N articles as read forwards.
10137 If N is negative, mark backwards instead.
10138 The difference between N and the actual number of articles marked is
10141 (gnus-summary-mark-forward n gnus-del-mark t))
10143 (defun gnus-summary-mark-as-read-backward (n)
10144 "Mark the N articles as read backwards.
10145 The difference between N and the actual number of articles marked is
10148 (gnus-summary-mark-forward (- n) gnus-del-mark t))
10150 (defun gnus-summary-mark-as-read (&optional article mark)
10151 "Mark current article as read.
10152 ARTICLE specifies the article to be marked as read.
10153 MARK specifies a string to be inserted at the beginning of the line."
10154 (gnus-summary-mark-article article mark))
10156 (defun gnus-summary-clear-mark-forward (n)
10157 "Clear marks from N articles forward.
10158 If N is negative, clear backward instead.
10159 The difference between N and the number of marks cleared is returned."
10161 (gnus-summary-mark-forward n gnus-unread-mark))
10163 (defun gnus-summary-clear-mark-backward (n)
10164 "Clear marks from N articles backward.
10165 The difference between N and the number of marks cleared is returned."
10167 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10169 (defun gnus-summary-mark-unread-as-read ()
10170 "Intended to be used by `gnus-summary-mark-article-hook'."
10171 (or (memq gnus-current-article gnus-newsgroup-marked)
10172 (memq gnus-current-article gnus-newsgroup-dormant)
10173 (memq gnus-current-article gnus-newsgroup-expirable)
10174 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10176 (defun gnus-summary-mark-region-as-read (point mark all)
10177 "Mark all unread articles between point and mark as read.
10178 If given a prefix, mark all articles between point and mark as read,
10179 even ticked and dormant ones."
10180 (interactive "r\nP")
10183 (beginning-of-line)
10190 (not (memq (gnus-summary-article-number)
10191 gnus-newsgroup-marked))
10192 (not (memq (gnus-summary-article-number)
10193 gnus-newsgroup-dormant))))
10194 (gnus-summary-mark-article
10195 (gnus-summary-article-number) gnus-del-mark))
10197 (gnus-summary-find-next)))))
10199 (defun gnus-summary-mark-below (score mark)
10200 "Mark articles with score less than SCORE with MARK."
10201 (interactive "P\ncMark: ")
10202 (gnus-set-global-variables)
10203 (setq score (if score
10204 (prefix-numeric-value score)
10205 (or gnus-summary-default-score 0)))
10207 (set-buffer gnus-summary-buffer)
10208 (goto-char (point-min))
10209 (while (not (eobp))
10210 (and (< (gnus-summary-article-score) score)
10211 (gnus-summary-mark-article nil mark))
10212 (gnus-summary-find-next))))
10214 (defun gnus-summary-kill-below (&optional score)
10215 "Mark articles with score below SCORE as read."
10217 (gnus-set-global-variables)
10218 (gnus-summary-mark-below score gnus-killed-mark))
10220 (defun gnus-summary-clear-above (&optional score)
10221 "Clear all marks from articles with score above SCORE."
10223 (gnus-set-global-variables)
10224 (gnus-summary-mark-above score gnus-unread-mark))
10226 (defun gnus-summary-tick-above (&optional score)
10227 "Tick all articles with score above SCORE."
10229 (gnus-set-global-variables)
10230 (gnus-summary-mark-above score gnus-ticked-mark))
10232 (defun gnus-summary-mark-above (score mark)
10233 "Mark articles with score over SCORE with MARK."
10234 (interactive "P\ncMark: ")
10235 (gnus-set-global-variables)
10236 (setq score (if score
10237 (prefix-numeric-value score)
10238 (or gnus-summary-default-score 0)))
10240 (set-buffer gnus-summary-buffer)
10241 (goto-char (point-min))
10243 (if (> (gnus-summary-article-score) score)
10244 (gnus-summary-mark-article nil mark))
10246 (gnus-summary-find-next)))))
10248 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10249 (defun gnus-summary-show-all-expunged ()
10250 "Display all the hidden articles that were expunged for low scores."
10252 (gnus-set-global-variables)
10253 (let ((buffer-read-only nil))
10254 (let ((scored gnus-newsgroup-scored)
10257 (or (gnus-summary-goto-subject (car (car scored)))
10258 (and (setq h (gnus-summary-article-header (car (car scored))))
10259 (< (cdr (car scored)) gnus-summary-expunge-below)
10260 (setq headers (cons h headers))))
10261 (setq scored (cdr scored)))
10262 (or headers (error "No expunged articles hidden."))
10263 (goto-char (point-min))
10265 (gnus-summary-update-lines
10268 (gnus-summary-prepare-unthreaded (nreverse headers))
10270 (goto-char (point-min))
10271 (gnus-summary-position-point)))
10273 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
10274 "Mark all articles not marked as unread in this newsgroup as read.
10275 If prefix argument ALL is non-nil, all articles are marked as read.
10276 If QUIETLY is non-nil, no questions will be asked.
10277 If TO-HERE is non-nil, it should be a point in the buffer. All
10278 articles before this point will be marked as read.
10279 The number of articles marked as read is returned."
10281 (gnus-set-global-variables)
10284 (not gnus-interactive-catchup) ;Without confirmation?
10288 "Mark absolutely all articles as read? "
10289 "Mark all unread articles as read? ")))
10291 (not gnus-newsgroup-adaptive)
10292 (not gnus-newsgroup-auto-expire))
10294 (and all (setq gnus-newsgroup-marked nil
10295 gnus-newsgroup-dormant nil))
10296 (setq gnus-newsgroup-unreads
10297 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
10298 ;; We actually mark all articles as canceled, which we
10299 ;; have to do when using auto-expiry or adaptive scoring.
10300 (gnus-summary-show-all-threads)
10301 (if (gnus-summary-first-subject (not all))
10303 (if to-here (< (point) to-here) t)
10304 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10305 (gnus-summary-find-next (not all)))))
10307 (setq gnus-newsgroup-unreads
10308 (append gnus-newsgroup-marked
10309 gnus-newsgroup-dormant)))))
10310 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10311 (if (and (not to-here) (eq 'nnvirtual (car method)))
10312 (nnvirtual-catchup-group
10313 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
10314 (gnus-summary-position-point)))
10316 (defun gnus-summary-catchup-to-here (&optional all)
10317 "Mark all unticked articles before the current one as read.
10318 If ALL is non-nil, also mark ticked and dormant articles as read."
10320 (gnus-set-global-variables)
10322 (and (gnus-summary-find-prev)
10324 (gnus-summary-catchup all t (point))
10325 (gnus-set-mode-line 'summary))))
10326 (gnus-summary-position-point))
10328 (defun gnus-summary-catchup-all (&optional quietly)
10329 "Mark all articles in this newsgroup as read."
10331 (gnus-set-global-variables)
10332 (gnus-summary-catchup t quietly))
10334 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10335 "Mark all articles not marked as unread in this newsgroup as read, then exit.
10336 If prefix argument ALL is non-nil, all articles are marked as read."
10338 (gnus-set-global-variables)
10339 (gnus-summary-catchup all quietly nil 'fast)
10340 ;; Select next newsgroup or exit.
10341 (if (eq gnus-auto-select-next 'quietly)
10342 (gnus-summary-next-group nil)
10343 (gnus-summary-exit)))
10345 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10346 "Mark all articles in this newsgroup as read, and then exit."
10348 (gnus-set-global-variables)
10349 (gnus-summary-catchup-and-exit t quietly))
10351 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
10352 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10353 "Mark all articles in this group as read and select the next group.
10354 If given a prefix, mark all articles, unread as well as ticked, as
10357 (gnus-set-global-variables)
10358 (gnus-summary-catchup all)
10359 (gnus-summary-next-group))
10361 ;; Thread-based commands.
10363 (defun gnus-summary-articles-in-thread (&optional article)
10364 "Return a list of all articles in the current thread.
10365 If ARTICLE is non-nil, return all articles in the thread that starts
10366 with that article."
10367 (let* ((article (or article (gnus-summary-article-number)))
10368 (data (gnus-data-find-list article))
10369 (top-level (gnus-data-level (car data)))
10371 (cond ((null gnus-thread-operation-ignore-subject)
10372 (gnus-simplify-subject-re
10373 (mail-header-subject (gnus-data-header (car data)))))
10374 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10375 (gnus-simplify-subject-fuzzy
10376 (mail-header-subject (gnus-data-header (car data)))))
10380 () ; This article doesn't exist.
10382 (and (or (not top-subject)
10383 (string= top-subject
10384 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10385 (gnus-simplify-subject-fuzzy
10386 (mail-header-subject
10387 (gnus-data-header (car data))))
10388 (gnus-simplify-subject-re
10389 (mail-header-subject
10390 (gnus-data-header (car data)))))))
10391 (setq articles (cons (gnus-data-number (car data)) articles)))
10392 (if (and (setq data (cdr data))
10393 (> (gnus-data-level (car data)) top-level))
10396 ;; Return the list of articles.
10397 (nreverse articles))))
10399 (defun gnus-summary-toggle-threads (&optional arg)
10400 "Toggle showing conversation threads.
10401 If ARG is positive number, turn showing conversation threads on."
10403 (gnus-set-global-variables)
10404 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10405 (setq gnus-show-threads
10406 (if (null arg) (not gnus-show-threads)
10407 (> (prefix-numeric-value arg) 0)))
10408 (gnus-summary-prepare)
10409 (gnus-summary-goto-subject current)
10410 (gnus-summary-position-point)))
10412 (defun gnus-summary-show-all-threads ()
10413 "Show all threads."
10415 (gnus-set-global-variables)
10417 (let ((buffer-read-only nil))
10418 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10419 (gnus-summary-position-point))
10421 (defun gnus-summary-show-thread ()
10422 "Show thread subtrees.
10423 Returns nil if no thread was there to be shown."
10425 (gnus-set-global-variables)
10426 (let ((buffer-read-only nil)
10428 ;; first goto end then to beg, to have point at beg after let
10429 (end (progn (end-of-line) (point)))
10430 (beg (progn (beginning-of-line) (point))))
10432 ;; Any hidden lines here?
10433 (search-forward "\r" end t)
10434 (subst-char-in-region beg end ?\^M ?\n t)
10436 (gnus-summary-position-point))))
10438 (defun gnus-summary-hide-all-threads ()
10439 "Hide all thread subtrees."
10441 (gnus-set-global-variables)
10443 (goto-char (point-min))
10444 (gnus-summary-hide-thread)
10445 (while (zerop (gnus-summary-next-thread 1))
10446 (gnus-summary-hide-thread)))
10447 (gnus-summary-position-point))
10449 (defun gnus-summary-hide-thread ()
10450 "Hide thread subtrees.
10451 Returns nil if no threads were there to be hidden."
10453 (gnus-set-global-variables)
10454 (let ((buffer-read-only nil)
10456 (level (gnus-summary-thread-level))
10457 (article (gnus-summary-article-number))
10459 ;; Go forward until either the buffer ends or the subthread
10463 (while (and (gnus-summary-find-next)
10464 (> (gnus-summary-thread-level) level))
10465 (setq end (point)))
10469 (search-backward "\n" start t))
10470 (subst-char-in-region start end ?\n ?\^M)
10471 (gnus-summary-goto-subject article)
10472 (gnus-summary-position-point)))))
10474 (defun gnus-summary-go-to-next-thread (&optional previous)
10475 "Go to the same level (or less) next thread.
10476 If PREVIOUS is non-nil, go to previous thread instead.
10477 Return the article number moved to, or nil if moving was impossible."
10478 (let ((level (gnus-summary-thread-level))
10479 (article (gnus-summary-article-number)))
10481 (while (and (gnus-summary-find-prev)
10482 (> (gnus-summary-thread-level) level)))
10483 (while (and (gnus-summary-find-next)
10484 (> (gnus-summary-thread-level) level))))
10485 (gnus-summary-recenter)
10486 (gnus-summary-position-point)
10487 (let ((oart (gnus-summary-article-number)))
10488 (and (/= oart article) oart))))
10490 (defun gnus-summary-next-thread (n)
10491 "Go to the same level next N'th thread.
10492 If N is negative, search backward instead.
10493 Returns the difference between N and the number of skips actually
10496 (gnus-set-global-variables)
10497 (let ((backward (< n 0))
10499 (while (and (> n 0)
10500 (gnus-summary-go-to-next-thread backward))
10502 (gnus-summary-position-point)
10503 (if (/= 0 n) (gnus-message 7 "No more threads"))
10506 (defun gnus-summary-prev-thread (n)
10507 "Go to the same level previous N'th thread.
10508 Returns the difference between N and the number of skips actually
10511 (gnus-set-global-variables)
10512 (gnus-summary-next-thread (- n)))
10514 (defun gnus-summary-go-down-thread ()
10515 "Go down one level in the current thread."
10516 (let ((children (gnus-summary-article-children)))
10518 (gnus-summary-goto-subject (car children)))))
10520 (defun gnus-summary-go-up-thread ()
10521 "Go up one level in the current thread."
10522 (let ((parent (gnus-summary-article-parent)))
10524 (gnus-summary-goto-subject parent))))
10526 (defun gnus-summary-down-thread (n)
10527 "Go down thread N steps.
10528 If N is negative, go up instead.
10529 Returns the difference between N and how many steps down that were
10532 (gnus-set-global-variables)
10535 (while (and (> n 0)
10536 (if up (gnus-summary-go-up-thread)
10537 (gnus-summary-go-down-thread)))
10539 (gnus-summary-position-point)
10540 (if (/= 0 n) (gnus-message 7 "Can't go further"))
10543 (defun gnus-summary-up-thread (n)
10544 "Go up thread N steps.
10545 If N is negative, go up instead.
10546 Returns the difference between N and how many steps down that were
10549 (gnus-set-global-variables)
10550 (gnus-summary-down-thread (- n)))
10552 (defun gnus-summary-kill-thread (&optional unmark)
10553 "Mark articles under current thread as read.
10554 If the prefix argument is positive, remove any kinds of marks.
10555 If the prefix argument is negative, tick articles instead."
10557 (gnus-set-global-variables)
10559 (setq unmark (prefix-numeric-value unmark)))
10560 (let ((articles (gnus-summary-articles-in-thread)))
10562 ;; Expand the thread.
10563 (gnus-summary-show-thread)
10564 ;; Mark all the articles.
10566 (gnus-summary-goto-subject (car articles))
10567 (cond ((null unmark)
10568 (gnus-summary-mark-article-as-read gnus-killed-mark))
10570 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10572 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10573 (setq articles (cdr articles))))
10574 ;; Hide killed subtrees.
10576 gnus-thread-hide-killed
10577 (gnus-summary-hide-thread))
10578 ;; If marked as read, go to next unread subject.
10580 ;; Go to next unread subject.
10581 (gnus-summary-next-subject 1 t)))
10582 (gnus-set-mode-line 'summary))
10584 ;; Summary sorting commands
10586 (defun gnus-summary-sort-by-number (&optional reverse)
10587 "Sort summary buffer by article number.
10588 Argument REVERSE means reverse order."
10590 (gnus-set-global-variables)
10592 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
10593 ;; a function, so we wrap it.
10594 (cons (lambda () (gnus-summary-article-number))
10595 'gnus-thread-sort-by-number) reverse))
10597 (defun gnus-summary-sort-by-author (&optional reverse)
10598 "Sort summary buffer by author name alphabetically.
10599 If case-fold-search is non-nil, case of letters is ignored.
10600 Argument REVERSE means reverse order."
10602 (gnus-set-global-variables)
10606 (let* ((header (gnus-summary-article-header))
10608 gnus-extract-address-components
10609 (mail-header-from header))))
10610 (concat (or (car extract) (cdr extract))
10611 "\r" (mail-header-subject header))))
10612 'gnus-thread-sort-by-author)
10615 (defun gnus-summary-sort-by-subject (&optional reverse)
10616 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10617 If case-fold-search is non-nil, case of letters is ignored.
10618 Argument REVERSE means reverse order."
10620 (gnus-set-global-variables)
10624 (let* ((header (gnus-summary-article-header))
10626 gnus-extract-address-components
10627 (mail-header-from header))))
10629 (downcase (gnus-simplify-subject (gnus-summary-article-subject) t))
10630 "\r" (or (car extract) (cdr extract)))))
10631 'gnus-thread-sort-by-subject)
10634 (defun gnus-summary-sort-by-date (&optional reverse)
10635 "Sort summary buffer by date.
10636 Argument REVERSE means reverse order."
10638 (gnus-set-global-variables)
10642 (gnus-sortable-date
10644 (gnus-summary-article-header))))
10645 'gnus-thread-sort-by-date)
10648 (defun gnus-summary-sort-by-score (&optional reverse)
10649 "Sort summary buffer by score.
10650 Argument REVERSE means reverse order."
10652 (gnus-set-global-variables)
10654 (cons (lambda () (gnus-summary-article-score))
10655 'gnus-thread-sort-by-score)
10658 (defvar gnus-summary-already-sorted nil)
10659 (defun gnus-summary-sort (predicate reverse)
10660 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10661 (if gnus-summary-already-sorted
10663 (let (buffer-read-only)
10664 (if (not gnus-show-threads)
10665 ;; We do untreaded sorting...
10667 (goto-char (point-min))
10668 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
10669 ;; ... or we do threaded sorting.
10670 (let ((gnus-thread-sort-functions (list (cdr predicate)))
10671 (gnus-summary-prepare-hook nil)
10672 (gnus-summary-already-sorted nil))
10673 ;; We do that by simply regenerating the threads.
10674 (gnus-summary-prepare)
10675 (and gnus-show-threads
10676 gnus-thread-hide-subtree
10677 (gnus-summary-hide-all-threads))
10678 ;; If in async mode, we send some info to the backend.
10679 (and gnus-newsgroup-async
10680 (gnus-request-asynchronous
10681 gnus-newsgroup-name gnus-newsgroup-data)))))))
10683 (defun gnus-sortable-date (date)
10684 "Make sortable string by string-lessp from DATE.
10685 Timezone package is used."
10686 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
10687 (year (aref date 0))
10688 (month (aref date 1))
10689 (day (aref date 2)))
10690 (timezone-make-sortable-date
10692 (timezone-make-time-string
10693 (aref date 3) (aref date 4) (aref date 5)))))
10696 ;; Summary saving commands.
10698 (defun gnus-summary-save-article (&optional n)
10699 "Save the current article using the default saver function.
10700 If N is a positive number, save the N next articles.
10701 If N is a negative number, save the N previous articles.
10702 If N is nil and any articles have been marked with the process mark,
10703 save those articles instead.
10704 The variable `gnus-default-article-saver' specifies the saver function."
10706 (gnus-set-global-variables)
10707 (let ((articles (gnus-summary-work-articles n))
10710 (let ((header (gnus-summary-article-header (car articles))))
10711 (if (vectorp header)
10713 (save-window-excursion
10714 (gnus-summary-select-article t nil nil (car articles)))
10715 (or gnus-save-all-headers
10716 (gnus-article-hide-headers t))
10717 ;; Remove any X-Gnus lines.
10720 (set-buffer gnus-article-buffer)
10721 (let ((buffer-read-only nil))
10722 (goto-char (point-min))
10723 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
10725 (while (re-search-forward "^X-Gnus" nil t)
10726 (beginning-of-line)
10727 (delete-region (point)
10728 (progn (forward-line 1) (point))))
10730 (save-window-excursion
10731 (if gnus-default-article-saver
10732 (setq file (funcall
10733 gnus-default-article-saver
10735 ((not gnus-prompt-before-saving)
10737 ((eq gnus-prompt-before-saving 'always)
10740 (error "No default saver is defined."))))
10741 (if (assq 'name header)
10742 (gnus-copy-file (cdr (assq 'name header)))
10743 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
10744 (gnus-summary-remove-process-mark (car articles))
10745 (setq articles (cdr articles)))
10746 (gnus-summary-position-point)
10749 (defun gnus-summary-pipe-output (&optional arg)
10750 "Pipe the current article to a subprocess.
10751 If N is a positive number, pipe the N next articles.
10752 If N is a negative number, pipe the N previous articles.
10753 If N is nil and any articles have been marked with the process mark,
10754 pipe those articles instead."
10756 (gnus-set-global-variables)
10757 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10758 (gnus-summary-save-article arg)))
10760 (defun gnus-summary-save-article-mail (&optional arg)
10761 "Append the current article to an mail file.
10762 If N is a positive number, save the N next articles.
10763 If N is a negative number, save the N previous articles.
10764 If N is nil and any articles have been marked with the process mark,
10765 save those articles instead."
10767 (gnus-set-global-variables)
10768 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10769 (gnus-summary-save-article arg)))
10771 (defun gnus-summary-save-article-rmail (&optional arg)
10772 "Append the current article to an rmail file.
10773 If N is a positive number, save the N next articles.
10774 If N is a negative number, save the N previous articles.
10775 If N is nil and any articles have been marked with the process mark,
10776 save those articles instead."
10778 (gnus-set-global-variables)
10779 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10780 (gnus-summary-save-article arg)))
10782 (defun gnus-summary-save-article-file (&optional arg)
10783 "Append the current article to a file.
10784 If N is a positive number, save the N next articles.
10785 If N is a negative number, save the N previous articles.
10786 If N is nil and any articles have been marked with the process mark,
10787 save those articles instead."
10789 (gnus-set-global-variables)
10790 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10791 (gnus-summary-save-article arg)))
10793 (defun gnus-summary-save-article-body-file (&optional arg)
10794 "Append the current article body to a file.
10795 If N is a positive number, save the N next articles.
10796 If N is a negative number, save the N previous articles.
10797 If N is nil and any articles have been marked with the process mark,
10798 save those articles instead."
10800 (gnus-set-global-variables)
10801 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10802 (gnus-summary-save-article arg)))
10804 (defun gnus-read-save-file-name (prompt default-name)
10805 (let ((methods gnus-split-methods)
10807 (if (not gnus-split-methods)
10810 (set-buffer gnus-article-buffer)
10811 (gnus-narrow-to-headers)
10813 (goto-char (point-min))
10814 (and (condition-case ()
10815 (re-search-forward (car (car methods)) nil t)
10817 (setq split-name (cons (nth 1 (car methods)) split-name)))
10818 (setq methods (cdr methods)))
10820 (cond ((null split-name)
10822 (concat prompt " (default "
10823 (file-name-nondirectory default-name) ") ")
10824 (file-name-directory default-name)
10826 ((= 1 (length split-name))
10828 (concat prompt " (default " (car split-name) ") ")
10829 gnus-article-save-directory
10830 (concat gnus-article-save-directory (car split-name))))
10832 (setq split-name (mapcar (lambda (el) (list el))
10833 (nreverse split-name)))
10834 (let ((result (completing-read
10835 (concat prompt " ")
10836 split-name nil nil)))
10837 (concat gnus-article-save-directory
10838 (if (string= result "")
10839 (car (car split-name))
10842 (defun gnus-summary-save-in-rmail (&optional filename)
10843 "Append this article to Rmail file.
10844 Optional argument FILENAME specifies file name.
10845 Directory to save to is default to `gnus-article-save-directory' which
10846 is initialized from the SAVEDIR environment variable."
10848 (gnus-set-global-variables)
10849 (let ((default-name
10850 (funcall gnus-rmail-save-name gnus-newsgroup-name
10851 gnus-current-headers gnus-newsgroup-last-rmail)))
10853 (cond ((eq filename 'default)
10855 (filename filename)
10856 (t (gnus-read-save-file-name
10857 "Save in rmail file:" default-name))))
10858 (gnus-make-directory (file-name-directory filename))
10859 (gnus-eval-in-buffer-window
10860 gnus-article-buffer
10864 (gnus-output-to-rmail filename))))
10865 ;; Remember the directory name to save articles
10866 (setq gnus-newsgroup-last-rmail filename)))
10868 (defun gnus-summary-save-in-mail (&optional filename)
10869 "Append this article to Unix mail file.
10870 Optional argument FILENAME specifies file name.
10871 Directory to save to is default to `gnus-article-save-directory' which
10872 is initialized from the SAVEDIR environment variable."
10874 (gnus-set-global-variables)
10875 (let ((default-name
10876 (funcall gnus-mail-save-name gnus-newsgroup-name
10877 gnus-current-headers gnus-newsgroup-last-mail)))
10879 (cond ((eq filename 'default)
10881 (filename filename)
10882 (t (gnus-read-save-file-name
10883 "Save in Unix mail file:" default-name))))
10885 (expand-file-name filename
10887 (file-name-directory default-name))))
10888 (gnus-make-directory (file-name-directory filename))
10889 (gnus-eval-in-buffer-window
10890 gnus-article-buffer
10894 (if (and (file-readable-p filename) (rmail-file-p filename))
10895 (gnus-output-to-rmail filename)
10896 (rmail-output filename 1 t t)))))
10897 ;; Remember the directory name to save articles.
10898 (setq gnus-newsgroup-last-mail filename)))
10900 (defun gnus-summary-save-in-file (&optional filename)
10901 "Append this article to file.
10902 Optional argument FILENAME specifies file name.
10903 Directory to save to is default to `gnus-article-save-directory' which
10904 is initialized from the SAVEDIR environment variable."
10906 (gnus-set-global-variables)
10907 (let ((default-name
10908 (funcall gnus-file-save-name gnus-newsgroup-name
10909 gnus-current-headers gnus-newsgroup-last-file)))
10911 (cond ((eq filename 'default)
10913 (filename filename)
10914 (t (gnus-read-save-file-name
10915 "Save in file:" default-name))))
10916 (gnus-make-directory (file-name-directory filename))
10917 (gnus-eval-in-buffer-window
10918 gnus-article-buffer
10922 (gnus-output-to-file filename))))
10923 ;; Remember the directory name to save articles.
10924 (setq gnus-newsgroup-last-file filename)))
10926 (defun gnus-summary-save-body-in-file (&optional filename)
10927 "Append this article body to a file.
10928 Optional argument FILENAME specifies file name.
10929 The directory to save in defaults to `gnus-article-save-directory' which
10930 is initialized from the SAVEDIR environment variable."
10932 (gnus-set-global-variables)
10933 (let ((default-name
10934 (funcall gnus-file-save-name gnus-newsgroup-name
10935 gnus-current-headers gnus-newsgroup-last-file)))
10937 (cond ((eq filename 'default)
10939 (filename filename)
10940 (t (gnus-read-save-file-name
10941 "Save body in file:" default-name))))
10942 (gnus-make-directory (file-name-directory filename))
10943 (gnus-eval-in-buffer-window
10944 gnus-article-buffer
10948 (goto-char (point-min))
10949 (and (search-forward "\n\n" nil t)
10950 (narrow-to-region (point) (point-max)))
10951 (gnus-output-to-file filename))))
10952 ;; Remember the directory name to save articles.
10953 (setq gnus-newsgroup-last-file filename)))
10955 (defun gnus-summary-save-in-pipe (&optional command)
10956 "Pipe this article to subprocess."
10958 (gnus-set-global-variables)
10960 (cond ((eq command 'default)
10961 gnus-last-shell-command)
10963 (t (read-string "Shell command on article: "
10964 gnus-last-shell-command))))
10965 (if (string-equal command "")
10966 (setq command gnus-last-shell-command))
10967 (gnus-eval-in-buffer-window
10968 gnus-article-buffer
10971 (shell-command-on-region (point-min) (point-max) command nil)))
10972 (setq gnus-last-shell-command command))
10974 ;; Summary extract commands
10976 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10977 (let ((buffer-read-only nil)
10978 (article (gnus-summary-article-number))
10980 (or (gnus-summary-goto-subject article)
10981 (error (format "No such article: %d" article)))
10982 (gnus-summary-position-point)
10983 ;; If all commands are to be bunched up on one line, we collect
10985 (if gnus-view-pseudos-separately
10987 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10990 (setq action (cdr (assq 'action (car ps))))
10991 (setq files (list (cdr (assq 'name (car ps)))))
10992 (while (and ps (cdr ps)
10993 (string= (or action "1")
10994 (or (cdr (assq 'action (car (cdr ps)))) "2")))
10995 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
10996 (setcdr ps (cdr (cdr ps))))
10999 (if (not (string-match "%s" action))
11000 (setq files (cons " " files)))
11001 (setq files (cons " " files))
11002 (and (assq 'execute (car ps))
11003 (setcdr (assq 'execute (car ps))
11004 (funcall (if (string-match "%s" action)
11007 (mapconcat (lambda (f) f) files " ")))))
11008 (setq ps (cdr ps)))))
11009 (if (and gnus-view-pseudos (not not-view))
11011 (and (assq 'execute (car pslist))
11012 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11013 (eq gnus-view-pseudos 'not-confirm)))
11014 (setq pslist (cdr pslist)))
11017 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
11018 (gnus-summary-article-number)))
11020 (gnus-summary-article-number)
11021 gnus-reffed-article-number gnus-unread-mark
11022 (progn (forward-line 1) (point))
11028 (insert " " (file-name-nondirectory
11029 (cdr (assq 'name (car pslist))))
11030 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11032 'gnus-number gnus-reffed-article-number)
11034 (setq gnus-newsgroup-unreads
11035 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
11036 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11037 (setq pslist (cdr pslist)))))))
11039 (defun gnus-pseudos< (p1 p2)
11040 (let ((c1 (cdr (assq 'action p1)))
11041 (c2 (cdr (assq 'action p2))))
11042 (and c1 c2 (string< c1 c2))))
11044 (defun gnus-request-pseudo-article (props)
11045 (cond ((assq 'execute props)
11046 (gnus-execute-command (cdr (assq 'execute props)))))
11047 (let ((gnus-current-article (gnus-summary-article-number)))
11048 (run-hooks 'gnus-mark-article-hook)))
11050 (defun gnus-execute-command (command &optional automatic)
11052 (gnus-article-setup-buffer)
11053 (set-buffer gnus-article-buffer)
11054 (let ((command (if automatic command (read-string "Command: " command)))
11055 (buffer-read-only nil))
11057 (insert "$ " command "\n\n")
11058 (if gnus-view-pseudo-asynchronously
11059 (start-process "gnus-execute" nil "sh" "-c" command)
11060 (call-process "sh" nil t nil "-c" command)))))
11062 (defun gnus-copy-file (file &optional to)
11065 (list (read-file-name "Copy file: " default-directory)
11066 (read-file-name "Copy file to: " default-directory)))
11067 (gnus-set-global-variables)
11068 (or to (setq to (read-file-name "Copy file to: " default-directory)))
11069 (and (file-directory-p to)
11070 (setq to (concat (file-name-as-directory to)
11071 (file-name-nondirectory file))))
11072 (copy-file file to))
11074 ;; Summary kill commands.
11076 (defun gnus-summary-edit-global-kill (article)
11077 "Edit the \"global\" kill file."
11078 (interactive (list (gnus-summary-article-number)))
11079 (gnus-set-global-variables)
11080 (gnus-group-edit-global-kill article))
11082 (defun gnus-summary-edit-local-kill ()
11083 "Edit a local kill file applied to the current newsgroup."
11085 (gnus-set-global-variables)
11086 (setq gnus-current-headers (gnus-summary-article-header))
11087 (gnus-set-global-variables)
11088 (gnus-group-edit-local-kill
11089 (gnus-summary-article-number) gnus-newsgroup-name))
11093 ;;; Gnus article mode
11096 (put 'gnus-article-mode 'mode-class 'special)
11098 (defvar gnus-boogaboo nil)
11100 (if gnus-article-mode-map
11102 (setq gnus-article-mode-map (make-keymap))
11103 (suppress-keymap gnus-article-mode-map)
11104 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
11105 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
11106 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
11107 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
11108 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
11109 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
11110 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
11111 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
11112 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
11113 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
11114 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
11116 ;; Duplicate almost all summary keystrokes in the article mode map.
11119 "p" "N" "P" "\M-\C-n" "\M-\C-p"
11120 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
11121 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
11122 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
11123 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
11124 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
11125 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
11126 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
11127 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
11128 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
11129 "\C-c\C-v\C-v" "\C-d" "v"
11130 ;; "Mt" "M!" "Md" "Mr"
11131 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
11132 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
11133 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
11134 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
11135 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
11136 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
11137 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
11138 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
11139 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
11140 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
11141 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
11143 (while (and gnus-boogaboo commands) ; disabled
11144 (define-key gnus-article-mode-map (car commands)
11145 'gnus-article-summary-command)
11146 (setq commands (cdr commands))))
11148 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
11149 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
11150 "=" "n" "^" "\M-^")))
11151 (while (and gnus-boogaboo commands) ; disabled
11152 (define-key gnus-article-mode-map (car commands)
11153 'gnus-article-summary-command-nosave)
11154 (setq commands (cdr commands)))))
11157 (defun gnus-article-mode ()
11158 "Major mode for displaying an article.
11160 All normal editing commands are switched off.
11162 The following commands are available:
11164 \\<gnus-article-mode-map>
11165 \\[gnus-article-next-page]\t Scroll the article one page forwards
11166 \\[gnus-article-prev-page]\t Scroll the article one page backwards
11167 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
11168 \\[gnus-article-show-summary]\t Display the summary buffer
11169 \\[gnus-article-mail]\t Send a reply to the address near point
11170 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
11171 \\[gnus-info-find-node]\t Go to the Gnus info node"
11173 (if (gnus-visual-p 'article-menu 'menu) (gnus-article-make-menu-bar))
11174 (kill-all-local-variables)
11175 (setq mode-line-modified "-- ")
11176 (make-local-variable 'mode-line-format)
11177 (setq mode-line-format (copy-sequence mode-line-format))
11178 (and (equal (nth 3 mode-line-format) " ")
11179 (setcar (nthcdr 3 mode-line-format) ""))
11180 (setq mode-name "Article")
11181 (setq major-mode 'gnus-article-mode)
11182 (make-local-variable 'minor-mode-alist)
11183 (or (assq 'gnus-show-mime minor-mode-alist)
11184 (setq minor-mode-alist
11185 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
11186 (use-local-map gnus-article-mode-map)
11187 (make-local-variable 'page-delimiter)
11188 (setq page-delimiter gnus-page-delimiter)
11189 (buffer-disable-undo (current-buffer))
11190 (setq buffer-read-only t) ;Disable modification
11191 (run-hooks 'gnus-article-mode-hook))
11193 (defun gnus-article-setup-buffer ()
11194 "Initialize article mode buffer."
11195 ;; Returns the article buffer.
11196 (if (get-buffer gnus-article-buffer)
11198 (set-buffer gnus-article-buffer)
11199 (buffer-disable-undo (current-buffer))
11200 (setq buffer-read-only t)
11201 (gnus-add-current-to-buffer-list)
11202 (or (eq major-mode 'gnus-article-mode)
11203 (gnus-article-mode))
11206 (set-buffer (get-buffer-create gnus-article-buffer))
11207 (gnus-add-current-to-buffer-list)
11208 (gnus-article-mode)
11209 (current-buffer))))
11211 ;; Set article window start at LINE, where LINE is the number of lines
11212 ;; from the head of the article.
11213 (defun gnus-article-set-window-start (&optional line)
11215 (get-buffer-window gnus-article-buffer)
11217 (set-buffer gnus-article-buffer)
11218 (goto-char (point-min))
11221 (gnus-message 6 "Moved to bookmark")
11222 (search-forward "\n\n" nil t)
11223 (forward-line line)
11226 (defun gnus-request-article-this-buffer (article group)
11227 "Get an article and insert it into this buffer."
11230 (if (get-buffer gnus-original-article-buffer)
11231 (set-buffer (get-buffer gnus-original-article-buffer))
11232 (set-buffer (get-buffer-create gnus-original-article-buffer))
11233 (buffer-disable-undo (current-buffer))
11234 (setq major-mode 'gnus-original-article-mode)
11235 (gnus-add-current-to-buffer-list))
11237 (setq group (or group gnus-newsgroup-name))
11239 ;; Open server if it has closed.
11240 (gnus-check-server (gnus-find-method-for-group group))
11242 ;; Using `gnus-request-article' directly will insert the article into
11243 ;; `nntp-server-buffer' - so we'll save some time by not having to
11244 ;; copy it from the server buffer into the article buffer.
11246 ;; We only request an article by message-id when we do not have the
11247 ;; headers for it, so we'll have to get those.
11248 (and (stringp article)
11249 (let ((gnus-override-method gnus-refer-article-method))
11250 (gnus-read-header article)))
11252 ;; If the article number is negative, that means that this article
11253 ;; doesn't belong in this newsgroup (possibly), so we find its
11254 ;; message-id and request it by id instead of number.
11255 (if (not (numberp article))
11258 (set-buffer gnus-summary-buffer)
11259 (let ((header (gnus-summary-article-header article)))
11261 (if (vectorp header)
11262 ;; It's a real article.
11263 (setq article (mail-header-id header))
11264 ;; It is an extracted pseudo-article.
11265 (setq article 'pseudo)
11266 (gnus-request-pseudo-article header)))
11268 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
11269 (if (not (eq (car method) 'nneething))
11271 (let ((dir (concat (file-name-as-directory (nth 1 method))
11272 (mail-header-subject header))))
11273 (if (file-directory-p dir)
11275 (setq article 'nneething)
11276 (gnus-group-enter-directory dir)))))))))
11279 ;; We first check `gnus-original-article-buffer'.
11280 ((and (equal (car gnus-original-article) group)
11281 (eq (cdr gnus-original-article) article))
11283 ;; Check the cache.
11284 ((and gnus-use-cache
11286 (gnus-cache-request-article article group))
11288 ;; Get the article from the backend.
11289 ((or (stringp article) (numberp article))
11291 (let ((gnus-override-method
11292 (and (stringp article) gnus-refer-article-method)))
11293 (and (gnus-request-article article group (current-buffer))
11295 ;; It was a pseudo.
11297 (setq gnus-original-article (cons group article))
11299 (insert-buffer gnus-original-article-buffer)))
11301 (defun gnus-read-header (id)
11302 "Read the headers of article ID and enter them into the Gnus system."
11303 (let ((group gnus-newsgroup-name)
11306 (if (gnus-check-backend-function 'request-head group)
11307 (gnus-request-head id group)
11308 (gnus-request-article id group)))
11310 (set-buffer nntp-server-buffer)
11311 (and (search-forward "\n\n" nil t)
11312 (delete-region (1- (point)) (point-max)))
11313 (goto-char (point-max))
11315 (goto-char (point-min))
11324 gnus-reffed-article-number)))
11325 " Article retrieved.\n")
11326 (if (not (setq header (car (gnus-get-newsgroup-headers))))
11327 () ; Malformed head.
11328 (if (and (stringp id)
11329 (not (string= (gnus-group-real-name group)
11331 ;; If we fetched by Message-ID and the article came
11332 ;; from a different group, we fudge some bogus article
11333 ;; numbers for this article.
11334 (mail-header-set-number header gnus-reffed-article-number))
11335 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11336 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
11337 (setq gnus-current-headers header)
11340 (defun gnus-article-prepare (article &optional all-headers header)
11341 "Prepare ARTICLE in article mode buffer.
11342 ARTICLE should either be an article number or a Message-ID.
11343 If ARTICLE is an id, HEADER should be the article headers.
11344 If ALL-HEADERS is non-nil, no headers are hidden."
11346 ;; Make sure we start in a summary buffer.
11347 (or (eq major-mode 'gnus-summary-mode)
11348 (set-buffer gnus-summary-buffer))
11349 (setq gnus-summary-buffer (current-buffer))
11350 ;; Make sure the connection to the server is alive.
11351 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
11354 (gnus-find-method-for-group gnus-newsgroup-name))
11355 (gnus-request-group gnus-newsgroup-name t)))
11356 (let* ((article (if header (mail-header-number header) article))
11357 (summary-buffer (current-buffer))
11358 (internal-hook gnus-article-internal-prepare-hook)
11359 (group gnus-newsgroup-name)
11362 (gnus-article-setup-buffer)
11363 (set-buffer gnus-article-buffer)
11364 (if (not (setq result (let ((buffer-read-only nil))
11365 (gnus-request-article-this-buffer
11367 ;; There is no such article.
11369 (if (not (numberp article))
11371 (setq gnus-article-current
11372 (cons gnus-newsgroup-name article))
11373 (set-buffer gnus-summary-buffer)
11374 (setq gnus-current-article article)
11375 (gnus-summary-mark-article article gnus-canceled-mark))
11376 (gnus-message 1 "No such article (may be canceled)")
11379 (if (or (eq result 'pseudo) (eq result 'nneething))
11382 (set-buffer summary-buffer)
11383 (setq gnus-last-article gnus-current-article
11384 gnus-newsgroup-history (cons gnus-current-article
11385 gnus-newsgroup-history)
11386 gnus-current-article 0
11387 gnus-current-headers nil
11388 gnus-article-current nil)
11389 (if (eq result 'nneething)
11390 (gnus-configure-windows 'summary)
11391 (gnus-configure-windows 'article))
11392 (gnus-set-global-variables))
11393 (gnus-set-mode-line 'article))
11394 ;; The result from the `request' was an actual article -
11395 ;; or at least some text that is now displayed in the
11397 (if (and (numberp article)
11398 (not (eq article gnus-current-article)))
11399 ;; Seems like a new article has been selected.
11400 ;; `gnus-current-article' must be an article number.
11402 (set-buffer summary-buffer)
11403 (setq gnus-last-article gnus-current-article
11404 gnus-newsgroup-history (cons gnus-current-article
11405 gnus-newsgroup-history)
11406 gnus-current-article article
11407 gnus-current-headers
11408 (gnus-summary-article-header gnus-current-article)
11409 gnus-article-current
11410 (cons gnus-newsgroup-name gnus-current-article))
11411 (gnus-summary-show-thread)
11412 (run-hooks 'gnus-mark-article-hook)
11413 (gnus-set-mode-line 'summary)
11414 (and (gnus-visual-p 'article-highlight 'highlight)
11415 (run-hooks 'gnus-visual-mark-article-hook))
11416 ;; Set the global newsgroup variables here.
11417 ;; Suggested by Jim Sisolak
11418 ;; <sisolak@trans4.neep.wisc.edu>.
11419 (gnus-set-global-variables)
11420 (setq gnus-have-all-headers
11421 (or all-headers gnus-show-all-headers))
11422 (and gnus-use-cache
11423 (vectorp (gnus-summary-article-header article))
11424 (gnus-cache-possibly-enter-article
11426 (gnus-summary-article-header article)
11427 (memq article gnus-newsgroup-marked)
11428 (memq article gnus-newsgroup-dormant)
11429 (memq article gnus-newsgroup-unreads)))))
11430 ;; Hooks for getting information from the article.
11431 ;; This hook must be called before being narrowed.
11432 (let (buffer-read-only)
11433 (run-hooks 'internal-hook)
11434 (run-hooks 'gnus-article-prepare-hook)
11435 ;; Decode MIME message.
11436 (if (and gnus-show-mime
11437 (or (not gnus-strict-mime)
11438 (gnus-fetch-field "Mime-Version")))
11439 (funcall gnus-show-mime-method))
11440 ;; Perform the article display hooks.
11441 (run-hooks 'gnus-article-display-hook))
11443 (goto-char (point-min))
11444 (and gnus-break-pages (gnus-narrow-to-page))
11445 (gnus-set-mode-line 'article)
11446 (gnus-configure-windows 'article)
11447 (goto-char (point-min))
11450 (defun gnus-article-show-all-headers ()
11451 "Show all article headers in article mode buffer."
11453 (gnus-article-setup-buffer)
11454 (set-buffer gnus-article-buffer)
11455 (let ((buffer-read-only nil))
11456 (remove-text-properties (point-min) (point-max)
11457 gnus-hidden-properties))))
11459 (defun gnus-article-hide-headers-if-wanted ()
11460 "Hide unwanted headers if `gnus-have-all-headers' is nil.
11461 Provided for backwards compatability."
11462 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
11463 (gnus-article-hide-headers)))
11465 (defun gnus-article-hide-headers (&optional delete)
11466 "Hide unwanted headers and possibly sort them as well."
11469 (set-buffer gnus-article-buffer)
11471 (let ((sorted gnus-sorted-header-list)
11472 (buffer-read-only nil)
11473 want-list beg want-l)
11474 ;; First we narrow to just the headers.
11476 (goto-char (point-min))
11477 ;; Hide any "From " lines at the beginning of (mail) articles.
11478 (while (looking-at "From ")
11481 (add-text-properties (point-min) (point) gnus-hidden-properties))
11482 ;; Then treat the rest of the header lines.
11485 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
11486 ;; Then we use the two regular expressions
11487 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
11488 ;; select which header lines is to remain visible in the
11490 (goto-char (point-min))
11491 (while (re-search-forward "^[^ \t]*:" nil t)
11492 (beginning-of-line)
11493 ;; We add the headers we want to keep to a list and delete
11494 ;; them from the buffer.
11495 (if (or (and (stringp gnus-visible-headers)
11496 (looking-at gnus-visible-headers))
11497 (and (not (stringp gnus-visible-headers))
11498 (stringp gnus-ignored-headers)
11499 (not (looking-at gnus-ignored-headers))))
11503 ;; Be sure to get multi-line headers...
11504 (re-search-forward "^[^ \t]*:" nil t)
11505 (beginning-of-line)
11507 (cons (buffer-substring beg (point)) want-list))
11508 (delete-region beg (point))
11511 ;; Next we perform the sorting by looking at
11512 ;; `gnus-sorted-header-list'.
11513 (goto-char (point-min))
11514 (while (and sorted want-list)
11515 (setq want-l want-list)
11517 (not (string-match (car sorted) (car want-l))))
11518 (setq want-l (cdr want-l)))
11521 (insert (car want-l))
11522 (setq want-list (delq (car want-l) want-list))))
11523 (setq sorted (cdr sorted)))
11524 ;; Any headers that were not matched by the sorted list we
11525 ;; just tack on the end of the visible header list.
11527 (insert (car want-list))
11528 (setq want-list (cdr want-list)))
11529 ;; And finally we make the unwanted headers invisible.
11531 (delete-region (point) (point-max))
11532 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11533 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
11535 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
11536 (defun gnus-article-treat-overstrike ()
11537 "Translate overstrikes into bold text."
11540 (set-buffer gnus-article-buffer)
11541 (let ((buffer-read-only nil))
11542 (while (search-forward "\b" nil t)
11543 (let ((next (following-char))
11544 (previous (char-after (- (point) 2))))
11545 (cond ((eq next previous)
11546 (put-text-property (- (point) 2) (point)
11548 (put-text-property (point) (1+ (point))
11551 (put-text-property (1- (point)) (1+ (point))
11553 (put-text-property (1- (point)) (point)
11556 (put-text-property (- (point) 2) (point)
11558 (put-text-property (point) (1+ (point))
11559 'face 'underline))))))))
11561 (defun gnus-article-word-wrap ()
11562 "Format too long lines."
11565 (set-buffer gnus-article-buffer)
11566 (let ((buffer-read-only nil))
11567 (goto-char (point-min))
11568 (search-forward "\n\n" nil t)
11570 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
11571 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
11572 (adaptive-fill-mode t))
11573 (while (not (eobp))
11574 (and (>= (current-column) (min fill-column (window-width)))
11575 (/= (preceding-char) ?:)
11576 (fill-paragraph nil))
11577 (end-of-line 2))))))
11579 (defun gnus-article-remove-cr ()
11580 "Remove carriage returns from an article."
11583 (set-buffer gnus-article-buffer)
11584 (let ((buffer-read-only nil))
11585 (goto-char (point-min))
11586 (while (search-forward "\r" nil t)
11587 (replace-match "" t t)))))
11589 (defun gnus-article-display-x-face (&optional force)
11590 "Look for an X-Face header and display it if present."
11591 (interactive (list 'force))
11593 (set-buffer gnus-article-buffer)
11594 ;; delete old process
11595 (and (process-status "gnus-x-face")
11596 (delete-process "gnus-x-face"))
11597 (let ((inhibit-point-motion-hooks t)
11598 (case-fold-search nil))
11600 (goto-char (point-min))
11601 (search-forward "\n\n")
11602 (narrow-to-region (point-min) (point))
11603 (goto-char (point-min))
11604 (if (not (and gnus-article-x-face-command
11606 (not gnus-article-x-face-too-ugly)
11607 (and gnus-article-x-face-too-ugly
11608 (not (string-match gnus-article-x-face-too-ugly
11609 (mail-fetch-field "from")))))
11611 (goto-char (point-min))
11612 (re-search-forward "^X-Face: " nil t))))
11614 (let ((beg (point))
11615 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
11616 (if (symbolp gnus-article-x-face-command)
11617 (and (or (fboundp gnus-article-x-face-command)
11618 (error "%s is not a function"
11619 gnus-article-x-face-command))
11620 (funcall gnus-article-x-face-command beg end))
11621 (let ((process-connection-type nil))
11622 (process-kill-without-query
11623 (start-process "gnus-x-face" nil "sh" "-c"
11624 gnus-article-x-face-command))
11625 (process-send-region "gnus-x-face" beg end)
11626 (process-send-eof "gnus-x-face")))))))))
11628 (defun gnus-article-de-quoted-unreadable (&optional force)
11629 "Do a naïve translation of a quoted-printable-encoded article.
11630 This is in no way, shape or form meant as a replacement for real MIME
11631 processing, but is simply a stop-gap measure until MIME support is
11633 If FORCE, decode the article whether it is marked as quoted-printable
11635 (interactive (list 'force))
11637 (set-buffer gnus-article-buffer)
11638 (let ((case-fold-search t)
11639 (buffer-read-only nil)
11640 (type (gnus-fetch-field "content-transfer-encoding")))
11641 (if (or force (and type (string-match "quoted-printable" type)))
11643 (goto-char (point-min))
11644 (search-forward "\n\n" nil 'move)
11645 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
11647 (defun gnus-mime-decode-quoted-printable (from to)
11648 ;; Decode quoted-printable from region between FROM and TO.
11651 (while (search-forward "=" to t)
11652 (cond ((eq (following-char) ?\n)
11655 ((looking-at "[0-9A-F][0-9A-F]")
11657 (insert (hexl-hex-string-to-integer
11658 (buffer-substring (point) (+ 2 (point)))))
11662 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
11664 (defvar gnus-article-time-units
11665 (list (cons 'year (* 365.25 24 60 60))
11666 (cons 'week (* 7 24 60 60))
11667 (cons 'day (* 24 60 60))
11668 (cons 'hour (* 60 60))
11672 (defun gnus-article-date-ut (&optional type)
11673 "Convert DATE date to universal time in the current article.
11674 If TYPE is `local', convert to local time; if it is `lapsed', output
11675 how much time has lapsed since DATE."
11676 (interactive (list 'ut))
11677 (let ((date (mail-header-date (or gnus-current-headers
11678 (gnus-summary-article-header) "")))
11679 (date-regexp "^Date: \\|^X-Sent: "))
11684 (set-buffer gnus-article-buffer)
11685 (let ((buffer-read-only nil))
11686 (goto-char (point-min))
11687 (if (and (re-search-forward date-regexp nil t)
11689 (beginning-of-line)
11690 (looking-at date-regexp)))
11691 (delete-region (gnus-point-at-bol)
11692 (progn (end-of-line) (1+ (point))))
11693 (goto-char (point-min))
11694 (goto-char (- (search-forward "\n\n") 2)))
11698 (concat "Date: " (condition-case ()
11699 (timezone-make-date-arpa-standard date)
11705 (timezone-make-date-arpa-standard date nil "UT")
11708 ((eq type 'original)
11709 (concat "Date: " date "\n"))
11711 ;; If the date is seriously mangled, the timezone
11712 ;; functions are liable to bug out, so we condition-case
11713 ;; the entire thing.
11714 (let* ((real-sec (condition-case ()
11715 (- (gnus-seconds-since-epoch
11716 (timezone-make-date-arpa-standard
11717 (current-time-string)
11718 (current-time-zone) "UT"))
11719 (gnus-seconds-since-epoch
11720 (timezone-make-date-arpa-standard
11723 (sec (abs real-sec))
11731 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
11733 (setq sec (- sec (* num (cdr unit))))
11735 (concat (if prev ", " "") (int-to-string
11737 " " (symbol-name (car unit))
11738 (if (> num 1) "s" ""))
11740 gnus-article-time-units "")
11743 " in the future\n")))))
11745 (error "Unknown conversion type: %s" type)))))))))
11747 (defun gnus-article-date-local ()
11748 "Convert the current article date to the local timezone."
11750 (gnus-article-date-ut 'local))
11752 (defun gnus-article-date-original ()
11753 "Convert the current article date to what it was originally.
11754 This is only useful if you have used some other date conversion
11755 function and want to see what the date was before converting."
11757 (gnus-article-date-ut 'original))
11759 (defun gnus-article-date-lapsed ()
11760 "Convert the current article date to time lapsed since it was sent."
11762 (gnus-article-date-ut 'lapsed))
11764 (defun gnus-article-maybe-highlight ()
11765 "Do some article highlighting if `gnus-visual' is non-nil."
11766 (if (gnus-visual-p 'article-highlight 'highlight)
11767 (gnus-article-highlight-some)))
11771 (defun gnus-output-to-rmail (file-name)
11772 "Append the current article to an Rmail file named FILE-NAME."
11774 ;; Most of these codes are borrowed from rmailout.el.
11775 (setq file-name (expand-file-name file-name))
11776 (setq rmail-default-rmail-file file-name)
11777 (let ((artbuf (current-buffer))
11778 (tmpbuf (get-buffer-create " *Gnus-output*")))
11780 (or (get-file-buffer file-name)
11781 (file-exists-p file-name)
11782 (if (gnus-yes-or-no-p
11783 (concat "\"" file-name "\" does not exist, create it? "))
11784 (let ((file-buffer (create-file-buffer file-name)))
11786 (set-buffer file-buffer)
11787 (rmail-insert-rmail-file-header)
11788 (let ((require-final-newline nil))
11789 (write-region (point-min) (point-max) file-name t 1)))
11790 (kill-buffer file-buffer))
11791 (error "Output file does not exist")))
11792 (set-buffer tmpbuf)
11793 (buffer-disable-undo (current-buffer))
11795 (insert-buffer-substring artbuf)
11796 (gnus-convert-article-to-rmail)
11797 ;; Decide whether to append to a file or to an Emacs buffer.
11798 (let ((outbuf (get-file-buffer file-name)))
11800 (append-to-file (point-min) (point-max) file-name)
11801 ;; File has been visited, in buffer OUTBUF.
11802 (set-buffer outbuf)
11803 (let ((buffer-read-only nil)
11804 (msg (and (boundp 'rmail-current-message)
11805 (symbol-value 'rmail-current-message))))
11806 ;; If MSG is non-nil, buffer is in RMAIL mode.
11809 (narrow-to-region (point-max) (point-max))))
11810 (insert-buffer-substring tmpbuf)
11813 (goto-char (point-min))
11815 (search-backward "\^_")
11816 (narrow-to-region (point) (point-max))
11817 (goto-char (1+ (point-min)))
11818 (rmail-count-new-messages t)
11819 (rmail-show-message msg)))))))
11820 (kill-buffer tmpbuf)))
11822 (defun gnus-output-to-file (file-name)
11823 "Append the current article to a file named FILE-NAME."
11824 (setq file-name (expand-file-name file-name))
11825 (let ((artbuf (current-buffer))
11826 (tmpbuf (get-buffer-create " *Gnus-output*")))
11828 (set-buffer tmpbuf)
11829 (buffer-disable-undo (current-buffer))
11831 (insert-buffer-substring artbuf)
11832 ;; Append newline at end of the buffer as separator, and then
11833 ;; save it to file.
11834 (goto-char (point-max))
11836 (append-to-file (point-min) (point-max) file-name))
11837 (kill-buffer tmpbuf)))
11839 (defun gnus-convert-article-to-rmail ()
11840 "Convert article in current buffer to Rmail message format."
11841 (let ((buffer-read-only nil))
11842 ;; Convert article directly into Babyl format.
11843 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11844 (goto-char (point-min))
11845 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11846 (while (search-forward "\n\^_" nil t) ;single char
11847 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
11848 (goto-char (point-max))
11851 (defun gnus-narrow-to-page (&optional arg)
11852 "Make text outside current page invisible except for page delimiter.
11853 A numeric arg specifies to move forward or backward by that many pages,
11854 thus showing a page other than the one point was originally in."
11856 (setq arg (if arg (prefix-numeric-value arg) 0))
11858 (forward-page -1) ;Beginning of current page.
11863 (forward-page (1- arg))))
11864 ;; Find the end of the page.
11866 ;; If we stopped due to end of buffer, stay there.
11867 ;; If we stopped after a page delimiter, put end of restriction
11868 ;; at the beginning of that line.
11869 ;; These are commented out.
11870 ;; (if (save-excursion (beginning-of-line)
11871 ;; (looking-at page-delimiter))
11872 ;; (beginning-of-line))
11873 (narrow-to-region (point)
11875 ;; Find the top of the page.
11877 ;; If we found beginning of buffer, stay there.
11878 ;; If extra text follows page delimiter on same line,
11880 ;; Otherwise, show text starting with following line.
11881 (if (and (eolp) (not (bobp)))
11885 (defun gnus-gmt-to-local ()
11886 "Rewrite Date header described in GMT to local in current buffer.
11887 Intended to be used with gnus-article-prepare-hook."
11891 (goto-char (point-min))
11892 (narrow-to-region (point-min)
11893 (progn (search-forward "\n\n" nil 'move) (point)))
11894 (goto-char (point-min))
11895 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
11896 (let ((buffer-read-only nil)
11897 (date (buffer-substring-no-properties
11898 (match-beginning 1) (match-end 1))))
11899 (delete-region (match-beginning 1) (match-end 1))
11901 (timezone-make-date-arpa-standard
11902 date nil (current-time-zone))))))))
11905 ;; Article mode commands
11907 (defun gnus-article-next-page (&optional lines)
11908 "Show next page of current article.
11909 If end of article, return non-nil. Otherwise return nil.
11910 Argument LINES specifies lines to be scrolled up."
11912 (move-to-window-line -1)
11913 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11914 (if (save-excursion
11916 (and (pos-visible-in-window-p) ;Not continuation line.
11918 ;; Nothing in this page.
11919 (if (or (not gnus-break-pages)
11922 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11924 (gnus-narrow-to-page 1) ;Go to next page.
11926 ;; More in this page.
11930 ;; Long lines may cause an end-of-buffer error.
11931 (goto-char (point-max))))
11934 (defun gnus-article-prev-page (&optional lines)
11935 "Show previous page of current article.
11936 Argument LINES specifies lines to be scrolled down."
11938 (move-to-window-line 0)
11939 (if (and gnus-break-pages
11941 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11943 (gnus-narrow-to-page -1) ;Go to previous page.
11944 (goto-char (point-max))
11946 (scroll-down lines)))
11948 (defun gnus-article-refer-article ()
11949 "Read article specified by message-id around point."
11951 (search-forward ">" nil t) ;Move point to end of "<....>".
11952 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11954 (buffer-substring (match-beginning 1) (match-end 1))))
11955 (set-buffer gnus-summary-buffer)
11956 (gnus-summary-refer-article message-id))
11957 (error "No references around point")))
11959 (defun gnus-article-show-summary ()
11960 "Reconfigure windows to show summary buffer."
11962 (gnus-configure-windows 'article)
11963 (gnus-summary-goto-subject gnus-current-article))
11965 (defun gnus-article-describe-briefly ()
11966 "Describe article mode commands briefly."
11969 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-next-page]:Next page \\[gnus-article-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
11971 (defun gnus-article-summary-command ()
11972 "Execute the last keystroke in the summary buffer."
11974 (let ((obuf (current-buffer))
11975 (owin (current-window-configuration))
11977 (switch-to-buffer gnus-summary-buffer 'norecord)
11978 (setq func (lookup-key (current-local-map) (this-command-keys)))
11979 (call-interactively func)
11981 (set-window-configuration owin)
11982 (set-window-point (get-buffer-window (current-buffer)) (point))))
11984 (defun gnus-article-summary-command-nosave ()
11985 "Execute the last keystroke in the summary buffer."
11988 (pop-to-buffer gnus-summary-buffer 'norecord)
11989 (setq func (lookup-key (current-local-map) (this-command-keys)))
11990 (call-interactively func)))
11993 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11996 (defalias 'gnus-batch-kill 'gnus-batch-score)
11998 (defun gnus-batch-score ()
11999 "Run batched scoring.
12000 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
12001 Newsgroups is a list of strings in Bnews format. If you want to score
12002 the comp hierarchy, you'd say \"comp.all\". If you would not like to
12003 score the alt hierarchy, you'd say \"!alt.all\"."
12006 (gnus-newsrc-parse-options
12007 (apply (function concat)
12008 (mapcar (lambda (g) (concat g " "))
12009 command-line-args-left))))
12010 (gnus-expert-user t)
12011 (nnmail-spool-file nil)
12012 (gnus-use-dribble-file nil)
12013 (yes (car yes-and-no))
12014 (no (cdr yes-and-no))
12016 ;; Disable verbose message.
12017 gnus-novice-user gnus-large-newsgroup)
12018 ;; Eat all arguments.
12019 (setq command-line-args-left nil)
12022 ;; Apply kills to specified newsgroups in command line arguments.
12023 (setq newsrc (cdr gnus-newsrc-alist))
12025 (setq group (car (car newsrc)))
12026 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
12027 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
12029 (or (eq (car entry) t)
12030 (not (zerop (car entry)))))
12031 (if yes (string-match yes group) t)
12032 (or (null no) (not (string-match no group))))
12034 (gnus-summary-read-group group nil t)
12035 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
12036 (gnus-summary-exit))))
12037 (setq newsrc (cdr newsrc)))
12039 (switch-to-buffer gnus-group-buffer)
12040 (gnus-group-save-newsrc)))
12042 (defun gnus-apply-kill-file ()
12043 "Apply a kill file to the current newsgroup.
12044 Returns the number of articles marked as read."
12045 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
12046 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
12047 (gnus-apply-kill-file-internal)
12050 (defun gnus-kill-save-kill-buffer ()
12052 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
12053 (if (get-file-buffer file)
12055 (set-buffer (get-file-buffer file))
12056 (and (buffer-modified-p) (save-buffer))
12057 (kill-buffer (current-buffer)))))))
12059 (defvar gnus-kill-file-name "KILL"
12060 "Suffix of the kill files.")
12062 (defun gnus-newsgroup-kill-file (newsgroup)
12063 "Return the name of a kill file name for NEWSGROUP.
12064 If NEWSGROUP is nil, return the global kill file name instead."
12065 (cond ((or (null newsgroup)
12066 (string-equal newsgroup ""))
12067 ;; The global KILL file is placed at top of the directory.
12068 (expand-file-name gnus-kill-file-name
12069 (or gnus-kill-files-directory "~/News")))
12070 ((gnus-use-long-file-name 'not-kill)
12071 ;; Append ".KILL" to newsgroup name.
12072 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
12073 "." gnus-kill-file-name)
12074 (or gnus-kill-files-directory "~/News")))
12076 ;; Place "KILL" under the hierarchical directory.
12077 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
12078 "/" gnus-kill-file-name)
12079 (or gnus-kill-files-directory "~/News")))))
12086 (defvar gnus-dribble-ignore nil)
12087 (defvar gnus-dribble-eval-file nil)
12089 (defun gnus-dribble-file-name ()
12091 (if gnus-dribble-directory
12092 (concat (file-name-as-directory gnus-dribble-directory)
12093 (file-name-nondirectory gnus-current-startup-file))
12094 gnus-current-startup-file)
12097 (defun gnus-dribble-enter (string)
12098 (if (and (not gnus-dribble-ignore)
12099 (or gnus-dribble-buffer
12101 (buffer-name gnus-dribble-buffer))
12102 (let ((obuf (current-buffer)))
12103 (set-buffer gnus-dribble-buffer)
12104 (insert string "\n")
12105 (set-window-point (get-buffer-window (current-buffer)) (point-max))
12106 (set-buffer obuf))))
12108 (defun gnus-dribble-read-file ()
12109 (let ((dribble-file (gnus-dribble-file-name)))
12111 (set-buffer (setq gnus-dribble-buffer
12113 (file-name-nondirectory dribble-file))))
12114 (gnus-add-current-to-buffer-list)
12116 (set-visited-file-name dribble-file)
12117 (buffer-disable-undo (current-buffer))
12118 (bury-buffer (current-buffer))
12119 (set-buffer-modified-p nil)
12120 (let ((auto (make-auto-save-file-name))
12121 (gnus-dribble-ignore t))
12122 (if (or (file-exists-p auto) (file-exists-p dribble-file))
12124 (if (file-newer-than-file-p auto dribble-file)
12125 (setq dribble-file auto))
12126 (insert-file-contents dribble-file)
12127 (if (not (zerop (buffer-size)))
12128 (set-buffer-modified-p t))
12130 "Auto-save file exists. Do you want to read it? ")
12131 (setq gnus-dribble-eval-file t))))))))
12133 (defun gnus-dribble-eval-file ()
12134 (if (not gnus-dribble-eval-file)
12136 (setq gnus-dribble-eval-file nil)
12138 (let ((gnus-dribble-ignore t))
12139 (set-buffer gnus-dribble-buffer)
12140 (eval-buffer (current-buffer))))))
12142 (defun gnus-dribble-delete-file ()
12143 (if (file-exists-p (gnus-dribble-file-name))
12144 (delete-file (gnus-dribble-file-name)))
12145 (if gnus-dribble-buffer
12147 (set-buffer gnus-dribble-buffer)
12148 (let ((auto (make-auto-save-file-name)))
12149 (if (file-exists-p auto)
12150 (delete-file auto))
12152 (set-buffer-modified-p nil)))))
12154 (defun gnus-dribble-save ()
12155 (if (and gnus-dribble-buffer
12156 (buffer-name gnus-dribble-buffer))
12158 (set-buffer gnus-dribble-buffer)
12161 (defun gnus-dribble-clear ()
12163 (if (gnus-buffer-exists-p gnus-dribble-buffer)
12165 (set-buffer gnus-dribble-buffer)
12167 (set-buffer-modified-p nil)
12168 (setq buffer-saved-size (buffer-size))))))
12171 ;;; Server Communication
12174 (defun gnus-start-news-server (&optional confirm)
12175 "Open a method for getting news.
12176 If CONFIRM is non-nil, the user will be asked for an NNTP server."
12178 (if gnus-current-select-method
12179 ;; Stream is already opened.
12181 ;; Open NNTP server.
12182 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
12185 ;; Read server name with completion.
12186 (setq gnus-nntp-server
12187 (completing-read "NNTP server: "
12188 (mapcar (lambda (server) (list server))
12189 (cons (list gnus-nntp-server)
12190 gnus-secondary-servers))
12191 nil nil gnus-nntp-server))))
12193 (if (and gnus-nntp-server
12194 (stringp gnus-nntp-server)
12195 (not (string= gnus-nntp-server "")))
12196 (setq gnus-select-method
12197 (cond ((or (string= gnus-nntp-server "")
12198 (string= gnus-nntp-server "::"))
12199 (list 'nnspool (system-name)))
12200 ((string-match "^:" gnus-nntp-server)
12201 (list 'nnmh gnus-nntp-server
12202 (list 'nnmh-directory
12203 (file-name-as-directory
12205 (concat "~/" (substring
12206 gnus-nntp-server 1)))))
12207 (list 'nnmh-get-new-mail nil)))
12209 (list 'nntp gnus-nntp-server)))))
12211 (setq how (car gnus-select-method))
12212 (cond ((eq how 'nnspool)
12214 (gnus-message 5 "Looking up local news spool..."))
12217 (gnus-message 5 "Looking up mh spool..."))
12220 (setq gnus-current-select-method gnus-select-method)
12221 (run-hooks 'gnus-open-server-hook)
12223 ;; gnus-open-server-hook might have opened it
12224 (gnus-server-opened gnus-select-method)
12225 (gnus-open-server gnus-select-method)
12228 "%s open error: '%s'. Continue? "
12229 (nth 1 gnus-select-method)
12230 (gnus-status-message gnus-select-method)))
12232 (gnus-message 1 "Couldn't open server on %s"
12233 (nth 1 gnus-select-method))
12237 (defun gnus-check-server (&optional method)
12238 "If the news server is down, start it up again."
12239 (let ((method (if method method gnus-select-method)))
12240 (and (stringp method)
12241 (setq method (gnus-server-to-method method)))
12242 (if (gnus-server-opened method)
12243 ;; Stream is already opened.
12246 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
12247 (run-hooks 'gnus-open-server-hook)
12249 (gnus-open-server method)
12252 (defun gnus-nntp-message (&optional message)
12253 "Check the status of the NNTP server.
12254 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
12255 is returned insted of the status string."
12256 (let ((status (gnus-status-message (gnus-find-method-for-group
12257 gnus-newsgroup-name)))
12258 (message (or message "")))
12259 (if (and (stringp status) (> (length status) 0))
12262 (defun gnus-get-function (method function)
12263 (and (stringp method)
12264 (setq method (gnus-server-to-method method)))
12265 (let ((func (intern (format "%s-%s" (car method) function))))
12266 (if (not (fboundp func))
12268 (require (car method))
12269 (if (not (fboundp func))
12270 (error "No such function: %s" func))))
12273 ;;; Interface functions to the backends.
12275 (defun gnus-open-server (method)
12276 (funcall (gnus-get-function method 'open-server)
12277 (nth 1 method) (nthcdr 2 method)))
12279 (defun gnus-close-server (method)
12280 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
12282 (defun gnus-request-list (method)
12283 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
12285 (defun gnus-request-list-newsgroups (method)
12286 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
12288 (defun gnus-request-newgroups (date method)
12289 (funcall (gnus-get-function method 'request-newgroups)
12290 date (nth 1 method)))
12292 (defun gnus-server-opened (method)
12293 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
12295 (defun gnus-status-message (method)
12296 (let ((method (if (stringp method) (gnus-find-method-for-group method)
12298 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
12300 (defun gnus-request-group (group &optional dont-check)
12301 (let ((method (gnus-find-method-for-group group)))
12302 (funcall (gnus-get-function method 'request-group)
12303 (gnus-group-real-name group) (nth 1 method) dont-check)))
12305 (defun gnus-request-asynchronous (group &optional articles)
12306 (let ((method (gnus-find-method-for-group group)))
12307 (funcall (gnus-get-function method 'request-asynchronous)
12308 (gnus-group-real-name group) (nth 1 method) articles)))
12310 (defun gnus-list-active-group (group)
12311 (let ((method (gnus-find-method-for-group group))
12312 (func 'list-active-group))
12313 (and (gnus-check-backend-function func group)
12314 (funcall (gnus-get-function method func)
12315 (gnus-group-real-name group) (nth 1 method)))))
12317 (defun gnus-request-group-description (group)
12318 (let ((method (gnus-find-method-for-group group))
12319 (func 'request-group-description))
12320 (and (gnus-check-backend-function func group)
12321 (funcall (gnus-get-function method func)
12322 (gnus-group-real-name group) (nth 1 method)))))
12324 (defun gnus-close-group (group)
12325 (let ((method (gnus-find-method-for-group group)))
12326 (funcall (gnus-get-function method 'close-group)
12327 (gnus-group-real-name group) (nth 1 method))))
12329 (defun gnus-retrieve-headers (articles group &optional fetch-old)
12330 (let ((method (gnus-find-method-for-group group)))
12331 (if (and gnus-use-cache (numberp (car articles)))
12332 (gnus-cache-retrieve-headers articles group)
12333 (funcall (gnus-get-function method 'retrieve-headers)
12334 articles (gnus-group-real-name group) (nth 1 method)
12337 (defun gnus-retrieve-groups (groups method)
12338 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
12340 (defun gnus-request-article (article group &optional buffer)
12341 (let ((method (gnus-find-method-for-group group)))
12342 (funcall (gnus-get-function method 'request-article)
12343 article (gnus-group-real-name group) (nth 1 method) buffer)))
12345 (defun gnus-request-head (article group)
12346 (let ((method (gnus-find-method-for-group group)))
12347 (funcall (gnus-get-function method 'request-head)
12348 article (gnus-group-real-name group) (nth 1 method))))
12350 (defun gnus-request-body (article group)
12351 (let ((method (gnus-find-method-for-group group)))
12352 (funcall (gnus-get-function method 'request-body)
12353 article (gnus-group-real-name group) (nth 1 method))))
12355 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12356 (defun gnus-request-post-buffer (post group subject header artbuf
12357 info follow-to respect-poster)
12358 (let* ((info (or info (and group (nth 2 (gnus-gethash
12359 group gnus-newsrc-hashtb)))))
12361 (if (and gnus-post-method
12362 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12364 (format "%s" (car (gnus-find-method-for-group
12365 gnus-newsgroup-name)))
12366 gnus-valid-select-methods)))
12368 (gnus-find-method-for-group gnus-newsgroup-name))))
12369 (or (gnus-check-server method)
12370 (error "Can't open server %s:%s" (car method) (nth 1 method)))
12371 (let ((mail-self-blind nil)
12372 (mail-archive-file-name nil))
12373 (funcall (gnus-get-function method 'request-post-buffer)
12374 post group subject header artbuf info follow-to
12377 (defun gnus-request-post (method &optional force)
12378 (and (stringp method)
12379 (setq method (gnus-server-to-method method)))
12380 (and (not force) gnus-post-method
12381 (memq 'post (assoc (format "%s" (car method))
12382 gnus-valid-select-methods))
12383 (setq method gnus-post-method))
12384 (funcall (gnus-get-function method 'request-post)
12387 (defun gnus-request-scan (group method)
12388 (let ((method (if group (gnus-find-method-for-group group) method)))
12389 (funcall (gnus-get-function method 'request-scan)
12390 (and group (gnus-group-real-name group)) (nth 1 method))))
12392 (defun gnus-request-update-info (info method)
12393 (funcall (gnus-get-function method 'request-update-info)
12394 (gnus-group-real-name (car info)) info (nth 1 method)))
12396 (defun gnus-request-expire-articles (articles group &optional force)
12397 (let ((method (gnus-find-method-for-group group)))
12398 (funcall (gnus-get-function method 'request-expire-articles)
12399 articles (gnus-group-real-name group) (nth 1 method)
12402 (defun gnus-request-move-article
12403 (article group server accept-function &optional last)
12404 (let ((method (gnus-find-method-for-group group)))
12405 (funcall (gnus-get-function method 'request-move-article)
12406 article (gnus-group-real-name group)
12407 (nth 1 method) accept-function last)))
12409 (defun gnus-request-accept-article (group &optional last)
12410 (let ((func (if (symbolp group) group
12411 (car (gnus-find-method-for-group group)))))
12412 (funcall (intern (format "%s-request-accept-article" func))
12413 (if (stringp group) (gnus-group-real-name group) group)
12416 (defun gnus-request-replace-article (article group buffer)
12417 (let ((func (car (gnus-find-method-for-group group))))
12418 (funcall (intern (format "%s-request-replace-article" func))
12419 article (gnus-group-real-name group) buffer)))
12421 (defun gnus-request-create-group (group)
12422 (let ((method (gnus-find-method-for-group group)))
12423 (funcall (gnus-get-function method 'request-create-group)
12424 (gnus-group-real-name group) (nth 1 method))))
12426 (defun gnus-request-delete-group (group &optional force)
12427 (let ((method (gnus-find-method-for-group group)))
12428 (funcall (gnus-get-function method 'request-delete-group)
12429 (gnus-group-real-name group) force (nth 1 method))))
12431 (defun gnus-request-rename-group (group new-name)
12432 (let ((method (gnus-find-method-for-group group)))
12433 (funcall (gnus-get-function method 'request-rename-group)
12434 (gnus-group-real-name group)
12435 (gnus-group-real-name new-name) (nth 1 method))))
12437 (defun gnus-member-of-valid (symbol group)
12438 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
12439 (memq symbol (assoc
12440 (format "%s" (car (gnus-find-method-for-group group)))
12441 gnus-valid-select-methods)))
12443 (defun gnus-secondary-method-p (method)
12444 "Return whether METHOD is a secondary select method."
12445 (let ((methods gnus-secondary-select-methods)
12446 (gmethod (gnus-server-get-method nil method)))
12447 (while (and methods
12448 (not (equal (gnus-server-get-method nil (car methods))
12450 (setq methods (cdr methods)))
12453 (defun gnus-find-method-for-group (group &optional info)
12454 "Find the select method that GROUP uses."
12455 (or gnus-override-method
12457 gnus-select-method)
12458 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
12461 (not (setq method (nth 4 info))))
12462 (setq method gnus-select-method)
12464 (cond ((stringp method)
12465 (gnus-server-to-method method))
12466 ((stringp (car method))
12467 (gnus-server-extend-method group method))
12470 (gnus-server-add-address method))))
12472 (defun gnus-check-backend-function (func group)
12473 "Check whether GROUP supports function FUNC."
12474 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
12476 (fboundp (intern (format "%s-%s" method func)))))
12478 (defun gnus-methods-using (feature)
12479 "Find all methods that have FEATURE."
12480 (let ((valids gnus-valid-select-methods)
12483 (if (memq feature (car valids))
12484 (setq outs (cons (car valids) outs)))
12485 (setq valids (cdr valids)))
12489 ;;; Active & Newsrc File Handling
12492 ;; Newsrc related functions.
12493 ;; Gnus internal format of gnus-newsrc-alist:
12494 ;; (("alt.general" 3 (1 . 1))
12495 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
12496 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
12497 ;; The first item is the group name; the second is the subscription
12498 ;; level; the third is either a range of a list of ranges of read
12499 ;; articles, the optional fourth element is a list of marked articles,
12500 ;; the optional fifth element is the select method.
12502 ;; Gnus internal format of gnus-newsrc-hashtb:
12503 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12504 ;; This is the entry for "alt.misc". The first element is the number
12505 ;; of unread articles in "alt.misc". The cdr of this entry is the
12506 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
12507 ;; trivial to remove or add new elements into gnus-newsrc-alist
12508 ;; without scanning the entire list. So, to get the actual information
12509 ;; of "alt.misc", you'd say something like
12510 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12512 ;; Gnus internal format of gnus-active-hashtb:
12516 ;; The only element in each entry in this hash table is a range of
12517 ;; (possibly) available articles. (Articles in this range may have
12518 ;; been expired or canceled.)
12520 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12521 ;; ("alt.misc" "alt.test" "alt.general" ...)
12523 (defun gnus-setup-news (&optional rawfile level)
12524 "Setup news information.
12525 If RAWFILE is non-nil, the .newsrc file will also be read.
12526 If LEVEL is non-nil, the news will be set up at level LEVEL."
12527 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
12528 ;; Clear some variables to re-initialize news information.
12529 (if init (setq gnus-newsrc-alist nil
12530 gnus-active-hashtb nil))
12532 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12533 (if init (gnus-read-newsrc-file rawfile))
12535 ;; If we don't read the complete active file, we fill in the
12537 (if (or (null gnus-read-active-file)
12538 (eq gnus-read-active-file 'some))
12539 (gnus-update-active-hashtb-from-killed))
12541 ;; Read the active file and create `gnus-active-hashtb'.
12542 ;; If `gnus-read-active-file' is nil, then we just create an empty
12543 ;; hash table. The partial filling out of the hash table will be
12544 ;; done in `gnus-get-unread-articles'.
12545 (and gnus-read-active-file
12547 (gnus-read-active-file))
12549 (or gnus-active-hashtb
12550 (setq gnus-active-hashtb (make-vector 4095 0)))
12552 ;; Possibly eval the dribble file.
12553 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
12555 (gnus-update-format-specifications)
12557 ;; Find new newsgroups and treat them.
12558 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12559 (gnus-server-opened gnus-select-method))
12560 (gnus-find-new-newsgroups))
12562 ;; Find the number of unread articles in each non-dead group.
12563 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
12564 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
12566 (if (and init gnus-check-bogus-newsgroups
12567 gnus-read-active-file (not level)
12568 (gnus-server-opened gnus-select-method))
12569 (gnus-check-bogus-newsgroups))))
12571 (defun gnus-find-new-newsgroups ()
12572 "Search for new newsgroups and add them.
12573 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12574 The `-n' option line from .newsrc is respected."
12576 (or (gnus-check-first-time-used)
12577 (if (or (consp gnus-check-new-newsgroups)
12578 (eq gnus-check-new-newsgroups 'ask-server))
12579 (gnus-ask-server-for-new-groups)
12581 group new-newsgroups)
12582 (gnus-message 5 "Looking for new newsgroups...")
12583 (or gnus-have-read-active-file (gnus-read-active-file))
12584 (setq gnus-newsrc-last-checked-date (current-time-string))
12585 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12586 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12587 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12590 (if (or (null (setq group (symbol-name sym)))
12591 (null (symbol-value sym))
12592 (gnus-gethash group gnus-killed-hashtb)
12593 (gnus-gethash group gnus-newsrc-hashtb))
12595 (let ((do-sub (gnus-matches-options-n group)))
12597 ((eq do-sub 'subscribe)
12598 (setq groups (1+ groups))
12599 (gnus-sethash group group gnus-killed-hashtb)
12600 (funcall gnus-subscribe-options-newsgroup-method group))
12601 ((eq do-sub 'ignore)
12604 (setq groups (1+ groups))
12605 (gnus-sethash group group gnus-killed-hashtb)
12606 (if gnus-subscribe-hierarchical-interactive
12607 (setq new-newsgroups (cons group new-newsgroups))
12608 (funcall gnus-subscribe-newsgroup-method group)))))))
12609 gnus-active-hashtb)
12611 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12612 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12614 (gnus-message 6 "%d new newsgroup%s arrived."
12615 groups (if (> groups 1) "s have" " has"))
12616 (gnus-message 6 "No new newsgroups."))))))
12618 (defun gnus-matches-options-n (group)
12619 ;; Returns `subscribe' if the group is to be uncoditionally
12620 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12621 ;; no match for the group.
12623 ;; First we check the two user variables.
12625 ((and gnus-options-subscribe
12626 (string-match gnus-options-subscribe group))
12628 ((and gnus-auto-subscribed-groups
12629 (string-match gnus-auto-subscribed-groups group))
12631 ((and gnus-options-not-subscribe
12632 (string-match gnus-options-not-subscribe group))
12634 ;; Then we go through the list that was retrieved from the .newsrc
12635 ;; file. This list has elements on the form
12636 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12637 ;; is in the reverse order of the options line) is returned.
12639 (let ((regs gnus-newsrc-options-n))
12641 (not (string-match (car (car regs)) group)))
12642 (setq regs (cdr regs)))
12643 (and regs (cdr (car regs)))))))
12645 (defun gnus-ask-server-for-new-groups ()
12646 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12647 (methods (cons gnus-select-method
12649 (and (consp gnus-check-new-newsgroups)
12650 gnus-check-new-newsgroups)
12651 gnus-secondary-select-methods)))
12653 (new-date (current-time-string))
12654 (hashtb (gnus-make-hashtable 100))
12655 group new-newsgroups got-new method)
12656 ;; Go through both primary and secondary select methods and
12657 ;; request new newsgroups.
12659 (setq method (gnus-server-get-method nil (car methods)))
12660 (and (gnus-check-server method)
12661 (gnus-request-newgroups date method)
12664 (set-buffer nntp-server-buffer)
12665 ;; Enter all the new groups in a hashtable.
12666 (gnus-active-to-gnus-format method hashtb 'ignore)))
12667 (setq methods (cdr methods)))
12668 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12669 ;; Now all new groups from all select methods are in `hashtb'.
12671 (lambda (group-sym)
12672 (setq group (symbol-name group-sym))
12673 (if (or (null group)
12674 (null (symbol-value group-sym))
12675 (gnus-gethash group gnus-newsrc-hashtb)
12676 (member group gnus-zombie-list)
12677 (member group gnus-killed-list))
12678 ;; The group is already known.
12680 (and (symbol-value group-sym)
12681 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
12682 (let ((do-sub (gnus-matches-options-n group)))
12683 (cond ((eq do-sub 'subscribe)
12684 (setq groups (1+ groups))
12685 (gnus-sethash group group gnus-killed-hashtb)
12687 gnus-subscribe-options-newsgroup-method group))
12688 ((eq do-sub 'ignore)
12691 (setq groups (1+ groups))
12692 (gnus-sethash group group gnus-killed-hashtb)
12693 (if gnus-subscribe-hierarchical-interactive
12694 (setq new-newsgroups (cons group new-newsgroups))
12695 (funcall gnus-subscribe-newsgroup-method group)))))))
12698 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12699 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12701 (gnus-message 6 "%d new newsgroup%s arrived."
12702 groups (if (> groups 1) "s have" " has")))
12705 (defun gnus-check-first-time-used ()
12706 (if (or (> (length gnus-newsrc-alist) 1)
12707 (file-exists-p gnus-startup-file)
12708 (file-exists-p (concat gnus-startup-file ".el"))
12709 (file-exists-p (concat gnus-startup-file ".eld")))
12711 (gnus-message 6 "First time user; subscribing you to default groups")
12712 (or gnus-have-read-active-file (gnus-read-active-file))
12713 (setq gnus-newsrc-last-checked-date (current-time-string))
12714 (let ((groups gnus-default-subscribed-newsgroups)
12718 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12721 (if (null (setq group (symbol-name sym)))
12723 (let ((do-sub (gnus-matches-options-n group)))
12725 ((eq do-sub 'subscribe)
12726 (gnus-sethash group group gnus-killed-hashtb)
12727 (funcall gnus-subscribe-options-newsgroup-method group))
12728 ((eq do-sub 'ignore)
12731 (setq gnus-killed-list (cons group gnus-killed-list)))))))
12732 gnus-active-hashtb)
12734 (if (gnus-gethash (car groups) gnus-active-hashtb)
12735 (gnus-group-change-level
12736 (car groups) gnus-level-default-subscribed gnus-level-killed))
12737 (setq groups (cdr groups)))
12738 (gnus-group-make-help-group)
12739 (and gnus-novice-user
12740 (gnus-message 7 "`A k' to list killed groups"))))))
12742 (defun gnus-subscribe-group (group previous &optional method)
12743 (gnus-group-change-level
12745 (list t group gnus-level-default-subscribed nil nil method)
12747 gnus-level-default-subscribed gnus-level-killed previous t))
12749 ;; `gnus-group-change-level' is the fundamental function for changing
12750 ;; subscription levels of newsgroups. This might mean just changing
12751 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12752 ;; again, which subscribes/unsubscribes a group, which is equally
12753 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12754 ;; from 8-9 to 1-7 means that you remove the group from the list of
12755 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12756 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12757 ;; which is trivial.
12758 ;; ENTRY can either be a string (newsgroup name) or a list (if
12759 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12760 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12762 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12763 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12765 (defun gnus-group-change-level (entry level &optional oldlevel
12766 previous fromkilled)
12767 (let (group info active num)
12768 ;; Glean what info we can from the arguments
12770 (if fromkilled (setq group (nth 1 entry))
12771 (setq group (car (nth 2 entry))))
12772 (setq group entry))
12773 (if (and (stringp entry)
12775 (< oldlevel gnus-level-zombie))
12776 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12777 (if (and (not oldlevel)
12779 (setq oldlevel (car (cdr (nth 2 entry)))))
12780 (if (stringp previous)
12781 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12783 (if (and (>= oldlevel gnus-level-zombie)
12784 (gnus-gethash group gnus-newsrc-hashtb))
12785 ;; We are trying to subscribe a group that is already
12789 (gnus-dribble-enter
12790 (format "(gnus-group-change-level %S %S %S %S %S)"
12791 group level oldlevel (car (nth 2 previous)) fromkilled))
12793 ;; Then we remove the newgroup from any old structures, if needed.
12794 ;; If the group was killed, we remove it from the killed or zombie
12795 ;; list. If not, and it is in fact going to be killed, we remove
12796 ;; it from the newsrc hash table and assoc.
12797 (cond ((>= oldlevel gnus-level-zombie)
12798 (if (= oldlevel gnus-level-zombie)
12799 (setq gnus-zombie-list (delete group gnus-zombie-list))
12800 (setq gnus-killed-list (delete group gnus-killed-list))))
12802 (if (and (>= level gnus-level-zombie)
12805 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
12807 (setcdr (gnus-gethash (car (nth 3 entry))
12808 gnus-newsrc-hashtb)
12810 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12812 ;; Finally we enter (if needed) the list where it is supposed to
12813 ;; go, and change the subscription level. If it is to be killed,
12814 ;; we enter it into the killed or zombie list.
12815 (cond ((>= level gnus-level-zombie)
12816 ;; Remove from the hash table.
12817 (gnus-sethash group nil gnus-newsrc-hashtb)
12818 (or (gnus-group-foreign-p group)
12819 ;; We do not enter foreign groups into the list of dead
12821 (if (= level gnus-level-zombie)
12822 (setq gnus-zombie-list (cons group gnus-zombie-list))
12823 (setq gnus-killed-list (cons group gnus-killed-list)))))
12825 ;; If the list is to be entered into the newsrc assoc, and
12826 ;; it was killed, we have to create an entry in the newsrc
12827 ;; hashtb format and fix the pointers in the newsrc assoc.
12828 (if (>= oldlevel gnus-level-zombie)
12832 (setq info (cdr entry))
12833 (setq num (car entry)))
12834 (setq active (gnus-gethash group gnus-active-hashtb))
12836 (if active (- (1+ (cdr active)) (car active)) t))
12837 ;; Check whether the group is foreign. If so, the
12838 ;; foreign select method has to be entered into the
12840 (let ((method (gnus-group-method-name group)))
12841 (if (eq method gnus-select-method)
12842 (setq info (list group level nil))
12843 (setq info (list group level nil nil method)))))
12846 (let ((p gnus-newsrc-alist))
12847 (while (cdr (cdr p))
12850 (setq entry (cons info (cdr (cdr previous))))
12853 (setcdr (cdr previous) entry)
12854 (gnus-sethash group (cons num (cdr previous))
12855 gnus-newsrc-hashtb))
12856 (setcdr previous entry)
12857 (gnus-sethash group (cons num previous)
12858 gnus-newsrc-hashtb))
12860 (setcdr (gnus-gethash (car (car (cdr entry)))
12861 gnus-newsrc-hashtb)
12863 ;; It was alive, and it is going to stay alive, so we
12864 ;; just change the level and don't change any pointers or
12865 ;; hash table entries.
12866 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
12868 (defun gnus-kill-newsgroup (newsgroup)
12869 "Obsolete function. Kills a newsgroup."
12870 (gnus-group-change-level
12871 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
12873 (defun gnus-check-bogus-newsgroups (&optional confirm)
12874 "Remove bogus newsgroups.
12875 If CONFIRM is non-nil, the user has to confirm the deletion of every
12877 (let ((newsrc (cdr gnus-newsrc-alist))
12879 (gnus-message 5 "Checking bogus newsgroups...")
12880 (or gnus-have-read-active-file (gnus-read-active-file))
12881 ;; Find all bogus newsgroup that are subscribed.
12883 (setq group (car (car newsrc)))
12884 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
12885 (nth 4 (car newsrc)) ; Foreign
12887 (not (gnus-y-or-n-p
12888 (format "Remove bogus newsgroup: %s " group)))))
12891 ;; Found a bogus newsgroup.
12892 (setq bogus (cons group bogus)))
12893 (setq newsrc (cdr newsrc)))
12894 ;; Remove all bogus subscribed groups by first killing them, and
12895 ;; then removing them from the list of killed groups.
12897 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12899 (gnus-group-change-level entry gnus-level-killed)
12900 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12901 (setq bogus (cdr bogus)))
12902 ;; Then we remove all bogus groups from the list of killed and
12903 ;; zombie groups. They are are removed without confirmation.
12904 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12907 (setq killed (symbol-value (car dead-lists)))
12909 (setq group (car killed))
12910 (or (gnus-gethash group gnus-active-hashtb)
12911 ;; The group is bogus.
12912 (set (car dead-lists)
12913 (delete group (symbol-value (car dead-lists)))))
12914 (setq killed (cdr killed)))
12915 (setq dead-lists (cdr dead-lists))))
12916 (gnus-message 5 "Checking bogus newsgroups...done")))
12918 (defun gnus-check-duplicate-killed-groups ()
12919 "Remove duplicates from the list of killed groups."
12921 (let ((killed gnus-killed-list))
12923 (gnus-message 9 "%d" (length killed))
12924 (setcdr killed (delete (car killed) (cdr killed)))
12925 (setq killed (cdr killed)))))
12927 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12928 ;; and compute how many unread articles there are in each group.
12929 (defun gnus-get-unread-articles (&optional level)
12930 (let* ((newsrc (cdr gnus-newsrc-alist))
12931 (level (or level (1+ gnus-level-subscribed)))
12934 (cond ((and gnus-activate-foreign-newsgroups
12935 (not (numberp gnus-activate-foreign-newsgroups)))
12936 (1+ gnus-level-subscribed))
12937 ((numberp gnus-activate-foreign-newsgroups)
12938 gnus-activate-foreign-newsgroups)
12942 (fboundp (intern (format "%s-request-update-info"
12943 (car gnus-select-method)))))
12944 info group active virtuals method fmethod)
12945 (gnus-message 5 "Checking new news...")
12948 (setq info (car newsrc)
12950 active (gnus-gethash group gnus-active-hashtb))
12952 ;; Check newsgroups. If the user doesn't want to check them, or
12953 ;; they can't be checked (for instance, if the news server can't
12954 ;; be reached) we just set the number of unread articles in this
12955 ;; newsgroup to t. This means that Gnus thinks that there are
12956 ;; unread articles, but it has no idea how many.
12957 (if (and (setq method (nth 4 info))
12958 (not (gnus-server-equal
12961 (setq fmethod (gnus-server-get-method nil method))
12962 ;; We do this here because it would be awkward
12963 ;; to do it anywhere else. Hell, it's pretty
12964 ;; awkward here as well, but at least it's
12965 ;; reasonable efficient.
12966 (and (fboundp (intern (format "%s-request-update-info"
12968 (<= (nth 1 info) foreign-level)
12969 (gnus-request-update-info info method)))))
12970 (not (gnus-secondary-method-p method)))
12971 ;; These groups are foreign. Check the level.
12972 (if (<= (nth 1 info) foreign-level)
12973 (setq active (gnus-activate-group (car info) 'scan)))
12975 ;; These groups are native or secondary.
12976 (if (<= (nth 1 info) level)
12978 (if (and update (not method))
12980 ;; Allow updating of native groups as well, even
12981 ;; though that's pretty unlikely.
12982 (gnus-request-update-info info gnus-select-method)
12983 (setq active (gnus-activate-group (car info) 'scan)))
12984 (or gnus-read-active-file
12985 (setq active (gnus-activate-group (car info) 'scan)))))))
12988 (gnus-get-unread-articles-in-group info active)
12989 ;; The group couldn't be reached, so we nix out the number of
12990 ;; unread articles and stuff.
12991 (gnus-sethash group nil gnus-active-hashtb)
12992 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
12994 (setq newsrc (cdr newsrc)))
12996 (gnus-message 5 "Checking new news...done")))
12998 ;; Create a hash table out of the newsrc alist. The `car's of the
12999 ;; alist elements are used as keys.
13000 (defun gnus-make-hashtable-from-newsrc-alist ()
13001 (let ((alist gnus-newsrc-alist)
13002 (ohashtb gnus-newsrc-hashtb)
13004 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
13006 (setq prev (setq gnus-newsrc-alist
13007 (if (equal (car (car gnus-newsrc-alist))
13010 (cons (list "dummy.group" 0 nil) alist)))))
13012 (gnus-sethash (car (car alist))
13013 (cons (and ohashtb (car (gnus-gethash
13014 (car (car alist)) ohashtb)))
13015 prev) gnus-newsrc-hashtb)
13017 alist (cdr alist)))))
13019 (defun gnus-make-hashtable-from-killed ()
13020 "Create a hash table from the killed and zombie lists."
13021 (let ((lists '(gnus-killed-list gnus-zombie-list))
13023 (setq gnus-killed-hashtb
13024 (gnus-make-hashtable
13025 (+ (length gnus-killed-list) (length gnus-zombie-list))))
13027 (setq list (symbol-value (car lists)))
13028 (setq lists (cdr lists))
13030 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
13031 (setq list (cdr list))))))
13033 (defun gnus-get-unread-articles-in-group (info active)
13034 (let* ((range (nth 2 info))
13036 (marked (nth 3 info)))
13037 ;; If a cache is present, we may have to alter the active info.
13038 (and gnus-use-cache
13039 (gnus-cache-possibly-alter-active (car info) active))
13040 ;; Modify the list of read articles according to what articles
13041 ;; are available; then tally the unread articles and add the
13042 ;; number to the group hash table entry.
13044 ((zerop (cdr active))
13047 (setq num (- (1+ (cdr active)) (car active))))
13048 ((not (listp (cdr range)))
13049 ;; Fix a single (num . num) range according to the
13050 ;; active hash table.
13051 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
13052 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
13053 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
13054 ;; Compute number of unread articles.
13055 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
13057 ;; The read list is a list of ranges. Fix them according to
13058 ;; the active hash table.
13059 ;; First peel off any elements that are below the lower
13061 (while (and (cdr range)
13063 (or (and (atom (car (cdr range))) (car (cdr range)))
13064 (car (car (cdr range))))))
13065 (if (numberp (car range))
13068 (or (and (numberp (car (cdr range)))
13070 (cdr (car (cdr range))))))
13071 (setcdr (car range)
13072 (or (and (numberp (nth 1 range)) (nth 1 range))
13073 (cdr (car (cdr range))))))
13074 (setcdr range (cdr (cdr range))))
13075 ;; Adjust the first element to be the same as the lower limit.
13076 (if (and (not (atom (car range)))
13077 (< (cdr (car range)) (car active)))
13078 (setcdr (car range) (1- (car active))))
13079 ;; Then we want to peel off any elements that are higher
13080 ;; than the upper active limit.
13081 (let ((srange range))
13082 ;; Go past all legal elements.
13083 (while (and (cdr srange)
13084 (<= (or (and (atom (car (cdr srange)))
13085 (car (cdr srange)))
13086 (car (car (cdr srange)))) (cdr active)))
13087 (setq srange (cdr srange)))
13089 ;; Nuke all remaining illegal elements.
13090 (setcdr srange nil))
13092 ;; Adjust the final element.
13093 (if (and (not (atom (car srange)))
13094 (> (cdr (car srange)) (cdr active)))
13095 (setcdr (car srange) (cdr active))))
13096 ;; Compute the number of unread articles.
13098 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
13099 (cdr (car range))))
13100 (or (and (atom (car range)) (car range))
13101 (car (car range))))))
13102 (setq range (cdr range)))
13103 (setq num (max 0 (- (cdr active) num)))))
13106 (and (assq 'tick marked)
13107 (inline (gnus-remove-illegal-marked-articles
13108 (assq 'tick marked) (nth 2 info))))
13109 (and (assq 'dormant marked)
13110 (inline (gnus-remove-illegal-marked-articles
13111 (assq 'dormant marked) (nth 2 info))))
13113 (gnus-gethash (car info) gnus-newsrc-hashtb)
13114 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
13115 (length (cdr (assq 'dormant marked)))))))))
13118 (defun gnus-remove-illegal-marked-articles (marked ranges)
13119 (let ((m (cdr marked)))
13120 ;; Make sure that all ticked articles are a subset of the unread
13123 (if (gnus-member-of-range (car m) ranges)
13124 (setcdr marked (cdr m))
13126 (setq m (cdr m)))))
13128 (defun gnus-activate-group (group &optional scan)
13129 ;; Check whether a group has been activated or not.
13130 ;; If SCAN, request a scan of that group as well.
13131 (let ((method (gnus-find-method-for-group group))
13133 (and (gnus-check-server method)
13134 ;; We escape all bugs and quit here to make it possible to
13135 ;; continue if a group is so out-there that it reports bugs
13139 (gnus-check-backend-function 'request-scan (car method))
13140 (gnus-request-scan group method))
13143 (gnus-request-group group)
13147 (set-buffer nntp-server-buffer)
13148 (goto-char (point-min))
13149 ;; Parse the result we got from `gnus-request-group'.
13150 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
13152 (goto-char (match-beginning 1))
13154 group (setq active (cons (read (current-buffer))
13155 (read (current-buffer))))
13156 gnus-active-hashtb)
13157 ;; Return the new active info.
13160 (defun gnus-update-read-articles
13161 (group unread unselected ticked &optional domarks replied expirable killed
13162 dormant bookmark score)
13163 "Update the list of read and ticked articles in GROUP using the
13164 UNREAD and TICKED lists.
13165 Note: UNSELECTED has to be sorted over `<'.
13166 Returns whether the updating was successful."
13167 (let* ((active (or gnus-newsgroup-active
13168 (gnus-gethash group gnus-active-hashtb)))
13169 (entry (gnus-gethash group gnus-newsrc-hashtb))
13170 (info (nth 2 entry))
13171 (marked (nth 3 info))
13173 (unread (sort (copy-sequence unread) (function <)))
13175 (if (or (not info) (not active))
13176 ;; There is no info on this group if it was, in fact,
13177 ;; killed. Gnus stores no information on killed groups, so
13178 ;; there's nothing to be done.
13179 ;; One could store the information somewhere temporarily,
13180 ;; perhaps... Hmmm...
13182 ;; Remove any negative articles numbers.
13183 (while (and unread (< (car unread) 0))
13184 (setq unread (cdr unread)))
13185 ;; Remove any expired article numbers
13186 (while (and unread (< (car unread) (car active)))
13187 (setq unread (cdr unread)))
13188 (while (and ticked (< (car ticked) (car active)))
13189 (setq ticked (cdr ticked)))
13190 (while (and dormant (< (car dormant) (car active)))
13191 (setq dormant (cdr dormant)))
13192 (setq unread (sort (append unselected unread) '<))
13193 ;; Compute the ranges of read articles by looking at the list of
13194 ;; unread articles.
13196 (if (/= (car unread) prev)
13197 (setq read (cons (if (= prev (1- (car unread))) prev
13198 (cons prev (1- (car unread)))) read)))
13199 (setq prev (1+ (car unread)))
13200 (setq unread (cdr unread)))
13201 (if (<= prev (cdr active))
13202 (setq read (cons (cons prev (cdr active)) read)))
13203 ;; Enter this list into the group info.
13204 (setcar (cdr (cdr info))
13205 (if (> (length read) 1) (nreverse read) read))
13206 ;; Enter the list of ticked articles.
13207 (gnus-set-marked-articles
13209 (if domarks replied (cdr (assq 'reply marked)))
13210 (if domarks expirable (cdr (assq 'expire marked)))
13211 (if domarks killed (cdr (assq 'killed marked)))
13212 (if domarks dormant (cdr (assq 'dormant marked)))
13213 (if domarks bookmark (cdr (assq 'bookmark marked)))
13214 (if domarks score (cdr (assq 'score marked))))
13215 ;; Set the number of unread articles in gnus-newsrc-hashtb.
13216 (gnus-get-unread-articles-in-group
13217 info (gnus-gethash group gnus-active-hashtb))
13220 (defun gnus-make-articles-unread (group articles)
13221 "Mark ARTICLES in GROUP as unread."
13222 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
13223 (gnus-gethash (gnus-group-real-name group)
13224 gnus-newsrc-hashtb))))
13225 (ranges (nth 2 info))
13228 (and (gnus-member-of-range (car articles) ranges)
13229 (setq news (cons (car articles) news)))
13230 (setq articles (cdr articles)))
13233 (setcar (nthcdr 2 info)
13234 (gnus-remove-from-range (nth 2 info) (nreverse news)))
13235 (gnus-group-update-group group t))))
13237 ;; Enter all dead groups into the hashtb.
13238 (defun gnus-update-active-hashtb-from-killed ()
13239 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
13240 (lists (list gnus-killed-list gnus-zombie-list))
13243 (setq killed (car lists))
13245 (gnus-sethash (car killed) nil hashtb)
13246 (setq killed (cdr killed)))
13247 (setq lists (cdr lists)))))
13249 ;; Get the active file(s) from the backend(s).
13250 (defun gnus-read-active-file ()
13251 (gnus-group-set-mode-line)
13252 (let ((methods (if (gnus-check-server gnus-select-method)
13253 ;; The native server is available.
13254 (cons gnus-select-method gnus-secondary-select-methods)
13255 ;; The native server is down, so we just do the
13257 gnus-secondary-select-methods))
13259 (setq gnus-have-read-active-file nil)
13261 (set-buffer nntp-server-buffer)
13263 (let* ((method (gnus-server-get-method nil (car methods)))
13264 (where (nth 1 method))
13265 (mesg (format "Reading active file%s via %s..."
13266 (if (and where (not (zerop (length where))))
13267 (concat " from " where) "")
13269 (gnus-message 5 mesg)
13270 (if (not (gnus-check-server method))
13272 ;; Request that the backend scan its incoming messages.
13273 (and (gnus-check-backend-function 'request-scan (car method))
13274 (gnus-request-scan nil method))
13276 ((and (eq gnus-read-active-file 'some)
13277 (gnus-check-backend-function 'retrieve-groups (car method)))
13278 (let ((newsrc (cdr gnus-newsrc-alist))
13279 (gmethod (gnus-server-get-method nil method))
13282 (and (gnus-server-equal
13283 (gnus-find-method-for-group
13284 (car (car newsrc)) (car newsrc))
13286 (setq groups (cons (gnus-group-real-name
13287 (car (car newsrc))) groups)))
13288 (setq newsrc (cdr newsrc)))
13289 (gnus-check-server method)
13290 (setq list-type (gnus-retrieve-groups groups method))
13294 1 "Cannot read partial active file from %s server."
13298 ((eq list-type 'active)
13299 (gnus-active-to-gnus-format method gnus-active-hashtb))
13301 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
13303 (if (not (gnus-request-list method))
13305 (gnus-message 1 "Cannot read active file from %s server."
13308 (gnus-active-to-gnus-format method)
13309 ;; We mark this active file as read.
13310 (setq gnus-have-read-active-file
13311 (cons method gnus-have-read-active-file))
13312 (gnus-message 5 "%sdone" mesg))))))
13313 (setq methods (cdr methods))))))
13315 ;; Read an active file and place the results in `gnus-active-hashtb'.
13316 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
13317 (let ((cur (current-buffer))
13319 (if (and gnus-active-hashtb
13320 (not (equal method gnus-select-method)))
13322 (setq gnus-active-hashtb
13323 (if (equal method gnus-select-method)
13324 (gnus-make-hashtable
13325 (count-lines (point-min) (point-max)))
13326 (gnus-make-hashtable 4096))))))
13327 (flag-hashtb (gnus-make-hashtable 60)))
13328 ;; Delete unnecessary lines.
13329 (goto-char (point-min))
13330 (while (search-forward "\nto." nil t)
13331 (delete-region (1+ (match-beginning 0))
13332 (progn (forward-line 1) (point))))
13333 (or (string= gnus-ignored-newsgroups "")
13335 (goto-char (point-min))
13336 (delete-matching-lines gnus-ignored-newsgroups)))
13337 ;; Make the group names readable as a lisp expression even if they
13338 ;; contain special characters.
13339 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
13340 (goto-char (point-max))
13341 (while (re-search-backward "[][';?()#]" nil t)
13343 ;; If these are groups from a foreign select method, we insert the
13344 ;; group prefix in front of the group names.
13345 (and method (not (gnus-server-equal
13346 (gnus-server-get-method nil method)
13347 (gnus-server-get-method nil gnus-select-method)))
13348 (let ((prefix (gnus-group-prefixed-name "" method)))
13349 (goto-char (point-min))
13350 (while (and (not (eobp))
13351 (progn (insert prefix)
13352 (zerop (forward-line 1)))))))
13353 ;; Store the active file in a hash table.
13354 (goto-char (point-min))
13355 (if (string-match "%[oO]" gnus-group-line-format)
13356 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
13357 ;; If we want information on moderated groups, we use this
13359 (let* ((mod-hashtb (make-vector 7 0))
13360 (m (intern "m" mod-hashtb))
13362 (while (not (eobp))
13363 (condition-case nil
13365 (narrow-to-region (point) (gnus-point-at-eol))
13366 (setq group (let ((obarray hashtb)) (read cur)))
13367 (if (and (numberp (setq max (read cur)))
13368 (numberp (setq min (read cur)))
13370 (skip-chars-forward " \t")
13372 (or (= (following-char) ?=)
13373 (= (following-char) ?x)
13374 (= (following-char) ?j)))))
13375 (set group (cons min max))
13377 ;; Enter moderated groups into a list.
13378 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
13379 (setq gnus-moderated-list
13380 (cons (symbol-name group) gnus-moderated-list))))
13387 ;; And if we do not care about moderation, we use this loop,
13388 ;; which is faster.
13389 (let (group max min)
13390 (while (not (eobp))
13393 (narrow-to-region (point) (gnus-point-at-eol))
13394 ;; group gets set to a symbol interned in the hash table
13395 ;; (what a hack!!) - jwz
13396 (setq group (let ((obarray hashtb)) (read cur)))
13397 (if (and (numberp (setq max (read cur)))
13398 (numberp (setq min (read cur)))
13400 (skip-chars-forward " \t")
13402 (or (= (following-char) ?=)
13403 (= (following-char) ?x)
13404 (= (following-char) ?j)))))
13405 (set group (cons min max))
13413 (gnus-message 3 "Warning - illegal active: %s"
13415 (gnus-point-at-bol) (gnus-point-at-eol)))))))
13417 (forward-line 1))))))
13419 (defun gnus-groups-to-gnus-format (method &optional hashtb)
13420 ;; Parse a "groups" active file.
13421 (let ((cur (current-buffer))
13423 (if (and method gnus-active-hashtb)
13425 (setq gnus-active-hashtb
13426 (gnus-make-hashtable
13427 (count-lines (point-min) (point-max)))))))
13428 (prefix (and method
13429 (not (gnus-server-equal
13430 (gnus-server-get-method nil method)
13431 (gnus-server-get-method nil gnus-select-method)))
13432 (gnus-group-prefixed-name "" method))))
13434 (goto-char (point-min))
13435 ;; We split this into to separate loops, one with the prefix
13436 ;; and one without to speed the reading up somewhat.
13438 (let (min max opoint group)
13439 (while (not (eobp))
13442 (read cur) (read cur)
13443 (setq min (read cur)
13446 (skip-chars-forward " \t")
13449 (set (let ((obarray hashtb)) (read cur))
13451 (error (and group (symbolp group) (set group nil))))
13453 (let (min max group)
13454 (while (not (eobp))
13456 (if (= (following-char) ?2)
13458 (read cur) (read cur)
13459 (setq min (read cur)
13461 (set (setq group (let ((obarray hashtb)) (read cur)))
13463 (error (and group (symbolp group) (set group nil))))
13464 (forward-line 1))))))
13466 (defun gnus-read-newsrc-file (&optional force)
13467 "Read startup file.
13468 If FORCE is non-nil, the .newsrc file is read."
13469 ;; Reset variables that might be defined in the .newsrc.eld file.
13470 (let ((variables gnus-variable-list))
13472 (set (car variables) nil)
13473 (setq variables (cdr variables))))
13474 (let* ((newsrc-file gnus-current-startup-file)
13475 (quick-file (concat newsrc-file ".el")))
13477 ;; We always load the .newsrc.eld file. If always contains
13478 ;; much information that can not be gotten from the .newsrc
13479 ;; file (ticked articles, killed groups, foreign methods, etc.)
13480 (gnus-read-newsrc-el-file quick-file)
13483 (and (file-newer-than-file-p newsrc-file quick-file)
13484 (file-newer-than-file-p newsrc-file
13485 (concat quick-file "d")))
13486 (not gnus-newsrc-alist))
13487 ;; We read the .newsrc file. Note that if there if a
13488 ;; .newsrc.eld file exists, it has already been read, and
13489 ;; the `gnus-newsrc-hashtb' has been created. While reading
13490 ;; the .newsrc file, Gnus will only use the information it
13491 ;; can find there for changing the data already read -
13492 ;; ie. reading the .newsrc file will not trash the data
13493 ;; already read (except for read articles).
13495 (gnus-message 5 "Reading %s..." newsrc-file)
13496 (set-buffer (find-file-noselect newsrc-file))
13497 (buffer-disable-undo (current-buffer))
13498 (gnus-newsrc-to-gnus-format)
13499 (kill-buffer (current-buffer))
13500 (gnus-message 5 "Reading %s...done" newsrc-file)))
13502 ;; Read any slave files.
13504 (gnus-master-read-slave-newsrc)))))
13506 (defun gnus-read-newsrc-el-file (file)
13507 (let ((ding-file (concat file "d")))
13508 ;; We always, always read the .eld file.
13509 (gnus-message 5 "Reading %s..." ding-file)
13510 (let (gnus-newsrc-assoc)
13511 (condition-case nil
13512 (load ding-file t t t)
13514 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
13515 (let ((inhibit-quit t))
13516 (gnus-uncompress-newsrc-alist))
13517 (gnus-make-hashtable-from-newsrc-alist)
13518 (if (not (file-newer-than-file-p file ding-file))
13520 ;; Old format quick file
13521 (gnus-message 5 "Reading %s..." file)
13522 ;; The .el file is newer than the .eld file, so we read that one
13524 (gnus-read-old-newsrc-el-file file))))
13526 ;; Parse the old-style quick startup file
13527 (defun gnus-read-old-newsrc-el-file (file)
13528 (let (newsrc killed marked group m)
13530 (let ((gnus-killed-assoc nil)
13531 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
13533 (condition-case nil
13536 (setq newsrc gnus-newsrc-assoc
13537 killed gnus-killed-assoc
13538 marked gnus-marked-assoc)))
13539 (setq gnus-newsrc-alist nil)
13541 (setq group (car newsrc))
13542 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13545 (setcar (nthcdr 2 info) (cdr (cdr group)))
13547 (if (nth 1 group) gnus-level-default-subscribed
13548 gnus-level-default-unsubscribed))
13549 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
13550 (setq gnus-newsrc-alist
13554 (if (nth 1 group) gnus-level-default-subscribed
13555 gnus-level-default-unsubscribed)
13556 (cdr (cdr group))))
13557 gnus-newsrc-alist)))
13558 (if (setq m (assoc (car group) marked))
13559 (setcdr (cdr (cdr info))
13560 (cons (list (cons 'tick (cdr m))) nil))))
13561 (setq newsrc (cdr newsrc)))
13562 (setq newsrc killed)
13564 (setcar newsrc (car (car newsrc)))
13565 (setq newsrc (cdr newsrc)))
13566 (setq gnus-killed-list killed))
13567 ;; The .el file version of this variable does not begin with
13568 ;; "options", while the .eld version does, so we just add it if it
13571 gnus-newsrc-options
13573 (and (not (string-match "^ *options" gnus-newsrc-options))
13574 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
13575 (and (not (string-match "\n$" gnus-newsrc-options))
13576 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
13577 ;; Finally, if we read some options lines, we parse them.
13578 (or (string= gnus-newsrc-options "")
13579 (gnus-newsrc-parse-options gnus-newsrc-options))))
13581 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
13582 (gnus-make-hashtable-from-newsrc-alist)))
13584 (defun gnus-make-newsrc-file (file)
13585 "Make server dependent file name by catenating FILE and server host name."
13586 (let* ((file (expand-file-name file nil))
13587 (real-file (concat file "-" (nth 1 gnus-select-method))))
13588 (if (or (file-exists-p real-file)
13589 (file-exists-p (concat real-file ".el"))
13590 (file-exists-p (concat real-file ".eld")))
13593 (defun gnus-uncompress-newsrc-alist ()
13594 ;; Uncompress all lists of marked articles in the newsrc assoc.
13595 (let ((newsrc gnus-newsrc-alist)
13598 (if (not (setq marked (nth 3 (car newsrc))))
13601 (or (eq 'score (car (car marked)))
13602 (eq 'bookmark (car (car marked)))
13603 (eq 'killed (car (car marked)))
13604 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13605 (setq marked (cdr marked))))
13606 (setq newsrc (cdr newsrc)))))
13608 (defun gnus-compress-newsrc-alist ()
13609 ;; Compress all lists of marked articles in the newsrc assoc.
13610 (let ((newsrc gnus-newsrc-alist)
13613 (if (not (setq marked (nth 3 (car newsrc))))
13616 (or (eq 'score (car (car marked)))
13617 (eq 'bookmark (car (car marked)))
13618 (eq 'killed (car (car marked)))
13619 (setcdr (car marked)
13621 (gnus-compress-sequence
13622 (sort (cdr (car marked)) '<) t)
13623 (error (cdr (car marked))))))
13624 (setq marked (cdr marked))))
13625 (setq newsrc (cdr newsrc)))))
13627 (defun gnus-newsrc-to-gnus-format ()
13628 (setq gnus-newsrc-options "")
13629 (setq gnus-newsrc-options-n nil)
13631 (or gnus-active-hashtb
13632 (setq gnus-active-hashtb (make-vector 4095 0)))
13633 (let ((buf (current-buffer))
13634 (already-read (> (length gnus-newsrc-alist) 1))
13635 group subscribed options-symbol newsrc Options-symbol
13637 (goto-char (point-min))
13638 ;; We intern the symbol `options' in the active hashtb so that we
13639 ;; can `eq' against it later.
13640 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
13641 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
13643 (while (not (eobp))
13644 ;; We first read the first word on the line by narrowing and
13645 ;; then reading into `gnus-active-hashtb'. Most groups will
13646 ;; already exist in that hashtb, so this will save some string
13650 (progn (skip-chars-forward "^ \t!:\n") (point)))
13651 (goto-char (point-min))
13653 (and (/= (point-min) (point-max))
13654 (let ((obarray gnus-active-hashtb)) (read buf))))
13656 ;; Now, the symbol we have read is either `options' or a group
13657 ;; name. If it is an options line, we just add it to a string.
13659 ((or (eq symbol options-symbol)
13660 (eq symbol Options-symbol))
13661 (setq gnus-newsrc-options
13662 ;; This concatting is quite inefficient, but since our
13663 ;; thorough studies show that approx 99.37% of all
13664 ;; .newsrc files only contain a single options line, we
13665 ;; don't give a damn, frankly, my dear.
13666 (concat gnus-newsrc-options
13668 (gnus-point-at-bol)
13669 ;; Options may continue on the next line.
13670 (or (and (re-search-forward "^[^ \t]" nil 'move)
13671 (progn (beginning-of-line) (point)))
13674 (or (boundp symbol) (set symbol nil))
13675 ;; It was a group name.
13676 (setq subscribed (= (following-char) ?:)
13677 group (symbol-name symbol)
13680 ;; If the line ends here, this is clearly a buggy line, so
13681 ;; we put point a the beginning of line and let the cond
13682 ;; below do the error handling.
13683 (beginning-of-line)
13684 ;; We skip to the beginning of the ranges.
13685 (skip-chars-forward "!: \t"))
13686 ;; We are now at the beginning of the list of read articles.
13687 ;; We read them range by range.
13690 ((looking-at "[0-9]+")
13691 ;; We narrow and read a number instead of buffer-substring/
13692 ;; string-to-int because it's faster. narrow/widen is
13693 ;; faster than save-restriction/narrow, and save-restriction
13694 ;; produces a garbage object.
13696 (narrow-to-region (match-beginning 0) (match-end 0))
13699 ;; If the next character is a dash, then this is a range.
13700 (if (= (following-char) ?-)
13702 ;; We read the upper bound of the range.
13704 (if (not (looking-at "[0-9]+"))
13705 ;; This is a buggy line, by we pretend that
13706 ;; it's kinda OK. Perhaps the user should be
13708 (setq reads (cons num1 reads))
13713 (narrow-to-region (match-beginning 0)
13718 ;; It was just a simple number, so we add it to the
13720 (setq reads (cons num1 reads)))
13721 ;; If the next char in ?\n, then we have reached the end
13722 ;; of the line and return nil.
13723 (/= (following-char) ?\n))
13724 ((= (following-char) ?\n)
13725 ;; End of line, so we end.
13728 ;; Not numbers and not eol, so this might be a buggy
13731 ;; If it was eob instead of ?\n, we allow it.
13733 ;; The line was buggy.
13735 (gnus-message 3 "Mangled line: %s"
13736 (buffer-substring (gnus-point-at-bol)
13737 (gnus-point-at-eol)))
13741 ;; Skip past ", ". Spaces are illegal in these ranges, but
13742 ;; we allow them, because it's a common mistake to put a
13743 ;; space after the comma.
13744 (skip-chars-forward ", "))
13746 ;; We have already read .newsrc.eld, so we gently update the
13747 ;; data in the hash table with the information we have just
13751 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
13754 ;; There is an entry for this file in the alist.
13756 (setcar (nthcdr 2 info) (nreverse reads))
13757 ;; We update the level very gently. In fact, we
13758 ;; only change it if there's been a status change
13759 ;; from subscribed to unsubscribed, or vice versa.
13760 (setq level (nth 1 info))
13761 (cond ((and (<= level gnus-level-subscribed)
13763 (setq level (if reads
13764 gnus-level-default-unsubscribed
13765 (1+ gnus-level-default-unsubscribed))))
13766 ((and (> level gnus-level-subscribed) subscribed)
13767 (setq level gnus-level-default-subscribed)))
13768 (setcar (cdr info) level))
13769 ;; This is a new group.
13770 (setq info (list group
13772 gnus-level-default-subscribed
13774 (1+ gnus-level-subscribed)
13775 gnus-level-default-unsubscribed))
13776 (nreverse reads))))
13777 (setq newsrc (cons info newsrc))))))
13780 (setq newsrc (nreverse newsrc))
13782 (if (not already-read)
13784 ;; We now have two newsrc lists - `newsrc', which is what we
13785 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13786 ;; what we've read from .newsrc.eld. We have to merge these
13787 ;; lists. We do this by "attaching" any (foreign) groups in the
13788 ;; gnus-newsrc-alist to the (native) group that precedes them.
13789 (let ((rc (cdr gnus-newsrc-alist))
13790 (prev gnus-newsrc-alist)
13793 (or (null (nth 4 (car rc))) ; It's a native group.
13794 (assoc (car (car rc)) newsrc) ; It's already in the alist.
13795 (if (setq entry (assoc (car (car prev)) newsrc))
13796 (setcdr (setq mentry (memq entry newsrc))
13797 (cons (car rc) (cdr mentry)))
13798 (setq newsrc (cons (car rc) newsrc))))
13802 (setq gnus-newsrc-alist newsrc)
13803 ;; We make the newsrc hashtb.
13804 (gnus-make-hashtable-from-newsrc-alist)
13806 ;; Finally, if we read some options lines, we parse them.
13807 (or (string= gnus-newsrc-options "")
13808 (gnus-newsrc-parse-options gnus-newsrc-options))))
13810 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13811 ;; The return value will be a list on the form
13812 ;; ((regexp1 . ignore)
13813 ;; (regexp2 . subscribe)...)
13814 ;; When handling new newsgroups, groups that match a `ignore' regexp
13815 ;; will be ignored, and groups that match a `subscribe' regexp will be
13816 ;; subscribed. A line like
13817 ;; options -n !all rec.all
13818 ;; will lead to a list that looks like
13819 ;; (("^rec\\..+" . subscribe)
13820 ;; ("^.+" . ignore))
13821 ;; So all "rec.*" groups will be subscribed, while all the other
13822 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13823 ;; different from "options -n rec.all !all".
13824 (defun gnus-newsrc-parse-options (options)
13827 (gnus-set-work-buffer)
13828 (insert (regexp-quote options))
13829 ;; First we treat all continuation lines.
13830 (goto-char (point-min))
13831 (while (re-search-forward "\n[ \t]+" nil t)
13832 (replace-match " " t t))
13833 ;; Then we transform all "all"s into ".+"s.
13834 (goto-char (point-min))
13835 (while (re-search-forward "\\ball\\b" nil t)
13836 (replace-match ".+" t t))
13837 (goto-char (point-min))
13838 ;; We remove all other options than the "-n" ones.
13839 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
13840 (replace-match " ")
13842 (goto-char (point-min))
13844 ;; We are only interested in "options -n" lines - we
13845 ;; ignore the other option lines.
13846 (while (re-search-forward "[ \t]-n" nil t)
13848 (or (save-excursion
13849 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
13851 (gnus-point-at-eol)))
13852 ;; Search for all "words"...
13853 (while (re-search-forward "[^ \t,\n]+" eol t)
13854 (if (= (char-after (match-beginning 0)) ?!)
13855 ;; If the word begins with a bang (!), this is a "not"
13856 ;; spec. We put this spec (minus the bang) and the
13857 ;; symbol `ignore' into the list.
13858 (setq out (cons (cons (concat
13859 "^" (buffer-substring
13860 (1+ (match-beginning 0))
13863 ;; There was no bang, so this is a "yes" spec.
13864 (setq out (cons (cons (concat
13865 "^" (buffer-substring (match-beginning 0)
13867 'subscribe) out)))))
13869 (setq gnus-newsrc-options-n out))))
13872 (defun gnus-save-newsrc-file ()
13873 "Save .newsrc file."
13874 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13875 ;; from the variable gnus-newsrc-alist.
13876 (and (or gnus-newsrc-alist gnus-killed-list)
13877 gnus-current-startup-file
13880 (if (and (or gnus-use-dribble-file gnus-slave)
13881 (or (not gnus-dribble-buffer)
13882 (not (buffer-name gnus-dribble-buffer))
13883 (zerop (save-excursion
13884 (set-buffer gnus-dribble-buffer)
13886 (gnus-message 4 "(No changes need to be saved)")
13887 (run-hooks 'gnus-save-newsrc-hook)
13889 (gnus-slave-save-newsrc)
13890 (if gnus-save-newsrc-file
13892 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
13893 ;; Make backup file of master newsrc.
13894 (gnus-gnus-to-newsrc-format)
13895 (gnus-message 5 "Saving %s...done"
13896 gnus-current-startup-file)))
13897 ;; Quickly loadable .newsrc.
13898 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13899 (setq buffer-file-name
13900 (concat gnus-current-startup-file ".eld"))
13901 (gnus-add-current-to-buffer-list)
13902 (buffer-disable-undo (current-buffer))
13904 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
13905 (gnus-gnus-to-quick-newsrc-format)
13906 (run-hooks 'gnus-save-quick-newsrc-hook)
13908 (kill-buffer (current-buffer))
13910 5 "Saving %s.eld...done" gnus-current-startup-file))
13911 (gnus-dribble-delete-file))))))
13913 (defun gnus-gnus-to-quick-newsrc-format ()
13914 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13915 (insert ";; Gnus startup file.\n")
13916 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13917 (insert ";; to read .newsrc.\n")
13918 (insert "(setq gnus-newsrc-file-version "
13919 (prin1-to-string gnus-version) ")\n")
13920 (let ((variables gnus-variable-list)
13922 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
13924 ;; insert lisp expressions.
13925 (gnus-compress-newsrc-alist)
13927 (setq variable (car variables))
13928 (and (boundp variable)
13929 (symbol-value variable)
13930 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13931 (insert "(setq " (symbol-name variable) " '"
13932 (prin1-to-string (symbol-value variable))
13934 (setq variables (cdr variables)))
13935 (gnus-uncompress-newsrc-alist)))
13937 (defun gnus-gnus-to-newsrc-format ()
13938 ;; Generate and save the .newsrc file.
13939 (let ((newsrc (cdr gnus-newsrc-alist))
13942 (set-buffer (create-file-buffer gnus-current-startup-file))
13943 (setq buffer-file-name gnus-current-startup-file)
13944 (buffer-disable-undo (current-buffer))
13947 (if gnus-newsrc-options (insert gnus-newsrc-options))
13948 ;; Write subscribed and unsubscribed.
13950 (setq info (car newsrc))
13951 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13953 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13955 (if (setq ranges (nth 2 info))
13958 (if (not (listp (cdr ranges)))
13959 (if (= (car ranges) (cdr ranges))
13960 (insert (int-to-string (car ranges)))
13961 (insert (int-to-string (car ranges)) "-"
13962 (int-to-string (cdr ranges))))
13964 (setq range (car ranges)
13965 ranges (cdr ranges))
13966 (if (or (atom range) (= (car range) (cdr range)))
13967 (insert (int-to-string
13968 (or (and (atom range) range)
13970 (insert (int-to-string (car range)) "-"
13971 (int-to-string (cdr range))))
13972 (if ranges (insert ","))))))
13974 (setq newsrc (cdr newsrc)))
13975 ;; It has been reported that sometime the modtime on the .newsrc
13976 ;; file seems to be off. We really do want to overwrite it, so
13977 ;; we clear the modtime here before saving. It's a bit odd,
13979 ;; sometimes the modtime clear isn't sufficient. most brute force:
13980 ;; delete the silly thing entirely first. but this fails to provide
13981 ;; such niceties as .newsrc~ creation.
13982 (if gnus-modtime-botch
13983 (delete-file gnus-startup-file)
13984 (clear-visited-file-modtime))
13985 (run-hooks 'gnus-save-standard-newsrc-hook)
13987 (kill-buffer (current-buffer)))))
13990 ;;; Slave functions.
13992 (defun gnus-slave-save-newsrc ()
13994 (set-buffer gnus-dribble-buffer)
13996 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
13997 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
13999 (defun gnus-master-read-slave-newsrc ()
14002 (file-name-directory gnus-current-startup-file)
14006 (file-name-nondirectory gnus-current-startup-file)
14010 (if (not slave-files)
14011 () ; There are no slave files to read.
14012 (gnus-message 7 "Reading slave newsrcs...")
14014 (set-buffer (get-buffer-create " *gnus slave*"))
14015 (buffer-disable-undo (current-buffer))
14017 (sort (mapcar (lambda (file)
14018 (list (nth 5 (file-attributes file)) file))
14021 (or (< (car (car f1)) (car (car f2)))
14022 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
14025 (setq file (nth 1 (car slave-files)))
14026 (insert-file-contents file)
14027 (if (condition-case ()
14029 (eval-buffer (current-buffer))
14032 (message "Possible error in %s" file)
14036 (or gnus-slave ; Slaves shouldn't delete these files.
14040 (setq slave-files (cdr slave-files))))
14041 (gnus-message 7 "Reading slave newsrcs...done"))))
14044 ;;; Group description.
14046 (defun gnus-read-all-descriptions-files ()
14047 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
14049 (gnus-read-descriptions-file (car methods))
14050 (setq methods (cdr methods)))
14053 (defun gnus-read-descriptions-file (&optional method)
14054 (let ((method (or method gnus-select-method)))
14055 ;; We create the hashtable whether we manage to read the desc file
14056 ;; to avoid trying to re-read after a failed read.
14057 (or gnus-description-hashtb
14058 (setq gnus-description-hashtb
14059 (gnus-make-hashtable (length gnus-active-hashtb))))
14060 ;; Mark this method's desc file as read.
14061 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
14062 gnus-description-hashtb)
14064 (gnus-message 5 "Reading descriptions file via %s..." (car method))
14066 ((not (gnus-check-server method))
14067 (gnus-message 1 "Couldn't open server")
14069 ((not (gnus-request-list-newsgroups method))
14070 (gnus-message 1 "Couldn't read newsgroups descriptions")
14076 (set-buffer nntp-server-buffer)
14077 (goto-char (point-min))
14078 (if (or (search-forward "\n.\n" nil t)
14079 (goto-char (point-max)))
14081 (beginning-of-line)
14082 (narrow-to-region (point-min) (point))))
14083 (goto-char (point-min))
14084 (while (not (eobp))
14085 ;; If we get an error, we set group to 0, which is not a
14089 (let ((obarray gnus-description-hashtb))
14090 ;; Group is set to a symbol interned in this
14092 (read nntp-server-buffer))
14094 (skip-chars-forward " \t")
14095 ;; ... which leads to this line being effectively ignored.
14096 (and (symbolp group)
14097 (set group (buffer-substring
14098 (point) (progn (end-of-line) (point)))))
14099 (forward-line 1))))
14100 (gnus-message 5 "Reading descriptions file...done")
14103 (defun gnus-group-get-description (group)
14104 ;; Get the description of a group by sending XGTITLE to the server.
14105 (and (gnus-request-group-description group)
14107 (set-buffer nntp-server-buffer)
14108 (goto-char (point-min))
14109 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
14110 (buffer-substring (match-beginning 1) (match-end 1))))))
14116 (defvar gnus-server-mode-hook nil
14117 "Hook run in `gnus-server-mode' buffers.")
14119 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
14120 "Format of server lines.
14121 It works along the same lines as a normal formatting string,
14122 with some simple extensions.")
14124 (defvar gnus-server-mode-line-format "Gnus List of servers"
14125 "The format specification for the server mode line.")
14127 (defconst gnus-server-line-format-alist
14128 (list (list ?h 'how ?s)
14130 (list ?w 'where ?s)
14133 (defconst gnus-server-mode-line-format-alist
14134 (list (list ?S 'news-server ?s)
14135 (list ?M 'news-method ?s)
14136 (list ?u 'user-defined ?s)))
14138 (defvar gnus-server-line-format-spec nil)
14139 (defvar gnus-server-mode-line-format-spec nil)
14140 (defvar gnus-server-killed-servers nil)
14142 (defvar gnus-server-mode-map nil)
14143 (put 'gnus-server-mode 'mode-class 'special)
14145 (if gnus-server-mode-map
14147 (setq gnus-server-mode-map (make-sparse-keymap))
14148 (suppress-keymap gnus-server-mode-map)
14149 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
14150 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
14151 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
14152 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
14153 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
14154 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
14155 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
14156 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
14157 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
14158 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
14160 (defun gnus-server-mode ()
14161 "Major mode for listing and editing servers.
14163 All normal editing commands are switched off.
14164 \\<gnus-server-mode-map>
14166 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
14168 The following commands are available:
14170 \\{gnus-server-mode-map}"
14172 (if (gnus-visual-p 'server-menu 'menu) (gnus-server-make-menu-bar))
14173 (kill-all-local-variables)
14174 (setq mode-line-modified "-- ")
14175 (make-local-variable 'mode-line-format)
14176 (setq mode-line-format (copy-sequence mode-line-format))
14177 (and (equal (nth 3 mode-line-format) " ")
14178 (setcar (nthcdr 3 mode-line-format) ""))
14179 (setq major-mode 'gnus-server-mode)
14180 (setq mode-name "Server")
14181 ; (gnus-group-set-mode-line)
14182 (setq mode-line-process nil)
14183 (use-local-map gnus-server-mode-map)
14184 (buffer-disable-undo (current-buffer))
14185 (setq truncate-lines t)
14186 (setq buffer-read-only t)
14187 (run-hooks 'gnus-server-mode-hook))
14189 (defun gnus-server-insert-server-line (sformat name method)
14190 (let* ((sformat (or sformat gnus-server-line-format-spec))
14192 (where (nth 1 method))
14194 (beginning-of-line)
14196 ;; Insert the text.
14197 (insert (eval sformat))
14198 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
14200 (defun gnus-server-setup-buffer ()
14201 (if (get-buffer gnus-server-buffer)
14204 (set-buffer (get-buffer-create gnus-server-buffer))
14206 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
14208 (defun gnus-server-prepare ()
14209 (setq gnus-server-mode-line-format-spec
14210 (gnus-parse-format gnus-server-mode-line-format
14211 gnus-server-mode-line-format-alist))
14212 (setq gnus-server-line-format-spec
14213 (gnus-parse-format gnus-server-line-format
14214 gnus-server-line-format-alist))
14215 (let ((alist gnus-server-alist)
14216 (buffer-read-only nil))
14219 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
14220 (setq alist (cdr alist))))
14221 (goto-char (point-min))
14222 (gnus-server-position-point))
14224 (defun gnus-server-server-name ()
14225 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
14226 (and server (symbol-name server))))
14228 (defalias 'gnus-server-position-point 'gnus-goto-colon)
14230 (defconst gnus-server-edit-buffer "*Gnus edit server*")
14232 (defun gnus-server-update-server (server)
14234 (set-buffer gnus-server-buffer)
14235 (let ((buffer-read-only nil)
14236 (info (cdr (assoc server gnus-server-alist))))
14237 (gnus-dribble-enter
14238 (concat "(gnus-server-set-info \"" server "\" '"
14239 (prin1-to-string info) ")"))
14240 ;; Buffer may be narrowed.
14243 (if (gnus-server-goto-server server)
14244 (delete-region (progn (beginning-of-line) (point))
14245 (progn (forward-line 1) (point))))
14246 (let ((entry (assoc server gnus-server-alist)))
14247 (gnus-server-insert-server-line nil (car entry) (cdr entry))
14248 (gnus-server-position-point))))))
14250 (defun gnus-server-set-info (server info)
14251 ;; Enter a select method into the virtual server alist.
14252 (gnus-dribble-enter
14253 (concat "(gnus-server-set-info \"" server "\" '"
14254 (prin1-to-string info) ")"))
14255 (let* ((server (nth 1 info))
14256 (entry (assoc server gnus-server-alist)))
14257 (if entry (setcdr entry info)
14258 (setq gnus-server-alist
14259 (nconc gnus-server-alist (list (cons server info)))))))
14261 (defun gnus-server-to-method (server)
14262 ;; Map virtual server names to select methods.
14263 (or (and (equal server "native") gnus-select-method)
14264 (cdr (assoc server gnus-server-alist))))
14266 (defun gnus-server-extend-method (group method)
14267 ;; This function "extends" a virtual server. If the server is
14268 ;; "hello", and the select method is ("hello" (my-var "something"))
14269 ;; in the group "alt.alt", this will result in a new virtual server
14270 ;; called "helly+alt.alt".
14272 (gnus-copy-sequence
14273 (if (equal (car method) "native") gnus-select-method
14274 (cdr (assoc (car method) gnus-server-alist))))))
14275 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14276 (nconc entry (cdr method))))
14278 (defun gnus-server-get-method (group method)
14279 ;; Input either a server name, and extended server name, or a
14280 ;; select method, and return a select method.
14281 (cond ((stringp method)
14282 (gnus-server-to-method method))
14283 ((and (stringp (car method)) group)
14284 (gnus-server-extend-method group method))
14286 (gnus-server-add-address method))))
14288 (defun gnus-server-add-address (method)
14289 (let ((method-name (symbol-name (car method))))
14290 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
14291 (not (assq (intern (concat method-name "-address")) method)))
14292 (append method (list (list (intern (concat method-name "-address"))
14296 (defun gnus-server-equal (s1 s2)
14298 (and (= (length s1) (length s2))
14300 (while (and s1 (member (car s1) s2))
14301 (setq s1 (cdr s1)))
14304 ;;; Interactive server functions.
14306 (defun gnus-server-kill-server (server)
14307 "Kill the server on the current line."
14308 (interactive (list (gnus-server-server-name)))
14309 (or (gnus-server-goto-server server)
14310 (if server (error "No such server: %s" server)
14311 (error "No server on the current line")))
14312 (gnus-dribble-enter "")
14313 (let ((buffer-read-only nil))
14314 (delete-region (progn (beginning-of-line) (point))
14315 (progn (forward-line 1) (point))))
14316 (setq gnus-server-killed-servers
14317 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
14318 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
14319 gnus-server-alist))
14320 (gnus-server-position-point))
14322 (defun gnus-server-yank-server ()
14323 "Yank the previously killed server."
14325 (or gnus-server-killed-servers
14326 (error "No killed servers to be yanked"))
14327 (let ((alist gnus-server-alist)
14328 (server (gnus-server-server-name))
14329 (killed (car gnus-server-killed-servers)))
14331 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
14332 (if (string= server (car (car gnus-server-alist)))
14333 (setq gnus-server-alist (cons killed gnus-server-alist))
14334 (while (and (cdr alist)
14335 (not (string= server (car (car (cdr alist))))))
14336 (setq alist (cdr alist)))
14337 (setcdr alist (cons killed (cdr alist)))))
14338 (gnus-server-update-server (car killed))
14339 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
14340 (gnus-server-position-point)))
14342 (defun gnus-server-exit ()
14343 "Return to the group buffer."
14345 (kill-buffer (current-buffer))
14346 (switch-to-buffer gnus-group-buffer))
14348 (defun gnus-server-list-servers ()
14349 "List all available servers."
14351 (let ((cur (gnus-server-server-name)))
14352 (gnus-server-prepare)
14353 (if cur (gnus-server-goto-server cur)
14354 (goto-char (point-max))
14356 (gnus-server-position-point)))
14358 (defun gnus-server-copy-server (from to)
14361 (or (gnus-server-server-name)
14362 (error "No server on the current line"))
14363 (read-string "Copy to: ")))
14364 (or from (error "No server on current line"))
14365 (or (and to (not (string= to ""))) (error "No name to copy to"))
14366 (and (assoc to gnus-server-alist) (error "%s already exists" to))
14367 (or (assoc from gnus-server-alist)
14368 (error "%s: no such server" from))
14369 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
14370 (setcar to-entry to)
14371 (setcar (nthcdr 2 to-entry) to)
14372 (setq gnus-server-killed-servers
14373 (cons to-entry gnus-server-killed-servers))
14374 (gnus-server-yank-server)))
14376 (defun gnus-server-add-server (how where)
14378 (list (intern (completing-read "Server method: "
14379 gnus-valid-select-methods nil t))
14380 (read-string "Server name: ")))
14381 (setq gnus-server-killed-servers
14382 (cons (list where how where) gnus-server-killed-servers))
14383 (gnus-server-yank-server))
14385 (defun gnus-server-goto-server (server)
14386 "Jump to a server line."
14388 (list (completing-read "Goto server: " gnus-server-alist nil t)))
14389 (let ((to (text-property-any (point-min) (point-max)
14390 'gnus-server (intern server))))
14394 (gnus-server-position-point)))))
14396 (defun gnus-server-edit-server (server)
14397 "Edit the server on the current line."
14398 (interactive (list (gnus-server-server-name)))
14400 (error "No server on current line"))
14401 (let ((winconf (current-window-configuration)))
14402 (get-buffer-create gnus-server-edit-buffer)
14403 (gnus-configure-windows 'edit-server)
14404 (gnus-add-current-to-buffer-list)
14406 (make-local-variable 'gnus-prev-winconf)
14407 (setq gnus-prev-winconf winconf)
14408 (use-local-map (copy-keymap (current-local-map)))
14409 (let ((done-func '(lambda ()
14410 "Exit editing mode and update the information."
14412 (gnus-server-edit-server-done 'group))))
14413 (setcar (cdr (nth 4 done-func)) server)
14414 (local-set-key "\C-c\C-c" done-func))
14416 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
14417 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
14419 (defun gnus-server-edit-server-done (server)
14421 (set-buffer (get-buffer-create gnus-server-edit-buffer))
14422 (goto-char (point-min))
14423 (let ((form (read (current-buffer)))
14424 (winconf gnus-prev-winconf))
14425 (gnus-server-set-info server form)
14426 (kill-buffer (current-buffer))
14427 (and winconf (set-window-configuration winconf))
14428 (set-buffer gnus-server-buffer)
14429 (gnus-server-update-server (gnus-server-server-name))
14430 (gnus-server-list-servers)
14431 (gnus-server-position-point)))
14433 (defun gnus-server-read-server (server)
14435 (interactive (list (gnus-server-server-name)))
14436 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
14438 (defun gnus-mouse-pick-server (e)
14440 (mouse-set-point e)
14441 (gnus-server-read-server (gnus-server-server-name)))
14444 ;;; entry points into gnus-score.el
14447 ;;; Finding score files.
14449 (defvar gnus-global-score-files nil
14450 "*List of global score files and directories.
14451 Set this variable if you want to use people's score files. One entry
14452 for each score file or each score file directory. Gnus will decide
14453 by itself what score files are applicable to which group.
14455 Say you want to use the single score file
14456 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
14457 score files in the \"/ftp.some-where:/pub/score\" directory.
14459 (setq gnus-global-score-files
14460 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
14461 \"/ftp.some-where:/pub/score\"))")
14463 (defun gnus-score-score-files (group)
14464 "Return a list of all possible score files."
14465 ;; Search and set any global score files.
14466 (and gnus-global-score-files
14467 (or gnus-internal-global-score-files
14468 (gnus-score-search-global-directories gnus-global-score-files)))
14469 ;; Fix the kill-file dir variable.
14470 (setq gnus-kill-files-directory
14471 (file-name-as-directory
14472 (or gnus-kill-files-directory "~/News/")))
14473 ;; If we can't read it, there are no score files.
14474 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
14475 (setq gnus-score-file-list nil)
14476 (if (gnus-use-long-file-name 'not-score)
14477 ;; We want long file names.
14478 (if (or (not gnus-score-file-list)
14479 (not (car gnus-score-file-list))
14480 (gnus-file-newer-than gnus-kill-files-directory
14481 (car gnus-score-file-list)))
14482 (setq gnus-score-file-list
14483 (cons (nth 5 (file-attributes gnus-kill-files-directory))
14486 gnus-kill-files-directory t
14487 (gnus-score-file-regexp))))))
14488 ;; We do not use long file names, so we have to do some
14489 ;; directory traversing.
14490 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
14491 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
14494 (setq dir (expand-file-name
14495 (concat gnus-kill-files-directory
14496 (gnus-replace-chars-in-string group ?. ?/))))
14497 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
14498 (setq suffix (car suffixes)
14499 suffixes (cdr suffixes))
14500 (if (file-exists-p (concat dir "/" suffix))
14501 (setq files (cons (concat dir "/" suffix) files)))
14502 (while (>= (1+ (length dir)) mdir)
14503 (and (file-exists-p (concat dir "/all/" suffix))
14504 (setq files (cons (concat dir "/all/" suffix) files)))
14505 (string-match "/[^/]*$" dir)
14506 (setq dir (substring dir 0 (match-beginning 0)))))
14507 (setq gnus-score-file-list
14508 (cons nil (nreverse files)))))
14509 (cdr gnus-score-file-list)))
14511 (defun gnus-score-file-regexp ()
14512 (concat "\\(" gnus-score-file-suffix
14513 "\\|" gnus-adaptive-file-suffix "\\)$"))
14515 (defun gnus-score-find-bnews (group)
14516 "Return a list of score files for GROUP.
14517 The score files are those files in the ~/News directory which matches
14518 GROUP using BNews sys file syntax."
14519 (let* ((sfiles (append (gnus-score-score-files group)
14520 gnus-internal-global-score-files))
14521 (kill-dir (file-name-as-directory
14522 (expand-file-name gnus-kill-files-directory)))
14523 (klen (length kill-dir))
14524 ofiles not-match regexp)
14526 (set-buffer (get-buffer-create "*gnus score files*"))
14527 (buffer-disable-undo (current-buffer))
14528 ;; Go through all score file names and create regexp with them
14532 (insert (car sfiles))
14533 (goto-char (point-min))
14534 ;; First remove the suffix itself.
14535 (re-search-forward (concat "." (gnus-score-file-regexp)))
14536 (replace-match "" t t)
14537 (goto-char (point-min))
14538 (if (looking-at (regexp-quote kill-dir))
14539 ;; If the file name was just "SCORE", `klen' is one character
14541 (delete-char (min (1- (point-max)) klen))
14542 (goto-char (point-max))
14543 (search-backward "/")
14544 (delete-region (1+ (point)) (point-min)))
14545 ;; If short file names were used, we have to translate slashes.
14546 (goto-char (point-min))
14547 (while (re-search-forward "[/:]" nil t)
14548 (replace-match "." t t))
14549 ;; Cludge to get rid of "nntp+" problems.
14550 (goto-char (point-min))
14551 (and (looking-at "nn[a-z]+\\+")
14553 (search-forward "+")
14556 ;; Translate "all" to ".*".
14557 (while (search-forward "all" nil t)
14558 (replace-match ".*" t t))
14559 (goto-char (point-min))
14560 ;; Deal with "not."s.
14561 (if (looking-at "not.")
14564 (setq regexp (buffer-substring 5 (point-max))))
14565 (setq regexp (buffer-substring 1 (point-max)))
14566 (setq not-match nil))
14567 ;; Finally - if this resulting regexp matches the group name,
14568 ;; we add this score file to the list of score files
14569 ;; applicable to this group.
14570 (if (or (and not-match
14571 (not (string-match regexp group)))
14572 (and (not not-match)
14573 (string-match regexp group)))
14574 (setq ofiles (cons (car sfiles) ofiles)))
14575 (setq sfiles (cdr sfiles)))
14576 (kill-buffer (current-buffer))
14577 ;; Slight kludge here - the last score file returned should be
14578 ;; the local score file, whether it exists or not. This is so
14579 ;; that any score commands the user enters will go to the right
14580 ;; file, and not end up in some global score file.
14583 (if (gnus-use-long-file-name 'not-score)
14584 (concat gnus-kill-files-directory group "."
14585 gnus-score-file-suffix)
14586 (concat gnus-kill-files-directory
14587 (gnus-replace-chars-in-string group ?. ?/ ?: ?/)
14588 "/" gnus-score-file-suffix)))))
14589 (and (member localscore ofiles)
14590 (delete localscore ofiles))
14591 (setq ofiles (cons localscore ofiles)))
14592 (nreverse ofiles))))
14594 (defun gnus-score-find-single (group)
14595 "Return list containing the score file for GROUP."
14596 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
14597 (gnus-score-file-name group)))
14599 (defun gnus-score-find-hierarchical (group)
14600 "Return list of score files for GROUP.
14601 This includes the score file for the group and all its parents."
14602 (let ((all (copy-sequence '(nil)))
14604 (while (string-match "\\." group (1+ start))
14605 (setq start (match-beginning 0))
14606 (setq all (cons (substring group 0 start) all)))
14607 (setq all (cons group all))
14609 (mapcar (lambda (newsgroup)
14610 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
14611 (setq all (nreverse all)))
14612 (mapcar 'gnus-score-file-name all))))
14614 (defvar gnus-score-file-alist-cache nil)
14616 (defun gnus-score-find-alist (group)
14617 "Return list of score files for GROUP.
14618 The list is determined from the variable gnus-score-file-alist."
14619 (let ((alist gnus-score-file-multiple-match-alist)
14621 ;; if this group has been seen before, return the cached entry
14622 (if (setq score-files (assoc group gnus-score-file-alist-cache))
14623 (cdr score-files) ;ensures caching groups with no matches
14624 ;; handle the multiple match alist
14626 (and (string-match (car (car alist)) group)
14628 (nconc score-files (copy-sequence (cdr (car alist))))))
14629 (setq alist (cdr alist)))
14630 (setq alist gnus-score-file-single-match-alist)
14631 ;; handle the single match alist
14633 (and (string-match (car (car alist)) group)
14634 ;; progn used just in case ("regexp") has no files
14635 ;; and score-files is still nil. -sj
14636 ;; this can be construed as a "stop searching here" feature :>
14637 ;; and used to simplify regexps in the single-alist
14640 (nconc score-files (copy-sequence (cdr (car alist)))))
14642 (setq alist (cdr alist)))
14643 ;; cache the score files
14644 (setq gnus-score-file-alist-cache
14645 (cons (cons group score-files) gnus-score-file-alist-cache))
14649 (defun gnus-possibly-score-headers (&optional trace)
14650 (let ((func gnus-score-find-score-files-function)
14654 (setq func (list func)))
14655 ;; Go through all the functions for finding score files (or actual
14656 ;; scores) and add them to a list.
14657 (and func (setq score-files (gnus-score-find-alist gnus-newsgroup-name)))
14659 (and (symbolp (car func))
14660 (fboundp (car func))
14662 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
14663 (setq func (cdr func)))
14664 (if score-files (gnus-score-headers score-files trace))))
14666 (defun gnus-score-file-name (newsgroup &optional suffix)
14667 "Return the name of a score file for NEWSGROUP."
14668 (let ((suffix (or suffix gnus-score-file-suffix)))
14670 ((or (null newsgroup)
14671 (string-equal newsgroup ""))
14672 ;; The global score file is placed at top of the directory.
14674 suffix (or gnus-kill-files-directory "~/News")))
14675 ((gnus-use-long-file-name 'not-score)
14676 ;; Append ".SCORE" to newsgroup name.
14677 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
14679 (or gnus-kill-files-directory "~/News")))
14681 ;; Place "SCORE" under the hierarchical directory.
14682 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14684 (or gnus-kill-files-directory "~/News"))))))
14686 (defun gnus-score-search-global-directories (files)
14687 "Scan all global score directories for score files."
14688 ;; Set the variable `gnus-internal-global-score-files' to all
14689 ;; available global score files.
14690 (interactive (list gnus-global-score-files))
14693 (if (string-match "/$" (car files))
14694 (setq out (nconc (directory-files
14696 (concat (gnus-score-file-regexp) "$"))))
14697 (setq out (cons (car files) out)))
14698 (setq files (cdr files)))
14699 (setq gnus-internal-global-score-files out)))
14701 ;; Allow redefinition of Gnus functions.
14703 (gnus-ems-redefine)
14707 ;;; gnus.el ends here