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.5"
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))))
3417 (defvar gnus-tmp-prev-perm nil)
3420 (defun gnus-no-server (&optional arg)
3422 If ARG is a positive number, Gnus will use that as the
3423 startup level. If ARG is nil, Gnus will be started at level 2.
3424 If ARG is non-nil and not a positive number, Gnus will
3425 prompt the user for the name of an NNTP server to use.
3426 As opposed to `gnus', this command will not connect to the local server."
3429 (cons gnus-group-use-permanent-levels gnus-group-default-list-level)))
3430 (setq gnus-tmp-prev-perm nil)
3431 (setq gnus-group-use-permanent-levels t)
3432 (gnus (or arg (1- gnus-level-default-subscribed)) t)
3433 (setq gnus-tmp-prev-perm perm)))
3436 (defun gnus-slave (&optional arg)
3437 "Read news as a slave."
3439 (gnus arg nil 'slave))
3442 (defun gnus (&optional arg dont-connect slave)
3444 If ARG is non-nil and a positive number, Gnus will use that as the
3445 startup level. If ARG is non-nil and not a positive number, Gnus will
3446 prompt the user for the name of an NNTP server to use."
3448 (if (get-buffer gnus-group-buffer)
3450 (switch-to-buffer gnus-group-buffer)
3451 (gnus-group-get-new-news))
3455 (nnheader-init-server-buffer)
3456 ;; We do this if `gnus-no-server' has been run.
3457 (if gnus-tmp-prev-perm
3458 (setq gnus-group-use-permanent-levels (car gnus-tmp-prev-perm)
3459 gnus-group-default-list-level (cdr gnus-tmp-prev-perm)
3460 gnus-tmp-prev-perm nil))
3461 (gnus-read-init-file)
3463 (setq gnus-slave slave)
3465 (gnus-group-setup-buffer)
3466 (let ((buffer-read-only nil))
3468 (if (not gnus-inhibit-startup-message)
3470 (gnus-group-startup-message)
3473 (let ((level (and arg (numberp arg) (> arg 0) arg))
3479 (gnus-start-news-server (and arg (not level))))))
3480 (if (and (not dont-connect)
3483 (run-hooks 'gnus-startup-hook)
3484 ;; NNTP server is successfully open.
3486 ;; Find the current startup file name.
3487 (setq gnus-current-startup-file
3488 (gnus-make-newsrc-file gnus-startup-file))
3490 ;; Read the dribble file.
3491 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
3493 (gnus-summary-make-display-table)
3494 (gnus-setup-news nil level)
3495 (gnus-group-list-groups level)
3496 (gnus-configure-windows 'group))))))
3498 (defun gnus-unload ()
3499 "Unload all Gnus features."
3501 (or (boundp 'load-history)
3502 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
3503 (let ((history load-history)
3506 (and (string-match "^gnus" (car (car history)))
3507 (setq feature (cdr (assq 'provide (car history))))
3508 (unload-feature feature 'force))
3509 (setq history (cdr history)))))
3511 (defun gnus-indent-rigidly (start end arg)
3514 (narrow-to-region start end)
3515 (indent-rigidly start end arg)
3516 (goto-char (point-min))
3517 (while (search-forward "\t" nil t)
3518 (replace-match " " t t)))))
3520 (defun gnus-group-startup-message (&optional x y)
3521 "Insert startup message in current buffer."
3522 ;; Insert the message.
3527 _ ___ __ ___ __ _ ___
3546 ;; And then hack it.
3547 (gnus-indent-rigidly (point-min) (point-max)
3548 (/ (max (- (window-width) (or x 46)) 0) 2))
3549 (goto-char (point-min))
3551 (let* ((pheight (count-lines (point-min) (point-max)))
3552 (wheight (window-height))
3553 (rest (- wheight pheight)))
3554 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
3556 (goto-char (point-min))
3557 (and (search-forward "Praxis" nil t)
3558 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
3559 (goto-char (point-min)))
3561 (defun gnus-group-startup-message-old (&optional x y)
3562 "Insert startup message in current buffer."
3563 ;; Insert the message.
3579 ;; And then hack it.
3580 ;; 18 is the longest line.
3581 (indent-rigidly (point-min) (point-max)
3582 (/ (max (- (window-width) (or x 28)) 0) 2))
3583 (goto-char (point-min))
3584 ;; +4 is fuzzy factor.
3585 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3588 (goto-char (point-min))
3589 (search-forward "Praxis")
3590 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3591 (goto-char (point-min)))
3593 (defun gnus-group-setup-buffer ()
3594 (or (get-buffer gnus-group-buffer)
3596 (switch-to-buffer gnus-group-buffer)
3597 (gnus-add-current-to-buffer-list)
3599 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3601 (defun gnus-group-list-groups (&optional level unread)
3602 "List newsgroups with level LEVEL or lower that have unread articles.
3603 Default is all subscribed groups.
3604 If argument UNREAD is non-nil, groups with no unread articles are also
3606 (interactive (list (if current-prefix-arg
3607 (prefix-numeric-value current-prefix-arg)
3609 (gnus-group-default-level nil t)
3610 gnus-group-default-list-level
3611 gnus-level-subscribed))))
3613 (setq level (car gnus-group-list-mode)
3614 unread (cdr gnus-group-list-mode)))
3615 (setq level (gnus-group-default-level level))
3616 (gnus-group-setup-buffer) ;May call from out of group buffer
3617 (let ((case-fold-search nil)
3618 (group (gnus-group-group-name)))
3619 (funcall gnus-group-prepare-function level unread nil)
3620 (if (zerop (buffer-size))
3621 (gnus-message 5 gnus-no-groups-message)
3622 (goto-char (point-min))
3624 ;; Go to the first group with unread articles.
3625 (gnus-group-search-forward nil nil nil t)
3626 ;; Find the right group to put point on. If the current group
3627 ;; has disapeared in the new listing, try to find the next
3628 ;; one. If no next one can be found, just leave point at the
3629 ;; first newsgroup in the buffer.
3630 (if (not (gnus-goto-char
3631 (text-property-any (point-min) (point-max)
3632 'gnus-group (intern group))))
3633 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3635 (not (gnus-goto-char
3637 (point-min) (point-max) 'gnus-group
3638 (intern (car (car newsrc)))))))
3639 (setq newsrc (cdr newsrc)))
3640 (or newsrc (progn (goto-char (point-max))
3641 (forward-line -1))))))
3642 ;; Adjust cursor point.
3643 (gnus-group-position-point))))
3645 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3646 "List all newsgroups with unread articles of level LEVEL or lower.
3647 If ALL is non-nil, list groups that have no unread articles.
3648 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3649 If REGEXP, only list groups matching REGEXP."
3650 (set-buffer gnus-group-buffer)
3651 (let ((buffer-read-only nil)
3652 (newsrc (cdr gnus-newsrc-alist))
3653 (lowest (or lowest 1))
3654 info clevel unread group)
3656 (if (< lowest gnus-level-zombie)
3657 ;; List living groups.
3659 (setq info (car newsrc)
3662 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3663 (and unread ; This group might be bogus
3665 (string-match regexp group))
3666 (<= (setq clevel (car (cdr info))) level)
3668 (or all ; We list all groups?
3669 (eq unread t) ; We list unactivated groups
3670 (> unread 0) ; We list groups with unread articles
3671 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3672 (gnus-group-insert-group-line
3673 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3675 ;; List dead groups.
3676 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3677 (gnus-group-prepare-flat-list-dead
3678 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3679 gnus-level-zombie ?Z
3681 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3682 (gnus-group-prepare-flat-list-dead
3683 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3684 gnus-level-killed ?K regexp))
3686 (gnus-group-set-mode-line)
3687 (setq gnus-group-list-mode (cons level all))
3688 (run-hooks 'gnus-group-prepare-hook)))
3690 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3691 ;; List zombies and killed lists somehwat faster, which was
3692 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3693 ;; this by ignoring the group format specification altogether.
3696 (setq group (car groups)
3697 groups (cdr groups))
3698 (if (or (not regexp)
3699 (string-match regexp group))
3702 (insert (format " %c *: %s\n" mark group))
3703 (add-text-properties
3705 (list 'gnus-group (intern group)
3707 'gnus-level level)))))))
3709 (defun gnus-group-real-name (group)
3710 "Find the real name of a foreign newsgroup."
3711 (if (string-match ":[^:]+$" group)
3712 (substring group (1+ (match-beginning 0)))
3715 (defun gnus-group-prefixed-name (group method)
3716 "Return the whole name from GROUP and METHOD."
3717 (and (stringp method) (setq method (gnus-server-to-method method)))
3718 (concat (format "%s" (car method))
3720 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3721 (not (string= (nth 1 method) "")))
3722 (concat "+" (nth 1 method)))
3725 (defun gnus-group-real-prefix (group)
3726 "Return the prefix of the current group name."
3727 (if (string-match "^[^:]+:" group)
3728 (substring group 0 (match-end 0))
3731 (defun gnus-group-method-name (group)
3732 "Return the method used for selecting GROUP."
3733 (let ((prefix (gnus-group-real-prefix group)))
3734 (if (equal prefix "")
3736 (if (string-match "^[^\\+]+\\+" prefix)
3737 (list (intern (substring prefix 0 (1- (match-end 0))))
3738 (substring prefix (match-end 0) (1- (length prefix))))
3739 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3741 (defun gnus-group-foreign-p (group)
3742 "Return nil if GROUP is native, non-nil if it is foreign."
3743 (string-match ":" group))
3745 (defun gnus-group-topic-p ()
3746 "Return non-nil if the current line is a topic."
3747 (get-text-property (gnus-point-at-bol) 'gnus-topic))
3749 (defun gnus-group-add-parameter (group param)
3750 "Add parameter PARAM to GROUP."
3751 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
3753 () ; This is a dead group. We just ignore it.
3754 ;; Cons the new param to the old one and update.
3755 (gnus-group-set-info (cons param (nth 5 info)) group 'params))))
3757 (defun gnus-group-set-info (info &optional method-only-group part)
3758 (let* ((entry (gnus-gethash
3759 (or method-only-group (car info)) gnus-newsrc-hashtb))
3761 (info (if method-only-group (nth 2 entry) info)))
3762 (if (not method-only-group)
3765 (error "Trying to change non-existent group %s" method-only-group))
3766 ;; We have recevied parts of the actual group info - either the
3767 ;; select method or the group parameters. We first check
3768 ;; whether we have to extend the info, and if so, do that.
3769 (let ((len (length info))
3770 (total (if (eq part 'method) 5 6)))
3772 (setcdr (nthcdr (1- len) info)
3773 (make-list (- total len) nil)))
3774 ;; Then we enter the new info.
3775 (setcar (nthcdr (1- total) info) part-info)))
3776 ;; We uncompress some lists of marked articles.
3778 (if (not (setq marked (nth 3 info)))
3781 (or (eq 'score (car (car marked)))
3782 (eq 'bookmark (car (car marked)))
3783 (eq 'killed (car (car marked)))
3784 (setcdr (car marked)
3785 (gnus-uncompress-range (cdr (car marked)))))
3786 (setq marked (cdr marked)))))
3789 ;; This is a new group, so we just create it.
3791 (set-buffer gnus-group-buffer)
3793 ;; It's a foreign group...
3794 (gnus-group-make-group
3795 (gnus-group-real-name (car info))
3796 (prin1-to-string (car (nth 4 info)))
3797 (nth 1 (nth 4 info)))
3798 ;; It's a native group.
3799 (gnus-group-make-group (car info)))
3800 (gnus-message 6 "Note: New group created")
3802 (gnus-gethash (gnus-group-prefixed-name
3803 (gnus-group-real-name (car info))
3804 (or (nth 4 info) gnus-select-method))
3805 gnus-newsrc-hashtb))))
3806 ;; Whether it was a new group or not, we now have the entry, so we
3807 ;; can do the update.
3810 (setcar (nthcdr 2 entry) info)
3811 (if (and (not (eq (car entry) t))
3812 (gnus-gethash (car info) gnus-active-hashtb))
3813 (let ((marked (nth 3 info)))
3815 (max 0 (- (length (gnus-list-of-unread-articles
3817 (length (cdr (assq 'tick marked)))
3818 (length (cdr (assq 'dormant marked)))))))))
3819 (error "No such group: %s" (car info)))))
3821 (defun gnus-group-set-method-info (group select-method)
3822 (gnus-group-set-info select-method group 'method))
3824 (defun gnus-group-set-params-info (group params)
3825 (gnus-group-set-info params group 'params))
3827 (defun gnus-group-update-group-line ()
3828 "This function updates the current line in the newsgroup buffer and
3829 moves the point to the colon."
3830 (let* ((buffer-read-only nil)
3831 (group (gnus-group-group-name))
3832 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3835 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3838 (delete-region (point) (progn (forward-line 1) (point)))
3839 (gnus-group-insert-group-line-info group)
3841 (gnus-group-position-point)))
3843 (defun gnus-group-insert-group-line-info (group)
3844 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3848 (setq info (nth 2 entry))
3849 (gnus-group-insert-group-line
3850 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3851 (setq active (gnus-gethash group gnus-active-hashtb))
3852 (gnus-group-insert-group-line
3854 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3855 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3857 (defun gnus-group-insert-group-line (gformat group level marked number method)
3858 (let* ((gformat (or gformat gnus-group-line-format-spec))
3859 (active (gnus-gethash group gnus-active-hashtb))
3860 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3861 (number-of-dormant (length (cdr (assq 'dormant marked))))
3862 (number-of-ticked (length (cdr (assq 'tick marked))))
3863 (number-of-ticked-and-dormant
3864 (+ number-of-ticked number-of-dormant))
3865 (number-of-unread-unticked
3866 (if (numberp number) (int-to-string (max 0 number))
3869 (if (numberp number)
3870 (max 0 (- number-total number))
3872 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3873 ((<= level gnus-level-unsubscribed) ?U)
3874 ((= level gnus-level-zombie) ?Z)
3876 (qualified-group (gnus-group-real-name group))
3877 (newsgroup-description
3878 (if gnus-description-hashtb
3879 (or (gnus-gethash group gnus-description-hashtb) "")
3881 (moderated (if (member group gnus-moderated-list) ?m ? ))
3882 (moderated-string (if (eq moderated ?m) "(m)" ""))
3883 (method (gnus-server-get-method group method))
3884 (news-server (or (car (cdr method)) ""))
3885 (news-method (or (car method) ""))
3887 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3891 (> number-of-ticked 0))
3893 (number (if (eq number t) "*" (+ number number-of-dormant
3895 (process-marked (if (member group gnus-group-marked)
3896 gnus-process-mark ? ))
3897 (buffer-read-only nil)
3898 header ; passed as parameter to user-funcs.
3903 (insert (eval gformat))
3905 (add-text-properties
3906 b (1+ b) (list 'gnus-group (intern group)
3907 'gnus-unread (if (numberp number)
3908 (string-to-int number-of-unread-unticked)
3911 'gnus-level level))))
3913 (defun gnus-group-update-group (group &optional visible-only)
3914 "Update newsgroup info of GROUP.
3915 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3917 (set-buffer gnus-group-buffer)
3918 (let ((buffer-read-only nil)
3920 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3923 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3925 ;; Buffer may be narrowed.
3928 ;; Search a line to modify. If the buffer is large, the search
3929 ;; takes long time. In most cases, current point is on the line
3930 ;; we are looking for. So, first of all, check current line.
3933 (eq (get-text-property (point) 'gnus-group)
3938 (point-min) (point-max) 'gnus-group (intern group)))))
3939 ;; GROUP is listed in current buffer. So, delete old line.
3943 (delete-region (point) (progn (forward-line 1) (point))))
3944 ;; No such line in the buffer, find out where it's supposed to
3945 ;; go, and insert it there (or at the end of the buffer).
3946 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3949 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3955 (point-min) (point-max)
3956 'gnus-group (intern (car (car entry)))))))
3957 (setq entry (cdr entry)))
3958 (or entry (goto-char (point-max)))))))
3959 (if (or visible (not visible-only))
3960 (gnus-group-insert-group-line-info group))
3961 (gnus-group-set-mode-line))))
3963 (defun gnus-group-set-mode-line ()
3964 (if (memq 'group gnus-updated-mode-lines)
3965 (let* ((gformat (or gnus-group-mode-line-format-spec
3966 (setq gnus-group-mode-line-format-spec
3968 gnus-group-mode-line-format
3969 gnus-group-mode-line-format-alist))))
3970 (news-server (car (cdr gnus-select-method)))
3971 (news-method (car gnus-select-method))
3973 (mode-string (eval gformat)))
3974 (setq mode-string (eval gformat))
3975 (if (> (length mode-string) max-len)
3976 (setq mode-string (substring mode-string 0 (- max-len 4))))
3977 (setq mode-line-buffer-identification mode-string)
3978 (set-buffer-modified-p t))))
3980 (defun gnus-group-group-name ()
3981 "Get the name of the newsgroup on the current line."
3982 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3983 (and group (symbol-name group))))
3985 (defun gnus-group-group-level ()
3986 "Get the level of the newsgroup on the current line."
3987 (get-text-property (gnus-point-at-bol) 'gnus-level))
3989 (defun gnus-group-group-unread ()
3990 "Get the number of unread articles of the newsgroup on the current line."
3991 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3993 (defun gnus-group-search-forward (&optional backward all level first-too)
3994 "Find the next newsgroup with unread articles.
3995 If BACKWARD is non-nil, find the previous newsgroup instead.
3996 If ALL is non-nil, just find any newsgroup.
3997 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3999 If FIRST-TOO, the current line is also eligible as a target."
4000 (let ((way (if backward -1 1))
4001 (low gnus-level-killed)
4004 (if (and backward (progn (beginning-of-line)) (bobp))
4006 (or first-too (forward-line way))
4014 (get-text-property (point) 'gnus-unread)))
4015 (or (eq unread t) (and unread (> unread 0))))
4016 (setq lev (get-text-property (point)
4018 (<= lev gnus-level-subscribed)))
4020 (and (setq lev (get-text-property (point)
4029 (zerop (forward-line way)))))
4031 (progn (gnus-group-position-point) t)
4032 (goto-char (or pos beg))
4035 ;;; Gnus group mode commands
4039 (defun gnus-group-mark-group (n &optional unmark no-advance)
4040 "Mark the current group."
4042 (let ((buffer-read-only nil)
4046 (setq group (gnus-group-group-name))
4050 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
4055 (setq gnus-group-marked (delete group gnus-group-marked)))
4057 (setq gnus-group-marked
4058 (cons group (delete group gnus-group-marked))))
4060 (or no-advance (zerop (gnus-group-next-group 1))))
4062 (gnus-summary-position-point)
4065 (defun gnus-group-unmark-group (n)
4066 "Remove the mark from the current group."
4068 (gnus-group-mark-group n 'unmark))
4070 (defun gnus-group-mark-region (unmark beg end)
4071 "Mark all groups between point and mark.
4072 If UNMARK, remove the mark instead."
4073 (interactive "P\nr")
4074 (let ((num (count-lines beg end)))
4077 (- num (gnus-group-mark-group num unmark)))))
4079 (defun gnus-group-remove-mark (group)
4080 (and (gnus-group-goto-group group)
4082 (gnus-group-mark-group 1 'unmark t))))
4084 ;; Return a list of groups to work on. Take into consideration N (the
4085 ;; prefix) and the list of marked groups.
4086 (defun gnus-group-process-prefix (n)
4088 (setq n (prefix-numeric-value n))
4089 ;; There is a prefix, so we return a list of the N next
4091 (let ((way (if (< n 0) -1 1))
4096 (setq group (gnus-group-group-name)))
4097 (setq groups (cons group groups))
4099 (forward-line way)))
4102 ;; No prefix, but a list of marked articles.
4103 (reverse gnus-group-marked))
4105 ;; Neither marked articles or a prefix, so we return the
4107 (let ((group (gnus-group-group-name)))
4108 (and group (list group))))))
4110 ;; Selecting groups.
4112 (defun gnus-group-read-group (&optional all no-article group)
4113 "Read news in this newsgroup.
4114 If the prefix argument ALL is non-nil, already read articles become
4115 readable. If the optional argument NO-ARTICLE is non-nil, no article
4116 will be auto-selected upon group entry."
4118 (if (gnus-group-topic-p)
4119 (gnus-topic-fold) ; This is a topic line.
4120 ;; And this is a real group.
4121 (let ((group (or group (gnus-group-group-name)))
4122 number active marked entry)
4123 (or group (error "No group on current line"))
4125 (nth 3 (nth 2 (setq entry (gnus-gethash
4126 group gnus-newsrc-hashtb)))))
4127 ;; This group might be a dead group. In that case we have to get
4128 ;; the number of unread articles from `gnus-active-hashtb'.
4130 (setq number (car entry))
4131 (if (setq active (gnus-gethash group gnus-active-hashtb))
4132 (setq number (- (1+ (cdr active)) (car active)))))
4133 (gnus-summary-read-group
4134 group (or all (and (numberp number)
4135 (zerop (+ number (length (cdr (assq 'tick marked)))
4136 (length (cdr (assq 'dormant marked)))))))
4139 (defun gnus-group-select-group (&optional all)
4140 "Select this newsgroup.
4141 No article is selected automatically.
4142 If argument ALL is non-nil, already read articles become readable."
4144 (gnus-group-read-group all t))
4146 (defun gnus-group-quick-select-group (&optional all)
4147 "Select the current group \"quickly\".
4148 This means that no highlighting or scoring will be performed."
4151 gnus-score-find-score-files-function
4152 gnus-apply-kill-hook
4153 gnus-summary-expunge-below)
4154 (gnus-group-read-group all t)))
4157 (defun gnus-fetch-group (group)
4158 "Start Gnus if necessary and enter GROUP.
4159 Returns whether the fetching was successful or not."
4160 (interactive "sGroup name: ")
4161 (or (get-buffer gnus-group-buffer)
4163 (gnus-group-select-group))
4165 (defun gnus-group-select-group-all ()
4166 "Select the current group and display all articles in it."
4168 (gnus-group-select-group 'all))
4170 ;; Enter a group that is not in the group buffer. Non-nil is returned
4171 ;; if selection was successful.
4172 (defun gnus-group-read-ephemeral-group
4173 (group method &optional activate quit-config)
4174 (let ((group (if (gnus-group-foreign-p group) group
4175 (gnus-group-prefixed-name group method))))
4178 (list t nil (list group gnus-level-default-subscribed nil nil
4182 (if quit-config quit-config
4183 (cons (current-buffer) 'summary)))))))
4185 (set-buffer gnus-group-buffer)
4186 (or (gnus-check-server method)
4187 (error "Unable to contact server: %s" (gnus-status-message method)))
4188 (if activate (or (gnus-request-group group)
4189 (error "Couldn't request group")))
4191 (gnus-group-read-group t t group)
4194 (not (equal major-mode 'gnus-group-mode))))
4196 (defun gnus-group-jump-to-group (group)
4197 "Jump to newsgroup GROUP."
4199 (list (completing-read
4200 "Group: " gnus-active-hashtb nil
4201 (memq gnus-select-method gnus-have-read-active-file))))
4203 (if (equal group "")
4204 (error "Empty group name"))
4206 (let ((b (text-property-any
4207 (point-min) (point-max) 'gnus-group (intern group))))
4209 ;; Either go to the line in the group buffer...
4211 ;; ... or insert the line.
4213 (gnus-gethash group gnus-active-hashtb)
4214 (gnus-activate-group group)
4215 (error "%s error: %s" group (gnus-status-message group)))
4217 (gnus-group-update-group group)
4218 (goto-char (text-property-any
4219 (point-min) (point-max) 'gnus-group (intern group)))))
4220 ;; Adjust cursor point.
4221 (gnus-group-position-point))
4223 (defun gnus-group-goto-group (group)
4224 "Goto to newsgroup GROUP."
4225 (let ((b (text-property-any (point-min) (point-max)
4226 'gnus-group (intern group))))
4227 (and b (goto-char b))))
4229 (defun gnus-group-next-group (n)
4230 "Go to next N'th newsgroup.
4231 If N is negative, search backward instead.
4232 Returns the difference between N and the number of skips actually
4235 (gnus-group-next-unread-group n t))
4237 (defun gnus-group-next-unread-group (n &optional all level)
4238 "Go to next N'th unread newsgroup.
4239 If N is negative, search backward instead.
4240 If ALL is non-nil, choose any newsgroup, unread or not.
4241 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
4242 such group can be found, the next group with a level higher than
4244 Returns the difference between N and the number of skips actually
4247 (let ((backward (< n 0))
4250 (gnus-group-search-forward
4251 backward (or (not gnus-group-goto-unread) all) level))
4253 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
4254 (if level " on this level or higher" "")))
4257 (defun gnus-group-prev-group (n)
4258 "Go to previous N'th newsgroup.
4259 Returns the difference between N and the number of skips actually
4262 (gnus-group-next-unread-group (- n) t))
4264 (defun gnus-group-prev-unread-group (n)
4265 "Go to previous N'th unread newsgroup.
4266 Returns the difference between N and the number of skips actually
4269 (gnus-group-next-unread-group (- n)))
4271 (defun gnus-group-next-unread-group-same-level (n)
4272 "Go to next N'th unread newsgroup on the same level.
4273 If N is negative, search backward instead.
4274 Returns the difference between N and the number of skips actually
4277 (gnus-group-next-unread-group n t (gnus-group-group-level))
4278 (gnus-group-position-point))
4280 (defun gnus-group-prev-unread-group-same-level (n)
4281 "Go to next N'th unread newsgroup on the same level.
4282 Returns the difference between N and the number of skips actually
4285 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
4286 (gnus-group-position-point))
4288 (defun gnus-group-best-unread-group (&optional exclude-group)
4289 "Go to the group with the highest level.
4290 If EXCLUDE-GROUP, do not go to that group."
4292 (goto-char (point-min))
4295 (while (setq unread (get-text-property (point) 'gnus-unread))
4296 (if (and (numberp unread) (> unread 0))
4298 (if (and (< (get-text-property (point) 'gnus-level) best)
4299 (or (not exclude-group)
4300 (not (equal exclude-group (gnus-group-group-name)))))
4302 (setq best (get-text-property (point) 'gnus-level))
4303 (setq best-point (point))))))
4305 (if best-point (goto-char best-point))
4306 (gnus-summary-position-point)
4307 (and best-point (gnus-group-group-name))))
4309 (defun gnus-group-first-unread-group ()
4310 "Go to the first group with unread articles."
4313 (let ((opoint (point))
4315 (goto-char (point-min))
4316 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
4317 (not (zerop unread)) ; Has unread articles.
4318 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
4321 nil)) ; Not success.
4322 (gnus-group-position-point)))
4324 (defun gnus-group-enter-server-mode ()
4325 "Jump to the server buffer."
4327 (gnus-server-setup-buffer)
4328 (gnus-configure-windows 'server)
4329 (gnus-server-prepare))
4331 (defun gnus-group-make-group (name &optional method address)
4332 "Add a new newsgroup.
4333 The user will be prompted for a NAME, for a select METHOD, and an
4337 (read-string "Group name: ")
4340 "Method: " (append gnus-valid-select-methods gnus-server-alist)
4342 (if (assoc method gnus-valid-select-methods)
4344 (if (memq 'prompt-address
4345 (assoc method gnus-valid-select-methods))
4346 (read-string "Address: ")
4348 (list method nil)))))
4351 (set-buffer gnus-group-buffer)
4352 (let* ((meth (and method (if address (list (intern method) address)
4354 (nname (if method (gnus-group-prefixed-name name meth) name))
4356 (and (gnus-gethash nname gnus-newsrc-hashtb)
4357 (error "Group %s already exists" nname))
4358 (gnus-group-change-level
4359 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
4360 gnus-level-default-subscribed gnus-level-killed
4361 (and (gnus-group-group-name)
4362 (gnus-gethash (gnus-group-group-name)
4363 gnus-newsrc-hashtb))
4365 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
4367 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
4368 (gnus-group-insert-group-line-info nname)
4370 (if (assoc method gnus-valid-select-methods)
4371 (require (intern method)))
4372 (and (gnus-check-backend-function 'request-create-group nname)
4373 (gnus-request-create-group nname)))))
4375 (defun gnus-group-delete-group (group &optional force)
4376 "Delete the current group.
4377 If FORCE (the prefix) is non-nil, all the articles in the group will
4378 be deleted. This is \"deleted\" as in \"removed forever from the face
4379 of the Earth\". There is no undo."
4381 (list (gnus-group-group-name)
4382 current-prefix-arg))
4383 (or group (error "No group to rename"))
4384 (or (gnus-check-backend-function 'request-delete-group group)
4385 (error "This backend does not support group deletion"))
4387 (if (not (gnus-yes-or-no-p
4389 "Do you really want to delete %s%s? "
4390 group (if force " and all its contents" ""))))
4392 (gnus-message 6 "Deleting group %s..." group)
4393 (if (not (gnus-request-delete-group group force))
4395 (gnus-message 3 "Couldn't delete group %s" group)
4397 (gnus-message 6 "Deleting group %s...done" group)
4398 (gnus-group-goto-group group)
4399 (gnus-group-kill-group 1 t)
4401 (gnus-group-position-point)))
4403 (defun gnus-group-rename-group (group new-name)
4406 (gnus-group-group-name)
4408 (or (gnus-check-backend-function
4409 'request-rename-group (gnus-group-group-name))
4410 (error "This backend does not support renaming groups"))
4411 (read-string "New group name: "))))
4413 (or (gnus-check-backend-function 'request-rename-group group)
4414 (error "This backend does not support renaming groups"))
4416 (or group (error "No group to rename"))
4417 (and (string-match "^[ \t]*$" new-name)
4418 (error "Not a valid group name"))
4420 ;; We find the proper prefixed name.
4422 (gnus-group-prefixed-name
4423 (gnus-group-real-name new-name)
4424 (nth 4 (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))))
4426 (gnus-message 6 "Renaming group %s to %s..." group new-name)
4428 (if (not (gnus-request-rename-group group new-name))
4430 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
4432 ;; We rename the group internally by killing it...
4433 (gnus-group-goto-group group)
4434 (gnus-group-kill-group)
4435 ;; ... changing its name ...
4436 (setcar (cdr (car gnus-list-of-killed-groups))
4438 ;; ... and then yanking it. Magic!
4439 (gnus-group-yank-group)
4440 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
4442 (gnus-group-position-point)))
4445 (defun gnus-group-edit-group (group &optional part)
4446 "Edit the group on the current line."
4447 (interactive (list (gnus-group-group-name)))
4448 (let ((done-func '(lambda ()
4449 "Exit editing mode and update the information."
4451 (gnus-group-edit-group-done 'part 'group)))
4452 (part (or part 'info))
4453 (winconf (current-window-configuration))
4455 (or group (error "No group on current line"))
4456 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4457 (error "Killed group; can't be edited"))
4458 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4459 (gnus-configure-windows 'edit-group)
4460 (gnus-add-current-to-buffer-list)
4462 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4463 (use-local-map (copy-keymap emacs-lisp-mode-map))
4464 (local-set-key "\C-c\C-c" done-func)
4465 (make-local-variable 'gnus-prev-winconf)
4466 (setq gnus-prev-winconf winconf)
4467 ;; We modify the func to let it know what part it is editing.
4468 (setcar (cdr (nth 4 done-func)) (list 'quote part))
4469 (setcar (cdr (cdr (nth 4 done-func))) group)
4474 ";; Type `C-c C-c' after editing the select method.\n\n")
4476 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4478 ";; Type `C-c C-c' after editing the group info.\n\n")))
4479 (let ((cinfo (gnus-copy-sequence info))
4481 (if (not (setq marked (nth 3 cinfo)))
4484 (or (eq 'score (car (car marked)))
4485 (eq 'bookmark (car (car marked)))
4486 (eq 'killed (car (car marked)))
4487 (not (numberp (car (cdr (car marked)))))
4488 (setcdr (car marked)
4489 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4490 (setq marked (cdr marked))))
4493 (cond ((eq part 'method)
4494 (or (nth 4 info) "native"))
4501 (defun gnus-group-edit-group-method (group)
4502 "Edit the select method of GROUP."
4503 (interactive (list (gnus-group-group-name)))
4504 (gnus-group-edit-group group 'method))
4506 (defun gnus-group-edit-group-parameters (group)
4507 "Edit the group parameters of GROUP."
4508 (interactive (list (gnus-group-group-name)))
4509 (gnus-group-edit-group group 'params))
4511 (defun gnus-group-edit-group-done (part group)
4512 "Get info from buffer, update variables and jump to the group buffer."
4513 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4514 (goto-char (point-min))
4515 (let ((form (read (current-buffer)))
4516 (winconf gnus-prev-winconf))
4518 (gnus-group-set-info form)
4519 (gnus-group-set-info form group part))
4520 (kill-buffer (current-buffer))
4521 (and winconf (set-window-configuration winconf))
4522 (set-buffer gnus-group-buffer)
4523 (gnus-group-update-group (gnus-group-group-name))
4524 (gnus-group-position-point)))
4526 (defun gnus-group-make-help-group ()
4527 "Create the Gnus documentation group."
4529 (let ((path load-path)
4531 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4532 "gnus-help" '(nndoc "gnus-help")))
4534 (error "Documentation group already exists"))
4536 (not (file-exists-p (concat (file-name-as-directory (car path))
4538 (setq path (cdr path)))
4539 (or path (error "Couldn't find doc group"))
4540 (gnus-group-make-group
4541 (gnus-group-real-name name)
4543 (list 'nndoc-address
4544 (concat (file-name-as-directory (car path)) "doc.txt"))
4545 (list 'nndoc-article-type 'mbox)))
4547 (gnus-group-position-point))
4549 (defun gnus-group-make-doc-group (file type)
4550 "Create a group that uses a single file as the source."
4552 (list (read-file-name "File name: ")
4556 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4557 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4558 ((= char ?b) 'babyl)
4559 ((= char ?d) 'digest)
4560 (t (setq err (format "%c unknown. " char))
4563 (let* ((file (expand-file-name file))
4564 (name (gnus-generate-new-group-name
4565 (gnus-group-prefixed-name
4566 (file-name-nondirectory file) '(nndoc "")))))
4567 (gnus-group-make-group
4568 (gnus-group-real-name name)
4570 (list 'nndoc-address file)
4571 (list 'nndoc-article-type type)))
4573 (gnus-group-position-point)))
4575 (defun gnus-group-make-archive-group (&optional all)
4576 "Create the (ding) Gnus archive group of the most recent articles.
4577 Given a prefix, create a full group."
4579 (let ((group (gnus-group-prefixed-name
4580 (if all "ding.archives" "ding.recent") '(nndir ""))))
4581 (and (gnus-gethash group gnus-newsrc-hashtb)
4582 (error "Archive group already exists"))
4583 (gnus-group-make-group
4584 (gnus-group-real-name group)
4585 (list 'nndir (if all "hpc" "edu")
4586 (list 'nndir-directory
4587 (if all gnus-group-archive-directory
4588 gnus-group-recent-archive-directory)))))
4590 (gnus-group-position-point))
4592 (defun gnus-group-make-directory-group (dir)
4593 "Create an nndir group.
4594 The user will be prompted for a directory. The contents of this
4595 directory will be used as a newsgroup. The directory should contain
4596 mail messages or news articles in files that have numeric names."
4598 (list (read-file-name "Create group from directory: ")))
4599 (or (file-exists-p dir) (error "No such directory"))
4600 (or (file-directory-p dir) (error "Not a directory"))
4601 (gnus-group-make-group dir "nndir" dir)
4603 (gnus-group-position-point))
4605 (defun gnus-group-make-kiboze-group (group address scores)
4606 "Create an nnkiboze group.
4607 The user will be prompted for a name, a regexp to match groups, and
4608 score file entries for articles to include in the group."
4611 (read-string "nnkiboze group name: ")
4612 (read-string "Source groups (regexp): ")
4613 (let ((headers (mapcar (lambda (group) (list group))
4614 '("subject" "from" "number" "date" "message-id"
4615 "references" "chars" "lines" "xref"
4616 "followup" "all" "body" "head")))
4617 scores header regexp regexps)
4618 (while (not (equal "" (setq header (completing-read
4619 "Match on header: " headers nil t))))
4621 (while (not (equal "" (setq regexp (read-string
4622 (format "Match on %s (string): "
4624 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4625 (setq scores (cons (cons header regexps) scores)))
4627 (gnus-group-make-group group "nnkiboze" address)
4629 (gnus-set-work-buffer)
4630 (let (emacs-lisp-mode-hook)
4631 (pp scores (current-buffer)))
4632 (write-region (point-min) (point-max)
4633 (gnus-score-file-name (concat "nnkiboze:" group))))
4635 (gnus-group-position-point))
4637 (defun gnus-group-add-to-virtual (n vgroup)
4638 "Add the current group to a virtual group."
4640 (list current-prefix-arg
4641 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4643 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4644 (error "%s is not an nnvirtual group" vgroup))
4645 (let* ((groups (gnus-group-process-prefix n))
4646 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4647 (setcar (cdr method)
4649 (nth 1 method) "\\|"
4652 (gnus-group-remove-mark s)
4653 (concat "\\(^" (regexp-quote s) "$\\)"))
4655 (gnus-group-position-point))
4657 (defun gnus-group-make-empty-virtual (group)
4658 "Create a new, fresh, empty virtual group."
4659 (interactive "sCreate new, empty virtual group: ")
4660 (let* ((method (list 'nnvirtual "^$"))
4661 (pgroup (gnus-group-prefixed-name group method)))
4662 ;; Check whether it exists already.
4663 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4664 (error "Group %s already exists." pgroup))
4665 ;; Subscribe the new group after the group on the current line.
4666 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4667 (gnus-group-update-group pgroup)
4669 (gnus-group-position-point)))
4671 (defun gnus-group-enter-directory (dir)
4672 "Enter an ephemeral nneething group."
4673 (interactive "DDirectory to read: ")
4674 (let* ((method (list 'nneething dir))
4675 (leaf (gnus-group-prefixed-name
4676 (file-name-nondirectory (directory-file-name dir))
4678 (name (gnus-generate-new-group-name leaf)))
4679 (let ((nneething-read-only t))
4680 (or (gnus-group-read-ephemeral-group
4682 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4684 (error "Couldn't enter %s" dir)))))
4686 ;; Group sorting commands
4687 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4689 (defun gnus-group-sort-groups ()
4690 "Sort the group buffer according to `gnus-group-sort-function'."
4692 (let ((funcs (if (listp gnus-group-sort-function) gnus-group-sort-function
4693 (list gnus-group-sort-function))))
4694 ;; We peel off the dummy group off the alist.
4695 (and (equal (car (car gnus-newsrc-alist)) "dummy.group")
4696 (setq gnus-newsrc-alist (cdr gnus-newsrc-alist)))
4699 (setq gnus-newsrc-alist
4700 (sort (cdr gnus-newsrc-alist) (car funcs)))
4701 (setq funcs (cdr funcs))))
4702 (gnus-make-hashtable-from-newsrc-alist)
4703 (gnus-group-list-groups))
4705 (defun gnus-group-sort-by-alphabet (info1 info2)
4706 (string< (car info1) (car info2)))
4708 (defun gnus-group-sort-by-unread (info1 info2)
4709 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4710 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4711 (< (or (and (numberp n1) n1) 0)
4712 (or (and (numberp n2) n2) 0))))
4714 (defun gnus-group-sort-by-level (info1 info2)
4715 (< (nth 1 info1) (nth 1 info2)))
4717 (defun gnus-group-sort-by-method (info1 info2)
4718 (string< (symbol-name (car (gnus-find-method-for-group (car info1))))
4719 (symbol-name (car (gnus-find-method-for-group (car info2))))))
4721 ;; Group catching up.
4723 (defun gnus-group-catchup-current (&optional n all)
4724 "Mark all articles not marked as unread in current newsgroup as read.
4725 If prefix argument N is numeric, the ARG next newsgroups will be
4726 caught up. If ALL is non-nil, marked articles will also be marked as
4727 read. Cross references (Xref: header) of articles are ignored.
4728 The difference between N and actual number of newsgroups that were
4729 caught up is returned."
4731 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4735 "Do you really want to mark all articles as read? "
4736 "Mark all unread articles as read? "))))
4738 (let ((groups (gnus-group-process-prefix n))
4741 ;; Virtual groups have to be given special treatment.
4742 (let ((method (gnus-find-method-for-group (car groups))))
4743 (if (eq 'nnvirtual (car method))
4744 (nnvirtual-catchup-group
4745 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4746 (gnus-group-remove-mark (car groups))
4748 (gnus-group-goto-group (car groups))
4749 (gnus-group-catchup (car groups) all))
4750 (gnus-group-update-group-line)
4751 (setq ret (1+ ret)))
4752 (setq groups (cdr groups)))
4753 (gnus-group-next-unread-group 1)
4756 (defun gnus-group-catchup-current-all (&optional n)
4757 "Mark all articles in current newsgroup as read.
4758 Cross references (Xref: header) of articles are ignored."
4760 (gnus-group-catchup-current n 'all))
4762 (defun gnus-group-catchup (group &optional all)
4763 "Mark all articles in GROUP as read.
4764 If ALL is non-nil, all articles are marked as read.
4765 The return value is the number of articles that were marked as read,
4766 or nil if no action could be taken."
4767 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4769 (marked (nth 3 (nth 2 entry))))
4770 (if (not (numberp (car entry)))
4771 (gnus-message 1 "Can't catch up; non-active group")
4772 ;; Do the updating only if the newsgroup isn't killed.
4775 (gnus-update-read-articles
4776 group (and (not all) (append (cdr (assq 'tick marked))
4777 (cdr (assq 'dormant marked))))
4778 nil (and (not all) (cdr (assq 'tick marked))))
4780 (setq marked (nth 3 (nth 2 entry)))
4781 (setcar (nthcdr 3 (nth 2 entry))
4782 (delq (assq 'dormant marked)
4783 (nth 3 (nth 2 entry)))))))
4786 (defun gnus-group-expire-articles (&optional n)
4787 "Expire all expirable articles in the current newsgroup."
4789 (let ((groups (gnus-group-process-prefix n))
4791 (or groups (error "No groups to expire"))
4793 (setq group (car groups)
4794 groups (cdr groups))
4795 (gnus-group-remove-mark group)
4796 (if (not (gnus-check-backend-function 'request-expire-articles group))
4798 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4799 (expirable (if (gnus-group-total-expirable-p group)
4800 (cons nil (gnus-list-of-read-articles group))
4801 (assq 'expire (nth 3 info)))))
4804 (gnus-request-expire-articles
4805 (cdr expirable) group))))))))
4807 (defun gnus-group-expire-all-groups ()
4808 "Expire all expirable articles in all newsgroups."
4811 (gnus-message 5 "Expiring...")
4812 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4813 (cdr gnus-newsrc-alist))))
4814 (gnus-group-expire-articles nil)))
4815 (gnus-group-position-point)
4816 (gnus-message 5 "Expiring...done"))
4818 (defun gnus-group-set-current-level (n level)
4819 "Set the level of the next N groups to LEVEL."
4822 (prefix-numeric-value current-prefix-arg)
4824 (read-string (format "Level (default %s): " (gnus-group-group-level))
4825 (int-to-string (gnus-group-group-level))))))
4826 (or (and (>= level 1) (<= level gnus-level-killed))
4827 (error "Illegal level: %d" level))
4828 (let ((groups (gnus-group-process-prefix n))
4831 (setq group (car groups)
4832 groups (cdr groups))
4833 (gnus-group-remove-mark group)
4834 (gnus-message 6 "Changed level of %s from %d to %d"
4835 group (gnus-group-group-level) level)
4836 (gnus-group-change-level group level
4837 (gnus-group-group-level))
4838 (gnus-group-update-group-line)))
4839 (gnus-group-position-point))
4841 (defun gnus-group-unsubscribe-current-group (&optional n)
4842 "Toggle subscription of the current group.
4843 If given numerical prefix, toggle the N next groups."
4845 (let ((groups (gnus-group-process-prefix n))
4848 (setq group (car groups)
4849 groups (cdr groups))
4850 (gnus-group-remove-mark group)
4851 (gnus-group-unsubscribe-group
4852 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4853 gnus-level-default-unsubscribed
4854 gnus-level-default-subscribed))
4855 (gnus-group-update-group-line))
4856 (gnus-group-next-group 1)))
4858 (defun gnus-group-unsubscribe-group (group &optional level)
4859 "Toggle subscribe from/to unsubscribe GROUP.
4860 New newsgroup is added to .newsrc automatically."
4862 (list (completing-read
4863 "Group: " gnus-active-hashtb nil
4864 (memq gnus-select-method gnus-have-read-active-file))))
4865 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4867 ((string-match "^[ \t]$" group)
4868 (error "Empty group name"))
4870 ;; Toggle subscription flag.
4871 (gnus-group-change-level
4872 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4873 gnus-level-subscribed)
4874 (1+ gnus-level-subscribed)
4875 gnus-level-default-subscribed)))
4876 (gnus-group-update-group group))
4877 ((and (stringp group)
4878 (or (not (memq gnus-select-method gnus-have-read-active-file))
4879 (gnus-gethash group gnus-active-hashtb)))
4880 ;; Add new newsgroup.
4881 (gnus-group-change-level
4883 (if level level gnus-level-default-subscribed)
4884 (or (and (member group gnus-zombie-list)
4887 (and (gnus-group-group-name)
4888 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4889 (gnus-group-update-group group))
4890 (t (error "No such newsgroup: %s" group)))
4891 (gnus-group-position-point)))
4893 (defun gnus-group-transpose-groups (n)
4894 "Move the current newsgroup up N places.
4895 If given a negative prefix, move down instead. The difference between
4896 N and the number of steps taken is returned."
4898 (or (gnus-group-group-name)
4899 (error "No group on current line"))
4900 (gnus-group-kill-group 1)
4902 (forward-line (- n))
4903 (gnus-group-yank-group)
4904 (gnus-group-position-point)))
4906 (defun gnus-group-kill-all-zombies ()
4907 "Kill all zombie newsgroups."
4909 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4910 (setq gnus-zombie-list nil)
4911 (gnus-group-list-groups))
4913 (defun gnus-group-kill-region (begin end)
4914 "Kill newsgroups in current region (excluding current point).
4915 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4930 (beginning-of-line) ;Important when LINES < 1
4931 (gnus-group-kill-group lines)))
4933 (defun gnus-group-kill-group (&optional n discard)
4934 "The the next N groups.
4935 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4936 However, only groups that were alive can be yanked; already killed
4937 groups or zombie groups can't be yanked.
4938 The return value is the name of the (last) group that was killed."
4940 (let ((buffer-read-only nil)
4941 (groups (gnus-group-process-prefix n))
4943 (if (or t (< (length groups) 10))
4944 ;; This is faster when there are few groups.
4946 (setq group (car groups)
4947 groups (cdr groups))
4948 (gnus-group-remove-mark group)
4949 (setq level (gnus-group-group-level))
4951 (if (and (not discard)
4952 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
4953 (setq gnus-list-of-killed-groups
4954 (cons (cons (car entry) (nth 2 entry))
4955 gnus-list-of-killed-groups)))
4956 (gnus-group-change-level
4957 (if entry entry group) gnus-level-killed (if entry nil level)))
4958 ;; If there are lots and lots of groups to be killed, we use
4959 ;; this thing instead.
4963 (gnus-group-position-point)
4966 (defun gnus-group-yank-group (&optional arg)
4967 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4968 inserting it before the current newsgroup. The numeric ARG specifies
4969 how many newsgroups are to be yanked. The name of the (last)
4970 newsgroup yanked is returned."
4972 (if (not arg) (setq arg 1))
4973 (let (info group prev)
4974 (while (>= (setq arg (1- arg)) 0)
4975 (if (not (setq info (car gnus-list-of-killed-groups)))
4976 (error "No more newsgroups to yank"))
4977 (setq group (nth 2 info))
4978 ;; Find which newsgroup to insert this one before - search
4979 ;; backward until something suitable is found. If there are no
4980 ;; other newsgroups in this buffer, just make this newsgroup the
4982 (setq prev (gnus-group-group-name))
4983 (gnus-group-change-level
4984 info (nth 2 info) gnus-level-killed
4985 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4987 (gnus-group-insert-group-line-info (nth 1 info))
4988 (setq gnus-list-of-killed-groups
4989 (cdr gnus-list-of-killed-groups)))
4991 (gnus-group-position-point)
4994 (defun gnus-group-list-all-groups (&optional arg)
4995 "List all newsgroups with level ARG or lower.
4996 Default is gnus-level-unsubscribed, which lists all subscribed and most
4997 unsubscribed groups."
4999 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
5001 (defun gnus-group-list-killed ()
5002 "List all killed newsgroups in the group buffer."
5004 (if (not gnus-killed-list)
5005 (gnus-message 6 "No killed groups")
5006 (let (gnus-group-list-mode)
5007 (funcall gnus-group-prepare-function
5008 gnus-level-killed t gnus-level-killed))
5009 (goto-char (point-min)))
5010 (gnus-group-position-point))
5012 (defun gnus-group-list-zombies ()
5013 "List all zombie newsgroups in the group buffer."
5015 (if (not gnus-zombie-list)
5016 (gnus-message 6 "No zombie groups")
5017 (let (gnus-group-list-mode)
5018 (funcall gnus-group-prepare-function
5019 gnus-level-zombie t gnus-level-zombie))
5020 (goto-char (point-min)))
5021 (gnus-group-position-point))
5023 (defun gnus-group-list-active ()
5024 "List all groups that are available from the server(s)."
5026 ;; First we make sure that we have really read the active file.
5027 (or gnus-have-read-active-file
5028 (gnus-read-active-file))
5029 ;; Find all groups and sort them.
5035 (and (symbol-value sym)
5036 (setq list (cons (symbol-name sym) list))))
5040 (buffer-read-only nil))
5043 (gnus-group-insert-group-line-info (car groups))
5044 (setq groups (cdr groups)))
5045 (goto-char (point-min))))
5047 (defun gnus-group-get-new-news (&optional arg)
5048 "Get newly arrived articles.
5049 If ARG is a number, it specifies which levels you are interested in
5050 re-scanning. If ARG is non-nil and not a number, this will force
5051 \"hard\" re-reading of the active files from all servers."
5053 (run-hooks 'gnus-get-new-news-hook)
5054 ;; If ARG is not a number, then we read the active file.
5058 (let ((gnus-read-active-file t))
5059 (gnus-read-active-file))
5062 (setq arg (gnus-group-default-level arg t))
5063 (if (and gnus-read-active-file (not arg))
5065 (gnus-read-active-file)
5066 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
5067 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
5068 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
5069 (gnus-group-list-groups))
5071 (defun gnus-group-get-new-news-this-group (&optional n)
5072 "Check for newly arrived news in the current group (and the N-1 next groups).
5073 The difference between N and the number of newsgroup checked is returned.
5074 If N is negative, this group and the N-1 previous groups will be checked."
5076 (let* ((groups (gnus-group-process-prefix n))
5077 (ret (if (numberp n) (- n (length groups)) 0))
5080 (setq group (car groups)
5081 groups (cdr groups))
5082 (gnus-group-remove-mark group)
5083 (or (gnus-get-new-news-in-group group)
5086 (message "%s error: %s" group (gnus-status-message group))
5088 (gnus-group-next-unread-group 1 t)
5089 (gnus-summary-position-point)
5092 (defun gnus-get-new-news-in-group (group)
5094 (gnus-activate-group group 'scan)
5096 (gnus-get-unread-articles-in-group
5097 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
5098 (gnus-gethash group gnus-active-hashtb))
5099 (gnus-group-update-group-line)
5102 (defun gnus-group-fetch-faq (group &optional faq-dir)
5103 "Fetch the FAQ for the current group."
5106 (gnus-group-real-name (gnus-group-group-name))
5107 (cond (current-prefix-arg
5109 "Faq dir: " (and (listp gnus-group-faq-directory)
5110 gnus-group-faq-directory))))))
5112 (setq faq-dir (if (listp gnus-group-faq-directory)
5113 (car gnus-group-faq-directory)
5114 gnus-group-faq-directory)))
5115 (or group (error "No group name given"))
5116 (let ((file (concat (file-name-as-directory faq-dir)
5117 (gnus-group-real-name group))))
5118 (if (not (file-exists-p file))
5119 (error "No such file: %s" file)
5122 (defun gnus-group-describe-group (force &optional group)
5123 "Display a description of the current newsgroup."
5124 (interactive (list current-prefix-arg (gnus-group-group-name)))
5125 (and force (setq gnus-description-hashtb nil))
5126 (let ((method (gnus-find-method-for-group group))
5128 (or group (error "No group name given"))
5129 (and (or (and gnus-description-hashtb
5130 ;; We check whether this group's method has been
5131 ;; queried for a description file.
5133 (gnus-group-prefixed-name "" method)
5134 gnus-description-hashtb))
5135 (setq desc (gnus-group-get-description group))
5136 (gnus-read-descriptions-file method))
5138 (or desc (gnus-gethash group gnus-description-hashtb)
5139 "No description available")))))
5141 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5142 (defun gnus-group-describe-all-groups (&optional force)
5143 "Pop up a buffer with descriptions of all newsgroups."
5145 (and force (setq gnus-description-hashtb nil))
5146 (if (not (or gnus-description-hashtb
5147 (gnus-read-all-descriptions-files)))
5148 (error "Couldn't request descriptions file"))
5149 (let ((buffer-read-only nil)
5155 (insert (format " *: %-20s %s\n" (symbol-name group)
5156 (symbol-value group)))
5157 (add-text-properties
5158 b (1+ b) (list 'gnus-group group
5159 'gnus-unread t 'gnus-marked nil
5160 'gnus-level (1+ gnus-level-subscribed))))
5161 gnus-description-hashtb)
5162 (goto-char (point-min))
5163 (gnus-group-position-point)))
5165 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
5166 (defun gnus-group-apropos (regexp &optional search-description)
5167 "List all newsgroups that have names that match a regexp."
5168 (interactive "sGnus apropos (regexp): ")
5170 (obuf (current-buffer))
5172 ;; Go through all newsgroups that are known to Gnus.
5175 (and (symbol-name group)
5176 (string-match regexp (symbol-name group))
5177 (setq groups (cons (symbol-name group) groups))))
5179 ;; Go through all descriptions that are known to Gnus.
5180 (if search-description
5183 (and (string-match regexp (symbol-value group))
5184 (gnus-gethash (symbol-name group) gnus-active-hashtb)
5185 (setq groups (cons (symbol-name group) groups))))
5186 gnus-description-hashtb))
5188 (gnus-message 3 "No groups matched \"%s\"." regexp)
5189 ;; Print out all the groups.
5191 (pop-to-buffer "*Gnus Help*")
5192 (buffer-disable-undo (current-buffer))
5194 (setq groups (sort groups 'string<))
5196 ;; Groups may be entered twice into the list of groups.
5197 (if (not (string= (car groups) prev))
5199 (insert (setq prev (car groups)) "\n")
5200 (if (and gnus-description-hashtb
5201 (setq des (gnus-gethash (car groups)
5202 gnus-description-hashtb)))
5203 (insert " " des "\n"))))
5204 (setq groups (cdr groups)))
5205 (goto-char (point-min))))
5206 (pop-to-buffer obuf)))
5208 (defun gnus-group-description-apropos (regexp)
5209 "List all newsgroups that have names or descriptions that match a regexp."
5210 (interactive "sGnus description apropos (regexp): ")
5211 (if (not (or gnus-description-hashtb
5212 (gnus-read-all-descriptions-files)))
5213 (error "Couldn't request descriptions file"))
5214 (gnus-group-apropos regexp t))
5216 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5217 (defun gnus-group-list-matching (level regexp &optional all lowest)
5218 "List all groups with unread articles that match REGEXP.
5219 If the prefix LEVEL is non-nil, it should be a number that says which
5220 level to cut off listing groups.
5221 If ALL, also list groups with no unread articles.
5222 If LOWEST, don't list groups with level lower than LOWEST."
5223 (interactive "P\nsList newsgroups matching: ")
5224 (gnus-group-prepare-flat (or level gnus-level-subscribed)
5225 all (or lowest 1) regexp)
5226 (goto-char (point-min))
5227 (gnus-group-position-point))
5229 (defun gnus-group-list-all-matching (level regexp &optional lowest)
5230 "List all groups that match REGEXP.
5231 If the prefix LEVEL is non-nil, it should be a number that says which
5232 level to cut off listing groups.
5233 If LOWEST, don't list groups with level lower than LOWEST."
5234 (interactive "P\nsList newsgroups matching: ")
5235 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
5237 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
5238 (defun gnus-group-save-newsrc ()
5239 "Save the Gnus startup files."
5241 (gnus-save-newsrc-file))
5243 (defun gnus-group-restart (&optional arg)
5244 "Force Gnus to read the .newsrc file."
5246 (gnus-save-newsrc-file)
5247 (gnus-setup-news 'force)
5248 (gnus-group-list-groups arg))
5250 (defun gnus-group-read-init-file ()
5251 "Read the Gnus elisp init file."
5253 (gnus-read-init-file))
5255 (defun gnus-group-check-bogus-groups (&optional silent)
5256 "Check bogus newsgroups.
5257 If given a prefix, don't ask for confirmation before removing a bogus
5260 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
5261 (gnus-group-list-groups))
5263 (defun gnus-group-edit-global-kill (&optional article group)
5264 "Edit the global kill file.
5265 If GROUP, edit that local kill file instead."
5267 (setq gnus-current-kill-article article)
5268 (gnus-kill-file-edit-file group)
5271 (substitute-command-keys
5272 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
5274 (defun gnus-group-edit-local-kill (article group)
5275 "Edit a local kill file."
5276 (interactive (list nil (gnus-group-group-name)))
5277 (gnus-group-edit-global-kill article group))
5279 (defun gnus-group-force-update ()
5280 "Update `.newsrc' file."
5282 (gnus-save-newsrc-file))
5284 (defun gnus-group-suspend ()
5285 "Suspend the current Gnus session.
5286 In fact, cleanup buffers except for group mode buffer.
5287 The hook gnus-suspend-gnus-hook is called before actually suspending."
5289 (run-hooks 'gnus-suspend-gnus-hook)
5290 ;; Kill Gnus buffers except for group mode buffer.
5291 (let ((group-buf (get-buffer gnus-group-buffer)))
5292 ;; Do this on a separate list in case the user does a ^G before we finish
5293 (let ((gnus-buffer-list
5294 (delq group-buf (delq gnus-dribble-buffer
5295 (append gnus-buffer-list nil)))))
5296 (while gnus-buffer-list
5297 (gnus-kill-buffer (car gnus-buffer-list))
5298 (setq gnus-buffer-list (cdr gnus-buffer-list))))
5301 (setq gnus-buffer-list (list group-buf))
5302 (bury-buffer group-buf)
5303 (delete-windows-on group-buf t)))))
5305 (defun gnus-group-clear-dribble ()
5306 "Clear all information from the dribble buffer."
5308 (gnus-dribble-clear))
5310 (defun gnus-group-exit ()
5311 "Quit reading news after updating .newsrc.eld and .newsrc.
5312 The hook `gnus-exit-gnus-hook' is called before actually exiting."
5314 (if (or noninteractive ;For gnus-batch-kill
5315 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
5316 (not gnus-interactive-exit) ;Without confirmation
5318 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
5320 (run-hooks 'gnus-exit-gnus-hook)
5321 ;; Offer to save data from non-quitted summary buffers.
5322 (gnus-offer-save-summaries)
5323 ;; Save the newsrc file(s).
5324 (gnus-save-newsrc-file)
5326 (gnus-close-backends)
5327 ;; Reset everything.
5328 (gnus-clear-system))))
5330 (defun gnus-close-backends ()
5331 ;; Send a close request to all backends that support such a request.
5332 (let ((methods gnus-valid-select-methods)
5335 (if (fboundp (setq func (intern (concat (car (car methods))
5336 "-request-close"))))
5338 (setq methods (cdr methods)))))
5340 (defun gnus-group-quit ()
5341 "Quit reading news without updating .newsrc.eld or .newsrc.
5342 The hook `gnus-exit-gnus-hook' is called before actually exiting."
5344 (if (or noninteractive ;For gnus-batch-kill
5345 (zerop (buffer-size))
5346 (not (gnus-server-opened gnus-select-method))
5348 (not gnus-current-startup-file)
5350 (format "Quit reading news without saving %s? "
5351 (file-name-nondirectory gnus-current-startup-file))))
5353 (run-hooks 'gnus-exit-gnus-hook)
5354 (if gnus-use-full-window
5355 (delete-other-windows)
5356 (gnus-remove-some-windows))
5358 (gnus-close-backends)
5359 (gnus-clear-system))))
5361 (defun gnus-offer-save-summaries ()
5363 (let ((buflist (buffer-list))
5366 (and (setq bufname (buffer-name (car buflist)))
5367 (string-match "Summary" bufname)
5369 (set-buffer bufname)
5370 ;; We check that this is, indeed, a summary buffer.
5371 (eq major-mode 'gnus-summary-mode))
5372 (setq buffers (cons bufname buffers)))
5373 (setq buflist (cdr buflist)))
5376 "Update summary buffer %s? "
5379 (gnus-summary-exit))
5382 (defun gnus-group-describe-briefly ()
5383 "Give a one line description of the group mode commands."
5385 (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")))
5387 (defun gnus-group-browse-foreign-server (method)
5388 "Browse a foreign news server.
5389 If called interactively, this function will ask for a select method
5390 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
5391 If not, METHOD should be a list where the first element is the method
5392 and the second element is the address."
5394 (list (let ((how (completing-read
5396 (append gnus-valid-select-methods gnus-server-alist)
5398 ;; We either got a backend name or a virtual server name.
5399 ;; If the first, we also need an address.
5400 (if (assoc how gnus-valid-select-methods)
5402 ;; Suggested by mapjph@bath.ac.uk.
5405 (mapcar (lambda (server) (list server))
5406 gnus-secondary-servers)))
5407 ;; We got a server name, so we find the method.
5408 (gnus-server-to-method how)))))
5409 (gnus-browse-foreign-server method))
5413 ;;; Browse Server Mode
5416 (defvar gnus-browse-mode-hook nil)
5417 (defvar gnus-browse-mode-map nil)
5418 (put 'gnus-browse-mode 'mode-class 'special)
5420 (if gnus-browse-mode-map
5422 (setq gnus-browse-mode-map (make-keymap))
5423 (suppress-keymap gnus-browse-mode-map)
5424 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
5425 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
5426 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
5427 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
5428 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
5429 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
5430 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
5431 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
5432 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
5433 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
5434 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
5435 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
5436 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
5437 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
5438 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
5439 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
5440 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
5441 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
5444 (defvar gnus-browse-current-method nil)
5445 (defvar gnus-browse-return-buffer nil)
5447 (defvar gnus-browse-buffer "*Gnus Browse Server*")
5449 (defun gnus-browse-foreign-server (method &optional return-buffer)
5450 (setq gnus-browse-current-method method)
5451 (setq gnus-browse-return-buffer return-buffer)
5452 (let ((gnus-select-method method)
5454 (gnus-message 5 "Connecting to %s..." (nth 1 method))
5455 (or (gnus-check-server method)
5456 (error "Unable to contact server: %s" (gnus-status-message method)))
5457 (or (gnus-request-list method)
5458 (error "Couldn't request list: %s" (gnus-status-message method)))
5459 (get-buffer-create gnus-browse-buffer)
5460 (gnus-add-current-to-buffer-list)
5461 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
5462 (gnus-configure-windows 'browse)
5463 (buffer-disable-undo (current-buffer))
5464 (let ((buffer-read-only nil))
5467 (setq mode-line-buffer-identification
5469 "Gnus Browse Server {%s:%s}" (car method) (car (cdr method))))
5471 (set-buffer nntp-server-buffer)
5472 (let ((cur (current-buffer)))
5473 (goto-char (point-min))
5474 (or (string= gnus-ignored-newsgroups "")
5475 (delete-matching-lines gnus-ignored-newsgroups))
5476 (while (re-search-forward
5477 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
5478 (goto-char (match-end 1))
5479 (setq groups (cons (cons (buffer-substring (match-beginning 1)
5481 (max 0 (- (1+ (read cur)) (read cur))))
5483 (setq groups (sort groups
5485 (string< (car l1) (car l2)))))
5486 (let ((buffer-read-only nil))
5488 (setq group (car groups))
5490 (format "K%7d: %s\n" (cdr group) (car group)))
5491 (setq groups (cdr groups))))
5492 (switch-to-buffer (current-buffer))
5493 (goto-char (point-min))
5494 (gnus-group-position-point)))
5496 (defun gnus-browse-mode ()
5497 "Major mode for browsing a foreign server.
5499 All normal editing commands are switched off.
5501 \\<gnus-browse-mode-map>
5502 The only things you can do in this buffer is
5504 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
5505 The group will be inserted into the group buffer upon exit from this
5508 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
5510 3) `\\[gnus-browse-exit]' to return to the group buffer."
5512 (kill-all-local-variables)
5513 (if (gnus-visual-p 'browse-menu 'menu) (gnus-browse-make-menu-bar))
5514 (setq mode-line-modified "-- ")
5515 (make-local-variable 'mode-line-format)
5516 (setq mode-line-format (copy-sequence mode-line-format))
5517 (and (equal (nth 3 mode-line-format) " ")
5518 (setcar (nthcdr 3 mode-line-format) ""))
5519 (setq major-mode 'gnus-browse-mode)
5520 (setq mode-name "Browse Server")
5521 (setq mode-line-process nil)
5522 (use-local-map gnus-browse-mode-map)
5523 (buffer-disable-undo (current-buffer))
5524 (setq truncate-lines t)
5525 (setq buffer-read-only t)
5526 (run-hooks 'gnus-browse-mode-hook))
5528 (defun gnus-browse-read-group (&optional no-article)
5529 "Enter the group at the current line."
5531 (let ((group (gnus-browse-group-name)))
5532 (or (gnus-group-read-ephemeral-group
5533 group gnus-browse-current-method nil
5534 (cons (current-buffer) 'browse))
5535 (error "Couldn't enter %s" group))))
5537 (defun gnus-browse-select-group ()
5538 "Select the current group."
5540 (gnus-browse-read-group 'no))
5542 (defun gnus-browse-next-group (n)
5543 "Go to the next group."
5547 (gnus-group-position-point)))
5549 (defun gnus-browse-prev-group (n)
5550 "Go to the next group."
5552 (gnus-browse-next-group (- n)))
5554 (defun gnus-browse-unsubscribe-current-group (arg)
5555 "(Un)subscribe to the next ARG groups."
5558 (error "No group at current line."))
5559 (let ((ward (if (< arg 0) -1 1))
5561 (while (and (> arg 0)
5563 (gnus-browse-unsubscribe-group)
5564 (zerop (gnus-browse-next-group ward)))
5565 (setq arg (1- arg)))
5566 (gnus-group-position-point)
5567 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5570 (defun gnus-browse-group-name ()
5573 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5575 (gnus-group-prefixed-name
5576 (buffer-substring (match-beginning 1) (match-end 1))
5577 gnus-browse-current-method))))
5579 (defun gnus-browse-unsubscribe-group ()
5581 (buffer-read-only nil)
5585 (if (= (following-char) ?K) (setq sub t))
5586 (setq group (gnus-browse-group-name))
5591 (gnus-group-change-level
5592 (list t group gnus-level-default-subscribed
5593 nil nil gnus-browse-current-method)
5594 gnus-level-default-subscribed gnus-level-killed
5595 (and (car (nth 1 gnus-newsrc-alist))
5596 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5597 gnus-newsrc-hashtb))
5600 (gnus-group-change-level
5601 group gnus-level-killed gnus-level-default-subscribed)
5605 (defun gnus-browse-exit ()
5606 "Quit browsing and return to the group buffer."
5608 (if (eq major-mode 'gnus-browse-mode)
5609 (kill-buffer (current-buffer)))
5610 (if gnus-browse-return-buffer
5611 (gnus-configure-windows 'server 'force)
5612 (gnus-configure-windows 'group 'force)
5613 (gnus-group-list-groups nil)))
5615 (defun gnus-browse-describe-briefly ()
5616 "Give a one line description of the group mode commands."
5619 (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")))
5623 ;;; Gnus summary mode
5626 (defvar gnus-summary-mode-map nil)
5627 (defvar gnus-summary-mark-map nil)
5628 (defvar gnus-summary-mscore-map nil)
5629 (defvar gnus-summary-article-map nil)
5630 (defvar gnus-summary-thread-map nil)
5631 (defvar gnus-summary-goto-map nil)
5632 (defvar gnus-summary-exit-map nil)
5633 (defvar gnus-summary-interest-map nil)
5634 (defvar gnus-summary-sort-map nil)
5635 (defvar gnus-summary-backend-map nil)
5636 (defvar gnus-summary-save-map nil)
5637 (defvar gnus-summary-wash-map nil)
5638 (defvar gnus-summary-wash-hide-map nil)
5639 (defvar gnus-summary-wash-highlight-map nil)
5640 (defvar gnus-summary-wash-time-map nil)
5641 (defvar gnus-summary-help-map nil)
5642 (defvar gnus-summary-limit-map nil)
5644 (put 'gnus-summary-mode 'mode-class 'special)
5646 (if gnus-summary-mode-map
5648 (setq gnus-summary-mode-map (make-keymap))
5649 (suppress-keymap gnus-summary-mode-map)
5651 ;; Non-orthogonal keys
5653 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5654 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5655 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5656 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5657 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5658 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5659 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5660 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5661 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5662 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5663 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5664 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5665 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5666 (define-key gnus-summary-mode-map
5667 "\M-s" 'gnus-summary-search-article-forward)
5668 (define-key gnus-summary-mode-map
5669 "\M-r" 'gnus-summary-search-article-backward)
5670 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5671 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5672 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5673 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5674 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5675 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5676 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5677 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5678 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5679 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5680 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5681 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5682 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5683 (define-key gnus-summary-mode-map
5684 "k" 'gnus-summary-kill-same-subject-and-select)
5685 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5686 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5687 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5688 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5689 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5690 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5691 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5692 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5693 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5694 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5695 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5696 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5697 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5698 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5699 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5700 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5701 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5702 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5703 (define-key gnus-summary-mode-map
5704 "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5705 (define-key gnus-summary-mode-map
5706 "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5707 (define-key gnus-summary-mode-map
5708 "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5709 (define-key gnus-summary-mode-map
5710 "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5711 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5712 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5713 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5714 (define-key gnus-summary-mode-map
5715 "\C-x\C-s" 'gnus-summary-reselect-current-group)
5716 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5717 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5718 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5719 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5720 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5721 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5722 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5723 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5724 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5725 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5726 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5727 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5728 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5729 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5730 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5731 (define-key gnus-summary-mode-map "V" 'gnus-version)
5732 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5733 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5734 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5735 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5736 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5737 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5738 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5739 (define-key gnus-summary-mode-map "x" 'gnus-summary-limit-to-unread)
5740 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5741 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5742 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5743 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5744 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5745 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5746 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5747 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5748 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5749 (define-key gnus-summary-mode-map "/" 'gnus-summary-limit-to-subject)
5752 ;; Sort of orthogonal keymap
5753 (define-prefix-command 'gnus-summary-mark-map)
5754 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5755 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5756 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5757 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5758 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5759 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5760 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5761 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5762 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5763 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5764 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5765 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5766 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5767 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5768 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5769 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5770 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5771 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5772 (define-key gnus-summary-mark-map
5773 "k" 'gnus-summary-kill-same-subject-and-select)
5774 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5776 (define-prefix-command 'gnus-summary-mscore-map)
5777 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map)
5778 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5779 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5780 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5781 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5783 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map)
5785 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5787 (define-prefix-command 'gnus-summary-limit-map)
5788 (define-key gnus-summary-mark-map "N" 'gnus-summary-limit-map)
5789 (define-key gnus-summary-limit-map "n" 'gnus-summary-limit-to-articles)
5790 (define-key gnus-summary-limit-map "w" 'gnus-summary-pop-limit)
5791 (define-key gnus-summary-limit-map "s" 'gnus-summary-limit-to-subject)
5792 (define-key gnus-summary-limit-map "u" 'gnus-summary-limit-to-unread)
5793 (define-key gnus-summary-limit-map "m" 'gnus-summary-limit-to-marks)
5794 (define-key gnus-summary-limit-map "v" 'gnus-summary-limit-to-score)
5795 (define-key gnus-summary-limit-map "D" 'gnus-summary-limit-include-dormant)
5796 (define-key gnus-summary-limit-map "d" 'gnus-summary-limit-exclude-dormant)
5797 (define-key gnus-summary-limit-map "c"
5798 'gnus-summary-limit-exclude-childless-dormant)
5800 (define-prefix-command 'gnus-summary-goto-map)
5801 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5802 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5803 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5804 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5805 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5806 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5807 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5808 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5809 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5810 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5811 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5812 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5813 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5814 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5817 (define-prefix-command 'gnus-summary-thread-map)
5818 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5819 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5820 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5821 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5822 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5823 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5824 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5825 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5826 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5827 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5828 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5829 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5830 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5831 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5832 (define-key gnus-summary-thread-map "\M-#" 'gnus-uu-unmark-thread)
5835 (define-prefix-command 'gnus-summary-exit-map)
5836 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5837 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5838 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5839 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5840 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5841 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5842 (define-key gnus-summary-exit-map
5843 "n" 'gnus-summary-catchup-and-goto-next-group)
5844 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5845 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5846 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5847 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5850 (define-prefix-command 'gnus-summary-article-map)
5851 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5852 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5853 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5854 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5855 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5856 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5857 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5858 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5859 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5860 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5861 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5862 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5863 (define-key gnus-summary-article-map "R" 'gnus-summary-refer-references)
5864 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5865 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5869 (define-prefix-command 'gnus-summary-wash-map)
5870 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5872 (define-prefix-command 'gnus-summary-wash-hide-map)
5873 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map)
5874 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide)
5875 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers)
5876 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature)
5877 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation)
5878 (define-key gnus-summary-wash-hide-map "p" 'gnus-article-hide-pgp)
5879 (define-key gnus-summary-wash-hide-map
5880 "\C-c" 'gnus-article-hide-citation-maybe)
5882 (define-prefix-command 'gnus-summary-wash-highlight-map)
5883 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map)
5884 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight)
5885 (define-key gnus-summary-wash-highlight-map
5886 "h" 'gnus-article-highlight-headers)
5887 (define-key gnus-summary-wash-highlight-map
5888 "c" 'gnus-article-highlight-citation)
5889 (define-key gnus-summary-wash-highlight-map
5890 "s" 'gnus-article-highlight-signature)
5892 (define-prefix-command 'gnus-summary-wash-time-map)
5893 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map)
5894 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut)
5895 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut)
5896 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local)
5897 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed)
5898 (define-key gnus-summary-wash-time-map "o" 'gnus-article-date-original)
5900 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5901 (define-key gnus-summary-wash-map "B" 'gnus-article-add-buttons-to-head)
5902 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5903 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5904 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr)
5905 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5906 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5907 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
5908 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
5909 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header)
5910 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
5913 (define-prefix-command 'gnus-summary-help-map)
5914 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5915 (define-key gnus-summary-help-map "v" 'gnus-version)
5916 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5917 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5918 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5919 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5922 (define-prefix-command 'gnus-summary-backend-map)
5923 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5924 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5925 (define-key gnus-summary-backend-map "\M-\C-e"
5926 'gnus-summary-expire-articles-now)
5927 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5928 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5929 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5930 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5931 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5932 (define-key gnus-summary-backend-map "q" 'gnus-summary-respool-query)
5933 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5936 (define-prefix-command 'gnus-summary-save-map)
5937 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5938 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5939 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5940 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5941 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5942 (define-key gnus-summary-save-map "b" 'gnus-summary-save-article-body-file)
5943 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5944 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5945 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5946 (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5948 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5950 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
5951 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
5953 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map)
5955 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5956 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5962 (defun gnus-summary-mode (&optional group)
5963 "Major mode for reading articles.
5965 All normal editing commands are switched off.
5966 \\<gnus-summary-mode-map>
5967 Each line in this buffer represents one article. To read an
5968 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5969 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5972 You can also post articles and send mail from this buffer. To
5973 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5974 of an article, type `\\[gnus-summary-reply]'.
5976 There are approx. one gazillion commands you can execute in this
5977 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5979 The following commands are available:
5981 \\{gnus-summary-mode-map}"
5983 (if (gnus-visual-p 'summary-menu 'menu) (gnus-summary-make-menu-bar))
5984 (kill-all-local-variables)
5985 (let ((locals gnus-summary-local-variables))
5987 (if (consp (car locals))
5989 (make-local-variable (car (car locals)))
5990 (set (car (car locals)) (eval (cdr (car locals)))))
5991 (make-local-variable (car locals))
5992 (set (car locals) nil))
5993 (setq locals (cdr locals))))
5994 (gnus-make-thread-indent-array)
5995 (setq mode-line-modified "-- ")
5996 (make-local-variable 'mode-line-format)
5997 (setq mode-line-format (copy-sequence mode-line-format))
5998 (and (equal (nth 3 mode-line-format) " ")
5999 (setcar (nthcdr 3 mode-line-format) ""))
6000 (setq major-mode 'gnus-summary-mode)
6001 (setq mode-name "Summary")
6002 (make-local-variable 'minor-mode-alist)
6003 (use-local-map gnus-summary-mode-map)
6004 (buffer-disable-undo (current-buffer))
6005 (setq buffer-read-only t) ;Disable modification
6006 (setq truncate-lines t)
6007 (setq selective-display t)
6008 (setq selective-display-ellipses t) ;Display `...'
6009 (setq buffer-display-table gnus-summary-display-table)
6010 (setq gnus-newsgroup-name group)
6011 (run-hooks 'gnus-summary-mode-hook))
6013 (defun gnus-summary-make-display-table ()
6014 ;; Change the display table. Odd characters have a tendency to mess
6015 ;; up nicely formatted displays - we make all possible glyphs
6016 ;; display only a single character.
6018 ;; We start from the standard display table, if any.
6019 (setq gnus-summary-display-table
6020 (or (copy-sequence standard-display-table)
6021 (make-display-table)))
6022 ;; Nix out all the control chars...
6024 (while (>= (setq i (1- i)) 0)
6025 (aset gnus-summary-display-table i [??])))
6026 ;; ... but not newline and cr, of course. (cr is necessary for the
6027 ;; selective display).
6028 (aset gnus-summary-display-table ?\n nil)
6029 (aset gnus-summary-display-table ?\r nil)
6030 ;; We nix out any glyphs over 126 that are not set already.
6032 (while (>= (setq i (1- i)) 127)
6033 ;; Only modify if the entry is nil.
6034 (or (aref gnus-summary-display-table i)
6035 (aset gnus-summary-display-table i [??])))))
6037 (defun gnus-summary-clear-local-variables ()
6038 (let ((locals gnus-summary-local-variables))
6040 (if (consp (car locals))
6041 (and (vectorp (car (car locals)))
6042 (set (car (car locals)) nil))
6043 (and (vectorp (car locals))
6044 (set (car locals) nil)))
6045 (setq locals (cdr locals)))))
6047 ;; Summary data functions.
6049 (defmacro gnus-data-number (data)
6052 (defmacro gnus-data-mark (data)
6053 (` (nth 1 (, data))))
6055 (defmacro gnus-data-set-mark (data mark)
6056 (` (setcar (nthcdr 1 (, data)) (, mark))))
6058 (defmacro gnus-data-pos (data)
6059 (` (nth 2 (, data))))
6061 (defmacro gnus-data-header (data)
6062 (` (nth 3 (, data))))
6064 (defmacro gnus-data-level (data)
6065 (` (nth 4 (, data))))
6067 (defmacro gnus-data-unread-p (data)
6068 (` (= (nth 1 (, data)) gnus-unread-mark)))
6070 (defmacro gnus-data-find (number)
6071 (` (assq (, number) gnus-newsgroup-data)))
6073 (defmacro gnus-data-find-list (number &optional data)
6074 (` (memq (assq (, number) (, (or data 'gnus-newsgroup-data)))
6075 (, (or data 'gnus-newsgroup-data)))))
6077 (defmacro gnus-data-make (number mark pos header level)
6078 (` (list (, number) (, mark) (set-marker (make-marker) (, pos)) (, header)
6081 (defun gnus-data-enter (after-article number mark pos header level)
6082 (let ((data (gnus-data-find-list after-article)))
6083 (or data (error "No such article: %d" after-article))
6084 (setcdr data (cons (gnus-data-make number mark pos header level)
6087 (defun gnus-data-enter-list (after-article list)
6090 (let ((data (gnus-data-find-list after-article))
6092 (or data (error "No such article: %d" after-article))
6093 ;; Find the last element in the list to be spliced into the main
6096 (setq list (cdr list)))
6097 (setcdr list (cdr data))
6098 (setcdr data ilist))))
6100 (defun gnus-data-remove (article)
6101 (let ((data gnus-newsgroup-data))
6102 (if (= (gnus-data-number (car data)) article)
6103 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
6104 gnus-newsgroup-data-reverse nil)
6106 (and (= (gnus-data-number (car (cdr data))) article)
6108 (set-marker (gnus-data-pos (car (cdr data))) nil)
6109 (setcdr data (cdr (cdr data)))
6111 gnus-newsgroup-data-reverse nil)))
6112 (setq data (cdr data))))))
6114 (defmacro gnus-data-list (backward)
6116 (or gnus-newsgroup-data-reverse
6117 (setq gnus-newsgroup-data-reverse
6118 (reverse gnus-newsgroup-data)))
6119 gnus-newsgroup-data)))
6121 (defun gnus-summary-article-pseudo-p (article)
6122 (not (vectorp (gnus-data-header (gnus-data-find article)))))
6124 (defun gnus-article-parent-p (number)
6125 (let* ((data (gnus-data-find-list number)))
6126 (and (cdr data) ; There has to be an article after...
6127 (< (gnus-data-level (car data)) ; And it has to have a higher level.
6128 (gnus-data-level (nth 1 data))))))
6130 ;; Some summary mode macros.
6132 (defmacro gnus-summary-article-number (&optional number-or-nil)
6133 "The article number of the article on the current line.
6134 If there isn's an article number here, then we return the current
6137 '(get-text-property (point) 'gnus-number)
6138 '(or (get-text-property (point) 'gnus-number)
6139 gnus-current-article)))
6141 (defmacro gnus-summary-article-header (&optional number)
6142 (` (gnus-data-header (gnus-data-find
6143 (, (or number '(gnus-summary-article-number)))))))
6145 (defmacro gnus-summary-thread-level (&optional number)
6146 (` (gnus-data-level (gnus-data-find
6147 (, (or number '(gnus-summary-article-number)))))))
6149 (defmacro gnus-summary-article-mark (&optional number)
6150 (` (gnus-data-mark (gnus-data-find
6151 (, (or number '(gnus-summary-article-number)))))))
6153 (defmacro gnus-summary-article-pos (&optional number)
6154 (` (gnus-data-pos (gnus-data-find
6155 (, (or number '(gnus-summary-article-number)))))))
6157 (defmacro gnus-summary-article-subject (&optional number)
6158 "Return current subject string or nil if nothing."
6161 (` (gnus-data-header (assq (, number) gnus-newsgroup-data)))
6162 '(gnus-data-header (assq (gnus-summary-article-number)
6163 gnus-newsgroup-data))))))
6166 (mail-header-subject headers)))))
6168 (defmacro gnus-summary-article-score (&optional number)
6169 "Return current article score."
6170 (` (or (cdr (assq (, (or number '(gnus-summary-article-number)))
6171 gnus-newsgroup-scored))
6172 gnus-summary-default-score 0)))
6174 (defun gnus-summary-article-children (&optional number)
6175 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
6176 (level (gnus-data-level (car data)))
6178 (while (and (setq data (cdr data))
6179 (> (setq l (gnus-data-level (car data))) level))
6180 (and (= (1+ level) l)
6181 (setq children (cons (gnus-data-number (car data))
6183 (nreverse children)))
6185 (defun gnus-summary-article-parent (&optional number)
6186 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
6187 (gnus-data-list t)))
6188 (level (gnus-data-level (car data)))
6191 () ; This is a root.
6192 ;; We search until we find an article with a level less than
6193 ;; this one. That function has to be the parent.
6194 (while (and (setq data (cdr data))
6195 (not (< (gnus-data-level (car data)) level))))
6196 (and data (gnus-data-number (car data))))))
6199 ;; Various summary mode internalish functions.
6201 (defun gnus-mouse-pick-article (e)
6204 (gnus-summary-next-page nil t))
6206 (defun gnus-summary-setup-buffer (group)
6207 "Initialize summary buffer."
6208 (let ((buffer (concat "*Summary " group "*")))
6209 (if (get-buffer buffer)
6212 (not gnus-newsgroup-begin))
6213 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6214 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
6215 (gnus-add-current-to-buffer-list)
6216 (gnus-summary-mode group)
6217 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
6218 (setq gnus-newsgroup-name group)
6221 (defun gnus-set-global-variables ()
6222 ;; Set the global equivalents of the summary buffer-local variables
6223 ;; to the latest values they had. These reflect the summary buffer
6224 ;; that was in action when the last article was fetched.
6225 (if (eq major-mode 'gnus-summary-mode)
6227 (setq gnus-summary-buffer (current-buffer))
6228 (let ((name gnus-newsgroup-name)
6229 (marked gnus-newsgroup-marked)
6230 (unread gnus-newsgroup-unreads)
6231 (headers gnus-current-headers)
6232 (data gnus-newsgroup-data)
6233 (score-file gnus-current-score-file))
6235 (set-buffer gnus-group-buffer)
6236 (setq gnus-newsgroup-name name)
6237 (setq gnus-newsgroup-marked marked)
6238 (setq gnus-newsgroup-unreads unread)
6239 (setq gnus-current-headers headers)
6240 (setq gnus-newsgroup-data data)
6241 (setq gnus-current-score-file score-file))))))
6243 (defun gnus-summary-last-article-p (&optional article)
6244 "Return whether ARTICLE is the last article in the buffer."
6245 (if (not (setq article (or article (gnus-summary-article-number))))
6246 t ; All non-existant numbers are the last article. :-)
6247 (cdr (gnus-data-find-list article))))
6249 (defun gnus-summary-insert-dummy-line (sformat subject number)
6251 (setq sformat gnus-summary-dummy-line-format-spec))
6254 (point) (progn (insert (eval sformat)) (point))
6255 'gnus-number number))
6257 (defvar gnus-thread-indent-array nil)
6258 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
6259 (defun gnus-make-thread-indent-array ()
6261 (if (and gnus-thread-indent-array
6262 (= gnus-thread-indent-level gnus-thread-indent-array-level))
6264 (setq gnus-thread-indent-array (make-vector 201 "")
6265 gnus-thread-indent-array-level gnus-thread-indent-level)
6267 (aset gnus-thread-indent-array n
6268 (make-string (* n gnus-thread-indent-level) ? ))
6271 (defun gnus-summary-insert-line
6272 (sformat header level current unread replied expirable subject-or-nil
6273 &optional dummy score process)
6274 (or sformat (setq sformat gnus-summary-line-format-spec))
6275 (let* ((indentation (aref gnus-thread-indent-array level))
6276 (lines (mail-header-lines header))
6277 (score (or score gnus-summary-default-score 0))
6279 (if (or (null gnus-summary-default-score)
6280 (<= (abs (- score gnus-summary-default-score))
6281 gnus-summary-zcore-fuzz)) ?
6282 (if (< score gnus-summary-default-score)
6283 gnus-score-below-mark gnus-score-over-mark)))
6284 (replied (cond (process gnus-process-mark)
6285 (replied gnus-replied-mark)
6286 (t gnus-unread-mark)))
6287 (from (mail-header-from header))
6289 ((string-match "(.+)" from)
6290 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
6291 ((string-match "<[^>]+> *$" from)
6292 (let ((beg (match-beginning 0)))
6293 (or (and (string-match "^\"[^\"]*\"" from)
6294 (substring from (1+ (match-beginning 0))
6295 (1- (match-end 0))))
6296 (substring from 0 beg))))
6298 (subject (mail-header-subject header))
6299 (number (mail-header-number header))
6300 (opening-bracket (if dummy ?\< ?\[))
6301 (closing-bracket (if dummy ?\> ?\]))
6302 (buffer-read-only nil))
6303 (or (numberp lines) (setq lines 0))
6306 (progn (insert (eval sformat)) (point))
6307 'gnus-number number)))
6309 (defun gnus-summary-update-line (&optional dont-update)
6310 ;; Update summary line after change.
6311 (or (not gnus-summary-default-score)
6312 gnus-summary-inhibit-highlight
6313 (let ((gnus-summary-inhibit-highlight t)
6314 (article (gnus-summary-article-number)))
6317 (if (and gnus-summary-mark-below
6318 (< (gnus-summary-article-score)
6319 gnus-summary-mark-below))
6320 (and (not (memq article gnus-newsgroup-marked))
6321 (not (memq article gnus-newsgroup-dormant))
6322 (memq article gnus-newsgroup-unreads)
6323 (gnus-summary-mark-article-as-read gnus-low-score-mark))
6324 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
6325 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
6326 (and (gnus-visual-p 'summary-highlight 'highlight)
6327 (run-hooks 'gnus-summary-update-hook))))))
6329 (defun gnus-summary-update-lines (&optional beg end)
6330 ;; Mark article as read (or not) by taking into account scores.
6331 (let ((beg (or beg (point-min)))
6332 (end (or end (point-max))))
6333 (if (or (not gnus-summary-default-score)
6334 gnus-summary-inhibit-highlight)
6336 (let ((gnus-summary-inhibit-highlight t)
6339 (set-buffer gnus-summary-buffer)
6342 (while (and (not (eobp)) (< (point) end))
6343 (if (and gnus-summary-mark-below
6345 (setq article (gnus-summary-article-number))
6346 gnus-newsgroup-scored))
6347 gnus-summary-default-score 0)
6348 gnus-summary-mark-below))
6349 ;; We want to possibly mark it as read...
6350 (and (not (memq article gnus-newsgroup-marked))
6351 (not (memq article gnus-newsgroup-dormant))
6352 (memq article gnus-newsgroup-unreads)
6353 (gnus-summary-mark-article-as-read gnus-low-score-mark))
6354 ;; We want to possibly mark it as unread.
6355 (and (eq (gnus-summary-article-mark article)
6356 gnus-low-score-mark)
6357 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
6358 ;; Do the visual highlights at the same time.
6359 (and (gnus-visual-p 'summary-highlight 'highlight)
6360 (run-hooks 'gnus-summary-update-hook))
6361 (forward-line 1)))))))
6363 (defvar gnus-tmp-gathered nil)
6365 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
6366 ;; Sum up all elements (and sub-elements) in a list.
6368 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
6369 (if (and (consp thread) (cdr thread))
6372 'gnus-summary-number-of-articles-in-thread
6376 (if (> number 1) gnus-not-empty-thread-mark
6377 gnus-empty-thread-mark)
6380 ;; This function goes through the local params of GROUP and sets all
6381 ;; variable specs in that list.
6382 (defun gnus-summary-set-local-parameters (group)
6383 (let ((params (nth 5 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6386 (setq elem (car params)
6387 params (cdr params))
6390 (symbolp (car elem))
6392 (make-local-variable (car elem))
6393 (set (car elem) (eval (nth 1 elem))))))))
6395 (defun gnus-summary-read-group
6396 (group &optional show-all no-article kill-buffer no-display)
6397 "Start reading news in newsgroup GROUP.
6398 If SHOW-ALL is non-nil, already read articles are also listed.
6399 If NO-ARTICLE is non-nil, no article is selected initially.
6400 If NO-DISPLAY, don't generate a summary buffer."
6401 (gnus-message 5 "Retrieving newsgroup: %s..." group)
6402 (let* ((new-group (gnus-summary-setup-buffer group))
6403 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
6405 (did-select (and new-group (gnus-select-newsgroup group show-all))))
6408 (gnus-set-global-variables)
6409 (gnus-kill-buffer kill-buffer)
6410 (gnus-configure-windows 'summary 'force)
6411 (gnus-set-mode-line 'summary)
6412 (gnus-summary-position-point)
6416 (and (eq major-mode 'gnus-summary-mode)
6417 (not (equal (current-buffer) kill-buffer))
6419 (kill-buffer (current-buffer))
6420 (if (not quit-config)
6422 (set-buffer gnus-group-buffer)
6423 (gnus-group-jump-to-group group)
6424 (gnus-group-next-unread-group 1))
6425 (if (not (buffer-name (car quit-config)))
6426 (gnus-configure-windows 'group 'force)
6427 (set-buffer (car quit-config))
6428 (and (eq major-mode 'gnus-summary-mode)
6429 (gnus-set-global-variables))
6430 (gnus-configure-windows (cdr quit-config))))))
6431 (message "Can't select group")
6433 ((eq did-select 'quit)
6434 (and (eq major-mode 'gnus-summary-mode)
6435 (not (equal (current-buffer) kill-buffer))
6436 (kill-buffer (current-buffer)))
6437 (gnus-kill-buffer kill-buffer)
6438 (if (not quit-config)
6440 (set-buffer gnus-group-buffer)
6441 (gnus-group-jump-to-group group)
6442 (gnus-group-next-unread-group 1)
6443 (gnus-configure-windows 'group 'force))
6444 (if (not (buffer-name (car quit-config)))
6445 (gnus-configure-windows 'group 'force)
6446 (set-buffer (car quit-config))
6447 (and (eq major-mode 'gnus-summary-mode)
6448 (gnus-set-global-variables))
6449 (gnus-configure-windows (cdr quit-config))))
6452 (gnus-set-global-variables)
6453 ;; Save the active value in effect when the group was entered.
6454 (setq gnus-newsgroup-active
6456 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6457 ;; You can change the summary buffer in some way with this hook.
6458 (run-hooks 'gnus-select-group-hook)
6459 ;; Set any local variables in the group parameters.
6460 (gnus-summary-set-local-parameters gnus-newsgroup-name)
6461 ;; Do score processing.
6462 (and gnus-use-scoring (gnus-possibly-score-headers))
6463 (gnus-update-format-specifications)
6464 ;; Generate the summary buffer.
6466 (gnus-summary-prepare))
6467 (if (zerop (buffer-size))
6468 (cond (gnus-newsgroup-dormant
6469 (gnus-summary-limit-include-dormant))
6470 ((and gnus-newsgroup-scored show-all)
6471 (gnus-summary-show-all-expunged))))
6472 ;; Function `gnus-apply-kill-file' must be called in this hook.
6473 (run-hooks 'gnus-apply-kill-hook)
6474 (if (zerop (buffer-size))
6476 ;; This newsgroup is empty.
6477 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
6478 (gnus-message 6 "No unread news")
6479 (gnus-kill-buffer kill-buffer)
6483 ;; (let ((gnus-summary-buffer kill-buffer))
6484 ;; (gnus-configure-windows 'group))))
6485 ;; Hide conversation thread subtrees. We cannot do this in
6486 ;; gnus-summary-prepare-hook since kill processing may not
6487 ;; work with hidden articles.
6488 (and gnus-show-threads
6489 gnus-thread-hide-subtree
6490 (gnus-summary-hide-all-threads))
6491 ;; Show first unread article if requested.
6492 (goto-char (point-min))
6493 (if (and (not no-article)
6494 gnus-auto-select-first
6495 (gnus-summary-first-unread-article))
6497 (gnus-configure-windows 'summary 'force))
6498 (gnus-set-mode-line 'summary)
6499 (gnus-summary-position-point)
6500 ;; If in async mode, we send some info to the backend.
6501 (and gnus-newsgroup-async
6502 (gnus-request-asynchronous
6503 gnus-newsgroup-name gnus-newsgroup-data))
6504 (gnus-kill-buffer kill-buffer)
6505 (if (not (get-buffer-window gnus-group-buffer))
6507 ;; gotta use windows, because recenter does wierd stuff if
6508 ;; the current buffer ain't the displayed window.
6509 (let ((owin (selected-window)))
6510 (select-window (get-buffer-window gnus-group-buffer))
6511 (and (gnus-group-goto-group group)
6513 (select-window owin))))
6516 (defun gnus-summary-prepare ()
6517 ;; Generate the summary buffer.
6518 (let ((buffer-read-only nil))
6520 (setq gnus-newsgroup-data nil
6521 gnus-newsgroup-data-reverse nil)
6522 (gnus-summary-prepare-threads
6523 (if gnus-show-threads
6524 (gnus-gather-threads
6526 (gnus-make-threads)))
6527 gnus-newsgroup-headers)
6529 (gnus-summary-update-lines)
6530 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
6531 ;; Call hooks for modifying summary buffer.
6532 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
6533 (goto-char (point-min))
6534 (run-hooks 'gnus-summary-prepare-hook)))
6536 (defun gnus-gather-threads (threads)
6537 "Gather threads that have lost their roots."
6538 (if (not gnus-summary-make-false-root)
6540 (let ((hashtb (gnus-make-hashtable 1023))
6543 subject hthread whole-subject)
6546 (setq subject (mail-header-subject (car (car threads)))))
6547 (if (and gnus-summary-gather-exclude-subject
6548 (string-match gnus-summary-gather-exclude-subject
6550 () ; We don't want to do anything with this.
6551 (if gnus-summary-gather-subject-limit
6552 (or (and (numberp gnus-summary-gather-subject-limit)
6553 (> (length subject) gnus-summary-gather-subject-limit)
6555 (substring subject 0
6556 gnus-summary-gather-subject-limit)))
6557 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
6558 (setq subject (gnus-simplify-subject-fuzzy subject))))
6559 (setq subject (gnus-simplify-subject-re subject)))
6561 (gnus-gethash subject hashtb))
6563 (or (stringp (car (car hthread)))
6564 (setcar hthread (list whole-subject (car hthread))))
6565 (setcdr (car hthread) (nconc (cdr (car hthread))
6566 (list (car threads))))
6567 (setcdr prev (cdr threads))
6568 (setq threads prev))
6569 (gnus-sethash subject threads hashtb)))
6571 (setq threads (cdr threads)))
6574 (defun gnus-make-threads ()
6575 ;; This function takes the dependencies already made by
6576 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6577 ;; through the dependecies in the hash table and finds all the
6578 ;; roots. Roots do not refer back to any valid articles.
6580 (and gnus-fetch-old-headers
6581 (eq gnus-headers-retrieved-by 'nov)
6582 (gnus-build-old-threads))
6585 (or (car (symbol-value refs))
6586 (setq threads (append (cdr (symbol-value refs)) threads))))
6587 gnus-newsgroup-dependencies)
6590 (defun gnus-cut-thread (thread)
6591 ;; Remove leaf dormant or ancient articles from THREAD.
6592 (let ((head (car thread))
6593 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6594 (if (and (null tail)
6595 (let ((number (mail-header-number head)))
6596 (or (memq number gnus-newsgroup-ancient)
6597 (memq number gnus-newsgroup-dormant)
6598 (and gnus-summary-expunge-below
6599 (or (eq gnus-fetch-old-headers 'some)
6600 (numberp gnus-fetch-old-headers))
6601 (< (or (cdr (assq number gnus-newsgroup-scored))
6602 gnus-summary-default-score 0)
6603 gnus-summary-expunge-below)
6605 (setq gnus-newsgroup-unreads
6606 (delq number gnus-newsgroup-unreads))
6607 (setq gnus-newsgroup-reads
6608 (cons (cons number gnus-low-score-mark)
6609 gnus-newsgroup-reads))
6610 (setq gnus-newsgroup-expunged-tally
6611 (1+ gnus-newsgroup-expunged-tally))
6614 (list (cons head tail)))))
6616 (defun gnus-trim-thread (thread)
6617 ;; Remove root ancient articles with only one child from THREAD.
6618 (if (and (or (eq gnus-fetch-old-headers 'some)
6619 (numberp gnus-fetch-old-headers))
6620 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient)
6621 (= (length thread) 2))
6622 (gnus-trim-thread (nth 1 thread))
6625 (defun gnus-make-sub-thread (root)
6626 ;; This function makes a sub-tree for a node in the tree.
6627 (let ((children (reverse (cdr (gnus-gethash (downcase (mail-header-id root))
6628 gnus-newsgroup-dependencies)))))
6629 (cons root (mapcar (lambda (c) (gnus-make-sub-thread (car c))) children))))
6631 (defun gnus-build-old-threads ()
6632 ;; Look at all the articles that refer back to old articles, and
6633 ;; fetch the headers for the articles that aren't there. This will
6634 ;; build complete threads - if the roots haven't been expired by the
6639 (if (not (car (symbol-value refs)))
6641 (setq heads (cdr (symbol-value refs)))
6643 (if (not (memq (mail-header-number (car (car heads)))
6644 gnus-newsgroup-dormant))
6646 (setq id (symbol-name refs))
6647 (while (and (setq id (gnus-build-get-header id))
6648 (not (car (gnus-gethash
6649 id gnus-newsgroup-dependencies)))))
6651 (setq heads (cdr heads)))))))
6652 gnus-newsgroup-dependencies)))
6654 (defun gnus-build-get-header (id)
6655 ;; Look through the buffer of NOV lines and find the header to
6656 ;; ID. Enter this line into the dependencies hash table, and return
6657 ;; the id of the parent article (if any).
6658 (let ((deps gnus-newsgroup-dependencies)
6662 (set-buffer nntp-server-buffer)
6663 (goto-char (point-min))
6664 (while (and (not found) (search-forward id nil t))
6666 (setq found (looking-at
6667 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6668 (regexp-quote id))))
6669 (or found (beginning-of-line 2)))
6674 (setq header (gnus-nov-parse-line
6675 (read (current-buffer)) deps))
6676 (setq ref (mail-header-references header))
6677 (string-match "\\(<[^>]+>\\) *$" ref)
6678 (substring ref (match-beginning 1) (match-end 1))))))
6680 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6681 gnus-newsgroup-ancient (cons (mail-header-number header)
6682 gnus-newsgroup-ancient))))))
6684 ;; Re-build the thread containing ID.
6685 (defun gnus-rebuild-thread (id)
6686 (let ((dep gnus-newsgroup-dependencies)
6687 (buffer-read-only nil)
6688 current parent headers refs thread art data)
6689 (while (and id (setq headers
6690 (car (setq art (gnus-gethash (downcase id) dep)))))
6692 (setq id (and (setq refs (mail-header-references headers))
6693 (string-match "\\(<[^>]+>\\) *$" refs)
6694 (substring refs (match-beginning 1) (match-end 1)))))
6695 (setq thread (gnus-make-sub-thread (car parent)))
6696 (gnus-rebuild-remove-articles thread)
6697 (let ((beg (point)))
6698 (setq current (save-excursion
6700 (gnus-summary-article-number)))
6701 (let (gnus-newsgroup-data)
6702 (gnus-summary-prepare-threads (list thread))
6703 (setq data (nreverse gnus-newsgroup-data)))
6704 (gnus-data-enter-list current data)
6705 (gnus-summary-update-lines beg (point)))))
6707 ;; Delete all lines in the summary buffer that correspond to articles
6709 (defun gnus-rebuild-remove-articles (thread)
6711 (and (gnus-summary-goto-subject
6712 (setq number (mail-header-number (car thread))))
6714 (gnus-data-remove number))
6715 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6717 (defun gnus-sort-threads (threads)
6718 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6719 (let ((fun gnus-thread-sort-functions))
6721 (setq threads (sort threads (car fun))
6725 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6726 (defmacro gnus-thread-header (thread)
6727 ;; Return header of first article in THREAD.
6728 ;; Note that THREAD must never, evr be anything else than a variable -
6729 ;; using some other form will lead to serious barfage.
6730 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
6731 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6732 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6735 (defun gnus-thread-sort-by-number (h1 h2)
6736 "Sort threads by root article number."
6737 (< (mail-header-number (gnus-thread-header h1))
6738 (mail-header-number (gnus-thread-header h2))))
6740 (defun gnus-thread-sort-by-author (h1 h2)
6741 "Sort threads by root author."
6743 (let ((extract (funcall
6744 gnus-extract-address-components
6745 (mail-header-from (gnus-thread-header h1)))))
6746 (or (car extract) (cdr extract)))
6747 (let ((extract (funcall
6748 gnus-extract-address-components
6749 (mail-header-from (gnus-thread-header h2)))))
6750 (or (car extract) (cdr extract)))))
6752 (defun gnus-thread-sort-by-subject (h1 h2)
6753 "Sort threads by root subject."
6755 (downcase (gnus-simplify-subject
6756 (mail-header-subject (gnus-thread-header h1))))
6757 (downcase (gnus-simplify-subject
6758 (mail-header-subject (gnus-thread-header h2))))))
6760 (defun gnus-thread-sort-by-date (h1 h2)
6761 "Sort threads by root article date."
6763 (gnus-sortable-date (mail-header-date (gnus-thread-header h1)))
6764 (gnus-sortable-date (mail-header-date (gnus-thread-header h2)))))
6766 (defun gnus-thread-sort-by-score (h1 h2)
6767 "Sort threads by root article score.
6768 Unscored articles will be counted as having a score of zero."
6769 (> (or (cdr (assq (mail-header-number (gnus-thread-header h1))
6770 gnus-newsgroup-scored))
6771 gnus-summary-default-score 0)
6772 (or (cdr (assq (mail-header-number (gnus-thread-header h2))
6773 gnus-newsgroup-scored))
6774 gnus-summary-default-score 0)))
6776 (defun gnus-thread-sort-by-total-score (h1 h2)
6777 "Sort threads by the sum of all scores in the thread.
6778 Unscored articles will be counted as having a score of zero."
6779 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6781 (defun gnus-thread-total-score (thread)
6782 ;; This function find the total score of THREAD.
6784 (if (stringp (car thread))
6785 (apply gnus-thread-score-function 0
6786 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6787 (gnus-thread-total-score-1 thread))
6788 (gnus-thread-total-score-1 (list thread))))
6790 (defun gnus-thread-total-score-1 (root)
6791 ;; This function find the total score of the thread below ROOT.
6792 (setq root (car root))
6793 (apply gnus-thread-score-function
6794 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
6795 gnus-summary-default-score 0)
6796 (mapcar 'gnus-thread-total-score
6797 (cdr (gnus-gethash (downcase (mail-header-id root))
6798 gnus-newsgroup-dependencies)))))
6800 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6801 (defvar gnus-tmp-prev-subject nil)
6802 (defvar gnus-tmp-false-parent nil)
6803 (defvar gnus-tmp-root-expunged nil)
6805 (defun gnus-summary-prepare-threads (threads &optional cull)
6806 "Prepare summary buffer from THREADS and indentation LEVEL.
6807 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6808 or a straight list of headers."
6809 (message "Generating summary...")
6811 thread header number subject stack state gnus-tmp-gathered mark
6812 new-roots new-adopts thread-end)
6814 (setq gnus-tmp-prev-subject nil)
6816 (if (vectorp (car threads))
6817 ;; If this is a straight (sic) list of headers, then a
6818 ;; threaded summary display isn't required, so we just create
6819 ;; an unthreaded one.
6820 (gnus-summary-prepare-unthreaded threads cull)
6822 ;; Do the threaded display.
6824 (while (or threads stack new-adopts new-roots)
6826 (if (and (= level 0)
6828 (= (car (car stack)) 0))
6829 (not gnus-tmp-false-parent)
6830 (or new-adopts new-roots))
6833 (setq level (if gnus-tmp-root-expunged 0 1)
6834 thread (list (car new-adopts))
6835 header (car (car thread))
6836 new-adopts (cdr new-adopts))
6838 (setq thread (list (car new-roots))
6839 header (car (car thread))
6840 new-roots (cdr new-roots)))))
6843 ;; If there are some threads, we do them before the
6844 ;; threads on the stack.
6845 (setq thread threads
6846 header (car (car thread)))
6847 ;; There were no current threads, so we pop something off
6849 (setq state (car stack)
6853 header (car (car thread)))))
6855 (setq gnus-tmp-false-parent nil)
6856 (setq gnus-tmp-root-expunged nil)
6857 (setq thread-end nil)
6859 (if (stringp header)
6861 ;; The header is a dummy root.
6863 ((eq gnus-summary-make-false-root 'adopt)
6864 ;; We let the first article adopt the rest.
6865 (setq new-adopts (nconc new-adopts
6866 (cdr (cdr (car thread)))))
6867 (setq gnus-tmp-gathered
6869 (lambda (h) (mail-header-number (car h)))
6870 (cdr (cdr (car thread))))
6872 (setcdr (cdr (car thread)) nil)
6874 gnus-tmp-false-parent t))
6875 ((eq gnus-summary-make-false-root 'empty)
6876 ;; We print adopted articles with empty subject fields.
6877 (setq gnus-tmp-gathered
6879 (lambda (h) (mail-header-number (car h)))
6880 (cdr (cdr (car thread))))
6883 ((eq gnus-summary-make-false-root 'dummy)
6884 ;; We output a dummy root.
6885 (gnus-summary-insert-dummy-line
6886 nil header (mail-header-number
6887 (car (car (cdr (car thread)))))))
6889 ;; We do not make a root for the gathered
6890 ;; sub-threads at all.
6893 (setq number (mail-header-number header)
6894 subject (mail-header-subject header))
6897 ((and (null gnus-thread-ignore-subject)
6899 gnus-tmp-prev-subject
6900 (not (gnus-subject-equal gnus-tmp-prev-subject subject)))
6901 (setq new-roots (nconc new-roots (list (car thread)))
6904 ((and gnus-newsgroup-limit
6905 (not (memq number gnus-newsgroup-limit)))
6906 (setq gnus-tmp-gathered
6908 (lambda (h) (mail-header-number (car h)))
6911 (setq new-adopts (if (cdr (car thread))
6918 (setq gnus-tmp-root-expunged t)))
6919 ((and (memq number gnus-newsgroup-dormant)
6922 ((and gnus-summary-expunge-below
6923 (< (or (cdr (assq number gnus-newsgroup-scored))
6924 gnus-summary-default-score 0)
6925 gnus-summary-expunge-below))
6927 gnus-newsgroup-expunged-tally
6928 (1+ gnus-newsgroup-expunged-tally)
6929 gnus-newsgroup-unreads
6930 (delq number gnus-newsgroup-unreads)
6931 gnus-newsgroup-reads
6932 (cons (cons number gnus-low-score-mark)
6933 gnus-newsgroup-reads))))
6941 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6942 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6943 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6944 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6945 (t (or (cdr (assq number gnus-newsgroup-reads))
6946 gnus-ancient-mark))))
6948 (gnus-summary-insert-line
6949 nil header level nil mark
6950 (memq number gnus-newsgroup-replied)
6951 (memq number gnus-newsgroup-expirable)
6953 ((and gnus-thread-ignore-subject
6954 gnus-tmp-prev-subject
6955 (not (gnus-subject-equal
6956 gnus-tmp-prev-subject subject)))
6959 (if (and (eq gnus-summary-make-false-root 'empty)
6960 (memq number gnus-tmp-gathered))
6961 gnus-summary-same-subject
6963 (t gnus-summary-same-subject))
6964 (and (eq gnus-summary-make-false-root 'adopt)
6966 (memq number gnus-tmp-gathered))
6967 (cdr (assq number gnus-newsgroup-scored))
6968 (memq number gnus-newsgroup-processable)))
6970 (setq gnus-newsgroup-data
6971 (cons (gnus-data-make number mark (- (point) 4)
6973 gnus-newsgroup-data))
6975 (setq gnus-tmp-prev-subject
6976 (gnus-simplify-subject-re subject)))))
6979 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6980 (setq level (1+ level))
6981 (setq threads (if thread-end nil (cdr (car thread))))
6982 (or threads (setq level 0)))))
6983 (message "Generating summary...done"))
6985 (defun gnus-summary-prepare-unthreaded (headers &optional cull)
6986 (let (header number mark)
6989 (setq header (car headers)
6990 headers (cdr headers)
6991 number (mail-header-number header))
6993 ;; We may have to root out some bad articles...
6995 ((and gnus-summary-expunge-below
6996 (< (or (cdr (assq number gnus-newsgroup-scored))
6997 gnus-summary-default-score 0)
6998 gnus-summary-expunge-below))
6999 (setq gnus-newsgroup-unreads
7000 (delq number gnus-newsgroup-unreads))
7001 (setq gnus-newsgroup-reads
7002 (cons (cons number gnus-low-score-mark)
7003 gnus-newsgroup-reads))
7004 (setq gnus-newsgroup-expunged-tally
7005 (1+ gnus-newsgroup-expunged-tally)))
7006 ((and gnus-newsgroup-limit
7007 (not (memq number gnus-newsgroup-limit)))
7008 ;; Don't print this article - it's not in the limit.
7013 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
7014 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
7015 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
7016 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
7017 (t (or (cdr (assq number gnus-newsgroup-reads))
7018 gnus-ancient-mark))))
7019 (setq gnus-newsgroup-data
7020 (cons (gnus-data-make number mark (1+ (point)) header 0)
7021 gnus-newsgroup-data))
7022 (gnus-summary-insert-line
7023 nil header 0 nil mark (memq number gnus-newsgroup-replied)
7024 (memq number gnus-newsgroup-expirable)
7025 (mail-header-subject header) nil
7026 (cdr (assq number gnus-newsgroup-scored))
7027 (memq number gnus-newsgroup-processable)))))))
7029 (defun gnus-select-newsgroup (group &optional read-all)
7030 "Select newsgroup GROUP.
7031 If READ-ALL is non-nil, all articles in the group are selected."
7032 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
7033 (info (nth 2 entry))
7036 (or (gnus-check-server
7037 (setq gnus-current-select-method (gnus-find-method-for-group group)))
7038 (error "Couldn't open server"))
7040 (or (and entry (not (eq (car entry) t))) ; Either it's active...
7041 (gnus-activate-group group) ; Or we can activate it...
7042 (progn ; Or we bug out.
7043 (kill-buffer (current-buffer))
7044 (error "Couldn't request group %s: %s"
7045 group (gnus-status-message group))))
7047 (setq gnus-newsgroup-name group)
7048 (setq gnus-newsgroup-unselected nil)
7049 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
7051 (and gnus-asynchronous
7052 (gnus-check-backend-function
7053 'request-asynchronous gnus-newsgroup-name)
7054 (setq gnus-newsgroup-async
7055 (gnus-request-asynchronous gnus-newsgroup-name)))
7057 (setq articles (gnus-articles-to-read group read-all))
7061 (gnus-message 3 "Couldn't select newsgroup")
7063 ((eq articles 0) nil)
7065 ;; Init the dependencies hash table.
7066 (setq gnus-newsgroup-dependencies
7067 (gnus-make-hashtable (length articles)))
7068 ;; Retrieve the headers and read them in.
7069 (gnus-message 5 "Fetching headers...")
7070 (setq gnus-newsgroup-headers
7072 (setq gnus-headers-retrieved-by
7073 (gnus-retrieve-headers
7074 articles gnus-newsgroup-name
7075 ;; We might want to fetch old headers, but
7076 ;; not if there is only 1 article.
7077 (and gnus-fetch-old-headers
7079 (not (eq gnus-fetch-old-headers 'some))
7080 (not (numberp gnus-fetch-old-headers)))
7081 (> (length articles) 1))))))
7082 (gnus-get-newsgroup-headers-xover articles)
7083 (gnus-get-newsgroup-headers)))
7084 (gnus-message 5 "Fetching headers...done")
7085 ;; Remove canceled articles from the list of unread articles.
7086 (setq gnus-newsgroup-unreads
7087 (gnus-set-sorted-intersection
7088 gnus-newsgroup-unreads
7089 (mapcar (lambda (headers) (mail-header-number headers))
7090 gnus-newsgroup-headers)))
7091 ;; Adjust and set lists of article marks.
7094 (gnus-adjust-marked-articles info)
7095 (setq gnus-newsgroup-marked
7097 (cdr (assq 'tick (setq marked (nth 3 info))))))
7098 (setq gnus-newsgroup-replied
7099 (copy-sequence (cdr (assq 'reply marked))))
7100 (setq gnus-newsgroup-expirable
7101 (copy-sequence (cdr (assq 'expire marked))))
7102 (setq gnus-newsgroup-killed
7103 (copy-sequence (cdr (assq 'killed marked))))
7104 (setq gnus-newsgroup-bookmarks
7105 (copy-sequence (cdr (assq 'bookmark marked))))
7106 (setq gnus-newsgroup-dormant
7107 (copy-sequence (cdr (assq 'dormant marked))))
7108 (setq gnus-newsgroup-scored
7109 (copy-sequence (cdr (assq 'score marked))))
7110 (setq gnus-newsgroup-processable nil)))
7111 ;; Check whether auto-expire is to be done in this group.
7112 (setq gnus-newsgroup-auto-expire
7113 (gnus-group-auto-expirable-p group))
7114 ;; First and last article in this newsgroup.
7115 (and gnus-newsgroup-headers
7116 (setq gnus-newsgroup-begin
7117 (mail-header-number (car gnus-newsgroup-headers)))
7118 (setq gnus-newsgroup-end
7120 (gnus-last-element gnus-newsgroup-headers))))
7121 (setq gnus-reffed-article-number -1)
7122 ;; GROUP is successfully selected.
7123 (or gnus-newsgroup-headers t)))))
7125 (defun gnus-articles-to-read (group read-all)
7126 ;; Find out what articles the user wants to read.
7128 ;; Select all articles if `read-all' is non-nil, or if all the
7129 ;; unread articles are dormant articles.
7130 (if (or (and read-all (not (numberp read-all)))
7131 (= (length gnus-newsgroup-unreads)
7132 (length gnus-newsgroup-dormant)))
7133 (gnus-uncompress-range
7134 (gnus-gethash group gnus-active-hashtb))
7135 gnus-newsgroup-unreads))
7136 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
7137 (scored (length scored-list))
7138 (number (length articles))
7139 (marked (+ (length gnus-newsgroup-marked)
7140 (length gnus-newsgroup-dormant)))
7147 (cond ((and (or (<= scored marked)
7149 (numberp gnus-large-newsgroup)
7150 (> number gnus-large-newsgroup))
7154 "How many articles from %s (default %d): "
7155 gnus-newsgroup-name number))))
7156 (if (string-match "^[ \t]*$" input)
7158 ((and (> scored marked) (< scored number))
7162 "%s %s (%d scored, %d total): "
7163 "How many articles from"
7164 group scored number))))
7165 (if (string-match "^[ \t]*$" input)
7169 (setq select (if (stringp select) (string-to-number select) select))
7170 (if (or (null select) (zerop select))
7172 (if (and (not (zerop scored)) (<= (abs select) scored))
7174 (setq articles (sort scored-list '<))
7175 (setq number (length articles)))
7176 (setq articles (copy-sequence articles)))
7178 (if (< (abs select) number)
7180 ;; Select the N oldest articles.
7181 (setcdr (nthcdr (1- (abs select)) articles) nil)
7182 ;; Select the N most recent articles.
7183 (setq articles (nthcdr (- number select) articles))))
7184 (setq gnus-newsgroup-unselected
7185 (gnus-sorted-intersection
7186 gnus-newsgroup-unreads
7187 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
7190 (defun gnus-killed-articles (killed articles)
7193 (if (inline (gnus-member-of-range (car articles) killed))
7194 (setq out (cons (car articles) out)))
7195 (setq articles (cdr articles)))
7198 (defun gnus-adjust-marked-articles (info &optional active)
7199 "Remove all marked articles that are no longer legal."
7200 (let ((marked-lists (nth 3 info))
7201 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
7203 ;; There are many types of marked articles.
7205 (setq m (cdr (setq prev (car marked-lists))))
7206 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
7207 ;; Make sure that all ticked articles are a subset of the
7208 ;; unread/unselected articles.
7210 (if (or (memq (car m) gnus-newsgroup-unreads)
7211 (memq (car m) gnus-newsgroup-unselected))
7213 (setcdr prev (cdr m)))
7215 ((eq 'score (car prev))
7216 ;; Scored articles should be a subset of
7217 ;; unread/unselected articles.
7219 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
7220 (memq (car (car m)) gnus-newsgroup-unreads))
7222 (setcdr prev (cdr m)))
7224 ((eq 'bookmark (car prev))
7225 ;; Bookmarks should be a subset of active articles.
7227 (if (< (car (car m)) (car active))
7228 (setcdr prev (cdr m))
7231 ((eq 'killed (car prev))
7232 ;; Articles that have been through the kill process are
7233 ;; to be a subset of active articles.
7234 (while (and m (< (or (and (numberp (car m)) (car m))
7237 (setcdr prev (cdr m))
7239 (if (and m (< (or (and (numberp (car m)) (car m))
7242 (setcar (if (numberp (car m)) m (car m)) (car active))))
7243 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
7244 ;; The replied and expirable articles have to be articles
7247 (if (< (car m) (car active))
7248 (setcdr prev (cdr m))
7251 (setq marked-lists (cdr marked-lists)))
7252 ;; Remove all lists that are empty.
7253 (setq marked-lists (nth 3 info))
7256 (while (= 1 (length (car marked-lists)))
7257 (setq marked-lists (cdr marked-lists)))
7258 (setq m (cdr (setq prev marked-lists)))
7260 (if (= 1 (length (car m)))
7261 (setcdr prev (cdr m))
7264 (setcar (nthcdr 3 info) marked-lists)))
7265 ;; Finally, if there are no marked lists at all left, and if there
7266 ;; are no elements after the lists in the info list, we just chop
7267 ;; the info list off before the marked lists.
7268 (and (null marked-lists)
7269 (not (nthcdr 4 info))
7270 (setcdr (nthcdr 2 info) nil)))
7273 (defun gnus-set-marked-articles
7274 (info ticked replied expirable killed dormant bookmark score)
7275 "Enter the various lists of marked articles into the newsgroup info list."
7277 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
7278 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
7279 (and expirable (setq newmarked (cons (cons 'expire expirable)
7281 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
7282 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
7283 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
7285 (and score (setq newmarked (cons (cons 'score score) newmarked)))
7288 (setcar (nthcdr 3 info) newmarked)
7289 (and (not newmarked)
7290 (not (nthcdr 4 info))
7291 (setcdr (nthcdr 2 info) nil)))
7293 (setcdr (nthcdr 2 info) (list newmarked))))))
7295 (defun gnus-add-marked-articles (group type articles &optional info force)
7296 ;; Add ARTICLES of TYPE to the info of GROUP.
7297 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
7298 ;; add, but replace marked articles of TYPE with ARTICLES.
7299 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7302 (and (not (setq marked (nthcdr 3 info)))
7303 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
7304 (and (not (setq m (assq type (car marked))))
7305 (setcar marked (cons (cons type articles) (car marked))))
7308 (nconc m articles)))))
7310 (defun gnus-set-mode-line (where)
7311 "This function sets the mode line of the article or summary buffers.
7312 If WHERE is `summary', the summary mode line format will be used."
7313 (if (memq where gnus-updated-mode-lines)
7316 (set-buffer gnus-summary-buffer)
7317 (let* ((mformat (if (eq where 'article)
7318 gnus-article-mode-line-format-spec
7319 gnus-summary-mode-line-format-spec))
7320 (group-name gnus-newsgroup-name)
7321 (article-number (or gnus-current-article 0))
7322 (unread (- (length gnus-newsgroup-unreads)
7323 (length gnus-newsgroup-dormant)))
7324 (unread-and-unticked
7325 (- unread (length gnus-newsgroup-marked)))
7326 (unselected (length gnus-newsgroup-unselected))
7327 (unread-and-unselected
7328 (cond ((and (zerop unread-and-unticked)
7329 (zerop unselected)) "")
7331 (format "{%d more}" unread-and-unticked))
7332 (t (format "{%d(+%d) more}"
7333 unread-and-unticked unselected))))
7335 (if gnus-current-headers
7336 (mail-header-subject gnus-current-headers) ""))
7337 (max-len (and gnus-mode-non-string-length
7338 (- (frame-width) gnus-mode-non-string-length)))
7339 header);; passed as argument to any user-format-funcs
7340 (setq mode-string (eval mformat))
7341 (or (numberp max-len)
7342 (setq max-len (length mode-string)))
7343 (if (< max-len 4) (setq max-len 4))
7344 (if (> (length mode-string) max-len)
7345 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
7346 ;; function `substring' might cut on a middle
7347 ;; of multi-octet character.
7349 (concat (gnus-truncate-string mode-string (- max-len 3))
7351 (setq mode-string (format (format "%%-%ds" max-len)
7353 (setq mode-line-buffer-identification mode-string)
7354 (set-buffer-modified-p t))))
7356 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads ticked dormant)
7357 "Go through the HEADERS list and add all Xrefs to a hash table.
7358 The resulting hash table is returned, or nil if no Xrefs were found."
7359 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
7361 (gnus-group-foreign-p from-newsgroup)
7363 (assoc (symbol-name (car from-method))
7364 gnus-valid-select-methods))))
7365 (gnus-group-real-prefix from-newsgroup)))
7366 (xref-hashtb (make-vector 63 0))
7367 start group entry number xrefs header)
7369 (setq header (car headers))
7370 (if (and (setq xrefs (mail-header-xref header))
7371 (not (memq (setq number (mail-header-number header)) unreads))
7372 (not (memq number ticked))
7373 (not (memq number dormant)))
7376 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
7377 (setq start (match-end 0))
7378 (setq group (concat prefix (substring xrefs (match-beginning 1)
7381 (string-to-int (substring xrefs (match-beginning 2)
7383 (if (setq entry (gnus-gethash group xref-hashtb))
7384 (setcdr entry (cons number (cdr entry)))
7385 (gnus-sethash group (cons number nil) xref-hashtb)))))
7386 (setq headers (cdr headers)))
7387 (if start xref-hashtb nil)))
7389 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable
7391 "Look through all the headers and mark the Xrefs as read."
7392 (let ((virtual (memq 'virtual
7393 (assoc (symbol-name (car (gnus-find-method-for-group
7395 gnus-valid-select-methods)))
7396 name entry info xref-hashtb idlist method
7399 (set-buffer gnus-group-buffer)
7400 (if (setq xref-hashtb
7401 (gnus-create-xref-hashtb
7402 from-newsgroup headers unreads ticked dormant))
7405 (if (string= from-newsgroup (setq name (symbol-name group)))
7407 (setq idlist (symbol-value group))
7408 ;; Dead groups are not updated.
7410 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
7412 (if (stringp (setq nth4 (nth 4 info)))
7413 (setq nth4 (gnus-server-to-method nth4))))
7414 ;; Only do the xrefs if the group has the same
7415 ;; select method as the group we have just read.
7416 (or (gnus-methods-equal-p
7417 nth4 (gnus-find-method-for-group from-newsgroup))
7420 (setq method (gnus-find-method-for-group
7422 (and (equal (car nth4) (car method))
7423 (equal (nth 1 nth4) (nth 1 method))))
7424 gnus-use-cross-reference
7425 (or (not (eq gnus-use-cross-reference t))
7427 ;; Only do cross-references on subscribed
7428 ;; groups, if that is what is wanted.
7429 (<= (nth 1 info) gnus-level-subscribed)))
7430 (gnus-group-make-articles-read name idlist expirable))))
7433 (defun gnus-group-make-articles-read (group articles expirable)
7435 (entry (gnus-gethash group gnus-newsrc-hashtb))
7436 (info (nth 2 entry))
7437 (active (gnus-gethash group gnus-active-hashtb))
7438 exps expirable range)
7439 ;; First peel off all illegal article numbers.
7441 (let ((ids articles)
7442 (ticked (cdr (assq 'tick (nth 3 info))))
7443 (dormant (cdr (assq 'dormant (nth 3 info))))
7448 (if (and first (> id (cdr active)))
7450 ;; We'll end up in this situation in one particular
7451 ;; obscure situation. If you re-scan a group and get
7452 ;; a new article that is cross-posted to a different
7453 ;; group that has not been re-scanned, you might get
7454 ;; crossposted article that has a higher number than
7455 ;; Gnus believes possible. So we re-activate this
7456 ;; group as well. This might mean doing the
7457 ;; crossposting thingie will *increase* the number
7458 ;; of articles in some groups. Tsk, tsk.
7459 (setq active (or (gnus-activate-group group) active))))
7460 (if (or (> id (cdr active))
7464 (setq articles (delq id articles)))
7465 (and (memq id expirable)
7466 (setq exps (cons id exps)))
7467 (setq ids (cdr ids)))))
7468 ;; Update expirable articles.
7469 (gnus-add-marked-articles nil 'expirable exps info)
7473 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
7474 (setcar (nthcdr 2 info)
7478 (setq articles (sort articles '<)))))
7479 ;; Then we have to re-compute how many unread
7480 ;; articles there are in this group.
7485 (setq num (- (1+ (cdr active)) (car active))))
7486 ((not (listp (cdr range)))
7487 (setq num (- (cdr active) (- (1+ (cdr range))
7491 (if (numberp (car range))
7493 (setq num (+ num (- (1+ (cdr (car range)))
7494 (car (car range))))))
7495 (setq range (cdr range)))
7496 (setq num (- (cdr active) num))))
7497 ;; Update the number of unread articles.
7501 (length (cdr (assq 'tick (nth 3 info))))
7503 (cdr (assq 'dormant (nth 3 info)))))))
7504 ;; Update the group buffer.
7505 (gnus-group-update-group group t)))))
7507 (defun gnus-methods-equal-p (m1 m2)
7508 (let ((m1 (or m1 gnus-select-method))
7509 (m2 (or m2 gnus-select-method)))
7511 (and (eq (car m1) (car m2))
7512 (or (not (memq 'address (assoc (symbol-name (car m1))
7513 gnus-valid-select-methods)))
7514 (equal (nth 1 m1) (nth 1 m2)))))))
7516 (defsubst gnus-header-value ()
7517 (buffer-substring (match-end 0) (gnus-point-at-eol)))
7519 (defvar gnus-newsgroup-none-id 0)
7521 (defun gnus-get-newsgroup-headers ()
7522 (setq gnus-article-internal-prepare-hook nil)
7523 (let ((cur nntp-server-buffer)
7524 (dependencies (save-excursion (set-buffer gnus-summary-buffer)
7525 gnus-newsgroup-dependencies))
7526 headers id id-dep ref-dep end ref)
7528 (set-buffer nntp-server-buffer)
7529 (let ((case-fold-search t)
7530 in-reply-to header number p lines)
7531 (goto-char (point-min))
7532 ;; Search to the beginning of the next header. Error messages
7533 ;; do not begin with 2 or 3.
7534 (while (re-search-forward "^[23][0-9]+ " nil t)
7537 ;; This implementation of this function, with nine
7538 ;; search-forwards instead of the one re-search-forward and
7539 ;; a case (which basically was the old function) is actually
7540 ;; about twice as fast, even though it looks messier. You
7541 ;; can't have everything, I guess. Speed and elegance
7542 ;; doesn't always go hand in hand.
7551 (narrow-to-region (point)
7552 (or (and (search-forward "\n.\n" nil t)
7558 (if (search-forward "\nsubject: " nil t)
7559 (gnus-header-value) "(none)"))
7563 (if (search-forward "\nfrom: " nil t)
7564 (gnus-header-value) "(nobody)"))
7568 (if (search-forward "\ndate: " nil t)
7569 (gnus-header-value) ""))
7573 (if (search-forward "\nmessage-id: " nil t)
7574 (setq id (gnus-header-value))
7575 ;; If there was no message-id, we just fake one to make
7576 ;; subsequent routines simpler.
7577 (setq id (concat "none+"
7579 (setq gnus-newsgroup-none-id
7580 (1+ gnus-newsgroup-none-id)))))))
7584 (if (search-forward "\nreferences: " nil t)
7587 (setq end (match-end 0))
7594 (search-backward ">" end t)
7597 (search-backward "<" end t)
7599 ;; Get the references from the in-reply-to header if there
7600 ;; were no references and the in-reply-to header looks
7602 (if (and (search-forward "\nin-reply-to: " nil t)
7603 (setq in-reply-to (gnus-header-value))
7604 (string-match "<[^>]+>" in-reply-to))
7606 (setq ref (substring in-reply-to (match-beginning 0)
7608 (setq ref (downcase ref))))
7615 (if (search-forward "\nlines: " nil t)
7616 (if (numberp (setq lines (read cur)))
7622 (and (search-forward "\nxref: " nil t)
7623 (gnus-header-value)))))
7624 ;; We do the threading while we read the headers. The
7625 ;; message-id and the last reference are both entered into
7626 ;; the same hash table. Some tippy-toeing around has to be
7627 ;; done in case an article has arrived before the article
7628 ;; which it refers to.
7629 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
7630 (if (car (symbol-value id-dep))
7631 ;; An article with this Message-ID has already
7632 ;; been seen, so we ignore this one, except we add
7633 ;; any additional Xrefs (in case the two articles
7634 ;; came from different servers).
7636 (mail-header-set-xref
7637 (car (symbol-value id-dep))
7638 (concat (or (mail-header-xref
7639 (car (symbol-value id-dep))) "")
7640 (or (mail-header-xref header) "")))
7642 (setcar (symbol-value id-dep) header))
7643 (set id-dep (list header)))
7646 (if (boundp (setq ref-dep (intern ref dependencies)))
7647 (setcdr (symbol-value ref-dep)
7648 (nconc (cdr (symbol-value ref-dep))
7649 (list (symbol-value id-dep))))
7650 (set ref-dep (list nil (symbol-value id-dep))))
7651 (setq headers (cons header headers))))
7652 (goto-char (point-max))
7654 (nreverse headers)))))
7656 ;; The following macros and functions were written by Felix Lee
7657 ;; <flee@cse.psu.edu>.
7659 (defmacro gnus-nov-read-integer ()
7661 (if (= (following-char) ?\t)
7663 (let ((num (condition-case nil (read buffer) (error nil))))
7664 (if (numberp num) num 0)))
7665 (or (eobp) (forward-char 1))))
7667 (defmacro gnus-nov-skip-field ()
7668 '(search-forward "\t" eol 'move))
7670 (defmacro gnus-nov-field ()
7671 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
7673 ;; Goes through the xover lines and returns a list of vectors
7674 (defun gnus-get-newsgroup-headers-xover (sequence)
7675 "Parse the news overview data in the server buffer, and return a
7676 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7677 ;; Get the Xref when the users reads the articles since most/some
7678 ;; NNTP servers do not include Xrefs when using XOVER.
7679 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
7680 (let ((cur nntp-server-buffer)
7681 (dependencies gnus-newsgroup-dependencies)
7682 number headers header)
7684 (set-buffer nntp-server-buffer)
7685 (goto-char (point-min))
7686 (while (and sequence (not (eobp)))
7687 (setq number (read cur))
7688 (while (and sequence (< (car sequence) number))
7689 (setq sequence (cdr sequence)))
7691 (eq number (car sequence))
7693 (setq sequence (cdr sequence))
7695 (inline (gnus-nov-parse-line number dependencies)))
7696 (setq headers (cons header headers)))))
7698 (setq headers (nreverse headers)))
7701 ;; This function has to be called with point after the article number
7702 ;; on the beginning of the line.
7703 (defun gnus-nov-parse-line (number dependencies)
7705 (eol (gnus-point-at-eol))
7706 (buffer (current-buffer))
7707 header ref id id-dep ref-dep)
7709 ;; overview: [num subject from date id refs chars lines misc]
7710 (narrow-to-region (point) eol)
7717 (gnus-nov-field) ; subject
7718 (gnus-nov-field) ; from
7719 (gnus-nov-field) ; date
7720 (setq id (or (gnus-nov-field)
7723 (setq none (1+ none)))))) ; id
7726 (let ((beg (point)))
7727 (search-forward "\t" eol)
7728 (if (search-backward ">" beg t)
7734 (search-backward "<" beg t)
7737 (gnus-nov-field)) ; refs
7738 (gnus-nov-read-integer) ; chars
7739 (gnus-nov-read-integer) ; lines
7740 (if (= (following-char) ?\n)
7742 (gnus-nov-field)) ; misc
7746 (message "Strange nov line.")
7752 ;; We build the thread tree.
7754 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
7755 (if (car (symbol-value id-dep))
7756 ;; An article with this Message-ID has already been seen,
7757 ;; so we ignore this one, except we add any additional
7758 ;; Xrefs (in case the two articles came from different
7761 (mail-header-set-xref
7762 (car (symbol-value id-dep))
7763 (concat (or (mail-header-xref
7764 (car (symbol-value id-dep))) "")
7765 (or (mail-header-xref header) "")))
7767 (setcar (symbol-value id-dep) header))
7768 (set id-dep (list header))))
7771 (if (boundp (setq ref-dep (intern (or ref "none")
7773 (setcdr (symbol-value ref-dep)
7774 (nconc (cdr (symbol-value ref-dep))
7775 (list (symbol-value id-dep))))
7776 (set ref-dep (list nil (symbol-value id-dep))))))
7779 (defun gnus-article-get-xrefs ()
7780 "Fill in the Xref value in `gnus-current-headers', if necessary.
7781 This is meant to be called in `gnus-article-internal-prepare-hook'."
7782 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7783 gnus-current-headers)))
7784 (or (not gnus-use-cross-reference)
7786 (and (mail-header-xref headers)
7787 (not (string= (mail-header-xref headers) "")))
7788 (let ((case-fold-search t)
7791 (gnus-narrow-to-headers)
7792 (goto-char (point-min))
7793 (if (or (and (eq (downcase (following-char)) ?x)
7794 (looking-at "Xref:"))
7795 (search-forward "\nXref:" nil t))
7797 (goto-char (1+ (match-end 0)))
7798 (setq xref (buffer-substring (point)
7799 (progn (end-of-line) (point))))
7800 (mail-header-set-xref headers xref))))))))
7802 ;; Insert article ID in the summary buffer and select it as well.
7803 (defun gnus-summary-insert-article (id)
7804 (let ((header (gnus-read-header id))
7807 () ; We couldn't fetch ID.
7808 (gnus-rebuild-thread (mail-header-id header))
7809 (gnus-summary-goto-subject (setq number (mail-header-number header)))
7812 ;; We have to update the boundaries, possibly.
7813 (and (> number gnus-newsgroup-end)
7814 (setq gnus-newsgroup-end number))
7815 (and (< number gnus-newsgroup-begin)
7816 (setq gnus-newsgroup-begin number))
7817 (setq gnus-newsgroup-unselected
7818 (delq number gnus-newsgroup-unselected))))
7819 (gnus-summary-show-article))))
7821 (defun gnus-summary-work-articles (n)
7822 "Return a list of articles to be worked upon. The prefix argument,
7823 the list of process marked articles, and the current article will be
7824 taken into consideration."
7825 (let (articles article)
7826 (if (and n (numberp n))
7827 (let ((backward (< n 0))
7833 (cons (setq article (gnus-summary-article-number))
7836 (gnus-summary-find-prev nil article)
7837 (gnus-summary-find-next nil article)))
7839 (sort articles (function <)))
7840 (or (reverse gnus-newsgroup-processable)
7841 (list (gnus-summary-article-number))))))
7843 (defun gnus-summary-search-group (&optional backward use-level)
7844 "Search for next unread newsgroup.
7845 If optional argument BACKWARD is non-nil, search backward instead."
7847 (set-buffer gnus-group-buffer)
7848 (if (gnus-group-search-forward
7849 backward nil (if use-level (gnus-group-group-level) nil))
7850 (gnus-group-group-name))))
7852 (defun gnus-summary-best-group (&optional exclude-group)
7853 "Find the name of the best unread group.
7854 If EXCLUDE-GROUP, do not go to this group."
7856 (set-buffer gnus-group-buffer)
7858 (gnus-group-best-unread-group exclude-group))))
7860 (defun gnus-summary-find-next (&optional unread article backward)
7861 (if backward (gnus-summary-find-prev)
7862 (let* ((article (or article (gnus-summary-article-number)))
7863 (arts (cdr (gnus-data-find-list article)))
7869 (and (gnus-data-unread-p (car arts))
7870 (setq result (car arts)
7872 (setq arts (cdr arts)))
7876 (goto-char (gnus-data-pos result))
7877 (gnus-data-number result))))))
7879 (defun gnus-summary-find-prev (&optional unread article)
7880 (let* ((article (or article (gnus-summary-article-number)))
7882 (setq arts (cdr (gnus-data-find-list article (gnus-data-list 'rev))))
7887 (and (gnus-data-unread-p (car arts))
7888 (setq result (car arts)
7890 (setq arts (cdr arts)))
7894 (goto-char (gnus-data-pos result))
7895 (gnus-data-number result)))))
7897 (defun gnus-summary-find-subject (subject &optional unread backward article)
7898 (let* ((article (or article (gnus-summary-article-number)))
7899 (articles (gnus-data-list backward))
7900 (arts (cdr (gnus-data-find-list article articles)))
7903 (and (or (not unread)
7904 (gnus-data-unread-p (car arts)))
7905 (vectorp (gnus-data-header (car arts)))
7907 subject (mail-header-subject (gnus-data-header (car arts))))
7908 (setq result (car arts)
7910 (setq arts (cdr arts)))
7912 (goto-char (gnus-data-pos result))
7913 (gnus-data-number result))))
7915 (defun gnus-summary-search-forward (&optional unread subject backward)
7917 (gnus-summary-find-subject subject unread backward))
7919 (gnus-summary-find-prev unread))
7921 (gnus-summary-find-next unread))))
7923 (defun gnus-summary-recenter ()
7924 "Center point in the summary window.
7925 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7926 displayed, no centering will be performed."
7927 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7928 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7929 (let* ((top (cond ((< (window-height) 4) 0)
7930 ((< (window-height) 7) 1)
7932 (height (1- (window-height)))
7933 (bottom (save-excursion (goto-char (point-max))
7934 (forward-line (- height))
7936 (window (get-buffer-window (current-buffer))))
7938 ;; The user has to want it,
7939 gnus-auto-center-summary
7940 ;; the article buffer must be displayed,
7941 (get-buffer-window gnus-article-buffer)
7942 ;; Set the window start to either `bottom', which is the biggest
7943 ;; possible valid number, or the second line from the top,
7944 ;; whichever is the least.
7946 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7948 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7949 (defun gnus-short-group-name (group &optional levels)
7950 "Collapse GROUP name LEVELS."
7951 (let* ((name "") (foreign "") (depth -1) (skip 1)
7954 (while (string-match "\\." group skip)
7955 (setq skip (match-end 0)
7958 (if (string-match ":" group)
7959 (setq foreign (substring group 0 (match-end 0))
7960 group (substring group (match-end 0))))
7962 (if (and (string-match "\\." group) (> levels 0))
7963 (setq name (concat name (substring group 0 1))
7964 group (substring group (match-end 0))
7966 name (concat name "."))
7967 (setq name (concat foreign name group)
7971 (defun gnus-summary-jump-to-group (newsgroup)
7972 "Move point to NEWSGROUP in group mode buffer."
7973 ;; Keep update point of group mode buffer if visible.
7974 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7975 (save-window-excursion
7976 ;; Take care of tree window mode.
7977 (if (get-buffer-window gnus-group-buffer)
7978 (pop-to-buffer gnus-group-buffer))
7979 (gnus-group-jump-to-group newsgroup))
7981 ;; Take care of tree window mode.
7982 (if (get-buffer-window gnus-group-buffer)
7983 (pop-to-buffer gnus-group-buffer)
7984 (set-buffer gnus-group-buffer))
7985 (gnus-group-jump-to-group newsgroup))))
7987 ;; This function returns a list of article numbers based on the
7988 ;; difference between the ranges of read articles in this group and
7989 ;; the range of active articles.
7990 (defun gnus-list-of-unread-articles (group)
7991 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7992 (active (gnus-gethash group gnus-active-hashtb))
7995 ;; If none are read, then all are unread.
7997 (setq first (car active))
7998 ;; If the range of read articles is a single range, then the
7999 ;; first unread article is the article after the last read
8000 ;; article. Sounds logical, doesn't it?
8001 (if (not (listp (cdr read)))
8002 (setq first (1+ (cdr read)))
8003 ;; `read' is a list of ranges.
8004 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
8005 (car (car read)))) 1)
8009 (while (< first nlast)
8010 (setq unread (cons first unread))
8011 (setq first (1+ first))))
8012 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
8013 (setq nlast (if (atom (car (cdr read)))
8015 (car (car (cdr read)))))
8016 (setq read (cdr read)))))
8017 ;; And add the last unread articles.
8018 (while (<= first last)
8019 (setq unread (cons first unread))
8020 (setq first (1+ first)))
8021 ;; Return the list of unread articles.
8024 (defun gnus-list-of-read-articles (group)
8025 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
8026 (active (gnus-gethash group gnus-active-hashtb)))
8028 (gnus-sorted-complement
8029 (gnus-uncompress-range active)
8030 (gnus-list-of-unread-articles group)))))
8032 ;; Various summary commands
8034 (defun gnus-summary-universal-argument ()
8035 "Perform any operation on all articles marked with the process mark."
8037 (gnus-set-global-variables)
8038 (let ((articles (reverse gnus-newsgroup-processable))
8040 (or articles (error "No articles marked"))
8041 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
8042 (error "Undefined key"))
8044 (gnus-summary-goto-subject (car articles))
8045 (command-execute func)
8046 (gnus-summary-remove-process-mark (car articles))
8047 (setq articles (cdr articles)))))
8049 (defun gnus-summary-toggle-truncation (&optional arg)
8050 "Toggle truncation of summary lines.
8051 With arg, turn line truncation on iff arg is positive."
8053 (setq truncate-lines
8054 (if (null arg) (not truncate-lines)
8055 (> (prefix-numeric-value arg) 0)))
8058 (defun gnus-summary-reselect-current-group (&optional all)
8059 "Once exit and then reselect the current newsgroup.
8060 The prefix argument ALL means to select all articles."
8062 (gnus-set-global-variables)
8063 (let ((current-subject (gnus-summary-article-number))
8064 (group gnus-newsgroup-name))
8065 (setq gnus-newsgroup-begin nil)
8066 (gnus-summary-exit t)
8067 ;; We have to adjust the point of group mode buffer because the
8068 ;; current point was moved to the next unread newsgroup by
8070 (gnus-summary-jump-to-group group)
8071 (gnus-group-read-group all t)
8072 (gnus-summary-goto-subject current-subject)))
8074 (defun gnus-summary-rescan-group (&optional all)
8075 "Exit the newsgroup, ask for new articles, and select the newsgroup."
8077 (gnus-set-global-variables)
8078 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
8079 (let ((group gnus-newsgroup-name))
8081 (gnus-summary-jump-to-group group)
8083 (set-buffer gnus-group-buffer)
8084 (gnus-group-get-new-news-this-group 1))
8085 (gnus-summary-jump-to-group group)
8086 (gnus-group-read-group all)))
8088 (defun gnus-summary-update-info ()
8089 (let* ((group gnus-newsgroup-name))
8090 (if gnus-newsgroup-kill-headers
8091 (setq gnus-newsgroup-killed
8092 (gnus-compress-sequence
8094 (gnus-set-sorted-intersection
8095 (gnus-uncompress-range gnus-newsgroup-killed)
8096 (setq gnus-newsgroup-unselected
8097 (sort gnus-newsgroup-unselected '<)))
8098 (setq gnus-newsgroup-unreads
8099 (sort gnus-newsgroup-unreads '<))) t)))
8100 (or (listp (cdr gnus-newsgroup-killed))
8101 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
8102 (let ((headers gnus-newsgroup-headers))
8103 (gnus-close-group group)
8104 (run-hooks 'gnus-exit-group-hook)
8105 (gnus-update-read-articles
8106 group gnus-newsgroup-unreads gnus-newsgroup-unselected
8107 gnus-newsgroup-marked
8108 t gnus-newsgroup-replied gnus-newsgroup-expirable
8109 gnus-newsgroup-killed gnus-newsgroup-dormant
8110 gnus-newsgroup-bookmarks
8111 (and gnus-save-score gnus-newsgroup-scored))
8112 (and gnus-use-cross-reference
8113 (gnus-mark-xrefs-as-read
8114 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable
8115 gnus-newsgroup-marked gnus-newsgroup-dormant))
8116 ;; Do adaptive scoring, and possibly save score files.
8117 (and gnus-newsgroup-adaptive
8118 (gnus-score-adaptive))
8119 (and gnus-use-scoring
8120 (fboundp 'gnus-score-save)
8121 (funcall 'gnus-score-save))
8122 ;; Do not switch windows but change the buffer to work.
8123 (set-buffer gnus-group-buffer)
8124 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
8125 (gnus-group-update-group group)))))
8127 (defun gnus-summary-exit (&optional temporary)
8128 "Exit reading current newsgroup, and then return to group selection mode.
8129 gnus-exit-group-hook is called with no arguments if that value is non-nil."
8131 (gnus-set-global-variables)
8132 (gnus-kill-save-kill-buffer)
8133 (let* ((group gnus-newsgroup-name)
8134 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
8135 gnus-newsgroup-name))))
8137 (buf (current-buffer)))
8138 (run-hooks 'gnus-summary-prepare-exit-hook)
8139 ;; Make all changes in this group permanent.
8140 (gnus-summary-update-info)
8142 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
8143 ;; Make sure where I was, and go to next newsgroup.
8144 (set-buffer gnus-group-buffer)
8147 (gnus-group-jump-to-group group)
8148 (gnus-group-next-unread-group 1)))
8151 ;; We set all buffer-local variables to nil. It is unclear why
8152 ;; this is needed, but if we don't, buffer-local variables are
8153 ;; not garbage-collected, it seems. This would the lead to en
8154 ;; ever-growing Emacs.
8156 (gnus-summary-clear-local-variables)
8157 ;; We clear the global counterparts of the buffer-local
8158 ;; variables as well, just to be on the safe side.
8159 (gnus-configure-windows 'group 'force)
8160 (gnus-summary-clear-local-variables)
8161 ;; Return to group mode buffer.
8162 (if (eq mode 'gnus-summary-mode)
8163 (gnus-kill-buffer buf))
8164 (if (get-buffer gnus-article-buffer)
8165 (bury-buffer gnus-article-buffer))
8166 (setq gnus-current-select-method gnus-select-method)
8167 (pop-to-buffer gnus-group-buffer)
8168 (if (not quit-config)
8170 (gnus-group-jump-to-group group)
8171 (gnus-group-next-unread-group 1))
8172 (if (not (buffer-name (car quit-config)))
8173 (gnus-configure-windows 'group 'force)
8174 (set-buffer (car quit-config))
8175 (and (eq major-mode 'gnus-summary-mode)
8176 (gnus-set-global-variables))
8177 (gnus-configure-windows (cdr quit-config))))
8178 (run-hooks 'gnus-summary-exit-hook))))
8180 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
8181 (defun gnus-summary-exit-no-update (&optional no-questions)
8182 "Quit reading current newsgroup without updating read article info."
8184 (gnus-set-global-variables)
8185 (let* ((group gnus-newsgroup-name)
8186 (quit-config (nth 1 (assoc 'quit-config
8187 (gnus-find-method-for-group group)))))
8188 (if (or no-questions
8190 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
8192 (gnus-close-group group)
8193 (gnus-summary-clear-local-variables)
8194 (set-buffer gnus-group-buffer)
8195 (gnus-summary-clear-local-variables)
8196 ;; Return to group selection mode.
8197 (gnus-configure-windows 'group 'force)
8198 (if (get-buffer gnus-summary-buffer)
8199 (kill-buffer gnus-summary-buffer))
8200 (if (get-buffer gnus-article-buffer)
8201 (bury-buffer gnus-article-buffer))
8202 (if (equal (gnus-group-group-name) group)
8203 (gnus-group-next-unread-group 1))
8206 (if (not (buffer-name (car quit-config)))
8207 (gnus-configure-windows 'group 'force)
8208 (set-buffer (car quit-config))
8209 (and (eq major-mode 'gnus-summary-mode)
8210 (gnus-set-global-variables))
8211 (gnus-configure-windows (cdr quit-config)))))))))
8213 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
8214 (defun gnus-summary-fetch-faq (&optional faq-dir)
8215 "Fetch the FAQ for the current group.
8216 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
8220 (if current-prefix-arg
8222 "Faq dir: " (and (listp gnus-group-faq-directory)
8223 gnus-group-faq-directory)))))
8224 (let (gnus-faq-buffer)
8225 (and (setq gnus-faq-buffer
8226 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
8227 (gnus-configure-windows 'summary-faq))))
8229 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
8230 (defun gnus-summary-describe-group (&optional force)
8231 "Describe the current newsgroup."
8233 (gnus-group-describe-group force gnus-newsgroup-name))
8235 (defun gnus-summary-describe-briefly ()
8236 "Describe summary mode commands briefly."
8239 (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")))
8241 ;; Walking around group mode buffer from summary mode.
8243 (defun gnus-summary-next-group (&optional no-article target-group backward)
8244 "Exit current newsgroup and then select next unread newsgroup.
8245 If prefix argument NO-ARTICLE is non-nil, no article is selected
8246 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
8247 previous group instead."
8249 (gnus-set-global-variables)
8250 (let ((current-group gnus-newsgroup-name)
8251 (current-buffer (current-buffer))
8253 ;; First we semi-exit this group to update Xrefs and all variables.
8254 ;; We can't do a real exit, because the window conf must remain
8255 ;; the same in case the user is prompted for info, and we don't
8256 ;; want the window conf to change before that...
8257 (gnus-summary-exit t)
8258 (while (not entered)
8259 ;; Then we find what group we are supposed to enter.
8260 (set-buffer gnus-group-buffer)
8261 (gnus-group-jump-to-group current-group)
8264 (if (eq gnus-keep-same-level 'best)
8265 (gnus-summary-best-group gnus-newsgroup-name)
8266 (gnus-summary-search-group backward gnus-keep-same-level))))
8267 (if (not target-group)
8268 ;; There are no further groups, so we return to the group
8271 (gnus-message 5 "Returning to the group buffer")
8273 (set-buffer current-buffer)
8274 (gnus-summary-exit))
8275 ;; We try to enter the target group.
8276 (gnus-group-jump-to-group target-group)
8277 (let ((unreads (gnus-group-group-unread)))
8278 (if (and (or (eq t unreads)
8279 (and unreads (not (zerop unreads))))
8280 (gnus-summary-read-group
8281 target-group nil no-article current-buffer))
8283 (setq current-group target-group
8284 target-group nil)))))))
8286 (defun gnus-summary-prev-group (&optional no-article)
8287 "Exit current newsgroup and then select previous unread newsgroup.
8288 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
8290 (gnus-summary-next-group no-article nil t))
8292 ;; Walking around summary lines.
8294 (defun gnus-summary-first-subject (&optional unread)
8295 "Go to the first unread subject.
8296 If UNREAD is non-nil, go to the first unread article.
8297 Returns the article selected or nil if there are no unread articles."
8302 ((null gnus-newsgroup-data)
8303 (gnus-message 3 "No articles in the group")
8305 ;; Pick the first article.
8307 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
8308 (gnus-data-number (car gnus-newsgroup-data)))
8309 ;; No unread articles.
8310 ((null gnus-newsgroup-unreads)
8311 (gnus-message 3 "No more unread articles")
8313 ;; Find the first unread article.
8315 (let ((data gnus-newsgroup-data))
8317 (not (gnus-data-unread-p (car data))))
8318 (setq data (cdr data)))
8321 (goto-char (gnus-data-pos (car data)))
8322 (gnus-data-number (car data)))))))
8323 (gnus-summary-position-point)))
8325 (defun gnus-summary-next-subject (n &optional unread dont-display)
8326 "Go to next N'th summary line.
8327 If N is negative, go to the previous N'th subject line.
8328 If UNREAD is non-nil, only unread articles are selected.
8329 The difference between N and the actual number of steps taken is
8332 (let ((backward (< n 0))
8336 (gnus-summary-find-prev unread)
8337 (gnus-summary-find-next unread)))
8339 (if (/= 0 n) (gnus-message 7 "No more%s articles"
8340 (if unread " unread" "")))
8343 (gnus-summary-recenter)
8344 (gnus-summary-position-point)))
8347 (defun gnus-summary-next-unread-subject (n)
8348 "Go to next N'th unread summary line."
8350 (gnus-summary-next-subject n t))
8352 (defun gnus-summary-prev-subject (n &optional unread)
8353 "Go to previous N'th summary line.
8354 If optional argument UNREAD is non-nil, only unread article is selected."
8356 (gnus-summary-next-subject (- n) unread))
8358 (defun gnus-summary-prev-unread-subject (n)
8359 "Go to previous N'th unread summary line."
8361 (gnus-summary-next-subject (- n) t))
8363 (defun gnus-summary-goto-subject (article &optional force)
8364 "Go the subject line of ARTICLE."
8368 (completing-read "Article number: "
8372 (int-to-string (mail-header-number headers))))
8373 gnus-newsgroup-headers)
8374 nil 'require-match))))
8375 (or article (error "No article number"))
8377 (data (gnus-data-find article)))
8380 (and (gnus-summary-insert-article article)
8381 (setq data (gnus-data-find article))))
8383 (message "Can't find article %d" article)
8384 (goto-char (gnus-data-pos data))
8385 ;; Skip dummy articles.
8386 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8387 (gnus-summary-find-next))
8393 (gnus-summary-position-point))))))
8395 ;; Walking around summary lines with displaying articles.
8397 (defun gnus-summary-expand-window (&optional arg)
8398 "Make the summary buffer take up the entire Emacs frame.
8399 Given a prefix, will force an `article' buffer configuration."
8401 (gnus-set-global-variables)
8403 (gnus-configure-windows 'article 'force)
8404 (gnus-configure-windows 'summary 'force)))
8406 (defun gnus-summary-display-article (article &optional all-header)
8407 "Display ARTICLE in article buffer."
8408 (gnus-set-global-variables)
8412 (gnus-article-prepare article all-header)
8413 (gnus-summary-show-thread)
8414 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8415 (gnus-summary-find-next))
8416 (run-hooks 'gnus-select-article-hook)
8417 (gnus-summary-recenter)
8418 (gnus-summary-goto-subject article)
8419 ;; Successfully display article.
8420 (gnus-summary-update-line)
8421 (gnus-article-set-window-start
8422 (cdr (assq article gnus-newsgroup-bookmarks)))
8425 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
8426 "Select the current article.
8427 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
8428 non-nil, the article will be re-fetched even if it already present in
8429 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
8431 (let ((article (or article (gnus-summary-article-number)))
8432 (all-headers (not (not all-headers))) ;Must be T or NIL.
8435 (gnus-summary-article-pseudo-p article)
8436 (error "This is a pseudo-article."))
8439 (set-buffer gnus-summary-buffer)
8440 (if (or (null gnus-current-article)
8441 (null gnus-article-current)
8442 (null (get-buffer gnus-article-buffer))
8443 (not (eq article (cdr gnus-article-current)))
8444 (not (equal (car gnus-article-current) gnus-newsgroup-name))
8446 ;; The requested article is different from the current article.
8448 (gnus-summary-display-article article all-headers)
8450 (if (or all-headers gnus-show-all-headers)
8451 (gnus-article-show-all-headers))
8454 (gnus-article-set-window-start
8455 (cdr (assq article gnus-newsgroup-bookmarks)))))))
8457 (defun gnus-summary-set-current-mark (&optional current-mark)
8458 "Obsolete function."
8461 (defun gnus-summary-next-article (&optional unread subject backward)
8462 "Select the next article.
8463 If UNREAD, only unread articles are selected.
8464 If SUBJECT, only articles with SUBJECT are selected.
8465 If BACKWARD, the previous article is selected instead of the next."
8467 (gnus-set-global-variables)
8470 ;; Is there such an article?
8471 ((and (gnus-summary-search-forward unread subject backward)
8472 (or (gnus-summary-display-article (gnus-summary-article-number))
8473 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8474 (gnus-summary-position-point))
8475 ;; If not, we try the first unread, if that is wanted.
8477 gnus-auto-select-same
8478 (or (gnus-summary-first-unread-article)
8479 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8480 (gnus-summary-position-point)
8481 (gnus-message 6 "Wrapped"))
8482 ;; Try to get next/previous article not displayed in this group.
8483 ((and gnus-auto-extend-newsgroup
8484 (not unread) (not subject))
8485 (gnus-summary-goto-article
8486 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
8488 ;; Go to next/previous group.
8490 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
8491 (gnus-summary-jump-to-group gnus-newsgroup-name))
8492 (let ((cmd last-command-char)
8494 (if (eq gnus-keep-same-level 'best)
8495 (gnus-summary-best-group gnus-newsgroup-name)
8496 (gnus-summary-search-group backward gnus-keep-same-level))))
8497 ;; For some reason, the group window gets selected. We change
8499 (select-window (get-buffer-window (current-buffer)))
8500 ;; Keep just the event type of CMD.
8501 ;(and (listp cmd) (setq cmd (car cmd)))
8502 ;; Select next unread newsgroup automagically.
8504 ((not gnus-auto-select-next)
8505 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
8506 ((or (eq gnus-auto-select-next 'quietly)
8507 (and (eq gnus-auto-select-next 'almost-quietly)
8508 (gnus-summary-last-article-p)))
8510 (if (assoc 'quit-config (gnus-find-method-for-group
8511 gnus-newsgroup-name))
8513 (gnus-message 7 "No more%s articles (%s)..."
8514 (if unread " unread" "")
8515 (if group (concat "selecting " group)
8517 (gnus-summary-next-group nil group backward)))
8519 (let ((keystrokes '(?\C-n ?\C-p))
8521 (while (or (null key) (memq key keystrokes))
8523 7 "No more%s articles%s" (if unread " unread" "")
8524 (if (and group (not (assoc 'quit-config
8525 (gnus-find-method-for-group
8526 gnus-newsgroup-name))))
8527 (format " (Type %s for %s [%s])"
8528 (single-key-description cmd) group
8529 (car (gnus-gethash group gnus-newsrc-hashtb)))
8530 (format " (Type %s to exit %s)"
8531 (single-key-description cmd)
8532 gnus-newsgroup-name)))
8533 ;; Confirm auto selection.
8534 (let* ((event (read-char-exclusive)))
8535 (setq key (if (listp event) (car event) event))
8536 (if (memq key keystrokes)
8537 (let ((obuf (current-buffer)))
8538 (switch-to-buffer gnus-group-buffer)
8540 (gnus-group-jump-to-group group))
8542 (execute-kbd-macro (char-to-string key))
8544 (setq group (gnus-group-group-name))
8545 (switch-to-buffer obuf)))))
8547 (if (or (not group) (assoc 'quit-config
8548 (gnus-find-method-for-group
8549 gnus-newsgroup-name)))
8551 (gnus-summary-next-group nil group backward))
8552 (execute-kbd-macro (char-to-string key)))))))))))
8554 (defun gnus-summary-next-unread-article ()
8555 "Select unread article after current one."
8557 (gnus-summary-next-article t (and gnus-auto-select-same
8558 (gnus-summary-article-subject))))
8560 (defun gnus-summary-prev-article (&optional unread subject)
8561 "Select the article after the current one.
8562 If UNREAD is non-nil, only unread articles are selected."
8564 (gnus-summary-next-article unread subject t))
8566 (defun gnus-summary-prev-unread-article ()
8567 "Select unred article before current one."
8569 (gnus-summary-prev-article t (and gnus-auto-select-same
8570 (gnus-summary-article-subject))))
8572 (defun gnus-summary-next-page (&optional lines circular)
8573 "Show next page of selected article.
8574 If end of article, select next article.
8575 Argument LINES specifies lines to be scrolled up.
8576 If CIRCULAR is non-nil, go to the start of the article instead of
8577 instead of selecting the next article when reaching the end of the
8580 (setq gnus-summary-buffer (current-buffer))
8581 (gnus-set-global-variables)
8582 (let ((article (gnus-summary-article-number))
8584 (gnus-configure-windows 'article)
8585 (if (or (null gnus-current-article)
8586 (null gnus-article-current)
8587 (/= article (cdr gnus-article-current))
8588 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8589 ;; Selected subject is different from current article's.
8590 (gnus-summary-display-article article)
8591 (gnus-eval-in-buffer-window
8593 (setq endp (gnus-article-next-page lines)))
8596 (gnus-summary-beginning-of-article))
8598 (gnus-message 3 "End of message"))
8600 (gnus-summary-next-unread-article)))))
8601 (gnus-summary-recenter)
8602 (gnus-summary-position-point)))
8604 (defun gnus-summary-prev-page (&optional lines)
8605 "Show previous page of selected article.
8606 Argument LINES specifies lines to be scrolled down."
8608 (gnus-set-global-variables)
8609 (let ((article (gnus-summary-article-number)))
8610 (gnus-configure-windows 'article)
8611 (if (or (null gnus-current-article)
8612 (null gnus-article-current)
8613 (/= article (cdr gnus-article-current))
8614 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8615 ;; Selected subject is different from current article's.
8616 (gnus-summary-display-article article)
8617 (gnus-summary-recenter)
8618 (gnus-eval-in-buffer-window gnus-article-buffer
8619 (gnus-article-prev-page lines))))
8620 (gnus-summary-position-point))
8622 (defun gnus-summary-scroll-up (lines)
8623 "Scroll up (or down) one line current article.
8624 Argument LINES specifies lines to be scrolled up (or down if negative)."
8626 (gnus-set-global-variables)
8627 (gnus-configure-windows 'article)
8628 (or (gnus-summary-select-article nil nil 'pseudo)
8629 (gnus-eval-in-buffer-window
8632 (if (gnus-article-next-page lines)
8633 (gnus-message 3 "End of message")))
8635 (gnus-article-prev-page (- lines))))))
8636 (gnus-summary-recenter)
8637 (gnus-summary-position-point))
8639 (defun gnus-summary-next-same-subject ()
8640 "Select next article which has the same subject as current one."
8642 (gnus-set-global-variables)
8643 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8645 (defun gnus-summary-prev-same-subject ()
8646 "Select previous article which has the same subject as current one."
8648 (gnus-set-global-variables)
8649 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8651 (defun gnus-summary-next-unread-same-subject ()
8652 "Select next unread article which has the same subject as current one."
8654 (gnus-set-global-variables)
8655 (gnus-summary-next-article t (gnus-summary-article-subject)))
8657 (defun gnus-summary-prev-unread-same-subject ()
8658 "Select previous unread article which has the same subject as current one."
8660 (gnus-set-global-variables)
8661 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8663 (defun gnus-summary-first-unread-article ()
8664 "Select the first unread article.
8665 Return nil if there are no unread articles."
8667 (gnus-set-global-variables)
8669 (if (gnus-summary-first-subject t)
8671 (gnus-summary-show-thread)
8672 (gnus-summary-first-subject t)
8673 (gnus-summary-display-article (gnus-summary-article-number))))
8674 (gnus-summary-position-point)))
8676 (defun gnus-summary-best-unread-article ()
8677 "Select the unread article with the highest score."
8679 (gnus-set-global-variables)
8680 (let ((best -1000000)
8681 (data gnus-newsgroup-data)
8684 (and (gnus-data-unread-p (car data))
8686 (gnus-summary-article-score (gnus-data-number (car data))))
8689 article (gnus-data-number (car data))))
8690 (setq data (cdr data)))
8692 (gnus-summary-goto-article article)
8693 (error "No unread articles"))
8694 (gnus-summary-position-point)))
8696 (defun gnus-summary-goto-article (article &optional all-headers force)
8697 "Fetch ARTICLE and display it if it exists.
8698 If ALL-HEADERS is non-nil, no header lines are hidden."
8704 (mapcar (lambda (headers)
8705 (list (int-to-string (mail-header-number headers))))
8706 gnus-newsgroup-headers)
8707 nil 'require-match))))
8709 (and (gnus-summary-goto-subject article force)
8710 (gnus-summary-display-article article all-headers))
8711 (gnus-summary-position-point)))
8713 (defun gnus-summary-goto-last-article ()
8714 "Go to the previously read article."
8717 (and gnus-last-article
8718 (gnus-summary-goto-article gnus-last-article))
8719 (gnus-summary-position-point)))
8721 (defun gnus-summary-pop-article (number)
8722 "Pop one article off the history and go to the previous.
8723 NUMBER articles will be popped off."
8726 (setq gnus-newsgroup-history
8727 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8729 (gnus-summary-goto-article (car to))
8730 (error "Article history empty")))
8731 (gnus-summary-position-point))
8733 ;; Summary commands and functions for limiting the summary buffer.
8735 (defun gnus-summary-limit-to-articles (n)
8736 "Limit the summary buffer to the next N articles.
8737 If not given a prefix, use the process marked articles instead."
8739 (gnus-set-global-variables)
8741 (let ((articles (gnus-summary-work-articles n)))
8742 (gnus-summary-limit articles))
8743 (gnus-summary-position-point)))
8745 (defun gnus-summary-pop-limit (&optional total)
8746 "Restore the previous limit.
8747 If given a prefix, remove all limits."
8749 (gnus-set-global-variables)
8751 (if total (setq gnus-newsgroup-limits nil))
8752 (gnus-summary-limit nil 'pop))
8753 (gnus-summary-position-point))
8755 (defun gnus-summary-limit-to-subject (subject)
8756 "Limit the summary buffer to articles that have subjects that match a regexp."
8757 (interactive "sRegexp: ")
8758 (if (equal "" subject)
8761 (let ((articles (gnus-summary-find-matching "subject" subject)))
8762 (or articles (error "Found no matches for \"%s\"" subject))
8763 (gnus-summary-limit articles))
8764 (gnus-summary-position-point))))
8766 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8768 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8770 (defun gnus-summary-limit-to-unread (&optional all)
8771 "Limit the summary buffer to articles that are not marked as read.
8772 If ALL is non-nil, limit strictly to unread articles."
8775 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark) t)
8776 (gnus-summary-limit-to-marks
8777 ;; Concat all the marks that say that an article is read and have
8780 (lambda (char) (char-to-string (symbol-value char)))
8781 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
8782 gnus-killed-mark gnus-kill-file-mark
8783 gnus-low-score-mark gnus-expirable-mark
8784 gnus-canceled-mark gnus-catchup-mark)
8787 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
8788 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
8790 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8791 "Limit the summary buffer to articles that are not marked with MARKS (e.g. \"DK\").
8792 If REVERSE, limit the summary buffer to articles that are marked
8794 Returns how many articles were removed."
8795 (interactive "sMarks: ")
8796 (gnus-set-global-variables)
8798 (if gnus-newsgroup-adaptive
8799 (gnus-score-remove-lines-adaptive marks)
8800 (let ((data gnus-newsgroup-data)
8801 (marks (append marks nil)) ; Transform to list.
8804 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
8805 (memq (gnus-data-mark (car data)) marks))
8806 (setq articles (cons (gnus-data-number (car data)) articles)))
8807 (setq data (cdr data)))
8808 (gnus-summary-limit articles)))
8809 (gnus-summary-position-point)))
8811 (defun gnus-summary-limit-to-score (&optional score)
8812 "Limit to articles with score at or above SCORE."
8814 (gnus-set-global-variables)
8815 (setq score (if score
8816 (prefix-numeric-value score)
8817 (or gnus-summary-default-score 0)))
8818 (let ((data gnus-newsgroup-data)
8821 (and (>= (gnus-summary-article-score (gnus-data-number (car data)))
8823 (setq articles (cons (gnus-data-number (car data)) articles)))
8824 (setq data (cdr data))
8826 (gnus-summary-limit articles)
8827 (gnus-summary-position-point)))))
8829 (defun gnus-summary-limit-include-dormant ()
8830 "Display all the hidden articles that are marked as dormant."
8832 (gnus-set-global-variables)
8833 (or gnus-newsgroup-dormant
8834 (error "There are no dormant articles in this group"))
8836 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8837 (gnus-summary-position-point)))
8839 (defun gnus-summary-limit-exclude-dormant ()
8840 "Hide all dormant articles."
8842 (gnus-set-global-variables)
8844 (gnus-summary-limit-to-marks (char-to-string gnus-dormant-mark) 'reverse)
8845 (gnus-summary-position-point)))
8847 (defun gnus-summary-limit-exclude-childless-dormant ()
8848 "Hide all dormant articles that have no children."
8850 (gnus-set-global-variables)
8851 (let ((data gnus-newsgroup-data)
8853 ;; Find all articles that are either not dormant or have
8856 (and (or (not (= (gnus-data-mark (car data)) gnus-dormant-mark))
8857 (gnus-article-parent-p (gnus-data-number (car data))))
8858 (setq articles (cons (gnus-data-number (car data))
8860 (setq data (cdr data)))
8863 (gnus-summary-limit articles)
8864 (gnus-summary-position-point))))
8866 (defun gnus-summary-limit (articles &optional pop)
8868 ;; We pop the previous limit off the stack and use that.
8869 (setq articles (car gnus-newsgroup-limits)
8870 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8871 ;; We use the new limit, so we push the old limit on the stack.
8872 (setq gnus-newsgroup-limits
8873 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
8875 (setq gnus-newsgroup-limit articles)
8876 (let ((total (length gnus-newsgroup-data))
8877 (data (gnus-data-find-list (gnus-summary-article-number)))
8879 ;; This will do all the work of generating the new summary buffer
8880 ;; according to the new limit.
8881 (gnus-summary-prepare)
8882 ;; Try to return to the article you were at, or on in the
8885 ;; We try to find some article after the current one.
8887 (and (gnus-summary-goto-subject (gnus-data-number (car data)))
8890 (setq data (cdr data))))
8892 ;; If there is no data, that means that we were after the last
8893 ;; article. The same goes when we can't find any articles
8894 ;; after the current one.
8896 (goto-char (point-max))
8897 (gnus-summary-find-prev)))
8898 ;; We return how many articles were removed from the summary
8899 ;; buffer as a result of the new limit.
8900 (- total (length gnus-newsgroup-data))))
8902 ;; Summary article oriented commands
8904 (defun gnus-summary-refer-parent-article (n)
8905 "Refer parent article N times.
8906 The difference between N and the number of articles fetched is returned."
8908 (gnus-set-global-variables)
8912 (let ((ref (mail-header-references (gnus-summary-article-header))))
8913 (if (and ref (not (equal ref ""))
8914 (string-match "<[^<>]*>[ \t]*$" ref))
8915 (or (gnus-summary-refer-article
8916 (substring ref (match-beginning 0) (match-end 0)))
8917 (gnus-message 1 "Couldn't find parent"))
8918 (gnus-message 1 "No references in article %d"
8919 (gnus-summary-article-number))
8922 (gnus-summary-position-point)
8925 (defun gnus-summary-refer-references ()
8926 "Fetch all articles mentioned in the References header.
8927 Return how many articles were fetched."
8929 (gnus-set-global-variables)
8930 (let ((ref (mail-header-references (gnus-summary-article-header)))
8932 (while (string-match "<[^]*>" ref)
8934 (gnus-summary-refer-article
8935 (substring ref (match-beginning 0) (match-end 0)))
8936 (setq ref (substring ref (match-end 0))))
8939 (defun gnus-summary-refer-article (message-id)
8940 "Fetch an article specified by MESSAGE-ID."
8941 (interactive "sMessage-ID: ")
8942 (if (or (not (stringp message-id))
8943 (zerop (length message-id)))
8945 ;; Construct the correct Message-ID if necessary.
8946 ;; Suggested by tale@pawl.rpi.edu.
8947 (or (string-match "^<" message-id)
8948 (setq message-id (concat "<" message-id)))
8949 (or (string-match ">$" message-id)
8950 (setq message-id (concat message-id ">")))
8951 (let ((header (car (gnus-gethash (downcase message-id)
8952 gnus-newsgroup-dependencies))))
8954 ;; The article is present in the buffer, to we just go to it.
8955 (gnus-summary-goto-article (mail-header-number header) nil t)
8956 ;; We fetch the article
8957 (let ((gnus-override-method gnus-refer-article-method)
8958 (gnus-ancient-mark gnus-read-mark)
8959 (tmp-point (window-start
8960 (get-buffer-window gnus-article-buffer)))
8962 (and gnus-refer-article-method
8963 (gnus-check-server gnus-refer-article-method))
8964 (gnus-summary-insert-article message-id))))))
8966 (defun gnus-summary-enter-digest-group ()
8967 "Enter a digest group based on the current article."
8969 (gnus-set-global-variables)
8970 (gnus-summary-select-article)
8971 ;; We do not want a narrowed article.
8972 (gnus-summary-stop-page-breaking)
8973 (let ((name (format "%s-%d"
8974 (gnus-group-prefixed-name
8975 gnus-newsgroup-name (list 'nndoc ""))
8976 gnus-current-article))
8977 (ogroup gnus-newsgroup-name)
8978 (buf (current-buffer)))
8979 (if (gnus-group-read-ephemeral-group
8980 name (list 'nndoc name
8981 (list 'nndoc-address (get-buffer gnus-article-buffer))
8982 '(nndoc-article-type digest))
8984 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8985 (list (list (cons 'to-group ogroup))))
8986 (switch-to-buffer buf)
8987 (gnus-set-global-variables)
8988 (gnus-configure-windows 'summary)
8989 (gnus-message 3 "Article not a digest?"))))
8991 (defun gnus-summary-isearch-article ()
8992 "Do incremental search forward on current article."
8994 (gnus-set-global-variables)
8995 (gnus-summary-select-article)
8996 (gnus-eval-in-buffer-window
8997 gnus-article-buffer (isearch-forward)))
8999 (defun gnus-summary-search-article-forward (regexp &optional backward)
9000 "Search for an article containing REGEXP forward.
9001 If BACKWARD, search backward instead."
9004 (format "Search article %s (regexp%s): "
9005 (if current-prefix-arg "backward" "forward")
9006 (if gnus-last-search-regexp
9007 (concat ", default " gnus-last-search-regexp)
9009 current-prefix-arg))
9010 (gnus-set-global-variables)
9011 (if (string-equal regexp "")
9012 (setq regexp (or gnus-last-search-regexp ""))
9013 (setq gnus-last-search-regexp regexp))
9014 (if (gnus-summary-search-article regexp backward)
9015 (gnus-article-set-window-start
9016 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
9017 (error "Search failed: \"%s\"" regexp)))
9019 (defun gnus-summary-search-article-backward (regexp)
9020 "Search for an article containing REGEXP backward."
9023 (format "Search article backward (regexp%s): "
9024 (if gnus-last-search-regexp
9025 (concat ", default " gnus-last-search-regexp)
9027 (gnus-summary-search-article-forward regexp 'backward))
9029 (defun gnus-summary-search-article (regexp &optional backward)
9030 "Search for an article containing REGEXP.
9031 Optional argument BACKWARD means do search for backward.
9032 gnus-select-article-hook is not called during the search."
9033 (let ((gnus-select-article-hook nil) ;Disable hook.
9034 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9037 (function re-search-backward) (function re-search-forward)))
9040 ;; Hidden thread subtrees must be searched for ,too.
9041 (gnus-summary-show-all-threads)
9042 ;; First of all, search current article.
9043 ;; We don't want to read article again from NNTP server nor reset
9045 (gnus-summary-select-article)
9046 (gnus-message 9 "Searching article: %d..." gnus-current-article)
9047 (setq last gnus-current-article)
9048 (gnus-eval-in-buffer-window
9052 ;; Begin search from current point.
9053 (setq found (funcall re-search regexp nil t))))
9054 ;; Then search next articles.
9055 (while (and (not found)
9056 (gnus-summary-display-article
9057 (if backward (gnus-summary-find-prev)
9058 (gnus-summary-find-next))))
9059 (gnus-message 9 "Searching article: %d..." gnus-current-article)
9060 (gnus-eval-in-buffer-window
9064 (goto-char (if backward (point-max) (point-min)))
9065 (setq found (funcall re-search regexp nil t)))))
9067 ;; Adjust article pointer.
9068 (or (eq last gnus-current-article)
9069 (setq gnus-last-article last))
9070 ;; Return T if found such article.
9073 (defun gnus-summary-find-matching (header regexp &optional backward unread
9075 "Return a list of all articles that match REGEXP on HEADER.
9076 The search stars on the current article and goes forwards unless
9077 BACKWARD is non-nil. If UNREAD is non-nil, only unread articles will
9078 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9079 in the comparisons."
9080 (let ((data (gnus-data-find-list (gnus-summary-article-number
9081 (gnus-data-list backward))))
9082 (func (intern (concat "gnus-header-" header)))
9083 (case-fold-search (not not-case-fold))
9085 (or (fboundp func) (error "%s is not a valid header" header))
9088 (and (or (not unread) ; We want all articles...
9089 (gnus-data-unread-p d)) ; Or just unreads.
9090 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9091 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
9092 (setq articles (cons (gnus-data-number d) articles))) ; Success!
9093 (setq data (cdr data)))
9094 (nreverse articles)))
9096 (defun gnus-summary-execute-command (header regexp command &optional backward)
9097 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9098 If HEADER is an empty string (or nil), the match is done on the entire
9099 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9101 (list (let ((completion-ignore-case t))
9104 (mapcar (lambda (string) (list string))
9105 '("Number" "Subject" "From" "Lines" "Date"
9106 "Message-ID" "Xref" "References"))
9107 nil 'require-match))
9108 (read-string "Regexp: ")
9109 (read-key-sequence "Command: ")
9110 current-prefix-arg))
9111 (gnus-set-global-variables)
9112 ;; Hidden thread subtrees must be searched as well.
9113 (gnus-summary-show-all-threads)
9114 ;; We don't want to change current point nor window configuration.
9116 (save-window-excursion
9117 (gnus-message 6 "Executing %s..." (key-description command))
9118 ;; We'd like to execute COMMAND interactively so as to give arguments.
9119 (gnus-execute header regexp
9121 (call-interactively '(, (key-binding command)))))
9123 (gnus-message 6 "Executing %s...done" (key-description command)))))
9125 (defun gnus-summary-beginning-of-article ()
9126 "Scroll the article back to the beginning."
9128 (gnus-set-global-variables)
9129 (gnus-summary-select-article)
9130 (gnus-configure-windows 'article)
9131 (gnus-eval-in-buffer-window
9134 (goto-char (point-min))
9135 (and gnus-break-pages (gnus-narrow-to-page))))
9137 (defun gnus-summary-end-of-article ()
9138 "Scroll to the end of the article."
9140 (gnus-set-global-variables)
9141 (gnus-summary-select-article)
9142 (gnus-configure-windows 'article)
9143 (gnus-eval-in-buffer-window
9146 (goto-char (point-max))
9148 (and gnus-break-pages (gnus-narrow-to-page))))
9150 (defun gnus-summary-show-article (&optional arg)
9151 "Force re-fetching of the current article.
9152 If ARG (the prefix) is non-nil, show the raw article without any
9153 article massaging functions being run."
9155 (gnus-set-global-variables)
9157 ;; Select the article the normal way.
9158 (gnus-summary-select-article nil 'force)
9159 ;; Bind the article treatment functions to nil.
9160 (let ((gnus-have-all-headers t)
9161 gnus-article-display-hook
9162 gnus-article-prepare-hook
9164 (gnus-summary-select-article nil 'force)))
9165 (gnus-configure-windows 'article)
9166 (gnus-summary-position-point))
9168 (defun gnus-summary-verbose-headers (&optional arg)
9169 "Toggle permanent full header display.
9170 If ARG is a positive number, turn header display on.
9171 If ARG is a negative number, turn header display off."
9173 (gnus-set-global-variables)
9174 (gnus-summary-toggle-header arg)
9175 (setq gnus-show-all-headers
9176 (cond ((or (not (numberp arg))
9178 (not gnus-show-all-headers))
9182 (defun gnus-summary-toggle-header (&optional arg)
9183 "Show the headers if they are hidden, or hide them if they are shown.
9184 If ARG is a positive number, show the entire header.
9185 If ARG is a negative number, hide the unwanted header lines."
9187 (gnus-set-global-variables)
9189 (set-buffer gnus-article-buffer)
9190 (let ((buffer-read-only nil))
9192 (if (> arg 0) (remove-text-properties (point-min) (point-max)
9193 gnus-hidden-properties)
9194 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
9195 (if (text-property-any (point-min) (point-max) 'invisible t)
9196 (remove-text-properties
9197 (point-min) (point-max) gnus-hidden-properties)
9198 ;; We hide the headers. This song and dance act below is
9199 ;; done because `gnus-have-all-headers' is buffer-local to
9200 ;; the summary buffer, and we only want to temporarily
9201 ;; change it in that buffer. Ugh.
9202 (let ((have gnus-have-all-headers))
9204 (set-buffer gnus-summary-buffer)
9205 (setq gnus-have-all-headers nil)
9207 (set-buffer gnus-article-buffer)
9208 (run-hooks 'gnus-article-display-hook))
9209 (setq gnus-have-all-headers have)))))
9210 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
9212 (defun gnus-summary-show-all-headers ()
9213 "Make all header lines visible."
9215 (gnus-set-global-variables)
9216 (gnus-article-show-all-headers))
9218 (defun gnus-summary-toggle-mime (&optional arg)
9219 "Toggle MIME processing.
9220 If ARG is a positive number, turn MIME processing on."
9222 (gnus-set-global-variables)
9223 (setq gnus-show-mime
9224 (if (null arg) (not gnus-show-mime)
9225 (> (prefix-numeric-value arg) 0)))
9226 (gnus-summary-select-article t 'force))
9228 (defun gnus-summary-caesar-message (&optional arg)
9229 "Caesar rotate the current article by 13.
9230 The numerical prefix specifies how manu places to rotate each letter
9233 (gnus-set-global-variables)
9234 (gnus-summary-select-article)
9235 (let ((mail-header-separator ""))
9236 (gnus-eval-in-buffer-window
9240 (let ((start (window-start)))
9241 (news-caesar-buffer-body arg)
9242 (set-window-start (get-buffer-window (current-buffer)) start))))))
9244 (defun gnus-summary-stop-page-breaking ()
9245 "Stop page breaking in the current article."
9247 (gnus-set-global-variables)
9248 (gnus-summary-select-article)
9249 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
9251 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
9253 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
9254 "Move the current article to a different newsgroup.
9255 If N is a positive number, move the N next articles.
9256 If N is a negative number, move the N previous articles.
9257 If N is nil and any articles have been marked with the process mark,
9258 move those articles instead.
9259 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9260 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
9261 re-spool using this method.
9262 For this function to work, both the current newsgroup and the
9263 newsgroup that you want to move to have to support the `request-move'
9264 and `request-accept' functions. (Ie. mail newsgroups at present.)"
9266 (gnus-set-global-variables)
9267 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
9268 (error "The current newsgroup does not support article moving"))
9269 (let ((articles (gnus-summary-work-articles n))
9270 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
9271 art-group to-method sel-met)
9272 (if (and (not to-newsgroup) (not select-method))
9275 (format "Where do you want to move %s? %s"
9276 (if (> (length articles) 1)
9277 (format "these %d articles" (length articles))
9279 (if gnus-current-move-group
9280 (format "(%s default) " gnus-current-move-group)
9282 gnus-active-hashtb nil nil prefix)))
9285 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
9286 (setq to-newsgroup (or gnus-current-move-group "")))
9287 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
9288 (gnus-activate-group to-newsgroup)
9289 (error "No such group: %s" to-newsgroup))
9290 (setq gnus-current-move-group to-newsgroup)))
9291 (setq to-method (if select-method (list select-method "")
9292 (gnus-find-method-for-group to-newsgroup)))
9293 (or (gnus-check-backend-function 'request-accept-article (car to-method))
9294 (error "%s does not support article copying" (car to-method)))
9295 (or (gnus-check-server to-method)
9296 (error "Can't open server %s" (car to-method)))
9297 (gnus-message 6 "Moving to %s: %s..."
9298 (or select-method to-newsgroup) articles)
9301 (gnus-request-move-article
9302 (car articles) ; Article to move
9303 gnus-newsgroup-name ; From newsgrouo
9304 (nth 1 (gnus-find-method-for-group
9305 gnus-newsgroup-name)) ; Server
9306 (list 'gnus-request-accept-article
9308 (list 'quote select-method)
9310 (not (cdr articles))) ; Accept form
9311 (not (cdr articles)))) ; Only save nov last time
9312 (let* ((buffer-read-only nil)
9315 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
9317 (gnus-group-prefixed-name
9319 (if select-method (list select-method "")
9320 (gnus-find-method-for-group to-newsgroup)))
9321 gnus-newsrc-hashtb)))
9322 (info (nth 2 entry))
9323 (article (car articles)))
9324 (gnus-summary-goto-subject article)
9326 (delete-region (point) (progn (forward-line 1) (point)))
9327 ;; Update the group that has been moved to.
9329 () ; This group does not exist yet.
9330 (if (not (memq article gnus-newsgroup-unreads))
9331 (setcar (cdr (cdr info))
9332 (gnus-add-to-range (nth 2 info)
9333 (list (cdr art-group)))))
9334 ;; Copy any marks over to the new group.
9335 (let ((marks '((tick . gnus-newsgroup-marked)
9336 (dormant . gnus-newsgroup-dormant)
9337 (expire . gnus-newsgroup-expirable)
9338 (bookmark . gnus-newsgroup-bookmarks)
9339 (reply . gnus-newsgroup-replied)))
9340 (to-article (cdr art-group)))
9342 (if (memq article (symbol-value (cdr (car marks))))
9343 (gnus-add-marked-articles
9344 (car info) (car (car marks)) (list to-article) info))
9345 (setq marks (cdr marks)))))
9347 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9348 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9349 (setq gnus-newsgroup-dormant
9350 (delq article gnus-newsgroup-dormant))
9351 (setq gnus-newsgroup-reads
9352 (cons (cons article gnus-canceled-mark)
9353 gnus-newsgroup-reads)))
9354 (gnus-message 1 "Couldn't move article %s" (car articles)))
9355 (gnus-summary-remove-process-mark (car articles))
9356 (setq articles (cdr articles)))))
9358 (defun gnus-summary-respool-article (&optional n respool-method)
9359 "Respool the current article.
9360 The article will be squeezed through the mail spooling process again,
9361 which means that it will be put in some mail newsgroup or other
9362 depending on `nnmail-split-methods'.
9363 If N is a positive number, respool the N next articles.
9364 If N is a negative number, respool the N previous articles.
9365 If N is nil and any articles have been marked with the process mark,
9366 respool those articles instead.
9368 Respooling can be done both from mail groups and \"real\" newsgroups.
9369 In the former case, the articles in question will be moved from the
9370 current group into whatever groups they are destined to. In the
9371 latter case, they will be copied into the relevant groups."
9373 (gnus-set-global-variables)
9374 (let ((respool-methods (gnus-methods-using 'respool))
9376 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
9378 (setq respool-method
9380 "What method do you want to use when respooling? "
9381 respool-methods nil t methname)))
9382 (or (string= respool-method "")
9383 (if (assoc (symbol-name
9384 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9386 (gnus-summary-move-article n nil (intern respool-method))
9387 (gnus-summary-copy-article n nil (intern respool-method))))))
9389 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
9390 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9391 "Move the current article to a different newsgroup.
9392 If N is a positive number, move the N next articles.
9393 If N is a negative number, move the N previous articles.
9394 If N is nil and any articles have been marked with the process mark,
9395 move those articles instead.
9396 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9397 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
9398 re-spool using this method.
9399 For this function to work, the newsgroup that you want to move to have
9400 to support the `request-move' and `request-accept'
9401 functions. (Ie. mail newsgroups at present.)"
9403 (gnus-set-global-variables)
9404 (let ((articles (gnus-summary-work-articles n))
9405 (copy-buf (get-buffer-create "*copy work*"))
9406 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
9407 art-group to-method)
9408 (buffer-disable-undo copy-buf)
9409 (if (and (not to-newsgroup) (not select-method))
9412 (format "Where do you want to copy %s? %s"
9413 (if (> (length articles) 1)
9414 (format "these %d articles" (length articles))
9416 (if gnus-current-move-group
9417 (format "(%s default) " gnus-current-move-group)
9419 gnus-active-hashtb nil nil prefix)))
9422 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
9423 (setq to-newsgroup (or gnus-current-move-group "")))
9424 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
9425 (gnus-activate-group to-newsgroup)
9426 (error "No such group: %s" to-newsgroup))
9427 (setq gnus-current-move-group to-newsgroup)))
9428 (setq to-method (if select-method (list select-method "")
9429 (gnus-find-method-for-group to-newsgroup)))
9430 (or (gnus-check-backend-function 'request-accept-article (car to-method))
9431 (error "%s does not support article copying" (car to-method)))
9432 (or (gnus-check-server to-method)
9433 (error "Can't open server %s" (car to-method)))
9435 (gnus-message 6 "Copying to %s: %s..."
9436 (or select-method to-newsgroup) articles)
9439 (set-buffer copy-buf)
9440 (gnus-request-article-this-buffer
9441 (car articles) gnus-newsgroup-name)
9442 (gnus-request-accept-article
9443 (if select-method (quote select-method) to-newsgroup)
9444 (not (cdr articles)))))
9447 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
9449 (gnus-group-prefixed-name
9451 (if select-method (list select-method "")
9452 (gnus-find-method-for-group to-newsgroup)))
9453 gnus-newsrc-hashtb)))
9454 (info (nth 2 entry))
9455 (article (car articles)))
9456 ;; We copy the info over to the new group.
9458 () ; This group does not exist (yet).
9459 (if (not (memq article gnus-newsgroup-unreads))
9460 (setcar (cdr (cdr info))
9461 (gnus-add-to-range (nth 2 info)
9462 (list (cdr art-group)))))
9463 ;; Copy any marks over to the new group.
9464 (let ((marks '((tick . gnus-newsgroup-marked)
9465 (dormant . gnus-newsgroup-dormant)
9466 (expire . gnus-newsgroup-expirable)
9467 (bookmark . gnus-newsgroup-bookmarks)
9468 (reply . gnus-newsgroup-replied)))
9469 (to-article (cdr art-group)))
9471 (if (memq article (symbol-value (cdr (car marks))))
9472 (gnus-add-marked-articles
9473 (car info) (car (car marks)) (list to-article) info))
9474 (setq marks (cdr marks))))))
9475 (gnus-message 1 "Couldn't copy article %s" (car articles)))
9476 (gnus-summary-remove-process-mark (car articles))
9477 (setq articles (cdr articles)))
9478 (kill-buffer copy-buf)))
9480 (defun gnus-summary-import-article (file)
9481 "Import a random file into a mail newsgroup."
9482 (interactive "fImport file: ")
9483 (let ((group gnus-newsgroup-name)
9485 (or (gnus-check-backend-function 'request-accept-article group)
9486 (error "%s does not support article importing" group))
9487 (or (file-readable-p file)
9488 (not (file-regular-p file))
9489 (error "Can't read %s" file))
9491 (set-buffer (get-buffer-create " *import file*"))
9492 (buffer-disable-undo (current-buffer))
9494 (insert-file-contents file)
9495 (goto-char (point-min))
9496 (if (nnheader-article-p)
9498 (setq atts (file-attributes file)
9499 lines (count-lines (point-min) (point-max)))
9500 (insert "From: " (read-string "From: ") "\n"
9501 "Subject: " (read-string "Subject: ") "\n"
9502 "Date: " (current-time-string (nth 5 atts)) "\n"
9503 "Message-ID: " (gnus-inews-message-id) "\n"
9504 "Lines: " (int-to-string lines) "\n"
9505 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9506 (gnus-request-accept-article group t)
9507 (kill-buffer (current-buffer)))))
9509 (defun gnus-summary-expire-articles ()
9510 "Expire all articles that are marked as expirable in the current group."
9512 (if (not (gnus-check-backend-function
9513 'request-expire-articles gnus-newsgroup-name))
9515 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9516 (expirable (if total
9517 (gnus-list-of-read-articles gnus-newsgroup-name)
9518 (setq gnus-newsgroup-expirable
9519 (sort gnus-newsgroup-expirable '<))))
9523 (gnus-message 6 "Expiring articles...")
9524 ;; The list of articles that weren't expired is returned.
9525 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
9526 (or total (setq gnus-newsgroup-expirable es))
9527 ;; We go through the old list of expirable, and mark all
9528 ;; really expired articles as non-existant.
9529 (or (eq es expirable) ;If nothing was expired, we don't mark.
9530 (let ((gnus-use-cache nil))
9532 (or (memq (car expirable) es)
9533 (gnus-summary-mark-article
9534 (car expirable) gnus-canceled-mark))
9535 (setq expirable (cdr expirable)))))
9536 (gnus-message 6 "Expiring articles...done")))))
9538 (defun gnus-summary-expire-articles-now ()
9539 "Expunge all expirable articles in the current group.
9540 This means that *all* articles that are marked as expirable will be
9541 deleted forever, right now."
9543 (or gnus-expert-user
9545 "Are you really, really, really sure you want to expunge? ")
9547 (let ((nnmail-expiry-wait -1)
9548 (nnmail-expiry-wait-function nil))
9549 (gnus-summary-expire-articles)))
9551 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9552 (defun gnus-summary-delete-article (&optional n)
9553 "Delete the N next (mail) articles.
9554 This command actually deletes articles. This is not a marking
9555 command. The article will disappear forever from you life, never to
9557 If N is negative, delete backwards.
9558 If N is nil and articles have been marked with the process mark,
9559 delete these instead."
9561 (or (gnus-check-backend-function 'request-expire-articles
9562 gnus-newsgroup-name)
9563 (error "The current newsgroup does not support article deletion."))
9564 ;; Compute the list of articles to delete.
9565 (let ((articles (gnus-summary-work-articles n))
9567 (if (and gnus-novice-user
9569 (format "Do you really want to delete %s forever? "
9570 (if (> (length articles) 1) "these articles"
9573 ;; Delete the articles.
9574 (setq not-deleted (gnus-request-expire-articles
9575 articles gnus-newsgroup-name 'force))
9577 (gnus-summary-remove-process-mark (car articles))
9578 ;; The backend might not have been able to delete the article
9580 (or (memq (car articles) not-deleted)
9581 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9582 (setq articles (cdr articles))))
9583 (gnus-summary-position-point)
9586 (defun gnus-summary-edit-article (&optional force)
9587 "Enter into a buffer and edit the current article.
9588 This will have permanent effect only in mail groups.
9589 If FORCE is non-nil, allow editing of articles even in read-only
9593 (not (gnus-group-read-only-p))
9594 (error "The current newsgroup does not support article editing."))
9595 (gnus-summary-select-article t)
9596 (gnus-configure-windows 'article)
9597 (select-window (get-buffer-window gnus-article-buffer))
9598 (gnus-message 6 "C-c C-c to end edits")
9599 (setq buffer-read-only nil)
9601 (use-local-map (copy-keymap (current-local-map)))
9602 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
9603 (buffer-enable-undo)
9605 (goto-char (point-min))
9606 (search-forward "\n\n" nil t))
9608 (defun gnus-summary-edit-article-done ()
9609 "Make edits to the current article permanent."
9611 (if (gnus-group-read-only-p)
9613 (gnus-summary-edit-article-postpone)
9614 (message "The current newsgroup does not support article editing.")
9616 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
9619 (if (not (gnus-request-replace-article
9620 (cdr gnus-article-current) (car gnus-article-current)
9622 (error "Couldn't replace article.")
9624 (use-local-map gnus-article-mode-map)
9625 (setq buffer-read-only t)
9626 (buffer-disable-undo (current-buffer))
9627 (gnus-configure-windows 'summary))
9628 (and (gnus-visual-p 'summary-highlight 'highlight)
9629 (run-hooks 'gnus-visual-mark-article-hook)))))
9631 (defun gnus-summary-edit-article-postpone ()
9632 "Postpone changes to the current article."
9635 (use-local-map gnus-article-mode-map)
9636 (setq buffer-read-only t)
9637 (buffer-disable-undo (current-buffer))
9638 (gnus-configure-windows 'summary)
9639 (and (gnus-visual-p 'summary-highlight 'highlight)
9640 (run-hooks 'gnus-visual-mark-article-hook)))
9642 (defun gnus-summary-respool-query ()
9643 "Query where the respool algorithm would put this article."
9645 (gnus-summary-select-article)
9647 (set-buffer gnus-article-buffer)
9649 (goto-char (point-min))
9650 (search-forward "\n\n")
9651 (narrow-to-region (point-min) (point))
9653 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
9655 ;; Summary score commands.
9657 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
9659 (defun gnus-summary-raise-score (n)
9660 "Raise the score of the current article by N."
9662 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
9664 (defun gnus-summary-set-score (n)
9665 "Set the score of the current article to N."
9667 ;; Skip dummy header line.
9669 (gnus-summary-show-thread)
9670 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
9671 (gnus-summary-find-next))
9672 (let ((buffer-read-only nil))
9674 (gnus-summary-update-mark
9675 (if (= n (or gnus-summary-default-score 0)) ?
9676 (if (< n (or gnus-summary-default-score 0))
9677 gnus-score-below-mark gnus-score-over-mark)) 'score))
9678 (let* ((article (gnus-summary-article-number))
9679 (score (assq article gnus-newsgroup-scored)))
9680 (if score (setcdr score n)
9681 (setq gnus-newsgroup-scored
9682 (cons (cons article n) gnus-newsgroup-scored))))
9683 (gnus-summary-update-line)))
9685 (defun gnus-summary-current-score ()
9686 "Return the score of the current article."
9688 (message "%s" (gnus-summary-article-score)))
9690 ;; Summary marking commands.
9692 (defun gnus-summary-raise-same-subject-and-select (score)
9693 "Raise articles which has the same subject with SCORE and select the next."
9695 (let ((subject (gnus-summary-article-subject)))
9696 (gnus-summary-raise-score score)
9697 (while (gnus-summary-find-subject subject)
9698 (gnus-summary-raise-score score))
9699 (gnus-summary-next-article t)))
9701 (defun gnus-summary-raise-same-subject (score)
9702 "Raise articles which has the same subject with SCORE."
9704 (let ((subject (gnus-summary-article-subject)))
9705 (gnus-summary-raise-score score)
9706 (while (gnus-summary-find-subject subject)
9707 (gnus-summary-raise-score score))
9708 (gnus-summary-next-subject 1 t)))
9710 (defun gnus-score-default (level)
9711 (if level (prefix-numeric-value level)
9712 gnus-score-interactive-default-score))
9714 (defun gnus-summary-raise-thread (&optional score)
9715 "Raise the score of the articles in the current thread with SCORE."
9717 (setq score (gnus-score-default score))
9720 (let ((articles (gnus-summary-articles-in-thread)))
9722 (gnus-summary-goto-subject (car articles))
9723 (gnus-summary-raise-score score)
9724 (setq articles (cdr articles))))
9726 (let ((gnus-summary-check-current t))
9727 (or (zerop (gnus-summary-next-subject 1 t))
9729 (gnus-summary-recenter)
9730 (gnus-summary-position-point)
9731 (gnus-set-mode-line 'summary))
9733 (defun gnus-summary-lower-same-subject-and-select (score)
9734 "Raise articles which has the same subject with SCORE and select the next."
9736 (gnus-summary-raise-same-subject-and-select (- score)))
9738 (defun gnus-summary-lower-same-subject (score)
9739 "Raise articles which has the same subject with SCORE."
9741 (gnus-summary-raise-same-subject (- score)))
9743 (defun gnus-summary-lower-thread (&optional score)
9744 "Lower score of articles in the current thread with SCORE."
9746 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
9748 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9749 "Mark articles which has the same subject as read, and then select the next.
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 ;; Select next unread article. If auto-select-same mode, should
9759 ;; select the first unread article.
9760 (gnus-summary-next-article t (and gnus-auto-select-same
9761 (gnus-summary-article-subject)))
9762 (gnus-message 7 "%d article%s marked as %s"
9763 count (if (= count 1) " is" "s are")
9764 (if unmark "unread" "read"))))
9766 (defun gnus-summary-kill-same-subject (&optional unmark)
9767 "Mark articles which has the same subject as read.
9768 If UNMARK is positive, remove any kind of mark.
9769 If UNMARK is negative, tick articles."
9772 (setq unmark (prefix-numeric-value unmark)))
9774 (gnus-summary-mark-same-subject
9775 (gnus-summary-article-subject) unmark)))
9776 ;; If marked as read, go to next unread subject.
9778 ;; Go to next unread subject.
9779 (gnus-summary-next-subject 1 t))
9780 (gnus-message 7 "%d articles are marked as %s"
9781 count (if unmark "unread" "read"))))
9783 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9784 "Mark articles with same SUBJECT as read, and return marked number.
9785 If optional argument UNMARK is positive, remove any kinds of marks.
9786 If optional argument UNMARK is negative, mark articles as unread instead."
9790 ((null unmark) ; Mark as read.
9793 (gnus-summary-mark-article-as-read gnus-killed-mark)
9794 (gnus-summary-show-thread) t)
9795 (gnus-summary-find-subject subject))
9796 (setq count (1+ count))))
9797 ((> unmark 0) ; Tick.
9800 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9801 (gnus-summary-show-thread) t)
9802 (gnus-summary-find-subject subject))
9803 (setq count (1+ count))))
9804 (t ; Mark as unread.
9807 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9808 (gnus-summary-show-thread) t)
9809 (gnus-summary-find-subject subject))
9810 (setq count (1+ count)))))
9811 (gnus-set-mode-line 'summary)
9812 ;; Return the number of marked articles.
9815 (defun gnus-summary-mark-as-processable (n &optional unmark)
9816 "Set the process mark on the next N articles.
9817 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9818 the process mark instead. The difference between N and the actual
9819 number of articles marked is returned."
9821 (let ((backward (< n 0))
9826 (gnus-summary-remove-process-mark
9827 (gnus-summary-article-number))
9828 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9829 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9831 (if (/= 0 n) (gnus-message 7 "No more articles"))
9832 (gnus-summary-recenter)
9833 (gnus-summary-position-point)
9836 (defun gnus-summary-unmark-as-processable (n)
9837 "Remove the process mark from the next N articles.
9838 If N is negative, mark backward instead. The difference between N and
9839 the actual number of articles marked is returned."
9841 (gnus-summary-mark-as-processable n t))
9843 (defun gnus-summary-unmark-all-processable ()
9844 "Remove the process mark from all articles."
9847 (while gnus-newsgroup-processable
9848 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9849 (gnus-summary-position-point))
9851 (defun gnus-summary-mark-as-expirable (n)
9852 "Mark N articles forward as expirable.
9853 If N is negative, mark backward instead. The difference between N and
9854 the actual number of articles marked is returned."
9856 (gnus-summary-mark-forward n gnus-expirable-mark))
9858 (defun gnus-summary-mark-article-as-replied (article)
9859 "Mark ARTICLE replied and update the summary line."
9860 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
9861 (let ((buffer-read-only nil))
9862 (if (gnus-summary-goto-subject article)
9864 (gnus-summary-update-mark gnus-replied-mark 'replied)
9867 (defun gnus-summary-set-bookmark (article)
9868 "Set a bookmark in current article."
9869 (interactive (list (gnus-summary-article-number)))
9870 (if (or (not (get-buffer gnus-article-buffer))
9871 (not gnus-current-article)
9872 (not gnus-article-current)
9873 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9874 (error "No current article selected"))
9875 ;; Remove old bookmark, if one exists.
9876 (let ((old (assq article gnus-newsgroup-bookmarks)))
9877 (if old (setq gnus-newsgroup-bookmarks
9878 (delq old gnus-newsgroup-bookmarks))))
9879 ;; Set the new bookmark, which is on the form
9880 ;; (article-number . line-number-in-body).
9881 (setq gnus-newsgroup-bookmarks
9885 (set-buffer gnus-article-buffer)
9889 (goto-char (point-min))
9890 (search-forward "\n\n" nil t)
9893 gnus-newsgroup-bookmarks))
9894 (gnus-message 6 "A bookmark has been added to the current article."))
9896 (defun gnus-summary-remove-bookmark (article)
9897 "Remove the bookmark from the current article."
9898 (interactive (list (gnus-summary-article-number)))
9899 ;; Remove old bookmark, if one exists.
9900 (let ((old (assq article gnus-newsgroup-bookmarks)))
9903 (setq gnus-newsgroup-bookmarks
9904 (delq old gnus-newsgroup-bookmarks))
9905 (gnus-message 6 "Removed bookmark."))
9906 (gnus-message 6 "No bookmark in current article."))))
9908 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9909 (defun gnus-summary-mark-as-dormant (n)
9910 "Mark N articles forward as dormant.
9911 If N is negative, mark backward instead. The difference between N and
9912 the actual number of articles marked is returned."
9914 (gnus-summary-mark-forward n gnus-dormant-mark))
9916 (defun gnus-summary-set-process-mark (article)
9917 "Set the process mark on ARTICLE and update the summary line."
9918 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
9919 (let ((buffer-read-only nil))
9920 (if (gnus-summary-goto-subject article)
9922 (gnus-summary-show-thread)
9923 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9924 (gnus-summary-find-next))
9925 (gnus-summary-update-mark gnus-process-mark 'replied)
9928 (defun gnus-summary-remove-process-mark (article)
9929 "Remove the process mark from ARTICLE and update the summary line."
9930 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9931 (let ((buffer-read-only nil))
9932 (if (gnus-summary-goto-subject article)
9934 (gnus-summary-show-thread)
9935 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9936 (gnus-summary-find-next))
9937 (gnus-summary-update-mark ? 'replied)
9938 (if (memq article gnus-newsgroup-replied)
9939 (gnus-summary-update-mark gnus-replied-mark 'replied))
9942 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9943 "Mark N articles as read forwards.
9944 If N is negative, mark backwards instead.
9945 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9947 The difference between N and the actual number of articles marked is
9950 (gnus-set-global-variables)
9951 (let ((backward (< n 0))
9952 (gnus-summary-goto-unread
9953 (and gnus-summary-goto-unread
9954 (not (memq mark (list gnus-unread-mark
9955 gnus-ticked-mark gnus-dormant-mark)))))
9957 (mark (or mark gnus-del-mark)))
9959 (gnus-summary-mark-article nil mark no-expire)
9960 (zerop (gnus-summary-next-subject
9961 (if backward -1 1) gnus-summary-goto-unread t)))
9963 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9964 (gnus-summary-recenter)
9965 (gnus-summary-position-point)
9966 (gnus-set-mode-line 'summary)
9969 (defun gnus-summary-mark-article-as-read (mark)
9970 "Mark the current article quickly as read with MARK."
9971 (let ((article (gnus-summary-article-number)))
9972 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9973 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9974 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9975 (setq gnus-newsgroup-reads
9976 (cons (cons article mark) gnus-newsgroup-reads))
9977 ;; Possibly remove from cache, if that is used.
9978 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9979 (and gnus-newsgroup-auto-expire
9980 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9981 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9982 (= mark gnus-read-mark))
9984 (setq mark gnus-expirable-mark)
9985 (setq gnus-newsgroup-expirable
9986 (cons article gnus-newsgroup-expirable))))
9987 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9988 (gnus-summary-find-next))
9990 (gnus-summary-update-mark mark 'unread)
9993 (defun gnus-summary-mark-article-as-unread (mark)
9994 "Mark the current article quickly as unread with MARK."
9995 (let ((article (gnus-summary-article-number)))
9996 (or (memq article gnus-newsgroup-unreads)
9997 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9998 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9999 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10000 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10001 (setq gnus-newsgroup-reads
10002 (delq (assq article gnus-newsgroup-reads)
10003 gnus-newsgroup-reads))
10004 (if (= mark gnus-ticked-mark)
10005 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
10006 (if (= mark gnus-dormant-mark)
10007 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
10009 ;; See whether the article is to be put in the cache.
10010 (and gnus-use-cache
10011 (vectorp (gnus-summary-article-header article))
10013 (gnus-cache-possibly-enter-article
10014 gnus-newsgroup-name article
10015 (gnus-summary-article-header article)
10016 (= mark gnus-ticked-mark)
10017 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10019 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
10020 (gnus-summary-find-next))
10022 (gnus-summary-update-mark mark 'unread)
10025 (defun gnus-summary-mark-article (&optional article mark no-expire)
10026 "Mark ARTICLE with MARK. MARK can be any character.
10027 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
10028 (dormant) and `?E' (expirable).
10029 If MARK is nil, then the default character `?D' is used.
10030 If ARTICLE is nil, then the article on the current line will be
10032 (and (stringp mark)
10033 (setq mark (aref mark 0)))
10034 ;; If no mark is given, then we check auto-expiring.
10035 (and (not no-expire)
10036 gnus-newsgroup-auto-expire
10038 (and (numberp mark)
10039 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
10040 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
10041 (= mark gnus-read-mark))))
10042 (setq mark gnus-expirable-mark))
10043 (let* ((mark (or mark gnus-del-mark))
10044 (article (or article (gnus-summary-article-number))))
10045 (or article (error "No article on current line"))
10046 (if (or (= mark gnus-unread-mark)
10047 (= mark gnus-ticked-mark)
10048 (= mark gnus-dormant-mark))
10049 (gnus-mark-article-as-unread article mark)
10050 (gnus-mark-article-as-read article mark))
10052 ;; See whether the article is to be put in the cache.
10053 (and gnus-use-cache
10054 (not (= mark gnus-canceled-mark))
10055 (vectorp (gnus-summary-article-header article))
10057 (gnus-cache-possibly-enter-article
10058 gnus-newsgroup-name article
10059 (gnus-summary-article-header article)
10060 (= mark gnus-ticked-mark)
10061 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10063 (if (gnus-summary-goto-subject article)
10064 (let ((buffer-read-only nil))
10065 (gnus-summary-show-thread)
10066 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
10067 (gnus-summary-find-next))
10069 (gnus-summary-update-mark mark 'unread)
10072 (defun gnus-summary-update-mark (mark type)
10073 (beginning-of-line)
10074 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10075 (buffer-read-only nil)
10079 ;; Go to the right position on the line.
10080 (forward-char forward)
10081 ;; Replace the old mark with the new mark.
10082 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
10083 ;; Optionally update the marks by some user rule.
10084 (and (eq type 'unread)
10086 (gnus-data-set-mark (gnus-data-find (gnus-summary-article-number))
10088 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10090 (defun gnus-mark-article-as-read (article &optional mark)
10091 "Enter ARTICLE in the pertinent lists and remove it from others."
10092 ;; Make the article expirable.
10093 (let ((mark (or mark gnus-del-mark)))
10094 (if (= mark gnus-expirable-mark)
10095 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
10096 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
10097 ;; Remove from unread and marked lists.
10098 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10099 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10100 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10101 (setq gnus-newsgroup-reads
10102 (cons (cons article mark) gnus-newsgroup-reads))
10103 ;; Possibly remove from cache, if that is used.
10104 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
10106 (defun gnus-mark-article-as-unread (article &optional mark)
10107 "Enter ARTICLE in the pertinent lists and remove it from others."
10108 (let ((mark (or mark gnus-ticked-mark)))
10109 ;; Add to unread list.
10110 (or (memq article gnus-newsgroup-unreads)
10111 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
10112 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10113 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10114 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10115 (setq gnus-newsgroup-reads
10116 (delq (assq article gnus-newsgroup-reads)
10117 gnus-newsgroup-reads))
10118 (if (= mark gnus-ticked-mark)
10119 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
10120 (if (= mark gnus-dormant-mark)
10121 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
10123 (defalias 'gnus-summary-mark-as-unread-forward
10124 'gnus-summary-tick-article-forward)
10125 (make-obsolete 'gnus-summary-mark-as-unread-forward
10126 'gnus-summary-tick-article-forward)
10127 (defun gnus-summary-tick-article-forward (n)
10128 "Tick N articles forwards.
10129 If N is negative, tick backwards instead.
10130 The difference between N and the number of articles ticked is returned."
10132 (gnus-summary-mark-forward n gnus-ticked-mark))
10134 (defalias 'gnus-summary-mark-as-unread-backward
10135 'gnus-summary-tick-article-backward)
10136 (make-obsolete 'gnus-summary-mark-as-unread-backward
10137 'gnus-summary-tick-article-backward)
10138 (defun gnus-summary-tick-article-backward (n)
10139 "Tick N articles backwards.
10140 The difference between N and the number of articles ticked is returned."
10142 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10144 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10145 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10146 (defun gnus-summary-tick-article (&optional article clear-mark)
10147 "Mark current article as unread.
10148 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10149 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10150 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10151 gnus-ticked-mark)))
10153 (defun gnus-summary-mark-as-read-forward (n)
10154 "Mark N articles as read forwards.
10155 If N is negative, mark backwards instead.
10156 The difference between N and the actual number of articles marked is
10159 (gnus-summary-mark-forward n gnus-del-mark t))
10161 (defun gnus-summary-mark-as-read-backward (n)
10162 "Mark the N articles as read backwards.
10163 The difference between N and the actual number of articles marked is
10166 (gnus-summary-mark-forward (- n) gnus-del-mark t))
10168 (defun gnus-summary-mark-as-read (&optional article mark)
10169 "Mark current article as read.
10170 ARTICLE specifies the article to be marked as read.
10171 MARK specifies a string to be inserted at the beginning of the line."
10172 (gnus-summary-mark-article article mark))
10174 (defun gnus-summary-clear-mark-forward (n)
10175 "Clear marks from N articles forward.
10176 If N is negative, clear backward instead.
10177 The difference between N and the number of marks cleared is returned."
10179 (gnus-summary-mark-forward n gnus-unread-mark))
10181 (defun gnus-summary-clear-mark-backward (n)
10182 "Clear marks from N articles backward.
10183 The difference between N and the number of marks cleared is returned."
10185 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10187 (defun gnus-summary-mark-unread-as-read ()
10188 "Intended to be used by `gnus-summary-mark-article-hook'."
10189 (or (memq gnus-current-article gnus-newsgroup-marked)
10190 (memq gnus-current-article gnus-newsgroup-dormant)
10191 (memq gnus-current-article gnus-newsgroup-expirable)
10192 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10194 (defun gnus-summary-mark-region-as-read (point mark all)
10195 "Mark all unread articles between point and mark as read.
10196 If given a prefix, mark all articles between point and mark as read,
10197 even ticked and dormant ones."
10198 (interactive "r\nP")
10201 (beginning-of-line)
10208 (not (memq (gnus-summary-article-number)
10209 gnus-newsgroup-marked))
10210 (not (memq (gnus-summary-article-number)
10211 gnus-newsgroup-dormant))))
10212 (gnus-summary-mark-article
10213 (gnus-summary-article-number) gnus-del-mark))
10215 (gnus-summary-find-next)))))
10217 (defun gnus-summary-mark-below (score mark)
10218 "Mark articles with score less than SCORE with MARK."
10219 (interactive "P\ncMark: ")
10220 (gnus-set-global-variables)
10221 (setq score (if score
10222 (prefix-numeric-value score)
10223 (or gnus-summary-default-score 0)))
10225 (set-buffer gnus-summary-buffer)
10226 (goto-char (point-min))
10227 (while (not (eobp))
10228 (and (< (gnus-summary-article-score) score)
10229 (gnus-summary-mark-article nil mark))
10230 (gnus-summary-find-next))))
10232 (defun gnus-summary-kill-below (&optional score)
10233 "Mark articles with score below SCORE as read."
10235 (gnus-set-global-variables)
10236 (gnus-summary-mark-below score gnus-killed-mark))
10238 (defun gnus-summary-clear-above (&optional score)
10239 "Clear all marks from articles with score above SCORE."
10241 (gnus-set-global-variables)
10242 (gnus-summary-mark-above score gnus-unread-mark))
10244 (defun gnus-summary-tick-above (&optional score)
10245 "Tick all articles with score above SCORE."
10247 (gnus-set-global-variables)
10248 (gnus-summary-mark-above score gnus-ticked-mark))
10250 (defun gnus-summary-mark-above (score mark)
10251 "Mark articles with score over SCORE with MARK."
10252 (interactive "P\ncMark: ")
10253 (gnus-set-global-variables)
10254 (setq score (if score
10255 (prefix-numeric-value score)
10256 (or gnus-summary-default-score 0)))
10258 (set-buffer gnus-summary-buffer)
10259 (goto-char (point-min))
10261 (if (> (gnus-summary-article-score) score)
10262 (gnus-summary-mark-article nil mark))
10264 (gnus-summary-find-next)))))
10266 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10267 (defun gnus-summary-show-all-expunged ()
10268 "Display all the hidden articles that were expunged for low scores."
10270 (gnus-set-global-variables)
10271 (let ((buffer-read-only nil))
10272 (let ((scored gnus-newsgroup-scored)
10275 (or (gnus-summary-goto-subject (car (car scored)))
10276 (and (setq h (gnus-summary-article-header (car (car scored))))
10277 (< (cdr (car scored)) gnus-summary-expunge-below)
10278 (setq headers (cons h headers))))
10279 (setq scored (cdr scored)))
10280 (or headers (error "No expunged articles hidden."))
10281 (goto-char (point-min))
10283 (gnus-summary-update-lines
10286 (gnus-summary-prepare-unthreaded (nreverse headers))
10288 (goto-char (point-min))
10289 (gnus-summary-position-point)))
10291 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
10292 "Mark all articles not marked as unread in this newsgroup as read.
10293 If prefix argument ALL is non-nil, all articles are marked as read.
10294 If QUIETLY is non-nil, no questions will be asked.
10295 If TO-HERE is non-nil, it should be a point in the buffer. All
10296 articles before this point will be marked as read.
10297 The number of articles marked as read is returned."
10299 (gnus-set-global-variables)
10302 (not gnus-interactive-catchup) ;Without confirmation?
10306 "Mark absolutely all articles as read? "
10307 "Mark all unread articles as read? ")))
10309 (not gnus-newsgroup-adaptive)
10310 (not gnus-newsgroup-auto-expire))
10312 (and all (setq gnus-newsgroup-marked nil
10313 gnus-newsgroup-dormant nil))
10314 (setq gnus-newsgroup-unreads
10315 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
10316 ;; We actually mark all articles as canceled, which we
10317 ;; have to do when using auto-expiry or adaptive scoring.
10318 (gnus-summary-show-all-threads)
10319 (if (gnus-summary-first-subject (not all))
10321 (if to-here (< (point) to-here) t)
10322 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10323 (gnus-summary-find-next (not all)))))
10325 (setq gnus-newsgroup-unreads
10326 (append gnus-newsgroup-marked
10327 gnus-newsgroup-dormant)))))
10328 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10329 (if (and (not to-here) (eq 'nnvirtual (car method)))
10330 (nnvirtual-catchup-group
10331 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
10332 (gnus-summary-position-point)))
10334 (defun gnus-summary-catchup-to-here (&optional all)
10335 "Mark all unticked articles before the current one as read.
10336 If ALL is non-nil, also mark ticked and dormant articles as read."
10338 (gnus-set-global-variables)
10340 (and (gnus-summary-find-prev)
10342 (gnus-summary-catchup all t (point))
10343 (gnus-set-mode-line 'summary))))
10344 (gnus-summary-position-point))
10346 (defun gnus-summary-catchup-all (&optional quietly)
10347 "Mark all articles in this newsgroup as read."
10349 (gnus-set-global-variables)
10350 (gnus-summary-catchup t quietly))
10352 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10353 "Mark all articles not marked as unread in this newsgroup as read, then exit.
10354 If prefix argument ALL is non-nil, all articles are marked as read."
10356 (gnus-set-global-variables)
10357 (gnus-summary-catchup all quietly nil 'fast)
10358 ;; Select next newsgroup or exit.
10359 (if (eq gnus-auto-select-next 'quietly)
10360 (gnus-summary-next-group nil)
10361 (gnus-summary-exit)))
10363 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10364 "Mark all articles in this newsgroup as read, and then exit."
10366 (gnus-set-global-variables)
10367 (gnus-summary-catchup-and-exit t quietly))
10369 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
10370 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10371 "Mark all articles in this group as read and select the next group.
10372 If given a prefix, mark all articles, unread as well as ticked, as
10375 (gnus-set-global-variables)
10376 (gnus-summary-catchup all)
10377 (gnus-summary-next-group))
10379 ;; Thread-based commands.
10381 (defun gnus-summary-articles-in-thread (&optional article)
10382 "Return a list of all articles in the current thread.
10383 If ARTICLE is non-nil, return all articles in the thread that starts
10384 with that article."
10385 (let* ((article (or article (gnus-summary-article-number)))
10386 (data (gnus-data-find-list article))
10387 (top-level (gnus-data-level (car data)))
10389 (cond ((null gnus-thread-operation-ignore-subject)
10390 (gnus-simplify-subject-re
10391 (mail-header-subject (gnus-data-header (car data)))))
10392 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10393 (gnus-simplify-subject-fuzzy
10394 (mail-header-subject (gnus-data-header (car data)))))
10398 () ; This article doesn't exist.
10400 (and (or (not top-subject)
10401 (string= top-subject
10402 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10403 (gnus-simplify-subject-fuzzy
10404 (mail-header-subject
10405 (gnus-data-header (car data))))
10406 (gnus-simplify-subject-re
10407 (mail-header-subject
10408 (gnus-data-header (car data)))))))
10409 (setq articles (cons (gnus-data-number (car data)) articles)))
10410 (if (and (setq data (cdr data))
10411 (> (gnus-data-level (car data)) top-level))
10414 ;; Return the list of articles.
10415 (nreverse articles))))
10417 (defun gnus-summary-toggle-threads (&optional arg)
10418 "Toggle showing conversation threads.
10419 If ARG is positive number, turn showing conversation threads on."
10421 (gnus-set-global-variables)
10422 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10423 (setq gnus-show-threads
10424 (if (null arg) (not gnus-show-threads)
10425 (> (prefix-numeric-value arg) 0)))
10426 (gnus-summary-prepare)
10427 (gnus-summary-goto-subject current)
10428 (gnus-summary-position-point)))
10430 (defun gnus-summary-show-all-threads ()
10431 "Show all threads."
10433 (gnus-set-global-variables)
10435 (let ((buffer-read-only nil))
10436 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10437 (gnus-summary-position-point))
10439 (defun gnus-summary-show-thread ()
10440 "Show thread subtrees.
10441 Returns nil if no thread was there to be shown."
10443 (gnus-set-global-variables)
10444 (let ((buffer-read-only nil)
10446 ;; first goto end then to beg, to have point at beg after let
10447 (end (progn (end-of-line) (point)))
10448 (beg (progn (beginning-of-line) (point))))
10450 ;; Any hidden lines here?
10451 (search-forward "\r" end t)
10452 (subst-char-in-region beg end ?\^M ?\n t)
10454 (gnus-summary-position-point))))
10456 (defun gnus-summary-hide-all-threads ()
10457 "Hide all thread subtrees."
10459 (gnus-set-global-variables)
10461 (goto-char (point-min))
10462 (gnus-summary-hide-thread)
10463 (while (zerop (gnus-summary-next-thread 1))
10464 (gnus-summary-hide-thread)))
10465 (gnus-summary-position-point))
10467 (defun gnus-summary-hide-thread ()
10468 "Hide thread subtrees.
10469 Returns nil if no threads were there to be hidden."
10471 (gnus-set-global-variables)
10472 (let ((buffer-read-only nil)
10474 (article (gnus-summary-article-number))
10476 ;; Go forward until either the buffer ends or the subthread
10480 (if (not (zerop (gnus-summary-next-thread 1)))
10482 (gnus-summary-find-prev)
10485 (search-backward "\n" start t))
10486 (subst-char-in-region start (point) ?\n ?\^M)
10487 (gnus-summary-goto-subject article)
10488 (gnus-summary-position-point))))))
10490 (defun gnus-summary-go-to-next-thread (&optional previous)
10491 "Go to the same level (or less) next thread.
10492 If PREVIOUS is non-nil, go to previous thread instead.
10493 Return the article number moved to, or nil if moving was impossible."
10494 (let* ((level (gnus-summary-thread-level))
10495 (article (gnus-summary-article-number))
10496 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
10499 (if (<= (gnus-data-level (car data)) level)
10500 (setq oart (gnus-data-number (car data))
10502 (setq data (cdr data))))
10504 (gnus-summary-goto-subject oart))))
10506 (defun gnus-summary-next-thread (n)
10507 "Go to the same level next N'th thread.
10508 If N is negative, search backward instead.
10509 Returns the difference between N and the number of skips actually
10512 (gnus-set-global-variables)
10513 (let ((backward (< n 0))
10515 (while (and (> n 0)
10516 (gnus-summary-go-to-next-thread backward))
10518 (gnus-summary-position-point)
10519 (if (/= 0 n) (gnus-message 7 "No more threads"))
10522 (defun gnus-summary-prev-thread (n)
10523 "Go to the same level previous N'th thread.
10524 Returns the difference between N and the number of skips actually
10527 (gnus-set-global-variables)
10528 (gnus-summary-next-thread (- n)))
10530 (defun gnus-summary-go-down-thread ()
10531 "Go down one level in the current thread."
10532 (let ((children (gnus-summary-article-children)))
10534 (gnus-summary-goto-subject (car children)))))
10536 (defun gnus-summary-go-up-thread ()
10537 "Go up one level in the current thread."
10538 (let ((parent (gnus-summary-article-parent)))
10540 (gnus-summary-goto-subject parent))))
10542 (defun gnus-summary-down-thread (n)
10543 "Go down thread N steps.
10544 If N is negative, go up instead.
10545 Returns the difference between N and how many steps down that were
10548 (gnus-set-global-variables)
10551 (while (and (> n 0)
10552 (if up (gnus-summary-go-up-thread)
10553 (gnus-summary-go-down-thread)))
10555 (gnus-summary-position-point)
10556 (if (/= 0 n) (gnus-message 7 "Can't go further"))
10559 (defun gnus-summary-up-thread (n)
10560 "Go up thread N steps.
10561 If N is negative, go up instead.
10562 Returns the difference between N and how many steps down that were
10565 (gnus-set-global-variables)
10566 (gnus-summary-down-thread (- n)))
10568 (defun gnus-summary-kill-thread (&optional unmark)
10569 "Mark articles under current thread as read.
10570 If the prefix argument is positive, remove any kinds of marks.
10571 If the prefix argument is negative, tick articles instead."
10573 (gnus-set-global-variables)
10575 (setq unmark (prefix-numeric-value unmark)))
10576 (let ((articles (gnus-summary-articles-in-thread)))
10578 ;; Expand the thread.
10579 (gnus-summary-show-thread)
10580 ;; Mark all the articles.
10582 (gnus-summary-goto-subject (car articles))
10583 (cond ((null unmark)
10584 (gnus-summary-mark-article-as-read gnus-killed-mark))
10586 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10588 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10589 (setq articles (cdr articles))))
10590 ;; Hide killed subtrees.
10592 gnus-thread-hide-killed
10593 (gnus-summary-hide-thread))
10594 ;; If marked as read, go to next unread subject.
10596 ;; Go to next unread subject.
10597 (gnus-summary-next-subject 1 t)))
10598 (gnus-set-mode-line 'summary))
10600 ;; Summary sorting commands
10602 (defun gnus-summary-sort-by-number (&optional reverse)
10603 "Sort summary buffer by article number.
10604 Argument REVERSE means reverse order."
10606 (gnus-set-global-variables)
10608 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
10609 ;; a function, so we wrap it.
10610 (cons (lambda () (gnus-summary-article-number))
10611 'gnus-thread-sort-by-number) reverse))
10613 (defun gnus-summary-sort-by-author (&optional reverse)
10614 "Sort summary buffer by author name alphabetically.
10615 If case-fold-search is non-nil, case of letters is ignored.
10616 Argument REVERSE means reverse order."
10618 (gnus-set-global-variables)
10622 (let* ((header (gnus-summary-article-header))
10624 gnus-extract-address-components
10625 (mail-header-from header))))
10626 (concat (or (car extract) (cdr extract))
10627 "\r" (mail-header-subject header))))
10628 'gnus-thread-sort-by-author)
10631 (defun gnus-summary-sort-by-subject (&optional reverse)
10632 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10633 If case-fold-search is non-nil, case of letters is ignored.
10634 Argument REVERSE means reverse order."
10636 (gnus-set-global-variables)
10640 (let* ((header (gnus-summary-article-header))
10642 gnus-extract-address-components
10643 (mail-header-from header))))
10645 (downcase (gnus-simplify-subject (gnus-summary-article-subject) t))
10646 "\r" (or (car extract) (cdr extract)))))
10647 'gnus-thread-sort-by-subject)
10650 (defun gnus-summary-sort-by-date (&optional reverse)
10651 "Sort summary buffer by date.
10652 Argument REVERSE means reverse order."
10654 (gnus-set-global-variables)
10658 (gnus-sortable-date
10660 (gnus-summary-article-header))))
10661 'gnus-thread-sort-by-date)
10664 (defun gnus-summary-sort-by-score (&optional reverse)
10665 "Sort summary buffer by score.
10666 Argument REVERSE means reverse order."
10668 (gnus-set-global-variables)
10670 (cons (lambda () (gnus-summary-article-score))
10671 'gnus-thread-sort-by-score)
10674 (defvar gnus-summary-already-sorted nil)
10675 (defun gnus-summary-sort (predicate reverse)
10676 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10677 (if gnus-summary-already-sorted
10679 (let (buffer-read-only)
10680 (if (not gnus-show-threads)
10681 ;; We do untreaded sorting...
10683 (goto-char (point-min))
10684 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
10685 ;; ... or we do threaded sorting.
10686 (let ((gnus-thread-sort-functions (list (cdr predicate)))
10687 (gnus-summary-prepare-hook nil)
10688 (gnus-summary-already-sorted nil))
10689 ;; We do that by simply regenerating the threads.
10690 (gnus-summary-prepare)
10691 (and gnus-show-threads
10692 gnus-thread-hide-subtree
10693 (gnus-summary-hide-all-threads))
10694 ;; If in async mode, we send some info to the backend.
10695 (and gnus-newsgroup-async
10696 (gnus-request-asynchronous
10697 gnus-newsgroup-name gnus-newsgroup-data)))))))
10699 (defun gnus-sortable-date (date)
10700 "Make sortable string by string-lessp from DATE.
10701 Timezone package is used."
10702 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
10703 (year (aref date 0))
10704 (month (aref date 1))
10705 (day (aref date 2)))
10706 (timezone-make-sortable-date
10708 (timezone-make-time-string
10709 (aref date 3) (aref date 4) (aref date 5)))))
10712 ;; Summary saving commands.
10714 (defun gnus-summary-save-article (&optional n)
10715 "Save the current article using the default saver function.
10716 If N is a positive number, save the N next articles.
10717 If N is a negative number, save the N previous articles.
10718 If N is nil and any articles have been marked with the process mark,
10719 save those articles instead.
10720 The variable `gnus-default-article-saver' specifies the saver function."
10722 (gnus-set-global-variables)
10723 (let ((articles (gnus-summary-work-articles n))
10726 (let ((header (gnus-summary-article-header (car articles))))
10727 (if (vectorp header)
10729 (save-window-excursion
10730 (gnus-summary-select-article t nil nil (car articles)))
10731 (or gnus-save-all-headers
10732 (gnus-article-hide-headers t))
10733 ;; Remove any X-Gnus lines.
10736 (set-buffer gnus-article-buffer)
10737 (let ((buffer-read-only nil))
10738 (goto-char (point-min))
10739 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
10741 (while (re-search-forward "^X-Gnus" nil t)
10742 (beginning-of-line)
10743 (delete-region (point)
10744 (progn (forward-line 1) (point))))
10746 (save-window-excursion
10747 (if gnus-default-article-saver
10748 (setq file (funcall
10749 gnus-default-article-saver
10751 ((not gnus-prompt-before-saving)
10753 ((eq gnus-prompt-before-saving 'always)
10756 (error "No default saver is defined."))))
10757 (if (assq 'name header)
10758 (gnus-copy-file (cdr (assq 'name header)))
10759 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
10760 (gnus-summary-remove-process-mark (car articles))
10761 (setq articles (cdr articles)))
10762 (gnus-summary-position-point)
10765 (defun gnus-summary-pipe-output (&optional arg)
10766 "Pipe the current article to a subprocess.
10767 If N is a positive number, pipe the N next articles.
10768 If N is a negative number, pipe the N previous articles.
10769 If N is nil and any articles have been marked with the process mark,
10770 pipe those articles instead."
10772 (gnus-set-global-variables)
10773 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10774 (gnus-summary-save-article arg)))
10776 (defun gnus-summary-save-article-mail (&optional arg)
10777 "Append the current article to an mail file.
10778 If N is a positive number, save the N next articles.
10779 If N is a negative number, save the N previous articles.
10780 If N is nil and any articles have been marked with the process mark,
10781 save those articles instead."
10783 (gnus-set-global-variables)
10784 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10785 (gnus-summary-save-article arg)))
10787 (defun gnus-summary-save-article-rmail (&optional arg)
10788 "Append the current article to an rmail file.
10789 If N is a positive number, save the N next articles.
10790 If N is a negative number, save the N previous articles.
10791 If N is nil and any articles have been marked with the process mark,
10792 save those articles instead."
10794 (gnus-set-global-variables)
10795 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10796 (gnus-summary-save-article arg)))
10798 (defun gnus-summary-save-article-file (&optional arg)
10799 "Append the current article to a file.
10800 If N is a positive number, save the N next articles.
10801 If N is a negative number, save the N previous articles.
10802 If N is nil and any articles have been marked with the process mark,
10803 save those articles instead."
10805 (gnus-set-global-variables)
10806 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10807 (gnus-summary-save-article arg)))
10809 (defun gnus-summary-save-article-body-file (&optional arg)
10810 "Append the current article body to a file.
10811 If N is a positive number, save the N next articles.
10812 If N is a negative number, save the N previous articles.
10813 If N is nil and any articles have been marked with the process mark,
10814 save those articles instead."
10816 (gnus-set-global-variables)
10817 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10818 (gnus-summary-save-article arg)))
10820 (defun gnus-read-save-file-name (prompt default-name)
10821 (let ((methods gnus-split-methods)
10823 (if (not gnus-split-methods)
10826 (set-buffer gnus-article-buffer)
10827 (gnus-narrow-to-headers)
10829 (goto-char (point-min))
10830 (and (condition-case ()
10831 (re-search-forward (car (car methods)) nil t)
10833 (setq split-name (cons (nth 1 (car methods)) split-name)))
10834 (setq methods (cdr methods)))
10836 (cond ((null split-name)
10838 (concat prompt " (default "
10839 (file-name-nondirectory default-name) ") ")
10840 (file-name-directory default-name)
10842 ((= 1 (length split-name))
10844 (concat prompt " (default " (car split-name) ") ")
10845 gnus-article-save-directory
10846 (concat gnus-article-save-directory (car split-name))))
10848 (setq split-name (mapcar (lambda (el) (list el))
10849 (nreverse split-name)))
10850 (let ((result (completing-read
10851 (concat prompt " ")
10852 split-name nil nil)))
10853 (concat gnus-article-save-directory
10854 (if (string= result "")
10855 (car (car split-name))
10858 (defun gnus-summary-save-in-rmail (&optional filename)
10859 "Append this article to Rmail file.
10860 Optional argument FILENAME specifies file name.
10861 Directory to save to is default to `gnus-article-save-directory' which
10862 is initialized from the SAVEDIR environment variable."
10864 (gnus-set-global-variables)
10865 (let ((default-name
10866 (funcall gnus-rmail-save-name gnus-newsgroup-name
10867 gnus-current-headers gnus-newsgroup-last-rmail)))
10869 (cond ((eq filename 'default)
10871 (filename filename)
10872 (t (gnus-read-save-file-name
10873 "Save in rmail file:" default-name))))
10874 (gnus-make-directory (file-name-directory filename))
10875 (gnus-eval-in-buffer-window
10876 gnus-article-buffer
10880 (gnus-output-to-rmail filename))))
10881 ;; Remember the directory name to save articles
10882 (setq gnus-newsgroup-last-rmail filename)))
10884 (defun gnus-summary-save-in-mail (&optional filename)
10885 "Append this article to Unix mail file.
10886 Optional argument FILENAME specifies file name.
10887 Directory to save to is default to `gnus-article-save-directory' which
10888 is initialized from the SAVEDIR environment variable."
10890 (gnus-set-global-variables)
10891 (let ((default-name
10892 (funcall gnus-mail-save-name gnus-newsgroup-name
10893 gnus-current-headers gnus-newsgroup-last-mail)))
10895 (cond ((eq filename 'default)
10897 (filename filename)
10898 (t (gnus-read-save-file-name
10899 "Save in Unix mail file:" default-name))))
10901 (expand-file-name filename
10903 (file-name-directory default-name))))
10904 (gnus-make-directory (file-name-directory filename))
10905 (gnus-eval-in-buffer-window
10906 gnus-article-buffer
10910 (if (and (file-readable-p filename) (rmail-file-p filename))
10911 (gnus-output-to-rmail filename)
10912 (rmail-output filename 1 t t)))))
10913 ;; Remember the directory name to save articles.
10914 (setq gnus-newsgroup-last-mail filename)))
10916 (defun gnus-summary-save-in-file (&optional filename)
10917 "Append this article to file.
10918 Optional argument FILENAME specifies file name.
10919 Directory to save to is default to `gnus-article-save-directory' which
10920 is initialized from the SAVEDIR environment variable."
10922 (gnus-set-global-variables)
10923 (let ((default-name
10924 (funcall gnus-file-save-name gnus-newsgroup-name
10925 gnus-current-headers gnus-newsgroup-last-file)))
10927 (cond ((eq filename 'default)
10929 (filename filename)
10930 (t (gnus-read-save-file-name
10931 "Save in file:" default-name))))
10932 (gnus-make-directory (file-name-directory filename))
10933 (gnus-eval-in-buffer-window
10934 gnus-article-buffer
10938 (gnus-output-to-file filename))))
10939 ;; Remember the directory name to save articles.
10940 (setq gnus-newsgroup-last-file filename)))
10942 (defun gnus-summary-save-body-in-file (&optional filename)
10943 "Append this article body to a file.
10944 Optional argument FILENAME specifies file name.
10945 The directory to save in defaults to `gnus-article-save-directory' which
10946 is initialized from the SAVEDIR environment variable."
10948 (gnus-set-global-variables)
10949 (let ((default-name
10950 (funcall gnus-file-save-name gnus-newsgroup-name
10951 gnus-current-headers gnus-newsgroup-last-file)))
10953 (cond ((eq filename 'default)
10955 (filename filename)
10956 (t (gnus-read-save-file-name
10957 "Save body in file:" default-name))))
10958 (gnus-make-directory (file-name-directory filename))
10959 (gnus-eval-in-buffer-window
10960 gnus-article-buffer
10964 (goto-char (point-min))
10965 (and (search-forward "\n\n" nil t)
10966 (narrow-to-region (point) (point-max)))
10967 (gnus-output-to-file filename))))
10968 ;; Remember the directory name to save articles.
10969 (setq gnus-newsgroup-last-file filename)))
10971 (defun gnus-summary-save-in-pipe (&optional command)
10972 "Pipe this article to subprocess."
10974 (gnus-set-global-variables)
10976 (cond ((eq command 'default)
10977 gnus-last-shell-command)
10979 (t (read-string "Shell command on article: "
10980 gnus-last-shell-command))))
10981 (if (string-equal command "")
10982 (setq command gnus-last-shell-command))
10983 (gnus-eval-in-buffer-window
10984 gnus-article-buffer
10987 (shell-command-on-region (point-min) (point-max) command nil)))
10988 (setq gnus-last-shell-command command))
10990 ;; Summary extract commands
10992 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10993 (let ((buffer-read-only nil)
10994 (article (gnus-summary-article-number))
10996 (or (gnus-summary-goto-subject article)
10997 (error (format "No such article: %d" article)))
10998 (gnus-summary-position-point)
10999 ;; If all commands are to be bunched up on one line, we collect
11001 (if gnus-view-pseudos-separately
11003 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11006 (setq action (cdr (assq 'action (car ps))))
11007 (setq files (list (cdr (assq 'name (car ps)))))
11008 (while (and ps (cdr ps)
11009 (string= (or action "1")
11010 (or (cdr (assq 'action (car (cdr ps)))) "2")))
11011 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
11012 (setcdr ps (cdr (cdr ps))))
11015 (if (not (string-match "%s" action))
11016 (setq files (cons " " files)))
11017 (setq files (cons " " files))
11018 (and (assq 'execute (car ps))
11019 (setcdr (assq 'execute (car ps))
11020 (funcall (if (string-match "%s" action)
11023 (mapconcat (lambda (f) f) files " ")))))
11024 (setq ps (cdr ps)))))
11025 (if (and gnus-view-pseudos (not not-view))
11027 (and (assq 'execute (car pslist))
11028 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11029 (eq gnus-view-pseudos 'not-confirm)))
11030 (setq pslist (cdr pslist)))
11033 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
11034 (gnus-summary-article-number)))
11036 (gnus-summary-article-number)
11037 gnus-reffed-article-number gnus-unread-mark
11038 (progn (forward-line 1) (point))
11044 (insert " " (file-name-nondirectory
11045 (cdr (assq 'name (car pslist))))
11046 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11048 'gnus-number gnus-reffed-article-number)
11050 (setq gnus-newsgroup-unreads
11051 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
11052 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11053 (setq pslist (cdr pslist)))))))
11055 (defun gnus-pseudos< (p1 p2)
11056 (let ((c1 (cdr (assq 'action p1)))
11057 (c2 (cdr (assq 'action p2))))
11058 (and c1 c2 (string< c1 c2))))
11060 (defun gnus-request-pseudo-article (props)
11061 (cond ((assq 'execute props)
11062 (gnus-execute-command (cdr (assq 'execute props)))))
11063 (let ((gnus-current-article (gnus-summary-article-number)))
11064 (run-hooks 'gnus-mark-article-hook)))
11066 (defun gnus-execute-command (command &optional automatic)
11068 (gnus-article-setup-buffer)
11069 (set-buffer gnus-article-buffer)
11070 (let ((command (if automatic command (read-string "Command: " command)))
11071 (buffer-read-only nil))
11073 (insert "$ " command "\n\n")
11074 (if gnus-view-pseudo-asynchronously
11075 (start-process "gnus-execute" nil "sh" "-c" command)
11076 (call-process "sh" nil t nil "-c" command)))))
11078 (defun gnus-copy-file (file &optional to)
11081 (list (read-file-name "Copy file: " default-directory)
11082 (read-file-name "Copy file to: " default-directory)))
11083 (gnus-set-global-variables)
11084 (or to (setq to (read-file-name "Copy file to: " default-directory)))
11085 (and (file-directory-p to)
11086 (setq to (concat (file-name-as-directory to)
11087 (file-name-nondirectory file))))
11088 (copy-file file to))
11090 ;; Summary kill commands.
11092 (defun gnus-summary-edit-global-kill (article)
11093 "Edit the \"global\" kill file."
11094 (interactive (list (gnus-summary-article-number)))
11095 (gnus-set-global-variables)
11096 (gnus-group-edit-global-kill article))
11098 (defun gnus-summary-edit-local-kill ()
11099 "Edit a local kill file applied to the current newsgroup."
11101 (gnus-set-global-variables)
11102 (setq gnus-current-headers (gnus-summary-article-header))
11103 (gnus-set-global-variables)
11104 (gnus-group-edit-local-kill
11105 (gnus-summary-article-number) gnus-newsgroup-name))
11109 ;;; Gnus article mode
11112 (put 'gnus-article-mode 'mode-class 'special)
11114 (if gnus-article-mode-map
11116 (setq gnus-article-mode-map (make-keymap))
11117 (suppress-keymap gnus-article-mode-map)
11118 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
11119 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
11120 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
11121 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
11122 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
11123 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
11124 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
11125 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
11126 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
11127 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
11128 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
11130 ;; Duplicate almost all summary keystrokes in the article mode map.
11133 "p" "N" "P" "\M-\C-n" "\M-\C-p"
11134 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
11135 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
11136 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
11137 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
11138 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
11139 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
11140 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
11141 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
11142 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
11143 "\C-c\C-v\C-v" "\C-d" "v"
11144 ;; "Mt" "M!" "Md" "Mr"
11145 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
11146 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
11147 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
11148 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
11149 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
11150 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
11151 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
11152 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
11153 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
11154 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
11155 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
11158 (define-key gnus-article-mode-map (car commands)
11159 'gnus-article-summary-command)
11160 (setq commands (cdr commands))))
11162 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
11163 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
11164 "=" "n" "^" "\M-^")))
11166 (define-key gnus-article-mode-map (car commands)
11167 'gnus-article-summary-command-nosave)
11168 (setq commands (cdr commands)))))
11171 (defun gnus-article-mode ()
11172 "Major mode for displaying an article.
11174 All normal editing commands are switched off.
11176 The following commands are available:
11178 \\<gnus-article-mode-map>
11179 \\[gnus-article-next-page]\t Scroll the article one page forwards
11180 \\[gnus-article-prev-page]\t Scroll the article one page backwards
11181 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
11182 \\[gnus-article-show-summary]\t Display the summary buffer
11183 \\[gnus-article-mail]\t Send a reply to the address near point
11184 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
11185 \\[gnus-info-find-node]\t Go to the Gnus info node"
11187 (if (gnus-visual-p 'article-menu 'menu) (gnus-article-make-menu-bar))
11188 (kill-all-local-variables)
11189 (setq mode-line-modified "-- ")
11190 (make-local-variable 'mode-line-format)
11191 (setq mode-line-format (copy-sequence mode-line-format))
11192 (and (equal (nth 3 mode-line-format) " ")
11193 (setcar (nthcdr 3 mode-line-format) ""))
11194 (setq mode-name "Article")
11195 (setq major-mode 'gnus-article-mode)
11196 (make-local-variable 'minor-mode-alist)
11197 (or (assq 'gnus-show-mime minor-mode-alist)
11198 (setq minor-mode-alist
11199 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
11200 (use-local-map gnus-article-mode-map)
11201 (make-local-variable 'page-delimiter)
11202 (setq page-delimiter gnus-page-delimiter)
11203 (buffer-disable-undo (current-buffer))
11204 (setq buffer-read-only t) ;Disable modification
11205 (run-hooks 'gnus-article-mode-hook))
11207 (defun gnus-article-setup-buffer ()
11208 "Initialize article mode buffer."
11209 ;; Returns the article buffer.
11210 (if (get-buffer gnus-article-buffer)
11212 (set-buffer gnus-article-buffer)
11213 (buffer-disable-undo (current-buffer))
11214 (setq buffer-read-only t)
11215 (gnus-add-current-to-buffer-list)
11216 (or (eq major-mode 'gnus-article-mode)
11217 (gnus-article-mode))
11220 (set-buffer (get-buffer-create gnus-article-buffer))
11221 (gnus-add-current-to-buffer-list)
11222 (gnus-article-mode)
11223 (current-buffer))))
11225 ;; Set article window start at LINE, where LINE is the number of lines
11226 ;; from the head of the article.
11227 (defun gnus-article-set-window-start (&optional line)
11229 (get-buffer-window gnus-article-buffer)
11231 (set-buffer gnus-article-buffer)
11232 (goto-char (point-min))
11235 (gnus-message 6 "Moved to bookmark")
11236 (search-forward "\n\n" nil t)
11237 (forward-line line)
11240 (defun gnus-request-article-this-buffer (article group)
11241 "Get an article and insert it into this buffer."
11244 (if (get-buffer gnus-original-article-buffer)
11245 (set-buffer (get-buffer gnus-original-article-buffer))
11246 (set-buffer (get-buffer-create gnus-original-article-buffer))
11247 (buffer-disable-undo (current-buffer))
11248 (setq major-mode 'gnus-original-article-mode)
11249 (gnus-add-current-to-buffer-list))
11251 (setq group (or group gnus-newsgroup-name))
11253 ;; Open server if it has closed.
11254 (gnus-check-server (gnus-find-method-for-group group))
11256 ;; Using `gnus-request-article' directly will insert the article into
11257 ;; `nntp-server-buffer' - so we'll save some time by not having to
11258 ;; copy it from the server buffer into the article buffer.
11260 ;; We only request an article by message-id when we do not have the
11261 ;; headers for it, so we'll have to get those.
11262 (and (stringp article)
11263 (let ((gnus-override-method gnus-refer-article-method))
11264 (gnus-read-header article)))
11266 ;; If the article number is negative, that means that this article
11267 ;; doesn't belong in this newsgroup (possibly), so we find its
11268 ;; message-id and request it by id instead of number.
11269 (if (not (numberp article))
11272 (set-buffer gnus-summary-buffer)
11273 (let ((header (gnus-summary-article-header article)))
11275 (if (vectorp header)
11276 ;; It's a real article.
11277 (setq article (mail-header-id header))
11278 ;; It is an extracted pseudo-article.
11279 (setq article 'pseudo)
11280 (gnus-request-pseudo-article header)))
11282 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
11283 (if (not (eq (car method) 'nneething))
11285 (let ((dir (concat (file-name-as-directory (nth 1 method))
11286 (mail-header-subject header))))
11287 (if (file-directory-p dir)
11289 (setq article 'nneething)
11290 (gnus-group-enter-directory dir)))))))))
11293 ;; We first check `gnus-original-article-buffer'.
11294 ((and (equal (car gnus-original-article) group)
11295 (eq (cdr gnus-original-article) article))
11297 ;; Check the cache.
11298 ((and gnus-use-cache
11300 (gnus-cache-request-article article group))
11302 ;; Get the article from the backend.
11303 ((or (stringp article) (numberp article))
11305 (let ((gnus-override-method
11306 (and (stringp article) gnus-refer-article-method)))
11307 (and (gnus-request-article article group (current-buffer))
11309 ;; It was a pseudo.
11311 (setq gnus-original-article (cons group article))
11312 (let (buffer-read-only)
11314 (insert-buffer-substring gnus-original-article-buffer))))
11316 (defun gnus-read-header (id)
11317 "Read the headers of article ID and enter them into the Gnus system."
11318 (let ((group gnus-newsgroup-name)
11321 (if (gnus-check-backend-function 'request-head group)
11322 (gnus-request-head id group)
11323 (gnus-request-article id group)))
11325 (set-buffer nntp-server-buffer)
11326 (and (search-forward "\n\n" nil t)
11327 (delete-region (1- (point)) (point-max)))
11328 (goto-char (point-max))
11330 (goto-char (point-min))
11339 gnus-reffed-article-number)))
11340 " Article retrieved.\n")
11341 (if (not (setq header (car (gnus-get-newsgroup-headers))))
11342 () ; Malformed head.
11343 (if (and (stringp id)
11344 (not (string= (gnus-group-real-name group)
11346 ;; If we fetched by Message-ID and the article came
11347 ;; from a different group, we fudge some bogus article
11348 ;; numbers for this article.
11349 (mail-header-set-number header gnus-reffed-article-number))
11350 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11351 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
11352 (setq gnus-current-headers header)
11355 (defun gnus-article-prepare (article &optional all-headers header)
11356 "Prepare ARTICLE in article mode buffer.
11357 ARTICLE should either be an article number or a Message-ID.
11358 If ARTICLE is an id, HEADER should be the article headers.
11359 If ALL-HEADERS is non-nil, no headers are hidden."
11361 ;; Make sure we start in a summary buffer.
11362 (or (eq major-mode 'gnus-summary-mode)
11363 (set-buffer gnus-summary-buffer))
11364 (setq gnus-summary-buffer (current-buffer))
11365 ;; Make sure the connection to the server is alive.
11366 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
11369 (gnus-find-method-for-group gnus-newsgroup-name))
11370 (gnus-request-group gnus-newsgroup-name t)))
11371 (let* ((article (if header (mail-header-number header) article))
11372 (summary-buffer (current-buffer))
11373 (internal-hook gnus-article-internal-prepare-hook)
11374 (group gnus-newsgroup-name)
11377 (gnus-article-setup-buffer)
11378 (set-buffer gnus-article-buffer)
11379 (if (not (setq result (let ((buffer-read-only nil))
11380 (gnus-request-article-this-buffer
11382 ;; There is no such article.
11384 (if (not (numberp article))
11386 (setq gnus-article-current
11387 (cons gnus-newsgroup-name article))
11388 (set-buffer gnus-summary-buffer)
11389 (setq gnus-current-article article)
11390 (gnus-summary-mark-article article gnus-canceled-mark))
11391 (gnus-message 1 "No such article (may be canceled)")
11394 (if (or (eq result 'pseudo) (eq result 'nneething))
11397 (set-buffer summary-buffer)
11398 (setq gnus-last-article gnus-current-article
11399 gnus-newsgroup-history (cons gnus-current-article
11400 gnus-newsgroup-history)
11401 gnus-current-article 0
11402 gnus-current-headers nil
11403 gnus-article-current nil)
11404 (if (eq result 'nneething)
11405 (gnus-configure-windows 'summary)
11406 (gnus-configure-windows 'article))
11407 (gnus-set-global-variables))
11408 (gnus-set-mode-line 'article))
11409 ;; The result from the `request' was an actual article -
11410 ;; or at least some text that is now displayed in the
11412 (if (and (numberp article)
11413 (not (eq article gnus-current-article)))
11414 ;; Seems like a new article has been selected.
11415 ;; `gnus-current-article' must be an article number.
11417 (set-buffer summary-buffer)
11418 (setq gnus-last-article gnus-current-article
11419 gnus-newsgroup-history (cons gnus-current-article
11420 gnus-newsgroup-history)
11421 gnus-current-article article
11422 gnus-current-headers
11423 (gnus-summary-article-header gnus-current-article)
11424 gnus-article-current
11425 (cons gnus-newsgroup-name gnus-current-article))
11426 (gnus-summary-show-thread)
11427 (run-hooks 'gnus-mark-article-hook)
11428 (gnus-set-mode-line 'summary)
11429 (and (gnus-visual-p 'article-highlight 'highlight)
11430 (run-hooks 'gnus-visual-mark-article-hook))
11431 ;; Set the global newsgroup variables here.
11432 ;; Suggested by Jim Sisolak
11433 ;; <sisolak@trans4.neep.wisc.edu>.
11434 (gnus-set-global-variables)
11435 (setq gnus-have-all-headers
11436 (or all-headers gnus-show-all-headers))
11437 (and gnus-use-cache
11438 (vectorp (gnus-summary-article-header article))
11439 (gnus-cache-possibly-enter-article
11441 (gnus-summary-article-header article)
11442 (memq article gnus-newsgroup-marked)
11443 (memq article gnus-newsgroup-dormant)
11444 (memq article gnus-newsgroup-unreads)))))
11445 ;; Hooks for getting information from the article.
11446 ;; This hook must be called before being narrowed.
11447 (let (buffer-read-only)
11448 (run-hooks 'internal-hook)
11449 (run-hooks 'gnus-article-prepare-hook)
11450 ;; Decode MIME message.
11451 (if (and gnus-show-mime
11452 (or (not gnus-strict-mime)
11453 (gnus-fetch-field "Mime-Version")))
11454 (funcall gnus-show-mime-method))
11455 ;; Perform the article display hooks.
11456 (run-hooks 'gnus-article-display-hook))
11458 (goto-char (point-min))
11459 (and gnus-break-pages (gnus-narrow-to-page))
11460 (gnus-set-mode-line 'article)
11461 (gnus-configure-windows 'article)
11462 (goto-char (point-min))
11465 (defun gnus-article-show-all-headers ()
11466 "Show all article headers in article mode buffer."
11468 (gnus-article-setup-buffer)
11469 (set-buffer gnus-article-buffer)
11470 (let ((buffer-read-only nil))
11471 (remove-text-properties (point-min) (point-max)
11472 gnus-hidden-properties))))
11474 (defun gnus-article-hide-headers-if-wanted ()
11475 "Hide unwanted headers if `gnus-have-all-headers' is nil.
11476 Provided for backwards compatability."
11477 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
11478 (gnus-article-hide-headers)))
11480 (defun gnus-article-hide-headers (&optional delete)
11481 "Hide unwanted headers and possibly sort them as well."
11484 (set-buffer gnus-article-buffer)
11486 (let ((sorted gnus-sorted-header-list)
11487 (buffer-read-only nil)
11488 want-list beg want-l)
11489 ;; First we narrow to just the headers.
11491 (goto-char (point-min))
11492 ;; Hide any "From " lines at the beginning of (mail) articles.
11493 (while (looking-at "From ")
11496 (add-text-properties (point-min) (point) gnus-hidden-properties))
11497 ;; Then treat the rest of the header lines.
11500 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
11501 ;; Then we use the two regular expressions
11502 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
11503 ;; select which header lines is to remain visible in the
11505 (goto-char (point-min))
11506 (while (re-search-forward "^[^ \t]*:" nil t)
11507 (beginning-of-line)
11508 ;; We add the headers we want to keep to a list and delete
11509 ;; them from the buffer.
11510 (if (or (and (stringp gnus-visible-headers)
11511 (looking-at gnus-visible-headers))
11512 (and (not (stringp gnus-visible-headers))
11513 (stringp gnus-ignored-headers)
11514 (not (looking-at gnus-ignored-headers))))
11518 ;; Be sure to get multi-line headers...
11519 (re-search-forward "^[^ \t]*:" nil t)
11520 (beginning-of-line)
11522 (cons (buffer-substring beg (point)) want-list))
11523 (delete-region beg (point))
11526 ;; Next we perform the sorting by looking at
11527 ;; `gnus-sorted-header-list'.
11528 (goto-char (point-min))
11529 (while (and sorted want-list)
11530 (setq want-l want-list)
11532 (not (string-match (car sorted) (car want-l))))
11533 (setq want-l (cdr want-l)))
11536 (insert (car want-l))
11537 (setq want-list (delq (car want-l) want-list))))
11538 (setq sorted (cdr sorted)))
11539 ;; Any headers that were not matched by the sorted list we
11540 ;; just tack on the end of the visible header list.
11542 (insert (car want-list))
11543 (setq want-list (cdr want-list)))
11544 ;; And finally we make the unwanted headers invisible.
11546 (delete-region (point) (point-max))
11547 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11548 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
11550 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
11551 (defun gnus-article-treat-overstrike ()
11552 "Translate overstrikes into bold text."
11555 (set-buffer gnus-article-buffer)
11556 (let ((buffer-read-only nil))
11557 (while (search-forward "\b" nil t)
11558 (let ((next (following-char))
11559 (previous (char-after (- (point) 2))))
11560 (cond ((eq next previous)
11561 (put-text-property (- (point) 2) (point)
11563 (put-text-property (point) (1+ (point))
11566 (put-text-property (1- (point)) (1+ (point))
11568 (put-text-property (1- (point)) (point)
11571 (put-text-property (- (point) 2) (point)
11573 (put-text-property (point) (1+ (point))
11574 'face 'underline))))))))
11576 (defun gnus-article-word-wrap ()
11577 "Format too long lines."
11580 (set-buffer gnus-article-buffer)
11581 (let ((buffer-read-only nil)
11584 (goto-char (point-min))
11585 (search-forward "\n\n" nil t)
11587 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
11588 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
11589 (adaptive-fill-mode t))
11590 (while (not (eobp))
11591 (and (>= (current-column) (min fill-column (window-width)))
11592 (/= (preceding-char) ?:)
11593 (fill-paragraph nil))
11594 (end-of-line 2))))))
11596 (defun gnus-article-remove-cr ()
11597 "Remove carriage returns from an article."
11600 (set-buffer gnus-article-buffer)
11601 (let ((buffer-read-only nil))
11602 (goto-char (point-min))
11603 (while (search-forward "\r" nil t)
11604 (replace-match "" t t)))))
11606 (defun gnus-article-display-x-face (&optional force)
11607 "Look for an X-Face header and display it if present."
11608 (interactive (list 'force))
11610 (set-buffer gnus-article-buffer)
11611 ;; delete old process
11612 (and (process-status "gnus-x-face")
11613 (delete-process "gnus-x-face"))
11614 (let ((inhibit-point-motion-hooks t)
11615 (case-fold-search nil)
11618 (goto-char (point-min))
11619 (search-forward "\n\n")
11620 (narrow-to-region (point-min) (point))
11621 (goto-char (point-min))
11622 (setq from (mail-fetch-field "from"))
11623 (if (not (and gnus-article-x-face-command
11625 (not gnus-article-x-face-too-ugly)
11626 (and gnus-article-x-face-too-ugly from
11627 (not (string-match gnus-article-x-face-too-ugly
11630 (goto-char (point-min))
11631 (re-search-forward "^X-Face: " nil t))))
11633 (let ((beg (point))
11634 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
11635 (if (symbolp gnus-article-x-face-command)
11636 (and (or (fboundp gnus-article-x-face-command)
11637 (error "%s is not a function"
11638 gnus-article-x-face-command))
11639 (funcall gnus-article-x-face-command beg end))
11640 (let ((process-connection-type nil))
11641 (process-kill-without-query
11642 (start-process "gnus-x-face" nil "sh" "-c"
11643 gnus-article-x-face-command))
11644 (process-send-region "gnus-x-face" beg end)
11645 (process-send-eof "gnus-x-face")))))))))
11647 (defun gnus-article-de-quoted-unreadable (&optional force)
11648 "Do a naïve translation of a quoted-printable-encoded article.
11649 This is in no way, shape or form meant as a replacement for real MIME
11650 processing, but is simply a stop-gap measure until MIME support is
11652 If FORCE, decode the article whether it is marked as quoted-printable
11654 (interactive (list 'force))
11656 (set-buffer gnus-article-buffer)
11657 (let ((case-fold-search t)
11658 (buffer-read-only nil)
11659 (type (gnus-fetch-field "content-transfer-encoding")))
11660 (if (or force (and type (string-match "quoted-printable" type)))
11662 (goto-char (point-min))
11663 (search-forward "\n\n" nil 'move)
11664 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
11666 (defun gnus-mime-decode-quoted-printable (from to)
11667 ;; Decode quoted-printable from region between FROM and TO.
11670 (while (search-forward "=" to t)
11671 (cond ((eq (following-char) ?\n)
11674 ((looking-at "[0-9A-F][0-9A-F]")
11676 (insert (hexl-hex-string-to-integer
11677 (buffer-substring (point) (+ 2 (point)))))
11681 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
11683 (defun gnus-article-hide-pgp ()
11684 "Hide any PGP headers and signatures in the current article."
11687 (set-buffer gnus-article-buffer)
11688 (let (buffer-read-only)
11689 (goto-char (point-min))
11690 ;; Hide the "header".
11691 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
11692 (add-text-properties (match-beginning 0) (match-end 0)
11693 gnus-hidden-properties))
11694 ;; Hide the actual signature.
11695 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
11696 (add-text-properties
11697 (match-beginning 0)
11698 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
11700 ;; Perhaps we shouldn't hide to the end of the buffer
11701 ;; if there is no end to the signature?
11703 gnus-hidden-properties)))))
11706 (defvar gnus-article-time-units
11707 (list (cons 'year (* 365.25 24 60 60))
11708 (cons 'week (* 7 24 60 60))
11709 (cons 'day (* 24 60 60))
11710 (cons 'hour (* 60 60))
11714 (defun gnus-article-date-ut (&optional type)
11715 "Convert DATE date to universal time in the current article.
11716 If TYPE is `local', convert to local time; if it is `lapsed', output
11717 how much time has lapsed since DATE."
11718 (interactive (list 'ut))
11719 (let ((date (mail-header-date (or gnus-current-headers
11720 (gnus-summary-article-header) "")))
11721 (date-regexp "^Date: \\|^X-Sent: "))
11726 (set-buffer gnus-article-buffer)
11727 (let ((buffer-read-only nil))
11728 (goto-char (point-min))
11729 (if (and (re-search-forward date-regexp nil t)
11731 (beginning-of-line)
11732 (looking-at date-regexp)))
11733 (delete-region (gnus-point-at-bol)
11734 (progn (end-of-line) (1+ (point))))
11735 (goto-char (point-min))
11736 (goto-char (- (search-forward "\n\n") 2)))
11740 (concat "Date: " (condition-case ()
11741 (timezone-make-date-arpa-standard date)
11747 (timezone-make-date-arpa-standard date nil "UT")
11750 ((eq type 'original)
11751 (concat "Date: " date "\n"))
11753 ;; If the date is seriously mangled, the timezone
11754 ;; functions are liable to bug out, so we condition-case
11755 ;; the entire thing.
11756 (let* ((real-sec (condition-case ()
11757 (- (gnus-seconds-since-epoch
11758 (timezone-make-date-arpa-standard
11759 (current-time-string)
11760 (current-time-zone) "UT"))
11761 (gnus-seconds-since-epoch
11762 (timezone-make-date-arpa-standard
11765 (sec (abs real-sec))
11773 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
11775 (setq sec (- sec (* num (cdr unit))))
11777 (concat (if prev ", " "") (int-to-string
11779 " " (symbol-name (car unit))
11780 (if (> num 1) "s" ""))
11782 gnus-article-time-units "")
11785 " in the future\n")))))
11787 (error "Unknown conversion type: %s" type)))))))))
11789 (defun gnus-article-date-local ()
11790 "Convert the current article date to the local timezone."
11792 (gnus-article-date-ut 'local))
11794 (defun gnus-article-date-original ()
11795 "Convert the current article date to what it was originally.
11796 This is only useful if you have used some other date conversion
11797 function and want to see what the date was before converting."
11799 (gnus-article-date-ut 'original))
11801 (defun gnus-article-date-lapsed ()
11802 "Convert the current article date to time lapsed since it was sent."
11804 (gnus-article-date-ut 'lapsed))
11806 (defun gnus-article-maybe-highlight ()
11807 "Do some article highlighting if `gnus-visual' is non-nil."
11808 (if (gnus-visual-p 'article-highlight 'highlight)
11809 (gnus-article-highlight-some)))
11813 (defun gnus-output-to-rmail (file-name)
11814 "Append the current article to an Rmail file named FILE-NAME."
11816 ;; Most of these codes are borrowed from rmailout.el.
11817 (setq file-name (expand-file-name file-name))
11818 (setq rmail-default-rmail-file file-name)
11819 (let ((artbuf (current-buffer))
11820 (tmpbuf (get-buffer-create " *Gnus-output*")))
11822 (or (get-file-buffer file-name)
11823 (file-exists-p file-name)
11824 (if (gnus-yes-or-no-p
11825 (concat "\"" file-name "\" does not exist, create it? "))
11826 (let ((file-buffer (create-file-buffer file-name)))
11828 (set-buffer file-buffer)
11829 (rmail-insert-rmail-file-header)
11830 (let ((require-final-newline nil))
11831 (write-region (point-min) (point-max) file-name t 1)))
11832 (kill-buffer file-buffer))
11833 (error "Output file does not exist")))
11834 (set-buffer tmpbuf)
11835 (buffer-disable-undo (current-buffer))
11837 (insert-buffer-substring artbuf)
11838 (gnus-convert-article-to-rmail)
11839 ;; Decide whether to append to a file or to an Emacs buffer.
11840 (let ((outbuf (get-file-buffer file-name)))
11842 (append-to-file (point-min) (point-max) file-name)
11843 ;; File has been visited, in buffer OUTBUF.
11844 (set-buffer outbuf)
11845 (let ((buffer-read-only nil)
11846 (msg (and (boundp 'rmail-current-message)
11847 (symbol-value 'rmail-current-message))))
11848 ;; If MSG is non-nil, buffer is in RMAIL mode.
11851 (narrow-to-region (point-max) (point-max))))
11852 (insert-buffer-substring tmpbuf)
11855 (goto-char (point-min))
11857 (search-backward "\^_")
11858 (narrow-to-region (point) (point-max))
11859 (goto-char (1+ (point-min)))
11860 (rmail-count-new-messages t)
11861 (rmail-show-message msg)))))))
11862 (kill-buffer tmpbuf)))
11864 (defun gnus-output-to-file (file-name)
11865 "Append the current article to a file named FILE-NAME."
11866 (setq file-name (expand-file-name file-name))
11867 (let ((artbuf (current-buffer))
11868 (tmpbuf (get-buffer-create " *Gnus-output*")))
11870 (set-buffer tmpbuf)
11871 (buffer-disable-undo (current-buffer))
11873 (insert-buffer-substring artbuf)
11874 ;; Append newline at end of the buffer as separator, and then
11875 ;; save it to file.
11876 (goto-char (point-max))
11878 (append-to-file (point-min) (point-max) file-name))
11879 (kill-buffer tmpbuf)))
11881 (defun gnus-convert-article-to-rmail ()
11882 "Convert article in current buffer to Rmail message format."
11883 (let ((buffer-read-only nil))
11884 ;; Convert article directly into Babyl format.
11885 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11886 (goto-char (point-min))
11887 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11888 (while (search-forward "\n\^_" nil t) ;single char
11889 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
11890 (goto-char (point-max))
11893 (defun gnus-narrow-to-page (&optional arg)
11894 "Make text outside current page invisible except for page delimiter.
11895 A numeric arg specifies to move forward or backward by that many pages,
11896 thus showing a page other than the one point was originally in."
11898 (setq arg (if arg (prefix-numeric-value arg) 0))
11900 (forward-page -1) ;Beginning of current page.
11905 (forward-page (1- arg))))
11906 ;; Find the end of the page.
11908 ;; If we stopped due to end of buffer, stay there.
11909 ;; If we stopped after a page delimiter, put end of restriction
11910 ;; at the beginning of that line.
11911 ;; These are commented out.
11912 ;; (if (save-excursion (beginning-of-line)
11913 ;; (looking-at page-delimiter))
11914 ;; (beginning-of-line))
11915 (narrow-to-region (point)
11917 ;; Find the top of the page.
11919 ;; If we found beginning of buffer, stay there.
11920 ;; If extra text follows page delimiter on same line,
11922 ;; Otherwise, show text starting with following line.
11923 (if (and (eolp) (not (bobp)))
11927 (defun gnus-gmt-to-local ()
11928 "Rewrite Date header described in GMT to local in current buffer.
11929 Intended to be used with gnus-article-prepare-hook."
11933 (goto-char (point-min))
11934 (narrow-to-region (point-min)
11935 (progn (search-forward "\n\n" nil 'move) (point)))
11936 (goto-char (point-min))
11937 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
11938 (let ((buffer-read-only nil)
11939 (date (buffer-substring-no-properties
11940 (match-beginning 1) (match-end 1))))
11941 (delete-region (match-beginning 1) (match-end 1))
11943 (timezone-make-date-arpa-standard
11944 date nil (current-time-zone))))))))
11947 ;; Article mode commands
11949 (defun gnus-article-next-page (&optional lines)
11950 "Show next page of current article.
11951 If end of article, return non-nil. Otherwise return nil.
11952 Argument LINES specifies lines to be scrolled up."
11954 (move-to-window-line -1)
11955 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11956 (if (save-excursion
11958 (and (pos-visible-in-window-p) ;Not continuation line.
11960 ;; Nothing in this page.
11961 (if (or (not gnus-break-pages)
11964 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11966 (gnus-narrow-to-page 1) ;Go to next page.
11968 ;; More in this page.
11972 ;; Long lines may cause an end-of-buffer error.
11973 (goto-char (point-max))))
11976 (defun gnus-article-prev-page (&optional lines)
11977 "Show previous page of current article.
11978 Argument LINES specifies lines to be scrolled down."
11980 (move-to-window-line 0)
11981 (if (and gnus-break-pages
11983 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11985 (gnus-narrow-to-page -1) ;Go to previous page.
11986 (goto-char (point-max))
11988 (scroll-down lines)))
11990 (defun gnus-article-refer-article ()
11991 "Read article specified by message-id around point."
11993 (search-forward ">" nil t) ;Move point to end of "<....>".
11994 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11996 (buffer-substring (match-beginning 1) (match-end 1))))
11997 (set-buffer gnus-summary-buffer)
11998 (gnus-summary-refer-article message-id))
11999 (error "No references around point")))
12001 (defun gnus-article-show-summary ()
12002 "Reconfigure windows to show summary buffer."
12004 (gnus-configure-windows 'article)
12005 (gnus-summary-goto-subject gnus-current-article))
12007 (defun gnus-article-describe-briefly ()
12008 "Describe article mode commands briefly."
12011 (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")))
12013 (defun gnus-article-summary-command ()
12014 "Execute the last keystroke in the summary buffer."
12016 (let ((obuf (current-buffer))
12017 (owin (current-window-configuration))
12019 (switch-to-buffer gnus-summary-buffer 'norecord)
12020 (setq func (lookup-key (current-local-map) (this-command-keys)))
12021 (call-interactively func)
12023 (set-window-configuration owin)
12024 (set-window-point (get-buffer-window (current-buffer)) (point))))
12026 (defun gnus-article-summary-command-nosave ()
12027 "Execute the last keystroke in the summary buffer."
12030 (pop-to-buffer gnus-summary-buffer 'norecord)
12031 (setq func (lookup-key (current-local-map) (this-command-keys)))
12032 (call-interactively func)))
12035 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
12038 (defalias 'gnus-batch-kill 'gnus-batch-score)
12040 (defun gnus-batch-score ()
12041 "Run batched scoring.
12042 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
12043 Newsgroups is a list of strings in Bnews format. If you want to score
12044 the comp hierarchy, you'd say \"comp.all\". If you would not like to
12045 score the alt hierarchy, you'd say \"!alt.all\"."
12048 (gnus-newsrc-parse-options
12049 (apply (function concat)
12050 (mapcar (lambda (g) (concat g " "))
12051 command-line-args-left))))
12052 (gnus-expert-user t)
12053 (nnmail-spool-file nil)
12054 (gnus-use-dribble-file nil)
12055 (yes (car yes-and-no))
12056 (no (cdr yes-and-no))
12058 ;; Disable verbose message.
12059 gnus-novice-user gnus-large-newsgroup)
12060 ;; Eat all arguments.
12061 (setq command-line-args-left nil)
12064 ;; Apply kills to specified newsgroups in command line arguments.
12065 (setq newsrc (cdr gnus-newsrc-alist))
12067 (setq group (car (car newsrc)))
12068 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
12069 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
12071 (or (eq (car entry) t)
12072 (not (zerop (car entry)))))
12073 (if yes (string-match yes group) t)
12074 (or (null no) (not (string-match no group))))
12076 (gnus-summary-read-group group nil t)
12077 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
12078 (gnus-summary-exit))))
12079 (setq newsrc (cdr newsrc)))
12081 (switch-to-buffer gnus-group-buffer)
12082 (gnus-group-save-newsrc)))
12084 (defun gnus-apply-kill-file ()
12085 "Apply a kill file to the current newsgroup.
12086 Returns the number of articles marked as read."
12087 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
12088 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
12089 (gnus-apply-kill-file-internal)
12092 (defun gnus-kill-save-kill-buffer ()
12094 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
12095 (if (get-file-buffer file)
12097 (set-buffer (get-file-buffer file))
12098 (and (buffer-modified-p) (save-buffer))
12099 (kill-buffer (current-buffer)))))))
12101 (defvar gnus-kill-file-name "KILL"
12102 "Suffix of the kill files.")
12104 (defun gnus-newsgroup-kill-file (newsgroup)
12105 "Return the name of a kill file name for NEWSGROUP.
12106 If NEWSGROUP is nil, return the global kill file name instead."
12107 (cond ((or (null newsgroup)
12108 (string-equal newsgroup ""))
12109 ;; The global KILL file is placed at top of the directory.
12110 (expand-file-name gnus-kill-file-name
12111 (or gnus-kill-files-directory "~/News")))
12112 ((gnus-use-long-file-name 'not-kill)
12113 ;; Append ".KILL" to newsgroup name.
12114 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
12115 "." gnus-kill-file-name)
12116 (or gnus-kill-files-directory "~/News")))
12118 ;; Place "KILL" under the hierarchical directory.
12119 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
12120 "/" gnus-kill-file-name)
12121 (or gnus-kill-files-directory "~/News")))))
12128 (defvar gnus-dribble-ignore nil)
12129 (defvar gnus-dribble-eval-file nil)
12131 (defun gnus-dribble-file-name ()
12133 (if gnus-dribble-directory
12134 (concat (file-name-as-directory gnus-dribble-directory)
12135 (file-name-nondirectory gnus-current-startup-file))
12136 gnus-current-startup-file)
12139 (defun gnus-dribble-enter (string)
12140 (if (and (not gnus-dribble-ignore)
12141 (or gnus-dribble-buffer
12143 (buffer-name gnus-dribble-buffer))
12144 (let ((obuf (current-buffer)))
12145 (set-buffer gnus-dribble-buffer)
12146 (insert string "\n")
12147 (set-window-point (get-buffer-window (current-buffer)) (point-max))
12148 (set-buffer obuf))))
12150 (defun gnus-dribble-read-file ()
12151 (let ((dribble-file (gnus-dribble-file-name)))
12153 (set-buffer (setq gnus-dribble-buffer
12155 (file-name-nondirectory dribble-file))))
12156 (gnus-add-current-to-buffer-list)
12158 (set-visited-file-name dribble-file)
12159 (buffer-disable-undo (current-buffer))
12160 (bury-buffer (current-buffer))
12161 (set-buffer-modified-p nil)
12162 (let ((auto (make-auto-save-file-name))
12163 (gnus-dribble-ignore t))
12164 (if (or (file-exists-p auto) (file-exists-p dribble-file))
12166 (if (file-newer-than-file-p auto dribble-file)
12167 (setq dribble-file auto))
12168 (insert-file-contents dribble-file)
12169 (if (not (zerop (buffer-size)))
12170 (set-buffer-modified-p t))
12172 "Auto-save file exists. Do you want to read it? ")
12173 (setq gnus-dribble-eval-file t))))))))
12175 (defun gnus-dribble-eval-file ()
12176 (if (not gnus-dribble-eval-file)
12178 (setq gnus-dribble-eval-file nil)
12180 (let ((gnus-dribble-ignore t))
12181 (set-buffer gnus-dribble-buffer)
12182 (eval-buffer (current-buffer))))))
12184 (defun gnus-dribble-delete-file ()
12185 (if (file-exists-p (gnus-dribble-file-name))
12186 (delete-file (gnus-dribble-file-name)))
12187 (if gnus-dribble-buffer
12189 (set-buffer gnus-dribble-buffer)
12190 (let ((auto (make-auto-save-file-name)))
12191 (if (file-exists-p auto)
12192 (delete-file auto))
12194 (set-buffer-modified-p nil)))))
12196 (defun gnus-dribble-save ()
12197 (if (and gnus-dribble-buffer
12198 (buffer-name gnus-dribble-buffer))
12200 (set-buffer gnus-dribble-buffer)
12203 (defun gnus-dribble-clear ()
12205 (if (gnus-buffer-exists-p gnus-dribble-buffer)
12207 (set-buffer gnus-dribble-buffer)
12209 (set-buffer-modified-p nil)
12210 (setq buffer-saved-size (buffer-size))))))
12213 ;;; Server Communication
12216 (defun gnus-start-news-server (&optional confirm)
12217 "Open a method for getting news.
12218 If CONFIRM is non-nil, the user will be asked for an NNTP server."
12220 (if gnus-current-select-method
12221 ;; Stream is already opened.
12223 ;; Open NNTP server.
12224 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
12227 ;; Read server name with completion.
12228 (setq gnus-nntp-server
12229 (completing-read "NNTP server: "
12230 (mapcar (lambda (server) (list server))
12231 (cons (list gnus-nntp-server)
12232 gnus-secondary-servers))
12233 nil nil gnus-nntp-server))))
12235 (if (and gnus-nntp-server
12236 (stringp gnus-nntp-server)
12237 (not (string= gnus-nntp-server "")))
12238 (setq gnus-select-method
12239 (cond ((or (string= gnus-nntp-server "")
12240 (string= gnus-nntp-server "::"))
12241 (list 'nnspool (system-name)))
12242 ((string-match "^:" gnus-nntp-server)
12243 (list 'nnmh gnus-nntp-server
12244 (list 'nnmh-directory
12245 (file-name-as-directory
12247 (concat "~/" (substring
12248 gnus-nntp-server 1)))))
12249 (list 'nnmh-get-new-mail nil)))
12251 (list 'nntp gnus-nntp-server)))))
12253 (setq how (car gnus-select-method))
12254 (cond ((eq how 'nnspool)
12256 (gnus-message 5 "Looking up local news spool..."))
12259 (gnus-message 5 "Looking up mh spool..."))
12262 (setq gnus-current-select-method gnus-select-method)
12263 (run-hooks 'gnus-open-server-hook)
12265 ;; gnus-open-server-hook might have opened it
12266 (gnus-server-opened gnus-select-method)
12267 (gnus-open-server gnus-select-method)
12270 "%s open error: '%s'. Continue? "
12271 (nth 1 gnus-select-method)
12272 (gnus-status-message gnus-select-method)))
12274 (gnus-message 1 "Couldn't open server on %s"
12275 (nth 1 gnus-select-method))
12279 (defun gnus-check-server (&optional method)
12280 "If the news server is down, start it up again."
12281 (let ((method (if method method gnus-select-method)))
12282 (and (stringp method)
12283 (setq method (gnus-server-to-method method)))
12284 (if (gnus-server-opened method)
12285 ;; Stream is already opened.
12288 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
12289 (run-hooks 'gnus-open-server-hook)
12291 (gnus-open-server method)
12294 (defun gnus-nntp-message (&optional message)
12295 "Check the status of the NNTP server.
12296 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
12297 is returned insted of the status string."
12298 (let ((status (gnus-status-message (gnus-find-method-for-group
12299 gnus-newsgroup-name)))
12300 (message (or message "")))
12301 (if (and (stringp status) (> (length status) 0))
12304 (defun gnus-get-function (method function)
12305 (and (stringp method)
12306 (setq method (gnus-server-to-method method)))
12307 (let ((func (intern (format "%s-%s" (car method) function))))
12308 (if (not (fboundp func))
12310 (require (car method))
12311 (if (not (fboundp func))
12312 (error "No such function: %s" func))))
12315 ;;; Interface functions to the backends.
12317 (defun gnus-open-server (method)
12318 (funcall (gnus-get-function method 'open-server)
12319 (nth 1 method) (nthcdr 2 method)))
12321 (defun gnus-close-server (method)
12322 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
12324 (defun gnus-request-list (method)
12325 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
12327 (defun gnus-request-list-newsgroups (method)
12328 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
12330 (defun gnus-request-newgroups (date method)
12331 (funcall (gnus-get-function method 'request-newgroups)
12332 date (nth 1 method)))
12334 (defun gnus-server-opened (method)
12335 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
12337 (defun gnus-status-message (method)
12338 (let ((method (if (stringp method) (gnus-find-method-for-group method)
12340 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
12342 (defun gnus-request-group (group &optional dont-check)
12343 (let ((method (gnus-find-method-for-group group)))
12344 (funcall (gnus-get-function method 'request-group)
12345 (gnus-group-real-name group) (nth 1 method) dont-check)))
12347 (defun gnus-request-asynchronous (group &optional articles)
12348 (let ((method (gnus-find-method-for-group group)))
12349 (funcall (gnus-get-function method 'request-asynchronous)
12350 (gnus-group-real-name group) (nth 1 method) articles)))
12352 (defun gnus-list-active-group (group)
12353 (let ((method (gnus-find-method-for-group group))
12354 (func 'list-active-group))
12355 (and (gnus-check-backend-function func group)
12356 (funcall (gnus-get-function method func)
12357 (gnus-group-real-name group) (nth 1 method)))))
12359 (defun gnus-request-group-description (group)
12360 (let ((method (gnus-find-method-for-group group))
12361 (func 'request-group-description))
12362 (and (gnus-check-backend-function func group)
12363 (funcall (gnus-get-function method func)
12364 (gnus-group-real-name group) (nth 1 method)))))
12366 (defun gnus-close-group (group)
12367 (let ((method (gnus-find-method-for-group group)))
12368 (funcall (gnus-get-function method 'close-group)
12369 (gnus-group-real-name group) (nth 1 method))))
12371 (defun gnus-retrieve-headers (articles group &optional fetch-old)
12372 (let ((method (gnus-find-method-for-group group)))
12373 (if (and gnus-use-cache (numberp (car articles)))
12374 (gnus-cache-retrieve-headers articles group)
12375 (funcall (gnus-get-function method 'retrieve-headers)
12376 articles (gnus-group-real-name group) (nth 1 method)
12379 (defun gnus-retrieve-groups (groups method)
12380 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
12382 (defun gnus-request-article (article group &optional buffer)
12383 (let ((method (gnus-find-method-for-group group)))
12384 (funcall (gnus-get-function method 'request-article)
12385 article (gnus-group-real-name group) (nth 1 method) buffer)))
12387 (defun gnus-request-head (article group)
12388 (let ((method (gnus-find-method-for-group group)))
12389 (funcall (gnus-get-function method 'request-head)
12390 article (gnus-group-real-name group) (nth 1 method))))
12392 (defun gnus-request-body (article group)
12393 (let ((method (gnus-find-method-for-group group)))
12394 (funcall (gnus-get-function method 'request-body)
12395 article (gnus-group-real-name group) (nth 1 method))))
12397 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12398 (defun gnus-request-post-buffer (post group subject header artbuf
12399 info follow-to respect-poster)
12400 (let* ((info (or info (and group (nth 2 (gnus-gethash
12401 group gnus-newsrc-hashtb)))))
12403 (if (and gnus-post-method
12404 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12406 (format "%s" (car (gnus-find-method-for-group
12407 gnus-newsgroup-name)))
12408 gnus-valid-select-methods)))
12410 (gnus-find-method-for-group gnus-newsgroup-name))))
12411 (or (gnus-check-server method)
12412 (error "Can't open server %s:%s" (car method) (nth 1 method)))
12413 (let ((mail-self-blind nil)
12414 (mail-archive-file-name nil))
12415 (funcall (gnus-get-function method 'request-post-buffer)
12416 post group subject header artbuf info follow-to
12419 (defun gnus-request-post (method &optional force)
12420 (and (stringp method)
12421 (setq method (gnus-server-to-method method)))
12422 (and (not force) gnus-post-method
12423 (memq 'post (assoc (format "%s" (car method))
12424 gnus-valid-select-methods))
12425 (setq method gnus-post-method))
12426 (funcall (gnus-get-function method 'request-post)
12429 (defun gnus-request-scan (group method)
12430 (let ((method (if group (gnus-find-method-for-group group) method)))
12431 (funcall (gnus-get-function method 'request-scan)
12432 (and group (gnus-group-real-name group)) (nth 1 method))))
12434 (defun gnus-request-update-info (info method)
12435 (funcall (gnus-get-function method 'request-update-info)
12436 (gnus-group-real-name (car info)) info (nth 1 method)))
12438 (defun gnus-request-expire-articles (articles group &optional force)
12439 (let ((method (gnus-find-method-for-group group)))
12440 (funcall (gnus-get-function method 'request-expire-articles)
12441 articles (gnus-group-real-name group) (nth 1 method)
12444 (defun gnus-request-move-article
12445 (article group server accept-function &optional last)
12446 (let ((method (gnus-find-method-for-group group)))
12447 (funcall (gnus-get-function method 'request-move-article)
12448 article (gnus-group-real-name group)
12449 (nth 1 method) accept-function last)))
12451 (defun gnus-request-accept-article (group &optional last)
12452 (let ((func (if (symbolp group) group
12453 (car (gnus-find-method-for-group group)))))
12454 (funcall (intern (format "%s-request-accept-article" func))
12455 (if (stringp group) (gnus-group-real-name group) group)
12458 (defun gnus-request-replace-article (article group buffer)
12459 (let ((func (car (gnus-find-method-for-group group))))
12460 (funcall (intern (format "%s-request-replace-article" func))
12461 article (gnus-group-real-name group) buffer)))
12463 (defun gnus-request-create-group (group)
12464 (let ((method (gnus-find-method-for-group group)))
12465 (funcall (gnus-get-function method 'request-create-group)
12466 (gnus-group-real-name group) (nth 1 method))))
12468 (defun gnus-request-delete-group (group &optional force)
12469 (let ((method (gnus-find-method-for-group group)))
12470 (funcall (gnus-get-function method 'request-delete-group)
12471 (gnus-group-real-name group) force (nth 1 method))))
12473 (defun gnus-request-rename-group (group new-name)
12474 (let ((method (gnus-find-method-for-group group)))
12475 (funcall (gnus-get-function method 'request-rename-group)
12476 (gnus-group-real-name group)
12477 (gnus-group-real-name new-name) (nth 1 method))))
12479 (defun gnus-member-of-valid (symbol group)
12480 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
12481 (memq symbol (assoc
12482 (format "%s" (car (gnus-find-method-for-group group)))
12483 gnus-valid-select-methods)))
12485 (defun gnus-secondary-method-p (method)
12486 "Return whether METHOD is a secondary select method."
12487 (let ((methods gnus-secondary-select-methods)
12488 (gmethod (gnus-server-get-method nil method)))
12489 (while (and methods
12490 (not (equal (gnus-server-get-method nil (car methods))
12492 (setq methods (cdr methods)))
12495 (defun gnus-find-method-for-group (group &optional info)
12496 "Find the select method that GROUP uses."
12497 (or gnus-override-method
12499 gnus-select-method)
12500 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
12503 (not (setq method (nth 4 info))))
12504 (setq method gnus-select-method)
12506 (cond ((stringp method)
12507 (gnus-server-to-method method))
12508 ((stringp (car method))
12509 (gnus-server-extend-method group method))
12512 (gnus-server-add-address method))))
12514 (defun gnus-check-backend-function (func group)
12515 "Check whether GROUP supports function FUNC."
12516 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
12518 (fboundp (intern (format "%s-%s" method func)))))
12520 (defun gnus-methods-using (feature)
12521 "Find all methods that have FEATURE."
12522 (let ((valids gnus-valid-select-methods)
12525 (if (memq feature (car valids))
12526 (setq outs (cons (car valids) outs)))
12527 (setq valids (cdr valids)))
12531 ;;; Active & Newsrc File Handling
12534 ;; Newsrc related functions.
12535 ;; Gnus internal format of gnus-newsrc-alist:
12536 ;; (("alt.general" 3 (1 . 1))
12537 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
12538 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
12539 ;; The first item is the group name; the second is the subscription
12540 ;; level; the third is either a range of a list of ranges of read
12541 ;; articles, the optional fourth element is a list of marked articles,
12542 ;; the optional fifth element is the select method.
12544 ;; Gnus internal format of gnus-newsrc-hashtb:
12545 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12546 ;; This is the entry for "alt.misc". The first element is the number
12547 ;; of unread articles in "alt.misc". The cdr of this entry is the
12548 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
12549 ;; trivial to remove or add new elements into gnus-newsrc-alist
12550 ;; without scanning the entire list. So, to get the actual information
12551 ;; of "alt.misc", you'd say something like
12552 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12554 ;; Gnus internal format of gnus-active-hashtb:
12558 ;; The only element in each entry in this hash table is a range of
12559 ;; (possibly) available articles. (Articles in this range may have
12560 ;; been expired or canceled.)
12562 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12563 ;; ("alt.misc" "alt.test" "alt.general" ...)
12565 (defun gnus-setup-news (&optional rawfile level)
12566 "Setup news information.
12567 If RAWFILE is non-nil, the .newsrc file will also be read.
12568 If LEVEL is non-nil, the news will be set up at level LEVEL."
12569 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
12570 ;; Clear some variables to re-initialize news information.
12571 (if init (setq gnus-newsrc-alist nil
12572 gnus-active-hashtb nil))
12574 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12575 (if init (gnus-read-newsrc-file rawfile))
12577 ;; If we don't read the complete active file, we fill in the
12579 (if (or (null gnus-read-active-file)
12580 (eq gnus-read-active-file 'some))
12581 (gnus-update-active-hashtb-from-killed))
12583 ;; Read the active file and create `gnus-active-hashtb'.
12584 ;; If `gnus-read-active-file' is nil, then we just create an empty
12585 ;; hash table. The partial filling out of the hash table will be
12586 ;; done in `gnus-get-unread-articles'.
12587 (and gnus-read-active-file
12589 (gnus-read-active-file))
12591 (or gnus-active-hashtb
12592 (setq gnus-active-hashtb (make-vector 4095 0)))
12594 ;; Possibly eval the dribble file.
12595 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
12597 (gnus-update-format-specifications)
12599 ;; Find new newsgroups and treat them.
12600 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12601 (gnus-server-opened gnus-select-method))
12602 (gnus-find-new-newsgroups))
12604 ;; Find the number of unread articles in each non-dead group.
12605 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
12606 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
12608 (if (and init gnus-check-bogus-newsgroups
12609 gnus-read-active-file (not level)
12610 (gnus-server-opened gnus-select-method))
12611 (gnus-check-bogus-newsgroups))))
12613 (defun gnus-find-new-newsgroups ()
12614 "Search for new newsgroups and add them.
12615 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12616 The `-n' option line from .newsrc is respected."
12618 (or (gnus-check-first-time-used)
12619 (if (or (consp gnus-check-new-newsgroups)
12620 (eq gnus-check-new-newsgroups 'ask-server))
12621 (gnus-ask-server-for-new-groups)
12623 group new-newsgroups)
12624 (gnus-message 5 "Looking for new newsgroups...")
12625 (or gnus-have-read-active-file (gnus-read-active-file))
12626 (setq gnus-newsrc-last-checked-date (current-time-string))
12627 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12628 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12629 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12632 (if (or (null (setq group (symbol-name sym)))
12633 (null (symbol-value sym))
12634 (gnus-gethash group gnus-killed-hashtb)
12635 (gnus-gethash group gnus-newsrc-hashtb))
12637 (let ((do-sub (gnus-matches-options-n group)))
12639 ((eq do-sub 'subscribe)
12640 (setq groups (1+ groups))
12641 (gnus-sethash group group gnus-killed-hashtb)
12642 (funcall gnus-subscribe-options-newsgroup-method group))
12643 ((eq do-sub 'ignore)
12646 (setq groups (1+ groups))
12647 (gnus-sethash group group gnus-killed-hashtb)
12648 (if gnus-subscribe-hierarchical-interactive
12649 (setq new-newsgroups (cons group new-newsgroups))
12650 (funcall gnus-subscribe-newsgroup-method group)))))))
12651 gnus-active-hashtb)
12653 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12654 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12656 (gnus-message 6 "%d new newsgroup%s arrived."
12657 groups (if (> groups 1) "s have" " has"))
12658 (gnus-message 6 "No new newsgroups."))))))
12660 (defun gnus-matches-options-n (group)
12661 ;; Returns `subscribe' if the group is to be uncoditionally
12662 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12663 ;; no match for the group.
12665 ;; First we check the two user variables.
12667 ((and gnus-options-subscribe
12668 (string-match gnus-options-subscribe group))
12670 ((and gnus-auto-subscribed-groups
12671 (string-match gnus-auto-subscribed-groups group))
12673 ((and gnus-options-not-subscribe
12674 (string-match gnus-options-not-subscribe group))
12676 ;; Then we go through the list that was retrieved from the .newsrc
12677 ;; file. This list has elements on the form
12678 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12679 ;; is in the reverse order of the options line) is returned.
12681 (let ((regs gnus-newsrc-options-n))
12683 (not (string-match (car (car regs)) group)))
12684 (setq regs (cdr regs)))
12685 (and regs (cdr (car regs)))))))
12687 (defun gnus-ask-server-for-new-groups ()
12688 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12689 (methods (cons gnus-select-method
12691 (and (consp gnus-check-new-newsgroups)
12692 gnus-check-new-newsgroups)
12693 gnus-secondary-select-methods)))
12695 (new-date (current-time-string))
12696 (hashtb (gnus-make-hashtable 100))
12697 group new-newsgroups got-new method)
12698 ;; Go through both primary and secondary select methods and
12699 ;; request new newsgroups.
12701 (setq method (gnus-server-get-method nil (car methods)))
12702 (and (gnus-check-server method)
12703 (gnus-request-newgroups date method)
12706 (set-buffer nntp-server-buffer)
12707 ;; Enter all the new groups in a hashtable.
12708 (gnus-active-to-gnus-format method hashtb 'ignore)))
12709 (setq methods (cdr methods)))
12710 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12711 ;; Now all new groups from all select methods are in `hashtb'.
12713 (lambda (group-sym)
12714 (setq group (symbol-name group-sym))
12715 (if (or (null group)
12716 (null (symbol-value group-sym))
12717 (gnus-gethash group gnus-newsrc-hashtb)
12718 (member group gnus-zombie-list)
12719 (member group gnus-killed-list))
12720 ;; The group is already known.
12722 (and (symbol-value group-sym)
12723 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
12724 (let ((do-sub (gnus-matches-options-n group)))
12725 (cond ((eq do-sub 'subscribe)
12726 (setq groups (1+ groups))
12727 (gnus-sethash group group gnus-killed-hashtb)
12729 gnus-subscribe-options-newsgroup-method group))
12730 ((eq do-sub 'ignore)
12733 (setq groups (1+ groups))
12734 (gnus-sethash group group gnus-killed-hashtb)
12735 (if gnus-subscribe-hierarchical-interactive
12736 (setq new-newsgroups (cons group new-newsgroups))
12737 (funcall gnus-subscribe-newsgroup-method group)))))))
12740 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12741 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12743 (gnus-message 6 "%d new newsgroup%s arrived."
12744 groups (if (> groups 1) "s have" " has")))
12747 (defun gnus-check-first-time-used ()
12748 (if (or (> (length gnus-newsrc-alist) 1)
12749 (file-exists-p gnus-startup-file)
12750 (file-exists-p (concat gnus-startup-file ".el"))
12751 (file-exists-p (concat gnus-startup-file ".eld")))
12753 (gnus-message 6 "First time user; subscribing you to default groups")
12754 (or gnus-have-read-active-file (gnus-read-active-file))
12755 (setq gnus-newsrc-last-checked-date (current-time-string))
12756 (let ((groups gnus-default-subscribed-newsgroups)
12760 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12763 (if (null (setq group (symbol-name sym)))
12765 (let ((do-sub (gnus-matches-options-n group)))
12767 ((eq do-sub 'subscribe)
12768 (gnus-sethash group group gnus-killed-hashtb)
12769 (funcall gnus-subscribe-options-newsgroup-method group))
12770 ((eq do-sub 'ignore)
12773 (setq gnus-killed-list (cons group gnus-killed-list)))))))
12774 gnus-active-hashtb)
12776 (if (gnus-gethash (car groups) gnus-active-hashtb)
12777 (gnus-group-change-level
12778 (car groups) gnus-level-default-subscribed gnus-level-killed))
12779 (setq groups (cdr groups)))
12780 (gnus-group-make-help-group)
12781 (and gnus-novice-user
12782 (gnus-message 7 "`A k' to list killed groups"))))))
12784 (defun gnus-subscribe-group (group previous &optional method)
12785 (gnus-group-change-level
12787 (list t group gnus-level-default-subscribed nil nil method)
12789 gnus-level-default-subscribed gnus-level-killed previous t))
12791 ;; `gnus-group-change-level' is the fundamental function for changing
12792 ;; subscription levels of newsgroups. This might mean just changing
12793 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12794 ;; again, which subscribes/unsubscribes a group, which is equally
12795 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12796 ;; from 8-9 to 1-7 means that you remove the group from the list of
12797 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12798 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12799 ;; which is trivial.
12800 ;; ENTRY can either be a string (newsgroup name) or a list (if
12801 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12802 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12804 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12805 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12807 (defun gnus-group-change-level (entry level &optional oldlevel
12808 previous fromkilled)
12809 (let (group info active num)
12810 ;; Glean what info we can from the arguments
12812 (if fromkilled (setq group (nth 1 entry))
12813 (setq group (car (nth 2 entry))))
12814 (setq group entry))
12815 (if (and (stringp entry)
12817 (< oldlevel gnus-level-zombie))
12818 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12819 (if (and (not oldlevel)
12821 (setq oldlevel (car (cdr (nth 2 entry)))))
12822 (if (stringp previous)
12823 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12825 (if (and (>= oldlevel gnus-level-zombie)
12826 (gnus-gethash group gnus-newsrc-hashtb))
12827 ;; We are trying to subscribe a group that is already
12831 (gnus-dribble-enter
12832 (format "(gnus-group-change-level %S %S %S %S %S)"
12833 group level oldlevel (car (nth 2 previous)) fromkilled))
12835 ;; Then we remove the newgroup from any old structures, if needed.
12836 ;; If the group was killed, we remove it from the killed or zombie
12837 ;; list. If not, and it is in fact going to be killed, we remove
12838 ;; it from the newsrc hash table and assoc.
12839 (cond ((>= oldlevel gnus-level-zombie)
12840 (if (= oldlevel gnus-level-zombie)
12841 (setq gnus-zombie-list (delete group gnus-zombie-list))
12842 (setq gnus-killed-list (delete group gnus-killed-list))))
12844 (if (and (>= level gnus-level-zombie)
12847 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
12849 (setcdr (gnus-gethash (car (nth 3 entry))
12850 gnus-newsrc-hashtb)
12852 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12854 ;; Finally we enter (if needed) the list where it is supposed to
12855 ;; go, and change the subscription level. If it is to be killed,
12856 ;; we enter it into the killed or zombie list.
12857 (cond ((>= level gnus-level-zombie)
12858 ;; Remove from the hash table.
12859 (gnus-sethash group nil gnus-newsrc-hashtb)
12860 (or (gnus-group-foreign-p group)
12861 ;; We do not enter foreign groups into the list of dead
12863 (if (= level gnus-level-zombie)
12864 (setq gnus-zombie-list (cons group gnus-zombie-list))
12865 (setq gnus-killed-list (cons group gnus-killed-list)))))
12867 ;; If the list is to be entered into the newsrc assoc, and
12868 ;; it was killed, we have to create an entry in the newsrc
12869 ;; hashtb format and fix the pointers in the newsrc assoc.
12870 (if (>= oldlevel gnus-level-zombie)
12874 (setq info (cdr entry))
12875 (setq num (car entry)))
12876 (setq active (gnus-gethash group gnus-active-hashtb))
12878 (if active (- (1+ (cdr active)) (car active)) t))
12879 ;; Check whether the group is foreign. If so, the
12880 ;; foreign select method has to be entered into the
12882 (let ((method (gnus-group-method-name group)))
12883 (if (eq method gnus-select-method)
12884 (setq info (list group level nil))
12885 (setq info (list group level nil nil method)))))
12888 (let ((p gnus-newsrc-alist))
12889 (while (cdr (cdr p))
12892 (setq entry (cons info (cdr (cdr previous))))
12895 (setcdr (cdr previous) entry)
12896 (gnus-sethash group (cons num (cdr previous))
12897 gnus-newsrc-hashtb))
12898 (setcdr previous entry)
12899 (gnus-sethash group (cons num previous)
12900 gnus-newsrc-hashtb))
12902 (setcdr (gnus-gethash (car (car (cdr entry)))
12903 gnus-newsrc-hashtb)
12905 ;; It was alive, and it is going to stay alive, so we
12906 ;; just change the level and don't change any pointers or
12907 ;; hash table entries.
12908 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
12910 (defun gnus-kill-newsgroup (newsgroup)
12911 "Obsolete function. Kills a newsgroup."
12912 (gnus-group-change-level
12913 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
12915 (defun gnus-check-bogus-newsgroups (&optional confirm)
12916 "Remove bogus newsgroups.
12917 If CONFIRM is non-nil, the user has to confirm the deletion of every
12919 (let ((newsrc (cdr gnus-newsrc-alist))
12921 (gnus-message 5 "Checking bogus newsgroups...")
12922 (or gnus-have-read-active-file (gnus-read-active-file))
12923 ;; Find all bogus newsgroup that are subscribed.
12925 (setq group (car (car newsrc)))
12926 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
12927 (nth 4 (car newsrc)) ; Foreign
12929 (not (gnus-y-or-n-p
12930 (format "Remove bogus newsgroup: %s " group)))))
12933 ;; Found a bogus newsgroup.
12934 (setq bogus (cons group bogus)))
12935 (setq newsrc (cdr newsrc)))
12936 ;; Remove all bogus subscribed groups by first killing them, and
12937 ;; then removing them from the list of killed groups.
12939 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12941 (gnus-group-change-level entry gnus-level-killed)
12942 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12943 (setq bogus (cdr bogus)))
12944 ;; Then we remove all bogus groups from the list of killed and
12945 ;; zombie groups. They are are removed without confirmation.
12946 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12949 (setq killed (symbol-value (car dead-lists)))
12951 (setq group (car killed))
12952 (or (gnus-gethash group gnus-active-hashtb)
12953 ;; The group is bogus.
12954 (set (car dead-lists)
12955 (delete group (symbol-value (car dead-lists)))))
12956 (setq killed (cdr killed)))
12957 (setq dead-lists (cdr dead-lists))))
12958 (gnus-message 5 "Checking bogus newsgroups...done")))
12960 (defun gnus-check-duplicate-killed-groups ()
12961 "Remove duplicates from the list of killed groups."
12963 (let ((killed gnus-killed-list))
12965 (gnus-message 9 "%d" (length killed))
12966 (setcdr killed (delete (car killed) (cdr killed)))
12967 (setq killed (cdr killed)))))
12969 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12970 ;; and compute how many unread articles there are in each group.
12971 (defun gnus-get-unread-articles (&optional level)
12972 (let* ((newsrc (cdr gnus-newsrc-alist))
12973 (level (or level (1+ gnus-level-subscribed)))
12976 (cond ((and gnus-activate-foreign-newsgroups
12977 (not (numberp gnus-activate-foreign-newsgroups)))
12978 (1+ gnus-level-subscribed))
12979 ((numberp gnus-activate-foreign-newsgroups)
12980 gnus-activate-foreign-newsgroups)
12984 (fboundp (intern (format "%s-request-update-info"
12985 (car gnus-select-method)))))
12986 info group active virtuals method fmethod)
12987 (gnus-message 5 "Checking new news...")
12990 (setq info (car newsrc)
12992 active (gnus-gethash group gnus-active-hashtb))
12994 ;; Check newsgroups. If the user doesn't want to check them, or
12995 ;; they can't be checked (for instance, if the news server can't
12996 ;; be reached) we just set the number of unread articles in this
12997 ;; newsgroup to t. This means that Gnus thinks that there are
12998 ;; unread articles, but it has no idea how many.
12999 (if (and (setq method (nth 4 info))
13000 (not (gnus-server-equal
13003 (setq fmethod (gnus-server-get-method nil method))
13004 ;; We do this here because it would be awkward
13005 ;; to do it anywhere else. Hell, it's pretty
13006 ;; awkward here as well, but at least it's
13007 ;; reasonable efficient.
13008 (and (fboundp (intern (format "%s-request-update-info"
13010 (<= (nth 1 info) foreign-level)
13011 (gnus-request-update-info info method)))))
13012 (not (gnus-secondary-method-p method)))
13013 ;; These groups are foreign. Check the level.
13014 (if (<= (nth 1 info) foreign-level)
13015 (setq active (gnus-activate-group (car info) 'scan)))
13017 ;; These groups are native or secondary.
13018 (if (<= (nth 1 info) level)
13020 (if (and update (not method))
13022 ;; Allow updating of native groups as well, even
13023 ;; though that's pretty unlikely.
13024 (gnus-request-update-info info gnus-select-method)
13025 (setq active (gnus-activate-group (car info) 'scan)))
13026 (or gnus-read-active-file
13027 (setq active (gnus-activate-group (car info) 'scan)))))))
13030 (gnus-get-unread-articles-in-group info active)
13031 ;; The group couldn't be reached, so we nix out the number of
13032 ;; unread articles and stuff.
13033 (gnus-sethash group nil gnus-active-hashtb)
13034 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
13036 (setq newsrc (cdr newsrc)))
13038 (gnus-message 5 "Checking new news...done")))
13040 ;; Create a hash table out of the newsrc alist. The `car's of the
13041 ;; alist elements are used as keys.
13042 (defun gnus-make-hashtable-from-newsrc-alist ()
13043 (let ((alist gnus-newsrc-alist)
13044 (ohashtb gnus-newsrc-hashtb)
13046 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
13048 (setq prev (setq gnus-newsrc-alist
13049 (if (equal (car (car gnus-newsrc-alist))
13052 (cons (list "dummy.group" 0 nil) alist)))))
13054 (gnus-sethash (car (car alist))
13055 (cons (and ohashtb (car (gnus-gethash
13056 (car (car alist)) ohashtb)))
13057 prev) gnus-newsrc-hashtb)
13059 alist (cdr alist)))))
13061 (defun gnus-make-hashtable-from-killed ()
13062 "Create a hash table from the killed and zombie lists."
13063 (let ((lists '(gnus-killed-list gnus-zombie-list))
13065 (setq gnus-killed-hashtb
13066 (gnus-make-hashtable
13067 (+ (length gnus-killed-list) (length gnus-zombie-list))))
13069 (setq list (symbol-value (car lists)))
13070 (setq lists (cdr lists))
13072 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
13073 (setq list (cdr list))))))
13075 (defun gnus-get-unread-articles-in-group (info active)
13076 (let* ((range (nth 2 info))
13078 (marked (nth 3 info)))
13079 ;; If a cache is present, we may have to alter the active info.
13080 (and gnus-use-cache
13081 (gnus-cache-possibly-alter-active (car info) active))
13082 ;; Modify the list of read articles according to what articles
13083 ;; are available; then tally the unread articles and add the
13084 ;; number to the group hash table entry.
13086 ((zerop (cdr active))
13089 (setq num (- (1+ (cdr active)) (car active))))
13090 ((not (listp (cdr range)))
13091 ;; Fix a single (num . num) range according to the
13092 ;; active hash table.
13093 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
13094 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
13095 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
13096 ;; Compute number of unread articles.
13097 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
13099 ;; The read list is a list of ranges. Fix them according to
13100 ;; the active hash table.
13101 ;; First peel off any elements that are below the lower
13103 (while (and (cdr range)
13105 (or (and (atom (car (cdr range))) (car (cdr range)))
13106 (car (car (cdr range))))))
13107 (if (numberp (car range))
13110 (or (and (numberp (car (cdr range)))
13112 (cdr (car (cdr range))))))
13113 (setcdr (car range)
13114 (or (and (numberp (nth 1 range)) (nth 1 range))
13115 (cdr (car (cdr range))))))
13116 (setcdr range (cdr (cdr range))))
13117 ;; Adjust the first element to be the same as the lower limit.
13118 (if (and (not (atom (car range)))
13119 (< (cdr (car range)) (car active)))
13120 (setcdr (car range) (1- (car active))))
13121 ;; Then we want to peel off any elements that are higher
13122 ;; than the upper active limit.
13123 (let ((srange range))
13124 ;; Go past all legal elements.
13125 (while (and (cdr srange)
13126 (<= (or (and (atom (car (cdr srange)))
13127 (car (cdr srange)))
13128 (car (car (cdr srange)))) (cdr active)))
13129 (setq srange (cdr srange)))
13131 ;; Nuke all remaining illegal elements.
13132 (setcdr srange nil))
13134 ;; Adjust the final element.
13135 (if (and (not (atom (car srange)))
13136 (> (cdr (car srange)) (cdr active)))
13137 (setcdr (car srange) (cdr active))))
13138 ;; Compute the number of unread articles.
13140 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
13141 (cdr (car range))))
13142 (or (and (atom (car range)) (car range))
13143 (car (car range))))))
13144 (setq range (cdr range)))
13145 (setq num (max 0 (- (cdr active) num)))))
13148 (and (assq 'tick marked)
13149 (inline (gnus-remove-illegal-marked-articles
13150 (assq 'tick marked) (nth 2 info))))
13151 (and (assq 'dormant marked)
13152 (inline (gnus-remove-illegal-marked-articles
13153 (assq 'dormant marked) (nth 2 info))))
13155 (gnus-gethash (car info) gnus-newsrc-hashtb)
13156 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
13157 (length (cdr (assq 'dormant marked)))))))))
13160 (defun gnus-remove-illegal-marked-articles (marked ranges)
13161 (let ((m (cdr marked)))
13162 ;; Make sure that all ticked articles are a subset of the unread
13165 (if (gnus-member-of-range (car m) ranges)
13166 (setcdr marked (cdr m))
13168 (setq m (cdr m)))))
13170 (defun gnus-activate-group (group &optional scan)
13171 ;; Check whether a group has been activated or not.
13172 ;; If SCAN, request a scan of that group as well.
13173 (let ((method (gnus-find-method-for-group group))
13175 (and (gnus-check-server method)
13176 ;; We escape all bugs and quit here to make it possible to
13177 ;; continue if a group is so out-there that it reports bugs
13181 (gnus-check-backend-function 'request-scan (car method))
13182 (gnus-request-scan group method))
13185 (gnus-request-group group)
13189 (set-buffer nntp-server-buffer)
13190 (goto-char (point-min))
13191 ;; Parse the result we got from `gnus-request-group'.
13192 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
13194 (goto-char (match-beginning 1))
13196 group (setq active (cons (read (current-buffer))
13197 (read (current-buffer))))
13198 gnus-active-hashtb)
13199 ;; Return the new active info.
13202 (defun gnus-update-read-articles
13203 (group unread unselected ticked &optional domarks replied expirable killed
13204 dormant bookmark score)
13205 "Update the list of read and ticked articles in GROUP using the
13206 UNREAD and TICKED lists.
13207 Note: UNSELECTED has to be sorted over `<'.
13208 Returns whether the updating was successful."
13209 (let* ((active (or gnus-newsgroup-active
13210 (gnus-gethash group gnus-active-hashtb)))
13211 (entry (gnus-gethash group gnus-newsrc-hashtb))
13212 (info (nth 2 entry))
13213 (marked (nth 3 info))
13215 (unread (sort (copy-sequence unread) (function <)))
13217 (if (or (not info) (not active))
13218 ;; There is no info on this group if it was, in fact,
13219 ;; killed. Gnus stores no information on killed groups, so
13220 ;; there's nothing to be done.
13221 ;; One could store the information somewhere temporarily,
13222 ;; perhaps... Hmmm...
13224 ;; Remove any negative articles numbers.
13225 (while (and unread (< (car unread) 0))
13226 (setq unread (cdr unread)))
13227 ;; Remove any expired article numbers
13228 (while (and unread (< (car unread) (car active)))
13229 (setq unread (cdr unread)))
13230 (while (and ticked (< (car ticked) (car active)))
13231 (setq ticked (cdr ticked)))
13232 (while (and dormant (< (car dormant) (car active)))
13233 (setq dormant (cdr dormant)))
13234 (setq unread (sort (append unselected unread) '<))
13235 ;; Compute the ranges of read articles by looking at the list of
13236 ;; unread articles.
13238 (if (/= (car unread) prev)
13239 (setq read (cons (if (= prev (1- (car unread))) prev
13240 (cons prev (1- (car unread)))) read)))
13241 (setq prev (1+ (car unread)))
13242 (setq unread (cdr unread)))
13243 (if (<= prev (cdr active))
13244 (setq read (cons (cons prev (cdr active)) read)))
13245 ;; Enter this list into the group info.
13246 (setcar (cdr (cdr info))
13247 (if (> (length read) 1) (nreverse read) read))
13248 ;; Enter the list of ticked articles.
13249 (gnus-set-marked-articles
13251 (if domarks replied (cdr (assq 'reply marked)))
13252 (if domarks expirable (cdr (assq 'expire marked)))
13253 (if domarks killed (cdr (assq 'killed marked)))
13254 (if domarks dormant (cdr (assq 'dormant marked)))
13255 (if domarks bookmark (cdr (assq 'bookmark marked)))
13256 (if domarks score (cdr (assq 'score marked))))
13257 ;; Set the number of unread articles in gnus-newsrc-hashtb.
13258 (gnus-get-unread-articles-in-group
13259 info (gnus-gethash group gnus-active-hashtb))
13262 (defun gnus-make-articles-unread (group articles)
13263 "Mark ARTICLES in GROUP as unread."
13264 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
13265 (gnus-gethash (gnus-group-real-name group)
13266 gnus-newsrc-hashtb))))
13267 (ranges (nth 2 info))
13270 (and (gnus-member-of-range (car articles) ranges)
13271 (setq news (cons (car articles) news)))
13272 (setq articles (cdr articles)))
13275 (setcar (nthcdr 2 info)
13276 (gnus-remove-from-range (nth 2 info) (nreverse news)))
13277 (gnus-group-update-group group t))))
13279 ;; Enter all dead groups into the hashtb.
13280 (defun gnus-update-active-hashtb-from-killed ()
13281 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
13282 (lists (list gnus-killed-list gnus-zombie-list))
13285 (setq killed (car lists))
13287 (gnus-sethash (car killed) nil hashtb)
13288 (setq killed (cdr killed)))
13289 (setq lists (cdr lists)))))
13291 ;; Get the active file(s) from the backend(s).
13292 (defun gnus-read-active-file ()
13293 (gnus-group-set-mode-line)
13294 (let ((methods (if (gnus-check-server gnus-select-method)
13295 ;; The native server is available.
13296 (cons gnus-select-method gnus-secondary-select-methods)
13297 ;; The native server is down, so we just do the
13299 gnus-secondary-select-methods))
13301 (setq gnus-have-read-active-file nil)
13303 (set-buffer nntp-server-buffer)
13305 (let* ((method (gnus-server-get-method nil (car methods)))
13306 (where (nth 1 method))
13307 (mesg (format "Reading active file%s via %s..."
13308 (if (and where (not (zerop (length where))))
13309 (concat " from " where) "")
13311 (gnus-message 5 mesg)
13312 (if (not (gnus-check-server method))
13314 ;; Request that the backend scan its incoming messages.
13315 (and (gnus-check-backend-function 'request-scan (car method))
13316 (gnus-request-scan nil method))
13318 ((and (eq gnus-read-active-file 'some)
13319 (gnus-check-backend-function 'retrieve-groups (car method)))
13320 (let ((newsrc (cdr gnus-newsrc-alist))
13321 (gmethod (gnus-server-get-method nil method))
13324 (and (gnus-server-equal
13325 (gnus-find-method-for-group
13326 (car (car newsrc)) (car newsrc))
13328 (setq groups (cons (gnus-group-real-name
13329 (car (car newsrc))) groups)))
13330 (setq newsrc (cdr newsrc)))
13331 (gnus-check-server method)
13332 (setq list-type (gnus-retrieve-groups groups method))
13336 1 "Cannot read partial active file from %s server."
13340 ((eq list-type 'active)
13341 (gnus-active-to-gnus-format method gnus-active-hashtb))
13343 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
13345 (if (not (gnus-request-list method))
13347 (gnus-message 1 "Cannot read active file from %s server."
13350 (gnus-active-to-gnus-format method)
13351 ;; We mark this active file as read.
13352 (setq gnus-have-read-active-file
13353 (cons method gnus-have-read-active-file))
13354 (gnus-message 5 "%sdone" mesg))))))
13355 (setq methods (cdr methods))))))
13357 ;; Read an active file and place the results in `gnus-active-hashtb'.
13358 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
13359 (let ((cur (current-buffer))
13361 (if (and gnus-active-hashtb
13362 (not (equal method gnus-select-method)))
13364 (setq gnus-active-hashtb
13365 (if (equal method gnus-select-method)
13366 (gnus-make-hashtable
13367 (count-lines (point-min) (point-max)))
13368 (gnus-make-hashtable 4096))))))
13369 (flag-hashtb (gnus-make-hashtable 60)))
13370 ;; Delete unnecessary lines.
13371 (goto-char (point-min))
13372 (while (search-forward "\nto." nil t)
13373 (delete-region (1+ (match-beginning 0))
13374 (progn (forward-line 1) (point))))
13375 (or (string= gnus-ignored-newsgroups "")
13377 (goto-char (point-min))
13378 (delete-matching-lines gnus-ignored-newsgroups)))
13379 ;; Make the group names readable as a lisp expression even if they
13380 ;; contain special characters.
13381 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
13382 (goto-char (point-max))
13383 (while (re-search-backward "[][';?()#]" nil t)
13385 ;; If these are groups from a foreign select method, we insert the
13386 ;; group prefix in front of the group names.
13387 (and method (not (gnus-server-equal
13388 (gnus-server-get-method nil method)
13389 (gnus-server-get-method nil gnus-select-method)))
13390 (let ((prefix (gnus-group-prefixed-name "" method)))
13391 (goto-char (point-min))
13392 (while (and (not (eobp))
13393 (progn (insert prefix)
13394 (zerop (forward-line 1)))))))
13395 ;; Store the active file in a hash table.
13396 (goto-char (point-min))
13397 (if (string-match "%[oO]" gnus-group-line-format)
13398 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
13399 ;; If we want information on moderated groups, we use this
13401 (let* ((mod-hashtb (make-vector 7 0))
13402 (m (intern "m" mod-hashtb))
13404 (while (not (eobp))
13405 (condition-case nil
13407 (narrow-to-region (point) (gnus-point-at-eol))
13408 (setq group (let ((obarray hashtb)) (read cur)))
13409 (if (and (numberp (setq max (read cur)))
13410 (numberp (setq min (read cur)))
13412 (skip-chars-forward " \t")
13414 (or (= (following-char) ?=)
13415 (= (following-char) ?x)
13416 (= (following-char) ?j)))))
13417 (set group (cons min max))
13419 ;; Enter moderated groups into a list.
13420 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
13421 (setq gnus-moderated-list
13422 (cons (symbol-name group) gnus-moderated-list))))
13429 ;; And if we do not care about moderation, we use this loop,
13430 ;; which is faster.
13431 (let (group max min)
13432 (while (not (eobp))
13435 (narrow-to-region (point) (gnus-point-at-eol))
13436 ;; group gets set to a symbol interned in the hash table
13437 ;; (what a hack!!) - jwz
13438 (setq group (let ((obarray hashtb)) (read cur)))
13439 (if (and (numberp (setq max (read cur)))
13440 (numberp (setq min (read cur)))
13442 (skip-chars-forward " \t")
13444 (or (= (following-char) ?=)
13445 (= (following-char) ?x)
13446 (= (following-char) ?j)))))
13447 (set group (cons min max))
13455 (gnus-message 3 "Warning - illegal active: %s"
13457 (gnus-point-at-bol) (gnus-point-at-eol)))))))
13459 (forward-line 1))))))
13461 (defun gnus-groups-to-gnus-format (method &optional hashtb)
13462 ;; Parse a "groups" active file.
13463 (let ((cur (current-buffer))
13465 (if (and method gnus-active-hashtb)
13467 (setq gnus-active-hashtb
13468 (gnus-make-hashtable
13469 (count-lines (point-min) (point-max)))))))
13470 (prefix (and method
13471 (not (gnus-server-equal
13472 (gnus-server-get-method nil method)
13473 (gnus-server-get-method nil gnus-select-method)))
13474 (gnus-group-prefixed-name "" method))))
13476 (goto-char (point-min))
13477 ;; We split this into to separate loops, one with the prefix
13478 ;; and one without to speed the reading up somewhat.
13480 (let (min max opoint group)
13481 (while (not (eobp))
13484 (read cur) (read cur)
13485 (setq min (read cur)
13488 (skip-chars-forward " \t")
13491 (set (let ((obarray hashtb)) (read cur))
13493 (error (and group (symbolp group) (set group nil))))
13495 (let (min max group)
13496 (while (not (eobp))
13498 (if (= (following-char) ?2)
13500 (read cur) (read cur)
13501 (setq min (read cur)
13503 (set (setq group (let ((obarray hashtb)) (read cur)))
13505 (error (and group (symbolp group) (set group nil))))
13506 (forward-line 1))))))
13508 (defun gnus-read-newsrc-file (&optional force)
13509 "Read startup file.
13510 If FORCE is non-nil, the .newsrc file is read."
13511 ;; Reset variables that might be defined in the .newsrc.eld file.
13512 (let ((variables gnus-variable-list))
13514 (set (car variables) nil)
13515 (setq variables (cdr variables))))
13516 (let* ((newsrc-file gnus-current-startup-file)
13517 (quick-file (concat newsrc-file ".el")))
13519 ;; We always load the .newsrc.eld file. If always contains
13520 ;; much information that can not be gotten from the .newsrc
13521 ;; file (ticked articles, killed groups, foreign methods, etc.)
13522 (gnus-read-newsrc-el-file quick-file)
13525 (and (file-newer-than-file-p newsrc-file quick-file)
13526 (file-newer-than-file-p newsrc-file
13527 (concat quick-file "d")))
13528 (not gnus-newsrc-alist))
13529 ;; We read the .newsrc file. Note that if there if a
13530 ;; .newsrc.eld file exists, it has already been read, and
13531 ;; the `gnus-newsrc-hashtb' has been created. While reading
13532 ;; the .newsrc file, Gnus will only use the information it
13533 ;; can find there for changing the data already read -
13534 ;; ie. reading the .newsrc file will not trash the data
13535 ;; already read (except for read articles).
13537 (gnus-message 5 "Reading %s..." newsrc-file)
13538 (set-buffer (find-file-noselect newsrc-file))
13539 (buffer-disable-undo (current-buffer))
13540 (gnus-newsrc-to-gnus-format)
13541 (kill-buffer (current-buffer))
13542 (gnus-message 5 "Reading %s...done" newsrc-file)))
13544 ;; Read any slave files.
13546 (gnus-master-read-slave-newsrc)))))
13548 (defun gnus-read-newsrc-el-file (file)
13549 (let ((ding-file (concat file "d")))
13550 ;; We always, always read the .eld file.
13551 (gnus-message 5 "Reading %s..." ding-file)
13552 (let (gnus-newsrc-assoc)
13553 (condition-case nil
13554 (load ding-file t t t)
13556 (gnus-message 1 "Error in %s" ding-file)
13558 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
13559 (let ((inhibit-quit t))
13560 (gnus-uncompress-newsrc-alist))
13561 (gnus-make-hashtable-from-newsrc-alist)
13562 (if (not (file-newer-than-file-p file ding-file))
13564 ;; Old format quick file
13565 (gnus-message 5 "Reading %s..." file)
13566 ;; The .el file is newer than the .eld file, so we read that one
13568 (gnus-read-old-newsrc-el-file file))))
13570 ;; Parse the old-style quick startup file
13571 (defun gnus-read-old-newsrc-el-file (file)
13572 (let (newsrc killed marked group m)
13574 (let ((gnus-killed-assoc nil)
13575 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
13577 (condition-case nil
13580 (setq newsrc gnus-newsrc-assoc
13581 killed gnus-killed-assoc
13582 marked gnus-marked-assoc)))
13583 (setq gnus-newsrc-alist nil)
13585 (setq group (car newsrc))
13586 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13589 (setcar (nthcdr 2 info) (cdr (cdr group)))
13591 (if (nth 1 group) gnus-level-default-subscribed
13592 gnus-level-default-unsubscribed))
13593 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
13594 (setq gnus-newsrc-alist
13598 (if (nth 1 group) gnus-level-default-subscribed
13599 gnus-level-default-unsubscribed)
13600 (cdr (cdr group))))
13601 gnus-newsrc-alist)))
13602 (if (setq m (assoc (car group) marked))
13603 (setcdr (cdr (cdr info))
13604 (cons (list (cons 'tick (cdr m))) nil))))
13605 (setq newsrc (cdr newsrc)))
13606 (setq newsrc killed)
13608 (setcar newsrc (car (car newsrc)))
13609 (setq newsrc (cdr newsrc)))
13610 (setq gnus-killed-list killed))
13611 ;; The .el file version of this variable does not begin with
13612 ;; "options", while the .eld version does, so we just add it if it
13615 gnus-newsrc-options
13617 (and (not (string-match "^ *options" gnus-newsrc-options))
13618 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
13619 (and (not (string-match "\n$" gnus-newsrc-options))
13620 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
13621 ;; Finally, if we read some options lines, we parse them.
13622 (or (string= gnus-newsrc-options "")
13623 (gnus-newsrc-parse-options gnus-newsrc-options))))
13625 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
13626 (gnus-make-hashtable-from-newsrc-alist)))
13628 (defun gnus-make-newsrc-file (file)
13629 "Make server dependent file name by catenating FILE and server host name."
13630 (let* ((file (expand-file-name file nil))
13631 (real-file (concat file "-" (nth 1 gnus-select-method))))
13632 (if (or (file-exists-p real-file)
13633 (file-exists-p (concat real-file ".el"))
13634 (file-exists-p (concat real-file ".eld")))
13637 (defun gnus-uncompress-newsrc-alist ()
13638 ;; Uncompress all lists of marked articles in the newsrc assoc.
13639 (let ((newsrc gnus-newsrc-alist)
13642 (if (not (setq marked (nth 3 (car newsrc))))
13645 (or (eq 'score (car (car marked)))
13646 (eq 'bookmark (car (car marked)))
13647 (eq 'killed (car (car marked)))
13648 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13649 (setq marked (cdr marked))))
13650 (setq newsrc (cdr newsrc)))))
13652 (defun gnus-compress-newsrc-alist ()
13653 ;; Compress all lists of marked articles in the newsrc assoc.
13654 (let ((newsrc gnus-newsrc-alist)
13657 (if (not (setq marked (nth 3 (car newsrc))))
13660 (or (eq 'score (car (car marked)))
13661 (eq 'bookmark (car (car marked)))
13662 (eq 'killed (car (car marked)))
13663 (setcdr (car marked)
13665 (gnus-compress-sequence
13666 (sort (cdr (car marked)) '<) t)
13667 (error (cdr (car marked))))))
13668 (setq marked (cdr marked))))
13669 (setq newsrc (cdr newsrc)))))
13671 (defun gnus-newsrc-to-gnus-format ()
13672 (setq gnus-newsrc-options "")
13673 (setq gnus-newsrc-options-n nil)
13675 (or gnus-active-hashtb
13676 (setq gnus-active-hashtb (make-vector 4095 0)))
13677 (let ((buf (current-buffer))
13678 (already-read (> (length gnus-newsrc-alist) 1))
13679 group subscribed options-symbol newsrc Options-symbol
13681 (goto-char (point-min))
13682 ;; We intern the symbol `options' in the active hashtb so that we
13683 ;; can `eq' against it later.
13684 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
13685 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
13687 (while (not (eobp))
13688 ;; We first read the first word on the line by narrowing and
13689 ;; then reading into `gnus-active-hashtb'. Most groups will
13690 ;; already exist in that hashtb, so this will save some string
13694 (progn (skip-chars-forward "^ \t!:\n") (point)))
13695 (goto-char (point-min))
13697 (and (/= (point-min) (point-max))
13698 (let ((obarray gnus-active-hashtb)) (read buf))))
13700 ;; Now, the symbol we have read is either `options' or a group
13701 ;; name. If it is an options line, we just add it to a string.
13703 ((or (eq symbol options-symbol)
13704 (eq symbol Options-symbol))
13705 (setq gnus-newsrc-options
13706 ;; This concatting is quite inefficient, but since our
13707 ;; thorough studies show that approx 99.37% of all
13708 ;; .newsrc files only contain a single options line, we
13709 ;; don't give a damn, frankly, my dear.
13710 (concat gnus-newsrc-options
13712 (gnus-point-at-bol)
13713 ;; Options may continue on the next line.
13714 (or (and (re-search-forward "^[^ \t]" nil 'move)
13715 (progn (beginning-of-line) (point)))
13718 (or (boundp symbol) (set symbol nil))
13719 ;; It was a group name.
13720 (setq subscribed (= (following-char) ?:)
13721 group (symbol-name symbol)
13724 ;; If the line ends here, this is clearly a buggy line, so
13725 ;; we put point a the beginning of line and let the cond
13726 ;; below do the error handling.
13727 (beginning-of-line)
13728 ;; We skip to the beginning of the ranges.
13729 (skip-chars-forward "!: \t"))
13730 ;; We are now at the beginning of the list of read articles.
13731 ;; We read them range by range.
13734 ((looking-at "[0-9]+")
13735 ;; We narrow and read a number instead of buffer-substring/
13736 ;; string-to-int because it's faster. narrow/widen is
13737 ;; faster than save-restriction/narrow, and save-restriction
13738 ;; produces a garbage object.
13740 (narrow-to-region (match-beginning 0) (match-end 0))
13743 ;; If the next character is a dash, then this is a range.
13744 (if (= (following-char) ?-)
13746 ;; We read the upper bound of the range.
13748 (if (not (looking-at "[0-9]+"))
13749 ;; This is a buggy line, by we pretend that
13750 ;; it's kinda OK. Perhaps the user should be
13752 (setq reads (cons num1 reads))
13757 (narrow-to-region (match-beginning 0)
13762 ;; It was just a simple number, so we add it to the
13764 (setq reads (cons num1 reads)))
13765 ;; If the next char in ?\n, then we have reached the end
13766 ;; of the line and return nil.
13767 (/= (following-char) ?\n))
13768 ((= (following-char) ?\n)
13769 ;; End of line, so we end.
13772 ;; Not numbers and not eol, so this might be a buggy
13775 ;; If it was eob instead of ?\n, we allow it.
13777 ;; The line was buggy.
13779 (gnus-message 3 "Mangled line: %s"
13780 (buffer-substring (gnus-point-at-bol)
13781 (gnus-point-at-eol)))
13785 ;; Skip past ", ". Spaces are illegal in these ranges, but
13786 ;; we allow them, because it's a common mistake to put a
13787 ;; space after the comma.
13788 (skip-chars-forward ", "))
13790 ;; We have already read .newsrc.eld, so we gently update the
13791 ;; data in the hash table with the information we have just
13795 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
13798 ;; There is an entry for this file in the alist.
13800 (setcar (nthcdr 2 info) (nreverse reads))
13801 ;; We update the level very gently. In fact, we
13802 ;; only change it if there's been a status change
13803 ;; from subscribed to unsubscribed, or vice versa.
13804 (setq level (nth 1 info))
13805 (cond ((and (<= level gnus-level-subscribed)
13807 (setq level (if reads
13808 gnus-level-default-unsubscribed
13809 (1+ gnus-level-default-unsubscribed))))
13810 ((and (> level gnus-level-subscribed) subscribed)
13811 (setq level gnus-level-default-subscribed)))
13812 (setcar (cdr info) level))
13813 ;; This is a new group.
13814 (setq info (list group
13816 gnus-level-default-subscribed
13818 (1+ gnus-level-subscribed)
13819 gnus-level-default-unsubscribed))
13820 (nreverse reads))))
13821 (setq newsrc (cons info newsrc))))))
13824 (setq newsrc (nreverse newsrc))
13826 (if (not already-read)
13828 ;; We now have two newsrc lists - `newsrc', which is what we
13829 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13830 ;; what we've read from .newsrc.eld. We have to merge these
13831 ;; lists. We do this by "attaching" any (foreign) groups in the
13832 ;; gnus-newsrc-alist to the (native) group that precedes them.
13833 (let ((rc (cdr gnus-newsrc-alist))
13834 (prev gnus-newsrc-alist)
13837 (or (null (nth 4 (car rc))) ; It's a native group.
13838 (assoc (car (car rc)) newsrc) ; It's already in the alist.
13839 (if (setq entry (assoc (car (car prev)) newsrc))
13840 (setcdr (setq mentry (memq entry newsrc))
13841 (cons (car rc) (cdr mentry)))
13842 (setq newsrc (cons (car rc) newsrc))))
13846 (setq gnus-newsrc-alist newsrc)
13847 ;; We make the newsrc hashtb.
13848 (gnus-make-hashtable-from-newsrc-alist)
13850 ;; Finally, if we read some options lines, we parse them.
13851 (or (string= gnus-newsrc-options "")
13852 (gnus-newsrc-parse-options gnus-newsrc-options))))
13854 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13855 ;; The return value will be a list on the form
13856 ;; ((regexp1 . ignore)
13857 ;; (regexp2 . subscribe)...)
13858 ;; When handling new newsgroups, groups that match a `ignore' regexp
13859 ;; will be ignored, and groups that match a `subscribe' regexp will be
13860 ;; subscribed. A line like
13861 ;; options -n !all rec.all
13862 ;; will lead to a list that looks like
13863 ;; (("^rec\\..+" . subscribe)
13864 ;; ("^.+" . ignore))
13865 ;; So all "rec.*" groups will be subscribed, while all the other
13866 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13867 ;; different from "options -n rec.all !all".
13868 (defun gnus-newsrc-parse-options (options)
13871 (gnus-set-work-buffer)
13872 (insert (regexp-quote options))
13873 ;; First we treat all continuation lines.
13874 (goto-char (point-min))
13875 (while (re-search-forward "\n[ \t]+" nil t)
13876 (replace-match " " t t))
13877 ;; Then we transform all "all"s into ".+"s.
13878 (goto-char (point-min))
13879 (while (re-search-forward "\\ball\\b" nil t)
13880 (replace-match ".+" t t))
13881 (goto-char (point-min))
13882 ;; We remove all other options than the "-n" ones.
13883 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
13884 (replace-match " ")
13886 (goto-char (point-min))
13888 ;; We are only interested in "options -n" lines - we
13889 ;; ignore the other option lines.
13890 (while (re-search-forward "[ \t]-n" nil t)
13892 (or (save-excursion
13893 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
13895 (gnus-point-at-eol)))
13896 ;; Search for all "words"...
13897 (while (re-search-forward "[^ \t,\n]+" eol t)
13898 (if (= (char-after (match-beginning 0)) ?!)
13899 ;; If the word begins with a bang (!), this is a "not"
13900 ;; spec. We put this spec (minus the bang) and the
13901 ;; symbol `ignore' into the list.
13902 (setq out (cons (cons (concat
13903 "^" (buffer-substring
13904 (1+ (match-beginning 0))
13907 ;; There was no bang, so this is a "yes" spec.
13908 (setq out (cons (cons (concat
13909 "^" (buffer-substring (match-beginning 0)
13911 'subscribe) out)))))
13913 (setq gnus-newsrc-options-n out))))
13916 (defun gnus-save-newsrc-file ()
13917 "Save .newsrc file."
13918 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13919 ;; from the variable gnus-newsrc-alist.
13920 (and (or gnus-newsrc-alist gnus-killed-list)
13921 gnus-current-startup-file
13924 (if (and (or gnus-use-dribble-file gnus-slave)
13925 (or (not gnus-dribble-buffer)
13926 (not (buffer-name gnus-dribble-buffer))
13927 (zerop (save-excursion
13928 (set-buffer gnus-dribble-buffer)
13930 (gnus-message 4 "(No changes need to be saved)")
13931 (run-hooks 'gnus-save-newsrc-hook)
13933 (gnus-slave-save-newsrc)
13934 (if gnus-save-newsrc-file
13936 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
13937 ;; Make backup file of master newsrc.
13938 (gnus-gnus-to-newsrc-format)
13939 (gnus-message 5 "Saving %s...done"
13940 gnus-current-startup-file)))
13941 ;; Quickly loadable .newsrc.
13942 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13943 (setq buffer-file-name
13944 (concat gnus-current-startup-file ".eld"))
13945 (gnus-add-current-to-buffer-list)
13946 (buffer-disable-undo (current-buffer))
13948 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
13949 (gnus-gnus-to-quick-newsrc-format)
13950 (run-hooks 'gnus-save-quick-newsrc-hook)
13952 (kill-buffer (current-buffer))
13954 5 "Saving %s.eld...done" gnus-current-startup-file))
13955 (gnus-dribble-delete-file))))))
13957 (defun gnus-gnus-to-quick-newsrc-format ()
13958 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13959 (insert ";; Gnus startup file.\n")
13960 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13961 (insert ";; to read .newsrc.\n")
13962 (insert "(setq gnus-newsrc-file-version "
13963 (prin1-to-string gnus-version) ")\n")
13964 (let ((variables gnus-variable-list)
13966 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
13968 ;; insert lisp expressions.
13969 (gnus-compress-newsrc-alist)
13971 (setq variable (car variables))
13972 (and (boundp variable)
13973 (symbol-value variable)
13974 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13975 (insert "(setq " (symbol-name variable) " '"
13976 (prin1-to-string (symbol-value variable))
13978 (setq variables (cdr variables)))
13979 (gnus-uncompress-newsrc-alist)))
13981 (defun gnus-gnus-to-newsrc-format ()
13982 ;; Generate and save the .newsrc file.
13983 (let ((newsrc (cdr gnus-newsrc-alist))
13986 (set-buffer (create-file-buffer gnus-current-startup-file))
13987 (setq buffer-file-name gnus-current-startup-file)
13988 (buffer-disable-undo (current-buffer))
13991 (if gnus-newsrc-options (insert gnus-newsrc-options))
13992 ;; Write subscribed and unsubscribed.
13994 (setq info (car newsrc))
13995 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13997 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13999 (if (setq ranges (nth 2 info))
14002 (if (not (listp (cdr ranges)))
14003 (if (= (car ranges) (cdr ranges))
14004 (insert (int-to-string (car ranges)))
14005 (insert (int-to-string (car ranges)) "-"
14006 (int-to-string (cdr ranges))))
14008 (setq range (car ranges)
14009 ranges (cdr ranges))
14010 (if (or (atom range) (= (car range) (cdr range)))
14011 (insert (int-to-string
14012 (or (and (atom range) range)
14014 (insert (int-to-string (car range)) "-"
14015 (int-to-string (cdr range))))
14016 (if ranges (insert ","))))))
14018 (setq newsrc (cdr newsrc)))
14019 ;; It has been reported that sometime the modtime on the .newsrc
14020 ;; file seems to be off. We really do want to overwrite it, so
14021 ;; we clear the modtime here before saving. It's a bit odd,
14023 ;; sometimes the modtime clear isn't sufficient. most brute force:
14024 ;; delete the silly thing entirely first. but this fails to provide
14025 ;; such niceties as .newsrc~ creation.
14026 (if gnus-modtime-botch
14027 (delete-file gnus-startup-file)
14028 (clear-visited-file-modtime))
14029 (run-hooks 'gnus-save-standard-newsrc-hook)
14031 (kill-buffer (current-buffer)))))
14034 ;;; Slave functions.
14036 (defun gnus-slave-save-newsrc ()
14038 (set-buffer gnus-dribble-buffer)
14040 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
14041 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
14043 (defun gnus-master-read-slave-newsrc ()
14046 (file-name-directory gnus-current-startup-file)
14050 (file-name-nondirectory gnus-current-startup-file)
14054 (if (not slave-files)
14055 () ; There are no slave files to read.
14056 (gnus-message 7 "Reading slave newsrcs...")
14058 (set-buffer (get-buffer-create " *gnus slave*"))
14059 (buffer-disable-undo (current-buffer))
14061 (sort (mapcar (lambda (file)
14062 (list (nth 5 (file-attributes file)) file))
14065 (or (< (car (car f1)) (car (car f2)))
14066 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
14069 (setq file (nth 1 (car slave-files)))
14070 (insert-file-contents file)
14071 (if (condition-case ()
14073 (eval-buffer (current-buffer))
14076 (message "Possible error in %s" file)
14080 (or gnus-slave ; Slaves shouldn't delete these files.
14084 (setq slave-files (cdr slave-files))))
14085 (gnus-message 7 "Reading slave newsrcs...done"))))
14088 ;;; Group description.
14090 (defun gnus-read-all-descriptions-files ()
14091 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
14093 (gnus-read-descriptions-file (car methods))
14094 (setq methods (cdr methods)))
14097 (defun gnus-read-descriptions-file (&optional method)
14098 (let ((method (or method gnus-select-method)))
14099 ;; We create the hashtable whether we manage to read the desc file
14100 ;; to avoid trying to re-read after a failed read.
14101 (or gnus-description-hashtb
14102 (setq gnus-description-hashtb
14103 (gnus-make-hashtable (length gnus-active-hashtb))))
14104 ;; Mark this method's desc file as read.
14105 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
14106 gnus-description-hashtb)
14108 (gnus-message 5 "Reading descriptions file via %s..." (car method))
14110 ((not (gnus-check-server method))
14111 (gnus-message 1 "Couldn't open server")
14113 ((not (gnus-request-list-newsgroups method))
14114 (gnus-message 1 "Couldn't read newsgroups descriptions")
14120 (set-buffer nntp-server-buffer)
14121 (goto-char (point-min))
14122 (if (or (search-forward "\n.\n" nil t)
14123 (goto-char (point-max)))
14125 (beginning-of-line)
14126 (narrow-to-region (point-min) (point))))
14127 (goto-char (point-min))
14128 (while (not (eobp))
14129 ;; If we get an error, we set group to 0, which is not a
14133 (let ((obarray gnus-description-hashtb))
14134 ;; Group is set to a symbol interned in this
14136 (read nntp-server-buffer))
14138 (skip-chars-forward " \t")
14139 ;; ... which leads to this line being effectively ignored.
14140 (and (symbolp group)
14141 (set group (buffer-substring
14142 (point) (progn (end-of-line) (point)))))
14143 (forward-line 1))))
14144 (gnus-message 5 "Reading descriptions file...done")
14147 (defun gnus-group-get-description (group)
14148 ;; Get the description of a group by sending XGTITLE to the server.
14149 (and (gnus-request-group-description group)
14151 (set-buffer nntp-server-buffer)
14152 (goto-char (point-min))
14153 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
14154 (buffer-substring (match-beginning 1) (match-end 1))))))
14160 (defvar gnus-server-mode-hook nil
14161 "Hook run in `gnus-server-mode' buffers.")
14163 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
14164 "Format of server lines.
14165 It works along the same lines as a normal formatting string,
14166 with some simple extensions.")
14168 (defvar gnus-server-mode-line-format "Gnus List of servers"
14169 "The format specification for the server mode line.")
14171 (defconst gnus-server-line-format-alist
14172 (list (list ?h 'how ?s)
14174 (list ?w 'where ?s)
14177 (defconst gnus-server-mode-line-format-alist
14178 (list (list ?S 'news-server ?s)
14179 (list ?M 'news-method ?s)
14180 (list ?u 'user-defined ?s)))
14182 (defvar gnus-server-line-format-spec nil)
14183 (defvar gnus-server-mode-line-format-spec nil)
14184 (defvar gnus-server-killed-servers nil)
14186 (defvar gnus-server-mode-map nil)
14187 (put 'gnus-server-mode 'mode-class 'special)
14189 (if gnus-server-mode-map
14191 (setq gnus-server-mode-map (make-sparse-keymap))
14192 (suppress-keymap gnus-server-mode-map)
14193 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
14194 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
14195 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
14196 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
14197 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
14198 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
14199 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
14200 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
14201 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
14202 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
14204 (defun gnus-server-mode ()
14205 "Major mode for listing and editing servers.
14207 All normal editing commands are switched off.
14208 \\<gnus-server-mode-map>
14210 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
14212 The following commands are available:
14214 \\{gnus-server-mode-map}"
14216 (if (gnus-visual-p 'server-menu 'menu) (gnus-server-make-menu-bar))
14217 (kill-all-local-variables)
14218 (setq mode-line-modified "-- ")
14219 (make-local-variable 'mode-line-format)
14220 (setq mode-line-format (copy-sequence mode-line-format))
14221 (and (equal (nth 3 mode-line-format) " ")
14222 (setcar (nthcdr 3 mode-line-format) ""))
14223 (setq major-mode 'gnus-server-mode)
14224 (setq mode-name "Server")
14225 ; (gnus-group-set-mode-line)
14226 (setq mode-line-process nil)
14227 (use-local-map gnus-server-mode-map)
14228 (buffer-disable-undo (current-buffer))
14229 (setq truncate-lines t)
14230 (setq buffer-read-only t)
14231 (run-hooks 'gnus-server-mode-hook))
14233 (defun gnus-server-insert-server-line (sformat name method)
14234 (let* ((sformat (or sformat gnus-server-line-format-spec))
14236 (where (nth 1 method))
14238 (beginning-of-line)
14240 ;; Insert the text.
14241 (insert (eval sformat))
14242 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
14244 (defun gnus-server-setup-buffer ()
14245 (if (get-buffer gnus-server-buffer)
14248 (set-buffer (get-buffer-create gnus-server-buffer))
14250 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
14252 (defun gnus-server-prepare ()
14253 (setq gnus-server-mode-line-format-spec
14254 (gnus-parse-format gnus-server-mode-line-format
14255 gnus-server-mode-line-format-alist))
14256 (setq gnus-server-line-format-spec
14257 (gnus-parse-format gnus-server-line-format
14258 gnus-server-line-format-alist))
14259 (let ((alist gnus-server-alist)
14260 (buffer-read-only nil))
14263 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
14264 (setq alist (cdr alist))))
14265 (goto-char (point-min))
14266 (gnus-server-position-point))
14268 (defun gnus-server-server-name ()
14269 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
14270 (and server (symbol-name server))))
14272 (defalias 'gnus-server-position-point 'gnus-goto-colon)
14274 (defconst gnus-server-edit-buffer "*Gnus edit server*")
14276 (defun gnus-server-update-server (server)
14278 (set-buffer gnus-server-buffer)
14279 (let ((buffer-read-only nil)
14280 (info (cdr (assoc server gnus-server-alist))))
14281 (gnus-dribble-enter
14282 (concat "(gnus-server-set-info \"" server "\" '"
14283 (prin1-to-string info) ")"))
14284 ;; Buffer may be narrowed.
14287 (if (gnus-server-goto-server server)
14288 (delete-region (progn (beginning-of-line) (point))
14289 (progn (forward-line 1) (point))))
14290 (let ((entry (assoc server gnus-server-alist)))
14291 (gnus-server-insert-server-line nil (car entry) (cdr entry))
14292 (gnus-server-position-point))))))
14294 (defun gnus-server-set-info (server info)
14295 ;; Enter a select method into the virtual server alist.
14296 (gnus-dribble-enter
14297 (concat "(gnus-server-set-info \"" server "\" '"
14298 (prin1-to-string info) ")"))
14299 (let* ((server (nth 1 info))
14300 (entry (assoc server gnus-server-alist)))
14301 (if entry (setcdr entry info)
14302 (setq gnus-server-alist
14303 (nconc gnus-server-alist (list (cons server info)))))))
14305 (defun gnus-server-to-method (server)
14306 ;; Map virtual server names to select methods.
14307 (or (and (equal server "native") gnus-select-method)
14308 (cdr (assoc server gnus-server-alist))))
14310 (defun gnus-server-extend-method (group method)
14311 ;; This function "extends" a virtual server. If the server is
14312 ;; "hello", and the select method is ("hello" (my-var "something"))
14313 ;; in the group "alt.alt", this will result in a new virtual server
14314 ;; called "helly+alt.alt".
14316 (gnus-copy-sequence
14317 (if (equal (car method) "native") gnus-select-method
14318 (cdr (assoc (car method) gnus-server-alist))))))
14319 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14320 (nconc entry (cdr method))))
14322 (defun gnus-server-get-method (group method)
14323 ;; Input either a server name, and extended server name, or a
14324 ;; select method, and return a select method.
14325 (cond ((stringp method)
14326 (gnus-server-to-method method))
14327 ((and (stringp (car method)) group)
14328 (gnus-server-extend-method group method))
14330 (gnus-server-add-address method))))
14332 (defun gnus-server-add-address (method)
14333 (let ((method-name (symbol-name (car method))))
14334 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
14335 (not (assq (intern (concat method-name "-address")) method)))
14336 (append method (list (list (intern (concat method-name "-address"))
14340 (defun gnus-server-equal (s1 s2)
14342 (and (= (length s1) (length s2))
14344 (while (and s1 (member (car s1) s2))
14345 (setq s1 (cdr s1)))
14348 ;;; Interactive server functions.
14350 (defun gnus-server-kill-server (server)
14351 "Kill the server on the current line."
14352 (interactive (list (gnus-server-server-name)))
14353 (or (gnus-server-goto-server server)
14354 (if server (error "No such server: %s" server)
14355 (error "No server on the current line")))
14356 (gnus-dribble-enter "")
14357 (let ((buffer-read-only nil))
14358 (delete-region (progn (beginning-of-line) (point))
14359 (progn (forward-line 1) (point))))
14360 (setq gnus-server-killed-servers
14361 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
14362 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
14363 gnus-server-alist))
14364 (gnus-server-position-point))
14366 (defun gnus-server-yank-server ()
14367 "Yank the previously killed server."
14369 (or gnus-server-killed-servers
14370 (error "No killed servers to be yanked"))
14371 (let ((alist gnus-server-alist)
14372 (server (gnus-server-server-name))
14373 (killed (car gnus-server-killed-servers)))
14375 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
14376 (if (string= server (car (car gnus-server-alist)))
14377 (setq gnus-server-alist (cons killed gnus-server-alist))
14378 (while (and (cdr alist)
14379 (not (string= server (car (car (cdr alist))))))
14380 (setq alist (cdr alist)))
14381 (setcdr alist (cons killed (cdr alist)))))
14382 (gnus-server-update-server (car killed))
14383 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
14384 (gnus-server-position-point)))
14386 (defun gnus-server-exit ()
14387 "Return to the group buffer."
14389 (kill-buffer (current-buffer))
14390 (switch-to-buffer gnus-group-buffer))
14392 (defun gnus-server-list-servers ()
14393 "List all available servers."
14395 (let ((cur (gnus-server-server-name)))
14396 (gnus-server-prepare)
14397 (if cur (gnus-server-goto-server cur)
14398 (goto-char (point-max))
14400 (gnus-server-position-point)))
14402 (defun gnus-server-copy-server (from to)
14405 (or (gnus-server-server-name)
14406 (error "No server on the current line"))
14407 (read-string "Copy to: ")))
14408 (or from (error "No server on current line"))
14409 (or (and to (not (string= to ""))) (error "No name to copy to"))
14410 (and (assoc to gnus-server-alist) (error "%s already exists" to))
14411 (or (assoc from gnus-server-alist)
14412 (error "%s: no such server" from))
14413 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
14414 (setcar to-entry to)
14415 (setcar (nthcdr 2 to-entry) to)
14416 (setq gnus-server-killed-servers
14417 (cons to-entry gnus-server-killed-servers))
14418 (gnus-server-yank-server)))
14420 (defun gnus-server-add-server (how where)
14422 (list (intern (completing-read "Server method: "
14423 gnus-valid-select-methods nil t))
14424 (read-string "Server name: ")))
14425 (setq gnus-server-killed-servers
14426 (cons (list where how where) gnus-server-killed-servers))
14427 (gnus-server-yank-server))
14429 (defun gnus-server-goto-server (server)
14430 "Jump to a server line."
14432 (list (completing-read "Goto server: " gnus-server-alist nil t)))
14433 (let ((to (text-property-any (point-min) (point-max)
14434 'gnus-server (intern server))))
14438 (gnus-server-position-point)))))
14440 (defun gnus-server-edit-server (server)
14441 "Edit the server on the current line."
14442 (interactive (list (gnus-server-server-name)))
14444 (error "No server on current line"))
14445 (let ((winconf (current-window-configuration)))
14446 (get-buffer-create gnus-server-edit-buffer)
14447 (gnus-configure-windows 'edit-server)
14448 (gnus-add-current-to-buffer-list)
14450 (make-local-variable 'gnus-prev-winconf)
14451 (setq gnus-prev-winconf winconf)
14452 (use-local-map (copy-keymap (current-local-map)))
14453 (let ((done-func '(lambda ()
14454 "Exit editing mode and update the information."
14456 (gnus-server-edit-server-done 'group))))
14457 (setcar (cdr (nth 4 done-func)) server)
14458 (local-set-key "\C-c\C-c" done-func))
14460 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
14461 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
14463 (defun gnus-server-edit-server-done (server)
14465 (set-buffer (get-buffer-create gnus-server-edit-buffer))
14466 (goto-char (point-min))
14467 (let ((form (read (current-buffer)))
14468 (winconf gnus-prev-winconf))
14469 (gnus-server-set-info server form)
14470 (kill-buffer (current-buffer))
14471 (and winconf (set-window-configuration winconf))
14472 (set-buffer gnus-server-buffer)
14473 (gnus-server-update-server (gnus-server-server-name))
14474 (gnus-server-list-servers)
14475 (gnus-server-position-point)))
14477 (defun gnus-server-read-server (server)
14479 (interactive (list (gnus-server-server-name)))
14480 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
14482 (defun gnus-mouse-pick-server (e)
14484 (mouse-set-point e)
14485 (gnus-server-read-server (gnus-server-server-name)))
14488 ;;; entry points into gnus-score.el
14491 ;;; Finding score files.
14493 (defvar gnus-global-score-files nil
14494 "*List of global score files and directories.
14495 Set this variable if you want to use people's score files. One entry
14496 for each score file or each score file directory. Gnus will decide
14497 by itself what score files are applicable to which group.
14499 Say you want to use the single score file
14500 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
14501 score files in the \"/ftp.some-where:/pub/score\" directory.
14503 (setq gnus-global-score-files
14504 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
14505 \"/ftp.some-where:/pub/score\"))")
14507 (defun gnus-score-score-files (group)
14508 "Return a list of all possible score files."
14509 ;; Search and set any global score files.
14510 (and gnus-global-score-files
14511 (or gnus-internal-global-score-files
14512 (gnus-score-search-global-directories gnus-global-score-files)))
14513 ;; Fix the kill-file dir variable.
14514 (setq gnus-kill-files-directory
14515 (file-name-as-directory
14516 (or gnus-kill-files-directory "~/News/")))
14517 ;; If we can't read it, there are no score files.
14518 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
14519 (setq gnus-score-file-list nil)
14520 (if (gnus-use-long-file-name 'not-score)
14521 ;; We want long file names.
14522 (if (or (not gnus-score-file-list)
14523 (not (car gnus-score-file-list))
14524 (gnus-file-newer-than gnus-kill-files-directory
14525 (car gnus-score-file-list)))
14526 (setq gnus-score-file-list
14527 (cons (nth 5 (file-attributes gnus-kill-files-directory))
14530 gnus-kill-files-directory t
14531 (gnus-score-file-regexp))))))
14532 ;; We do not use long file names, so we have to do some
14533 ;; directory traversing.
14534 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
14535 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
14538 (setq dir (expand-file-name
14539 (concat gnus-kill-files-directory
14540 (gnus-replace-chars-in-string group ?. ?/))))
14541 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
14542 (setq suffix (car suffixes)
14543 suffixes (cdr suffixes))
14544 (if (file-exists-p (concat dir "/" suffix))
14545 (setq files (cons (concat dir "/" suffix) files)))
14546 (while (>= (1+ (length dir)) mdir)
14547 (and (file-exists-p (concat dir "/all/" suffix))
14548 (setq files (cons (concat dir "/all/" suffix) files)))
14549 (string-match "/[^/]*$" dir)
14550 (setq dir (substring dir 0 (match-beginning 0)))))
14551 (setq gnus-score-file-list
14552 (cons nil (nreverse files)))))
14553 (cdr gnus-score-file-list)))
14555 (defun gnus-score-file-regexp ()
14556 (concat "\\(" gnus-score-file-suffix
14557 "\\|" gnus-adaptive-file-suffix "\\)$"))
14559 (defun gnus-score-find-bnews (group)
14560 "Return a list of score files for GROUP.
14561 The score files are those files in the ~/News directory which matches
14562 GROUP using BNews sys file syntax."
14563 (let* ((sfiles (append (gnus-score-score-files group)
14564 gnus-internal-global-score-files))
14565 (kill-dir (file-name-as-directory
14566 (expand-file-name gnus-kill-files-directory)))
14567 (klen (length kill-dir))
14568 ofiles not-match regexp)
14570 (set-buffer (get-buffer-create "*gnus score files*"))
14571 (buffer-disable-undo (current-buffer))
14572 ;; Go through all score file names and create regexp with them
14576 (insert (car sfiles))
14577 (goto-char (point-min))
14578 ;; First remove the suffix itself.
14579 (re-search-forward (concat "." (gnus-score-file-regexp)))
14580 (replace-match "" t t)
14581 (goto-char (point-min))
14582 (if (looking-at (regexp-quote kill-dir))
14583 ;; If the file name was just "SCORE", `klen' is one character
14585 (delete-char (min (1- (point-max)) klen))
14586 (goto-char (point-max))
14587 (search-backward "/")
14588 (delete-region (1+ (point)) (point-min)))
14589 ;; If short file names were used, we have to translate slashes.
14590 (goto-char (point-min))
14591 (while (re-search-forward "[/:]" nil t)
14592 (replace-match "." t t))
14593 ;; Cludge to get rid of "nntp+" problems.
14594 (goto-char (point-min))
14595 (and (looking-at "nn[a-z]+\\+")
14597 (search-forward "+")
14600 ;; Translate "all" to ".*".
14601 (while (search-forward "all" nil t)
14602 (replace-match ".*" t t))
14603 (goto-char (point-min))
14604 ;; Deal with "not."s.
14605 (if (looking-at "not.")
14608 (setq regexp (buffer-substring 5 (point-max))))
14609 (setq regexp (buffer-substring 1 (point-max)))
14610 (setq not-match nil))
14611 ;; Finally - if this resulting regexp matches the group name,
14612 ;; we add this score file to the list of score files
14613 ;; applicable to this group.
14614 (if (or (and not-match
14615 (not (string-match regexp group)))
14616 (and (not not-match)
14617 (string-match regexp group)))
14618 (setq ofiles (cons (car sfiles) ofiles)))
14619 (setq sfiles (cdr sfiles)))
14620 (kill-buffer (current-buffer))
14621 ;; Slight kludge here - the last score file returned should be
14622 ;; the local score file, whether it exists or not. This is so
14623 ;; that any score commands the user enters will go to the right
14624 ;; file, and not end up in some global score file.
14627 (if (gnus-use-long-file-name 'not-score)
14628 (concat gnus-kill-files-directory group "."
14629 gnus-score-file-suffix)
14630 (concat gnus-kill-files-directory
14631 (gnus-replace-chars-in-string group ?. ?/ ?: ?/)
14632 "/" gnus-score-file-suffix)))))
14633 (and (member localscore ofiles)
14634 (delete localscore ofiles))
14635 (setq ofiles (cons localscore ofiles)))
14636 (nreverse ofiles))))
14638 (defun gnus-score-find-single (group)
14639 "Return list containing the score file for GROUP."
14640 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
14641 (gnus-score-file-name group)))
14643 (defun gnus-score-find-hierarchical (group)
14644 "Return list of score files for GROUP.
14645 This includes the score file for the group and all its parents."
14646 (let ((all (copy-sequence '(nil)))
14648 (while (string-match "\\." group (1+ start))
14649 (setq start (match-beginning 0))
14650 (setq all (cons (substring group 0 start) all)))
14651 (setq all (cons group all))
14653 (mapcar (lambda (newsgroup)
14654 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
14655 (setq all (nreverse all)))
14656 (mapcar 'gnus-score-file-name all))))
14658 (defvar gnus-score-file-alist-cache nil)
14660 (defun gnus-score-find-alist (group)
14661 "Return list of score files for GROUP.
14662 The list is determined from the variable gnus-score-file-alist."
14663 (let ((alist gnus-score-file-multiple-match-alist)
14665 ;; if this group has been seen before, return the cached entry
14666 (if (setq score-files (assoc group gnus-score-file-alist-cache))
14667 (cdr score-files) ;ensures caching groups with no matches
14668 ;; handle the multiple match alist
14670 (and (string-match (car (car alist)) group)
14672 (nconc score-files (copy-sequence (cdr (car alist))))))
14673 (setq alist (cdr alist)))
14674 (setq alist gnus-score-file-single-match-alist)
14675 ;; handle the single match alist
14677 (and (string-match (car (car alist)) group)
14678 ;; progn used just in case ("regexp") has no files
14679 ;; and score-files is still nil. -sj
14680 ;; this can be construed as a "stop searching here" feature :>
14681 ;; and used to simplify regexps in the single-alist
14684 (nconc score-files (copy-sequence (cdr (car alist)))))
14686 (setq alist (cdr alist)))
14687 ;; cache the score files
14688 (setq gnus-score-file-alist-cache
14689 (cons (cons group score-files) gnus-score-file-alist-cache))
14693 (defun gnus-possibly-score-headers (&optional trace)
14694 (let ((func gnus-score-find-score-files-function)
14698 (setq func (list func)))
14699 ;; Go through all the functions for finding score files (or actual
14700 ;; scores) and add them to a list.
14701 (and func (setq score-files (gnus-score-find-alist gnus-newsgroup-name)))
14703 (and (symbolp (car func))
14704 (fboundp (car func))
14706 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
14707 (setq func (cdr func)))
14708 (if score-files (gnus-score-headers score-files trace))))
14710 (defun gnus-score-file-name (newsgroup &optional suffix)
14711 "Return the name of a score file for NEWSGROUP."
14712 (let ((suffix (or suffix gnus-score-file-suffix)))
14714 ((or (null newsgroup)
14715 (string-equal newsgroup ""))
14716 ;; The global score file is placed at top of the directory.
14718 suffix (or gnus-kill-files-directory "~/News")))
14719 ((gnus-use-long-file-name 'not-score)
14720 ;; Append ".SCORE" to newsgroup name.
14721 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
14723 (or gnus-kill-files-directory "~/News")))
14725 ;; Place "SCORE" under the hierarchical directory.
14726 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14728 (or gnus-kill-files-directory "~/News"))))))
14730 (defun gnus-score-search-global-directories (files)
14731 "Scan all global score directories for score files."
14732 ;; Set the variable `gnus-internal-global-score-files' to all
14733 ;; available global score files.
14734 (interactive (list gnus-global-score-files))
14737 (if (string-match "/$" (car files))
14738 (setq out (nconc (directory-files
14740 (concat (gnus-score-file-regexp) "$"))))
14741 (setq out (cons (car files) out)))
14742 (setq files (cdr files)))
14743 (setq gnus-internal-global-score-files out)))
14745 ;; Allow redefinition of Gnus functions.
14747 (gnus-ems-redefine)
14751 ;;; gnus.el ends here