1 ;;; gnus.el --- a newsreader for GNU Emacs
3 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; Although Gnus looks suspiciously like GNUS, it isn't quite the same
29 ;; beast. Most internal structures have been changed. If you have
30 ;; written packages that depend on any of the hash tables,
31 ;; `gnus-newsrc-alist', `gnus-killed-assoc', marked lists, the .newsrc
32 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
33 ;; dependence on the buffers having a certain format, your code will
38 (eval '(run-hooks 'gnus-load-hook))
44 ;; Site dependent variables. These variables should be defined in
47 (defvar gnus-default-nntp-server nil
48 "Specify a default NNTP server.
49 This variable should be defined in paths.el, and should never be set
51 If you want to change servers, you should use `gnus-select-method'.
52 See the documentation to that variable.")
54 (defconst gnus-backup-default-subscribed-newsgroups
55 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
56 "Default default new newsgroups the first time Gnus is run.
57 Should be set in paths.el, and shouldn't be touched by the user.")
59 (defvar gnus-local-domain nil
60 "Local domain name without a host name.
61 The DOMAINNAME environment variable is used instead if it is defined.
62 If the `system-name' function returns the full Internet name, there is
63 no need to set this variable.")
65 (defvar gnus-local-organization nil
66 "String with a description of what organization (if any) the user belongs to.
67 The ORGANIZATION environment variable is used instead if it is defined.
68 If this variable contains a function, this function will be called
69 with the current newsgroup name as the argument. The function should
72 In any case, if the string (either in the variable, in the environment
73 variable, or returned by the function) is a file name, the contents of
74 this file will be used as the organization.")
76 (defvar gnus-use-generic-from nil
77 "If nil, the full host name will be the system name prepended to the domain name.
78 If this is a string, the full host name will be this string.
79 If this is non-nil, non-string, the domain name will be used as the
82 (defvar gnus-use-generic-path nil
83 "If nil, use the NNTP server name in the Path header.
84 If stringp, use this; if non-nil, use no host name (user name only).")
87 ;; Customization variables
89 ;; Don't touch this variable.
90 (defvar gnus-nntp-service "nntp"
91 "*NNTP service name (\"nntp\" or 119).
92 This is an obsolete variable, which is scarcely used. If you use an
93 nntp server for your newsgroup and want to change the port number
94 used to 899, you would say something along these lines:
96 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
98 (defvar gnus-select-method
100 (list 'nntp (or (getenv "NNTPSERVER")
101 (if (and gnus-default-nntp-server
102 (not (string= gnus-default-nntp-server "")))
103 gnus-default-nntp-server)
105 (if (or (null gnus-nntp-service)
106 (equal gnus-nntp-service "nntp"))
108 (list gnus-nntp-service)))
109 "*Default method for selecting a newsgroup.
110 This variable should be a list, where the first element is how the
111 news is to be fetched, the second is the address.
113 For instance, if you want to get your news via NNTP from
114 \"flab.flab.edu\", you could say:
116 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
118 If you want to use your local spool, say:
120 (setq gnus-select-method (list 'nnspool (system-name)))
122 If you use this variable, you must set `gnus-nntp-server' to nil.
124 There is a lot more to know about select methods and virtual servers -
125 see the manual for details.")
127 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
128 (defvar gnus-post-method nil
129 "*Preferred method for posting USENET news.
130 If this variable is nil, Gnus will use the current method to decide
131 which method to use when posting. If it is non-nil, it will override
132 the current method. This method will not be used in mail groups and
133 the like, only in \"real\" newsgroups.
135 The value must be a valid method as discussed in the documentation of
136 `gnus-select-method'.")
138 (defvar gnus-refer-article-method nil
139 "*Preferred method for fetching an article by Message-ID.
140 If you are reading news from the local spool (with nnspool), fetching
141 articles by Message-ID is painfully slow. By setting this method to an
142 nntp method, you might get acceptable results.
144 The value of this variable must be a valid select method as discussed
145 in the documentation of `gnus-select-method'")
147 (defvar gnus-secondary-select-methods nil
148 "*A list of secondary methods that will be used for reading news.
149 This is a list where each element is a complete select method (see
150 `gnus-select-method').
152 If, for instance, you want to read your mail with the nnml backend,
153 you could set this variable:
155 (setq gnus-secondary-select-methods '((nnml \"\")))")
157 (defvar gnus-secondary-servers nil
158 "*List of NNTP servers that the user can choose between interactively.
159 To make Gnus query you for a server, you have to give `gnus' a
160 non-numeric prefix - `C-u M-x gnus', in short.")
162 (defvar gnus-nntp-server nil
163 "*The name of the host running the NNTP server.
164 This variable is semi-obsolete. Use the `gnus-select-method'
167 (defvar gnus-startup-file "~/.newsrc"
168 "*Your `.newsrc' file.
169 `.newsrc-SERVER' will be used instead if that exists.")
171 (defvar gnus-init-file "~/.gnus"
172 "*Your Gnus elisp startup file.
173 If a file with the .el or .elc suffixes exist, it will be read
176 (defvar gnus-group-faq-directory
177 "/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
178 "*Directory where the group FAQs are stored.
179 This will most commonly be on a remote machine, and the file will be
182 Note that Gnus uses an aol machine as the default directory. If this
183 feels fundamentally unclean, just think of it as a way to finally get
184 something of value back from them.
186 If the default site is too slow, try one of these:
188 North America: ftp.uu.net /usenet/news.answers
189 mirrors.aol.com /pub/rtfm/usenet
190 ftp.seas.gwu.edu /pub/rtfm
191 rtfm.mit.edu /pub/usenet/news.answers
192 Europe: ftp.uni-paderborn.de /pub/FAQ
193 ftp.Germany.EU.net /pub/newsarchive/news.answers
194 ftp.sunet.se /pub/usenet
195 Asia: nctuccca.edu.tw /USENET/FAQ
196 hwarang.postech.ac.kr /pub/usenet/news.answers
197 ftp.hk.super.net /mirror/faqs")
199 (defvar gnus-group-archive-directory
200 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
201 "*The address of the (ding) archives.")
203 (defvar gnus-group-recent-archive-directory
204 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
205 "*The address of the most recent (ding) articles.")
207 (defvar gnus-default-subscribed-newsgroups nil
208 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
209 It should be a list of strings.
210 If it is `t', Gnus will not do anything special the first time it is
211 started; it'll just use the normal newsgroups subscription methods.")
213 (defvar gnus-use-cross-reference t
214 "*Non-nil means that cross referenced articles will be marked as read.
215 If nil, ignore cross references. If t, mark articles as read in
216 subscribed newsgroups. If neither t nor nil, mark as read in all
219 (defvar gnus-use-dribble-file t
220 "*Non-nil means that Gnus will use a dribble file to store user updates.
221 If Emacs should crash without saving the .newsrc files, complete
222 information can be restored from the dribble file.")
224 (defvar gnus-asynchronous nil
225 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
227 (defvar gnus-asynchronous-article-function nil
228 "*Function for picking articles to pre-fetch, possibly.")
230 (defvar gnus-score-file-single-match-alist nil
231 "*Alist mapping regexps to lists of score files.
232 Each element of this alist should be of the form
233 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
235 If the name of a group is matched by REGEXP, the corresponding scorefiles
236 will be used for that group.
237 The first match found is used, subsequent matching entries are ignored (to
238 use multiple matches, see gnus-score-file-multiple-match-alist).
240 These score files are loaded in addition to any files returned by
241 gnus-score-find-score-files-function (which see).")
243 (defvar gnus-score-file-multiple-match-alist nil
244 "*Alist mapping regexps to lists of score files.
245 Each element of this alist should be of the form
246 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
248 If the name of a group is matched by REGEXP, the corresponding scorefiles
249 will be used for that group.
250 If multiple REGEXPs match a group, the score files corresponding to each
251 match will be used (for only one match to be used, see
252 gnus-score-file-single-match-alist).
254 These score files are loaded in addition to any files returned by
255 gnus-score-find-score-files-function (which see).")
258 (defvar gnus-score-file-suffix "SCORE"
259 "*Suffix of the score files.")
261 (defvar gnus-adaptive-file-suffix "ADAPT"
262 "*Suffix of the adaptive score files.")
264 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
265 "*Function used to find score files.
266 The function will be called with the group name as the argument, and
267 should return a list of score files to apply to that group. The score
268 files do not actually have to exist.
270 Predefined values are:
272 gnus-score-find-single: Only apply the group's own score file.
273 gnus-score-find-hierarchical: Also apply score files from parent groups.
274 gnus-score-find-bnews: Apply score files whose names matches.
276 See the documentation to these functions for more information.
278 This variable can also be a list of functions to be called. Each
279 function should either return a list of score files, or a list of
282 (defvar gnus-score-interactive-default-score 1000
283 "*Scoring commands will raise/lower the score with this number as the default.")
285 (defvar gnus-large-newsgroup 200
286 "*The number of articles which indicates a large newsgroup.
287 If the number of articles in a newsgroup is greater than this value,
288 confirmation is required for selecting the newsgroup.")
290 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
291 (defvar gnus-no-groups-message "No news is horrible news"
292 "*Message displayed by Gnus when no groups are available.")
294 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
295 "*Non-nil means that the default name of a file to save articles in is the group name.
296 If it's nil, the directory form of the group name is used instead.
298 If this variable is a list, and the list contains the element
299 `not-score', long file names will not be used for score files; if it
300 contains the element `not-save', long file names will not be used for
301 saving; and if it contains the element `not-kill', long file names
302 will not be used for kill files.")
304 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
305 "*Name of the directory articles will be saved in (default \"~/News\").
306 Initialized from the SAVEDIR environment variable.")
308 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
309 "*Name of the directory where kill files will be stored (default \"~/News\").
310 Initialized from the SAVEDIR environment variable.")
312 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
313 "*A function to save articles in your favorite format.
314 The function must be interactively callable (in other words, it must
315 be an Emacs command).
317 Gnus provides the following functions:
319 * gnus-summary-save-in-rmail (Rmail format)
320 * gnus-summary-save-in-mail (Unix mail format)
321 * gnus-summary-save-in-folder (MH folder)
322 * gnus-summary-save-in-file (article format).
323 * gnus-summary-save-in-vm (use VM's folder format).")
325 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
326 "*A function generating a file name to save articles in Rmail format.
327 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
329 (defvar gnus-mail-save-name (function gnus-plain-save-name)
330 "*A function generating a file name to save articles in Unix mail format.
331 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
333 (defvar gnus-folder-save-name (function gnus-folder-save-name)
334 "*A function generating a file name to save articles in MH folder.
335 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
337 (defvar gnus-file-save-name (function gnus-numeric-save-name)
338 "*A function generating a file name to save articles in article format.
339 The function is called with NEWSGROUP, HEADERS, and optional
342 (defvar gnus-split-methods nil
343 "*Variable used to suggest where articles are to be saved.
344 The syntax of this variable is the same as `nnmail-split-methods'.
346 For instance, if you would like to save articles related to Gnus in
347 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
348 you could set this variable to something like:
350 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
351 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
353 (defvar gnus-save-score nil
354 "*If non-nil, save group scoring info.")
356 (defvar gnus-use-adaptive-scoring nil
357 "*If non-nil, use some adaptive scoring scheme.")
359 (defvar gnus-use-cache nil
360 "*If non-nil, Gnus will cache (some) articles locally.")
362 (defvar gnus-use-scoring t
363 "*If non-nil, enable scoring.")
365 (defvar gnus-fetch-old-headers nil
366 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
367 If an unread article in the group refers to an older, already read (or
368 just marked as read) article, the old article will not normally be
369 displayed in the Summary buffer. If this variable is non-nil, Gnus
370 will attempt to grab the headers to the old articles, and thereby
371 build complete threads. If it has the value `some', only enough
372 headers to connect otherwise loose threads will be displayed.
374 The server has to support XOVER for any of this to work.")
377 ;(defvar gnus-visual t
378 ; "*If non-nil, will do various highlighting.
379 ;If nil, no mouse highlights (or any other highlights) will be
380 ;performed. This might speed up Gnus some when generating large group
381 ;and summary buffers.")
383 (defvar gnus-novice-user t
384 "*Non-nil means that you are a usenet novice.
385 If non-nil, verbose messages may be displayed and confirmations may be
388 (defvar gnus-expert-user nil
389 "*Non-nil means that you will never be asked for confirmation about anything.
390 And that means *anything*.")
392 (defvar gnus-verbose 7
393 "*Integer that says how verbose Gnus should be.
394 The higher the number, the more messages Gnus will flash to say what
395 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
396 display most important messages; and at ten, Gnus will keep on
397 jabbering all the time.")
399 (defvar gnus-keep-same-level nil
400 "*Non-nil means that the next newsgroup after the current will be on the same level.
401 When you type, for instance, `n' after reading the last article in the
402 current newsgroup, you will go to the next newsgroup. If this variable
403 is nil, the next newsgroup will be the next from the group
405 If this variable is non-nil, Gnus will either put you in the
406 next newsgroup with the same level, or, if no such newsgroup is
407 available, the next newsgroup with the lowest possible level higher
408 than the current level.
409 If this variable is `best', Gnus will make the next newsgroup the one
410 with the best level.")
412 (defvar gnus-summary-make-false-root 'adopt
413 "*nil means that Gnus won't gather loose threads.
414 If the root of a thread has expired or been read in a previous
415 session, the information necessary to build a complete thread has been
416 lost. Instead of having many small sub-threads from this original thread
417 scattered all over the summary buffer, Gnus can gather them.
419 If non-nil, Gnus will try to gather all loose sub-threads from an
420 original thread into one large thread.
422 If this variable is non-nil, it should be one of `none', `adopt',
425 If this variable is `none', Gnus will not make a false root, but just
426 present the sub-threads after another.
427 If this variable is `dummy', Gnus will create a dummy root that will
428 have all the sub-threads as children.
429 If this variable is `adopt', Gnus will make one of the \"children\"
430 the parent and mark all the step-children as such.
431 If this variable is `empty', the \"children\" are printed with empty
432 subject fields. (Or rather, they will be printed with a string
433 given by the `gnus-summary-same-subject' variable.)")
435 (defvar gnus-summary-gather-subject-limit nil
436 "*Maximum length of subject comparisons when gathering loose threads.
437 Use nil to compare full subjects. Setting this variable to a low
438 number will help gather threads that have been corrupted by
439 newsreaders chopping off subject lines, but it might also mean that
440 unrelated articles that have subject that happen to begin with the
441 same few characters will be incorrectly gathered.
443 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
444 comparing subjects.")
446 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
447 (defvar gnus-summary-same-subject ""
448 "*String indicating that the current article has the same subject as the previous.
449 This variable will only be used if the value of
450 `gnus-summary-make-false-root' is `empty'.")
452 (defvar gnus-summary-goto-unread t
453 "*If non-nil, marking commands will go to the next unread article.")
455 (defvar gnus-group-goto-unread t
456 "*If non-nil, movement commands will go to the next unread and subscribed group.")
458 (defvar gnus-check-new-newsgroups t
459 "*Non-nil means that Gnus will add new newsgroups at startup.
460 If this variable is `ask-server', Gnus will ask the server for new
461 groups since the last time it checked. This means that the killed list
462 is no longer necessary, so you could set `gnus-save-killed-list' to
465 A variant is to have this variable be a list of select methods. Gnus
466 will then use the `ask-server' method on all these select methods to
467 query for new groups from all those servers.
470 (setq gnus-check-new-newsgroups
471 '((nntp \"some.server\") (nntp \"other.server\")))
473 If this variable is nil, then you have to tell Gnus explicitly to
474 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
476 (defvar gnus-check-bogus-newsgroups nil
477 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
478 If this variable is nil, then you have to tell Gnus explicitly to
479 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
481 (defvar gnus-read-active-file t
482 "*Non-nil means that Gnus will read the entire active file at startup.
483 If this variable is nil, Gnus will only know about the groups in your
486 If this variable is `some', Gnus will try to only read the relevant
487 parts of the active file from the server. Not all servers support
488 this, and it might be quite slow with other servers, but this should
489 generally be faster than both the t and nil value.
491 If you set this variable to nil or `some', you probably still want to
492 be told about new newsgroups that arrive. To do that, set
493 `gnus-check-new-newsgroups' to `ask-server'. This may not work
494 properly with all servers.")
496 (defvar gnus-level-subscribed 5
497 "*Groups with levels less than or equal to this variable are subscribed.")
499 (defvar gnus-level-unsubscribed 7
500 "*Groups with levels less than or equal to this variable are unsubscribed.
501 Groups with levels less than `gnus-level-subscribed', which should be
502 less than this variable, are subscribed.")
504 (defvar gnus-level-zombie 8
505 "*Groups with this level are zombie groups.")
507 (defvar gnus-level-killed 9
508 "*Groups with this level are killed.")
510 (defvar gnus-level-default-subscribed 3
511 "*New subscribed groups will be subscribed at this level.")
513 (defvar gnus-level-default-unsubscribed 6
514 "*New unsubscribed groups will be unsubscribed at this level.")
516 (defvar gnus-activate-foreign-newsgroups 4
517 "*If nil, Gnus will not check foreign newsgroups at startup.
518 If it is non-nil, it should be a number between one and nine. Foreign
519 newsgroups that have a level lower or equal to this number will be
520 activated on startup. For instance, if you want to active all
521 subscribed newsgroups, but not the rest, you'd set this variable to
522 `gnus-level-subscribed'.
524 If you subscribe to lots of newsgroups from different servers, startup
525 might take a while. By setting this variable to nil, you'll save time,
526 but you won't be told how many unread articles there are in the
529 (defvar gnus-save-newsrc-file t
530 "*Non-nil means that Gnus will save the `.newsrc' file.
531 Gnus always saves its own startup file, which is called
532 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
533 be readily understood by other newsreaders. If you don't plan on
534 using other newsreaders, set this variable to nil to save some time on
537 (defvar gnus-save-killed-list t
538 "*If non-nil, save the list of killed groups to the startup file.
539 This will save both time (when starting and quitting) and space (both
540 memory and disk), but it will also mean that Gnus has no record of
541 which groups are new and which are old, so the automatic new
542 newsgroups subscription methods become meaningless. You should always
543 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
546 (defvar gnus-interactive-catchup t
547 "*If non-nil, require your confirmation when catching up a group.")
549 (defvar gnus-interactive-post t
550 "*If non-nil, group name will be asked for when posting.")
552 (defvar gnus-interactive-exit t
553 "*If non-nil, require your confirmation when exiting Gnus.")
555 (defvar gnus-kill-killed t
556 "*If non-nil, Gnus will apply kill files to already killed articles.
557 If it is nil, Gnus will never apply kill files to articles that have
558 already been through the scoring process, which might very well save lots
561 (defvar gnus-extract-address-components 'gnus-extract-address-components
562 "*Function for extracting address components from a From header.
563 Two pre-defined function exist: `gnus-extract-address-components',
564 which is the default, quite fast, and too simplistic solution, and
565 `mail-extract-address-components', which works much better, but is
568 (defvar gnus-summary-default-score 0
569 "*Default article score level.
570 If this variable is nil, scoring will be disabled.")
572 (defvar gnus-summary-zcore-fuzz 0
573 "*Fuzziness factor for the zcore in the summary buffer.
574 Articles with scores closer than this to `gnus-summary-default-score'
575 will not be marked.")
577 (defvar gnus-simplify-subject-fuzzy-regexp nil
578 "*Regular expression that will be removed from subject strings if
579 fuzzy subject simplification is selected.")
581 (defvar gnus-group-default-list-level gnus-level-subscribed
582 "*Default listing level.
583 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
585 (defvar gnus-group-use-permanent-levels nil
586 "*If non-nil, once you set a level, Gnus will use this level.")
588 (defvar gnus-show-mime nil
589 "*If non-nil, do mime processing of articles.
590 The articles will simply be fed to the function given by
591 `gnus-show-mime-method'.")
593 (defvar gnus-strict-mime t
594 "*If nil, decode MIME header even if there is not Mime-Version field.")
596 (defvar gnus-show-mime-method (function metamail-buffer)
597 "*Function to process a MIME message.
598 The function is called from the article buffer.")
600 (defvar gnus-show-threads t
601 "*If non-nil, display threads in summary mode.")
603 (defvar gnus-thread-hide-subtree nil
604 "*If non-nil, hide all threads initially.
605 If threads are hidden, you have to run the command
606 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
607 to expose hidden threads.")
609 (defvar gnus-thread-hide-killed t
610 "*If non-nil, hide killed threads automatically.")
612 (defvar gnus-thread-ignore-subject nil
613 "*If non-nil, ignore subjects and do all threading based on the Reference header.
614 If nil, which is the default, articles that have different subjects
615 from their parents will start separate threads.")
617 (defvar gnus-thread-indent-level 4
618 "*Number that says how much each sub-thread should be indented.")
620 (defvar gnus-ignored-newsgroups
621 (purecopy (mapconcat 'identity
622 '("^to\\." ; not "real" groups
623 "^[0-9. \t]+ " ; all digits in name
624 "[][\"#'()]" ; bogus characters
627 "*A regexp to match uninteresting newsgroups in the active file.
628 Any lines in the active file matching this regular expression are
629 removed from the newsgroup list before anything else is done to it,
630 thus making them effectively non-existent.")
632 (defvar gnus-ignored-headers
633 "^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:"
634 "*All headers that match this regexp will be hidden.
635 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
637 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
638 "*All headers that do not match this regexp will be hidden.
639 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
641 (defvar gnus-sorted-header-list
642 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
643 "^Cc:" "^Date:" "^Organization:")
644 "*This variable is a list of regular expressions.
645 If it is non-nil, headers that match the regular expressions will
646 be placed first in the article buffer in the sequence specified by
649 (defvar gnus-show-all-headers nil
650 "*If non-nil, don't hide any headers.")
652 (defvar gnus-save-all-headers t
653 "*If non-nil, don't remove any headers before saving.")
655 (defvar gnus-inhibit-startup-message nil
656 "*If non-nil, the startup message will not be displayed.")
658 (defvar gnus-signature-separator "^-- *$"
659 "Regexp matching signature separator.")
661 (defvar gnus-auto-extend-newsgroup t
662 "*If non-nil, extend newsgroup forward and backward when requested.")
664 (defvar gnus-auto-select-first t
665 "*If non-nil, select the first unread article when entering a group.
666 If you want to prevent automatic selection of the first unread article
667 in some newsgroups, set the variable to nil in
668 `gnus-select-group-hook'.")
670 (defvar gnus-auto-select-next t
671 "*If non-nil, offer to go to the next group from the end of the previous.
672 If the value is t and the next newsgroup is empty, Gnus will exit
673 summary mode and go back to group mode. If the value is neither nil
674 nor t, Gnus will select the following unread newsgroup. In
675 particular, if the value is the symbol `quietly', the next unread
676 newsgroup will be selected without any confirmations.")
678 (defvar gnus-auto-select-same nil
679 "*If non-nil, select the next article with the same subject.")
681 (defvar gnus-summary-check-current nil
682 "*If non-nil, consider the current article when moving.
683 The \"unread\" movement commands will stay on the same line if the
684 current article is unread.")
686 (defvar gnus-auto-center-summary t
687 "*If non-nil, always center the current summary buffer.")
689 (defvar gnus-break-pages t
690 "*If non-nil, do page breaking on articles.
691 The page delimiter is specified by the `gnus-page-delimiter'
694 (defvar gnus-page-delimiter "^\^L"
695 "*Regexp describing what to use as article page delimiters.
696 The default value is \"^\^L\", which is a form linefeed at the
697 beginning of a line.")
699 (defvar gnus-use-full-window t
700 "*If non-nil, use the entire Emacs screen.")
702 (defvar gnus-window-configuration nil
703 "Obsolete variable. See `gnus-buffer-configuration'.")
705 (defvar gnus-buffer-configuration
706 '((group ([group 1.0 point]
707 (if gnus-carpal [group-carpal 4])))
708 (summary ([summary 1.0 point]
709 (if gnus-carpal [summary-carpal 4])))
710 (article ([summary 0.25 point]
711 (if gnus-carpal [summary-carpal 4])
713 (server ([server 1.0 point]
714 (if gnus-carpal [server-carpal 2])))
715 (browse ([browse 1.0 point]
716 (if gnus-carpal [browse-carpal 2])))
717 (group-mail ([mail 1.0 point]))
718 (summary-mail ([mail 1.0 point]))
719 (summary-reply ([article 0.5]
721 (info ([nil 1.0 point]))
722 (summary-faq ([summary 0.25]
724 (edit-group ([group 0.5]
725 [edit-group 1.0 point]))
726 (edit-server ([server 0.5]
727 [edit-server 1.0 point]))
728 (edit-score ([summary 0.25]
729 [edit-score 1.0 point]))
730 (post ([post 1.0 point]))
731 (reply ([article 0.5]
733 (mail-forward ([mail 1.0 point]))
734 (post-forward ([post 1.0 point]))
735 (reply-yank ([mail 1.0 point]))
736 (followup ([article 0.5]
738 (followup-yank ([post 1.0 point])))
739 "Window configuration for all possible Gnus buffers.
740 This variable is a list of lists. Each of these lists has a NAME and
741 a RULE. The NAMEs are common-sense names like `group', which names a
742 rule used when displaying the group buffer; `summary', which names a
743 rule for what happens when you enter a group and do not display an
744 article buffer; and so on. See the value of this variable for a
745 complete list of NAMEs.
747 Each RULE is a list of vectors. The first element in this vector is
748 the name of the buffer to be displayed; the second element is the
749 percentage of the screen this buffer is to occupy (a number in the
750 0.0-0.99 range); the optional third element is `point', which should
751 be present to denote which buffer point is to go to after making this
752 buffer configuration.")
754 (defvar gnus-window-to-buffer
755 '((group . gnus-group-buffer)
756 (summary . gnus-summary-buffer)
757 (article . gnus-article-buffer)
758 (server . gnus-server-buffer)
759 (browse . "*Gnus Browse Server*")
760 (edit-group . gnus-group-edit-buffer)
761 (edit-server . gnus-server-edit-buffer)
762 (group-carpal . gnus-carpal-group-buffer)
763 (summary-carpal . gnus-carpal-summary-buffer)
764 (server-carpal . gnus-carpal-server-buffer)
765 (browse-carpal . gnus-carpal-browse-buffer)
766 (edit-score . gnus-score-edit-buffer)
767 (mail . gnus-mail-buffer)
768 (post . gnus-post-news-buffer)
769 (faq . gnus-faq-buffer))
770 "Mapping from short symbols to buffer names or buffer variables.")
772 (defvar gnus-carpal nil
773 "*If non-nil, display clickable icons.")
775 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
776 "*Function called with a group name when new group is detected.
777 A few pre-made functions are supplied: `gnus-subscribe-randomly'
778 inserts new groups at the beginning of the list of groups;
779 `gnus-subscribe-alphabetically' inserts new groups in strict
780 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
781 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
784 ;; Suggested by a bug report by Hallvard B Furuseth.
785 ;; <h.b.furuseth@usit.uio.no>.
786 (defvar gnus-subscribe-options-newsgroup-method
787 (function gnus-subscribe-alphabetically)
788 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
789 If, for instance, you want to subscribe to all newsgroups in the
790 \"no\" and \"alt\" hierarchies, you'd put the following in your
793 options -n no.all alt.all
795 Gnus will the subscribe all new newsgroups in these hierarchies with
796 the subscription method in this variable.")
798 (defvar gnus-subscribe-hierarchical-interactive nil
799 "*If non-nil, Gnus will offer to subscribe hierarchically.
800 When a new hierarchy appears, Gnus will ask the user:
802 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
804 If the user pressed `d', Gnus will descend the hierarchy, `y' will
805 subscribe to all newsgroups in the hierarchy and `s' will skip this
806 hierarchy in its entirety.")
808 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
809 "*Function used for sorting the group buffer.
810 This function will be called with group info entries as the arguments
811 for the groups to be sorted. Pre-made functions include
812 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread' and
813 `gnus-group-sort-by-level'")
815 ;; Mark variables suggested by Thomas Michanek
816 ;; <Thomas.Michanek@telelogic.se>.
817 (defvar gnus-unread-mark ?
818 "*Mark used for unread articles.")
819 (defvar gnus-ticked-mark ?!
820 "*Mark used for ticked articles.")
821 (defvar gnus-dormant-mark ??
822 "*Mark used for dormant articles.")
823 (defvar gnus-del-mark ?r
824 "*Mark used for del'd articles.")
825 (defvar gnus-read-mark ?R
826 "*Mark used for read articles.")
827 (defvar gnus-expirable-mark ?E
828 "*Mark used for expirable articles.")
829 (defvar gnus-killed-mark ?K
830 "*Mark used for killed articles.")
831 (defvar gnus-kill-file-mark ?X
832 "*Mark used for articles killed by kill files.")
833 (defvar gnus-low-score-mark ?Y
834 "*Mark used for articles with a low score.")
835 (defvar gnus-catchup-mark ?C
836 "*Mark used for articles that are caught up.")
837 (defvar gnus-replied-mark ?A
838 "*Mark used for articles that have been replied to.")
839 (defvar gnus-process-mark ?#
841 (defvar gnus-ancient-mark ?O
842 "*Mark used for ancient articles.")
843 (defvar gnus-canceled-mark ?G
844 "*Mark used for canceled articles.")
845 (defvar gnus-score-over-mark ?+
846 "*Score mark used for articles with high scores.")
847 (defvar gnus-score-below-mark ?-
848 "*Score mark used for articles with low scores.")
849 (defvar gnus-empty-thread-mark ?
850 "*There is no thread under the article.")
851 (defvar gnus-not-empty-thread-mark ?=
852 "*There is a thread under the article.")
853 (defvar gnus-dummy-mark ?Z
854 "*This is a dummy article.")
856 (defvar gnus-view-pseudo-asynchronously nil
857 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
859 (defvar gnus-view-pseudos nil
860 "*If `automatic', pseudo-articles will be viewed automatically.
861 If `not-confirm', pseudos will be viewed automatically, and the user
862 will not be asked to confirm the command.")
864 (defvar gnus-view-pseudos-separately t
865 "*If non-nil, one pseudo-article will be created for each file to be viewed.
866 If nil, all files that use the same viewing command will be given as a
867 list of parameters to that command.")
869 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
870 "*Format of group lines.
871 It works along the same lines as a normal formatting string,
872 with some simple extensions.
874 %M Only marked articles (character, \"*\" or \" \")
875 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
876 %L Level of subscribedness (integer)
877 %N Number of unread articles (integer)
878 %I Number of dormant articles (integer)
879 %i Number of ticked and dormant (integer)
880 %T Number of ticked articles (integer)
881 %R Number of read articles (integer)
882 %t Total number of articles (integer)
883 %y Number of unread, unticked articles (integer)
884 %G Group name (string)
885 %g Qualified group name (string)
886 %D Group description (string)
887 %s Select method (string)
888 %o Moderated group (char, \"m\")
889 %p Process mark (char)
890 %O Moderated group (string, \"(m)\" or \"\")
891 %n Select from where (string)
892 %z A string that look like `<%s:%n>' if a foreign select method is used
893 %u User defined specifier. The next character in the format string should
894 be a letter. Gnus will call the function gnus-user-format-function-X,
895 where X is the letter following %u. The function will be passed the
896 current header as argument. The function should return a string, which
897 will be inserted into the buffer just like information from any other
900 Text between %( and %) will be highlighted with `gnus-mouse-face' when
901 the mouse point move inside the area. There can only be one such area.
903 Note that this format specification is not always respected. For
904 reasons of efficiency, when listing killed groups, this specification
905 is ignored altogether. If the spec is changed considerably, your
906 output may end up looking strange when listing both alive and killed
909 If you use %o or %O, reading the active file will be slower and quite
910 a bit of extra memory will be used. %D will also worsen performance.
911 Also note that if you change the format specification to include any
912 of these specs, you must probably re-start Gnus to see them go into
915 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
916 "*The format specification of the lines in the summary buffer.
918 It works along the same lines as a normal formatting string,
919 with some simple extensions.
921 %N Article number, left padded with spaces (string)
923 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
924 %n Name of the poster (string)
925 %a Extracted name of the poster (string)
926 %A Extracted address of the poster (string)
927 %F Contents of the From: header (string)
928 %x Contents of the Xref: header (string)
929 %D Date of the article (string)
930 %d Date of the article (string) in DD-MMM format
931 %M Message-id of the article (string)
932 %r References of the article (string)
933 %c Number of characters in the article (integer)
934 %L Number of lines in the article (integer)
935 %I Indentation based on thread level (a string of spaces)
936 %T A string with two possible values: 80 spaces if the article
937 is on thread level two or larger and 0 spaces on level one
938 %R \"A\" if this article has been replied to, \" \" otherwise (character)
939 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
940 %[ Opening bracket (character, \"[\" or \"<\")
941 %] Closing bracket (character, \"]\" or \">\")
942 %> Spaces of length thread-level (string)
943 %< Spaces of length (- 20 thread-level) (string)
944 %i Article score (number)
945 %z Article zcore (character)
946 %t Number of articles under the current thread (number).
947 %e Whether the thread is empty or not (character).
948 %u User defined specifier. The next character in the format string should
949 be a letter. Gnus will call the function gnus-user-format-function-X,
950 where X is the letter following %u. The function will be passed the
951 current header as argument. The function should return a string, which
952 will be inserted into the summary just like information from any other
955 Text between %( and %) will be highlighted with `gnus-mouse-face'
956 when the mouse point is placed inside the area. There can only be one
959 The %U (status), %R (replied) and %z (zcore) specs have to be handled
960 with care. For reasons of efficiency, Gnus will compute what column
961 these characters will end up in, and \"hard-code\" that. This means that
962 it is illegal to have these specs after a variable-length spec. Well,
963 you might not be arrested, but your summary buffer will look strange,
966 The smart choice is to have these specs as for to the left as
969 This restriction may disappear in later versions of Gnus.")
971 (defvar gnus-summary-dummy-line-format "* : : %S\n"
972 "*The format specification for the dummy roots in the summary buffer.
973 It works along the same lines as a normal formatting string,
974 with some simple extensions.
978 (defvar gnus-summary-mode-line-format "Gnus: %b [%A] %Z"
979 "*The format specification for the summary mode line.")
981 (defvar gnus-article-mode-line-format "Gnus: %b %S"
982 "*The format specification for the article mode line.")
984 (defvar gnus-group-mode-line-format "Gnus: %b {%M:%S} "
985 "*The format specification for the group mode line.")
987 (defvar gnus-valid-select-methods
988 '(("nntp" post address prompt-address)
990 ("nnvirtual" none virtual prompt-address)
991 ("nnmbox" mail respool)
992 ("nnml" mail respool)
993 ("nnmh" mail respool)
994 ("nndir" none prompt-address address)
995 ("nneething" none prompt-address)
997 ("nndoc" none prompt-address)
998 ("nnbabyl" mail respool)
999 ("nnkiboze" post virtual)
1001 ("nnfolder" mail respool))
1002 "An alist of valid select methods.
1003 The first element of each list lists should be a string with the name
1004 of the select method. The other elements may be be the category of
1005 this method (ie. `post', `mail', `none' or whatever) or other
1006 properties that this method has (like being respoolable).
1007 If you implement a new select method, all you should have to change is
1008 this variable. I think.")
1010 (defvar gnus-updated-mode-lines '(group article summary)
1011 "*List of buffers that should update their mode lines.
1012 The list may contain the symbols `group', `article' and `summary'. If
1013 the corresponding symbol is present, Gnus will keep that mode line
1014 updated with information that may be pertinent.
1015 If this variable is nil, screen refresh may be quicker.")
1017 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1018 (defvar gnus-mode-non-string-length nil
1019 "*Max length of mode-line non-string contents.
1020 If this is nil, Gnus will take space as is needed, leaving the rest
1021 of the modeline intact.")
1024 ;(defvar gnus-mouse-face 'highlight
1025 ; "*Face used for mouse highlighting in Gnus.
1026 ;No mouse highlights will be done if `gnus-visual' is nil.")
1028 (defvar gnus-summary-mark-below nil
1029 "*Mark all articles with a score below this variable as read.
1030 This variable is local to each summary buffer and usually set by the
1033 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1034 "*List of functions used for sorting threads in the summary buffer.
1035 By default, threads are sorted by article number.
1037 Each function takes two threads and return non-nil if the first thread
1038 should be sorted before the other. If you use more than one function,
1039 the primary sort function should be the last.
1041 Ready-mady functions include `gnus-thread-sort-by-number',
1042 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1043 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1044 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1046 (defvar gnus-thread-score-function '+
1047 "*Function used for calculating the total score of a thread.
1049 The function is called with the scores of the article and each
1050 subthread and should then return the score of the thread.
1052 Some functions you can use are `+', `max', or `min'.")
1054 (defvar gnus-options-subscribe nil
1055 "*All new groups matching this regexp will be subscribed unconditionally.
1056 Note that this variable deals only with new newsgroups. This variable
1057 does not affect old newsgroups.")
1059 (defvar gnus-options-not-subscribe nil
1060 "*All new groups matching this regexp will be ignored.
1061 Note that this variable deals only with new newsgroups. This variable
1062 does not affect old (already subscribed) newsgroups.")
1064 (defvar gnus-auto-expirable-newsgroups nil
1065 "*Groups in which to automatically mark read articles as expirable.
1066 If non-nil, this should be a regexp that should match all groups in
1067 which to perform auto-expiry. This only makes sense for mail groups.")
1069 (defvar gnus-hidden-properties '(invisible t intangible t)
1070 "Property list to use for hiding text.")
1072 (defvar gnus-modtime-botch nil
1073 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1074 due to the bogus appearance that .newsrc was modified on disc.")
1078 (defvar gnus-group-mode-hook nil
1079 "*A hook for Gnus group mode.")
1081 (defvar gnus-summary-mode-hook nil
1082 "*A hook for Gnus summary mode.
1083 This hook is run before any variables are set in the summary buffer.")
1085 (defvar gnus-article-mode-hook nil
1086 "*A hook for Gnus article mode.")
1088 (defun gnus-summary-prepare-exit-hook nil
1089 "*A hook called when preparing to exit from the summary buffer.
1090 It calls `gnus-summary-expire-articles' by default.")
1091 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1093 (defun gnus-summary-exit-hook nil
1094 "*A hook called on exit from the summary buffer.")
1096 (defvar gnus-open-server-hook nil
1097 "*A hook called just before opening connection to the news server.")
1099 (defvar gnus-load-hook nil
1100 "*A hook run while Gnus is loaded.")
1102 (defvar gnus-startup-hook nil
1103 "*A hook called at startup.
1104 This hook is called after Gnus is connected to the NNTP server.")
1106 (defvar gnus-get-new-news-hook nil
1107 "*A hook run just before Gnus checks for new news.")
1109 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1110 "*A function that is called to generate the group buffer.
1111 The function is called with three arguments: The first is a number;
1112 all group with a level less or equal to that number should be listed,
1113 if the second is non-nil, empty groups should also be displayed. If
1114 the third is non-nil, it is a number. No groups with a level lower
1115 than this number should be displayed.
1117 The only current function implemented is `gnus-group-prepare-flat'.")
1119 (defvar gnus-group-prepare-hook nil
1120 "*A hook called after the group buffer has been generated.
1121 If you want to modify the group buffer, you can use this hook.")
1123 (defvar gnus-summary-prepare-hook nil
1124 "*A hook called after the summary buffer has been generated.
1125 If you want to modify the summary buffer, you can use this hook.")
1127 (defvar gnus-article-prepare-hook nil
1128 "*A hook called after an article has been prepared in the article buffer.
1129 If you want to run a special decoding program like nkf, use this hook.")
1131 ;(defvar gnus-article-display-hook nil
1132 ; "*A hook called after the article is displayed in the article buffer.
1133 ;The hook is designed to change the contents of the article
1134 ;buffer. Typical functions that this hook may contain are
1135 ;`gnus-article-hide-headers' (hide selected headers),
1136 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1137 ;`gnus-article-hide-signature' (hide signature) and
1138 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1139 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1140 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1141 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1143 (defvar gnus-article-x-face-command
1144 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1145 "String or function to be executed to display an X-Face header.
1146 If it is a string, the command will be executed in a sub-shell
1147 asynchronously. The compressed face will be piped to this command.")
1149 (defvar gnus-article-x-face-too-ugly nil
1150 "Regexp matching posters whose face shouldn't be shown automatically.")
1152 (defvar gnus-select-group-hook nil
1153 "*A hook called when a newsgroup is selected.
1155 If you'd like to simplify subjects like the
1156 `gnus-summary-next-same-subject' command does, you can use the
1159 (setq gnus-select-group-hook
1162 (mapcar (lambda (header)
1163 (mail-header-set-subject
1165 (gnus-simplify-subject
1166 (mail-header-subject header) 're-only)))
1167 gnus-newsgroup-headers))))")
1169 (defvar gnus-select-article-hook
1170 '(gnus-summary-show-thread)
1171 "*A hook called when an article is selected.
1172 The default hook shows conversation thread subtrees of the selected
1173 article automatically using `gnus-summary-show-thread'.")
1175 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1176 "*A hook called to apply kill files to a group.
1177 This hook is intended to apply a kill file to the selected newsgroup.
1178 The function `gnus-apply-kill-file' is called by default.
1180 Since a general kill file is too heavy to use only for a few
1181 newsgroups, I recommend you to use a lighter hook function. For
1182 example, if you'd like to apply a kill file to articles which contains
1183 a string `rmgroup' in subject in newsgroup `control', you can use the
1186 (setq gnus-apply-kill-hook
1189 (cond ((string-match \"control\" gnus-newsgroup-name)
1190 (gnus-kill \"Subject\" \"rmgroup\")
1191 (gnus-expunge \"X\"))))))")
1193 (defvar gnus-visual-mark-article-hook
1194 (list 'gnus-highlight-selected-summary)
1195 "*Hook run after selecting an article in the summary buffer.
1196 It is meant to be used for highlighting the article in some way. It
1197 is not run if `gnus-visual' is nil.")
1199 (defun gnus-parse-headers-hook nil
1200 "*A hook called before parsing the headers.")
1202 (defvar gnus-exit-group-hook nil
1203 "*A hook called when exiting (not quitting) summary mode.")
1205 (defvar gnus-suspend-gnus-hook nil
1206 "*A hook called when suspending (not exiting) Gnus.")
1208 (defvar gnus-exit-gnus-hook nil
1209 "*A hook called when exiting Gnus.")
1211 (defvar gnus-save-newsrc-hook nil
1212 "*A hook called when saving the newsrc file.")
1214 (defvar gnus-summary-update-hook
1215 (list 'gnus-summary-highlight-line)
1216 "*A hook called when a summary line is changed.
1217 The hook will not be called if `gnus-visual' is nil.
1219 The default function `gnus-summary-highlight-line' will
1220 highlight the line according to the `gnus-summary-highlight'
1223 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1224 "*A hook called when an article is selected for the first time.
1225 The hook is intended to mark an article as read (or unread)
1226 automatically when it is selected.")
1228 ;; Remove any hilit infestation.
1229 (add-hook 'gnus-startup-hook
1231 (remove-hook 'gnus-summary-prepare-hook
1232 'hilit-rehighlight-buffer-quietly)
1233 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1234 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1235 (remove-hook 'gnus-article-prepare-hook
1236 'hilit-rehighlight-buffer-quietly)))
1240 ;; Internal variables
1242 ;; Avoid highlighting in kill files.
1243 (defvar gnus-summary-inhibit-highlight nil)
1244 (defvar gnus-newsgroup-selected-overlay nil)
1246 (defvar gnus-article-mode-map nil)
1247 (defvar gnus-dribble-buffer nil)
1248 (defvar gnus-headers-retrieved-by nil)
1249 (defvar gnus-article-reply nil)
1250 (defvar gnus-override-method nil)
1251 (defvar gnus-article-check-size nil)
1253 (defvar gnus-current-score-file nil)
1254 (defvar gnus-internal-global-score-files nil)
1255 (defvar gnus-score-file-list nil)
1256 (defvar gnus-scores-exclude-files nil)
1258 (defvar gnus-current-move-group nil)
1260 (defvar gnus-newsgroup-dependencies nil)
1261 (defvar gnus-newsgroup-threads nil)
1262 (defvar gnus-newsgroup-async nil)
1263 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1265 (defvar gnus-newsgroup-adaptive nil)
1267 (defvar gnus-summary-display-table nil)
1269 (defconst gnus-group-line-format-alist
1270 (list (list ?M 'marked ?c)
1271 (list ?S 'subscribed ?c)
1273 (list ?N 'number ?s)
1274 (list ?I 'number-of-dormant ?d)
1275 (list ?T 'number-of-ticked ?d)
1276 (list ?R 'number-of-read ?s)
1277 (list ?t 'number-total ?d)
1278 (list ?y 'number-of-unread-unticked ?s)
1279 (list ?i 'number-of-ticked-and-dormant ?d)
1281 (list ?G 'qualified-group ?s)
1282 (list ?D 'newsgroup-description ?s)
1283 (list ?o 'moderated ?c)
1284 (list ?O 'moderated-string ?s)
1285 (list ?p 'process-marked ?c)
1286 (list ?s 'news-server ?s)
1287 (list ?n 'news-method ?s)
1288 (list ?z 'news-method-string ?s)
1289 (list ?u 'user-defined ?s)))
1291 (defconst gnus-summary-line-format-alist
1292 (list (list ?N 'number ?d)
1293 (list ?S 'subject ?s)
1294 (list ?s 'subject-or-nil ?s)
1296 (list ?A '(car (cdr (funcall gnus-extract-address-components from)))
1298 (list ?a '(or (car (funcall gnus-extract-address-components from))
1301 (list ?x (macroexpand '(mail-header-xref header)) ?s)
1302 (list ?D (macroexpand '(mail-header-date header)) ?s)
1303 (list ?d '(gnus-dd-mmm (mail-header-date header)) ?s)
1304 (list ?M (macroexpand '(mail-header-id header)) ?s)
1305 (list ?r (macroexpand '(mail-header-references header)) ?s)
1306 (list ?c '(or (mail-header-chars header) 0) ?d)
1308 (list ?I 'indentation ?s)
1309 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1310 (list ?R 'replied ?c)
1311 (list ?\[ 'opening-bracket ?c)
1312 (list ?\] 'closing-bracket ?c)
1313 (list ?\> '(make-string level ? ) ?s)
1314 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1316 (list ?z 'score-char ?c)
1317 (list ?U 'unread ?c)
1318 (list ?t '(gnus-summary-number-of-articles-in-thread
1319 (and (boundp 'thread) (car thread)))
1321 (list ?e '(gnus-summary-number-of-articles-in-thread
1322 (and (boundp 'thread) (car thread)) t)
1324 (list ?u 'user-defined ?s))
1325 "An alist of format specifications that can appear in summary lines,
1326 and what variables they correspond with, along with the type of the
1327 variable (string, integer, character, etc).")
1329 (defconst gnus-summary-dummy-line-format-alist
1330 (list (list ?S 'subject ?s)
1331 (list ?N 'number ?d)
1332 (list ?u 'user-defined ?s)))
1334 (defconst gnus-summary-mode-line-format-alist
1335 (list (list ?G 'group-name ?s)
1336 (list ?g '(gnus-short-group-name group-name) ?s)
1337 (list ?A 'article-number ?d)
1338 (list ?Z 'unread-and-unselected ?s)
1339 (list ?V 'gnus-version ?s)
1340 (list ?U 'unread ?d)
1341 (list ?S 'subject ?s)
1342 (list ?e 'unselected ?d)
1343 (list ?u 'user-defined ?s)
1344 (list ?b 'buffer-name ?s)
1345 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1347 (defconst gnus-group-mode-line-format-alist
1348 (list (list ?S 'news-server ?s)
1349 (list ?M 'news-method ?s)
1350 (list ?b '(buffer-name) ?s)
1351 (list ?u 'user-defined ?s)))
1353 (defvar gnus-have-read-active-file nil)
1355 (defconst gnus-maintainer
1356 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1357 "The mail address of the Gnus maintainers.")
1359 (defconst gnus-version "Gnus v5.1"
1360 "Version number for this version of Gnus.")
1362 (defvar gnus-info-nodes
1363 '((gnus-group-mode "(gnus)The Group Buffer")
1364 (gnus-summary-mode "(gnus)The Summary Buffer")
1365 (gnus-article-mode "(gnus)The Article Buffer"))
1366 "Assoc list of major modes and related Info nodes.")
1368 (defvar gnus-group-buffer "*Group*")
1369 (defvar gnus-summary-buffer "*Summary*")
1370 (defvar gnus-article-buffer "*Article*")
1371 (defvar gnus-server-buffer "*Server*")
1373 (defvar gnus-work-buffer " *gnus work*")
1375 (defvar gnus-buffer-list nil
1376 "Gnus buffers that should be killed on exit.")
1378 (defvar gnus-server-alist nil
1379 "List of available servers.")
1381 (defvar gnus-variable-list
1382 '(gnus-newsrc-options gnus-newsrc-options-n
1383 gnus-newsrc-last-checked-date
1384 gnus-newsrc-alist gnus-server-alist
1385 gnus-killed-list gnus-zombie-list)
1386 "Gnus variables saved in the quick startup file.")
1388 (defvar gnus-overload-functions
1389 '((news-inews gnus-inews-news "rnewspost"))
1390 "Functions overloaded by gnus.
1391 It is a list of `(original overload &optional file)'.")
1393 (defvar gnus-newsrc-options nil
1394 "Options line in the .newsrc file.")
1396 (defvar gnus-newsrc-options-n nil
1397 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1399 (defvar gnus-newsrc-last-checked-date nil
1400 "Date Gnus last asked server for new newsgroups.")
1402 (defvar gnus-newsrc-alist nil
1403 "Assoc list of read articles.
1404 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1406 (defvar gnus-newsrc-hashtb nil
1407 "Hashtable of gnus-newsrc-alist.")
1409 (defvar gnus-killed-list nil
1410 "List of killed newsgroups.")
1412 (defvar gnus-killed-hashtb nil
1413 "Hash table equivalent of gnus-killed-list.")
1415 (defvar gnus-zombie-list nil
1416 "List of almost dead newsgroups.")
1418 (defvar gnus-description-hashtb nil
1419 "Descriptions of newsgroups.")
1421 (defvar gnus-list-of-killed-groups nil
1422 "List of newsgroups that have recently been killed by the user.")
1424 (defvar gnus-active-hashtb nil
1425 "Hashtable of active articles.")
1427 (defvar gnus-moderated-list nil
1428 "List of moderated newsgroups.")
1430 (defvar gnus-group-marked nil)
1432 (defvar gnus-current-startup-file nil
1433 "Startup file for the current host.")
1435 (defvar gnus-last-search-regexp nil
1436 "Default regexp for article search command.")
1438 (defvar gnus-last-shell-command nil
1439 "Default shell command on article.")
1441 (defvar gnus-current-select-method nil
1442 "The current method for selecting a newsgroup.")
1444 (defvar gnus-group-list-mode nil)
1446 (defvar gnus-article-internal-prepare-hook nil)
1448 (defvar gnus-newsgroup-name nil)
1449 (defvar gnus-newsgroup-begin nil)
1450 (defvar gnus-newsgroup-end nil)
1451 (defvar gnus-newsgroup-last-rmail nil)
1452 (defvar gnus-newsgroup-last-mail nil)
1453 (defvar gnus-newsgroup-last-folder nil)
1454 (defvar gnus-newsgroup-last-file nil)
1455 (defvar gnus-newsgroup-auto-expire nil)
1456 (defvar gnus-newsgroup-active nil)
1458 (defvar gnus-newsgroup-unreads nil
1459 "List of unread articles in the current newsgroup.")
1461 (defvar gnus-newsgroup-unselected nil
1462 "List of unselected unread articles in the current newsgroup.")
1464 (defvar gnus-newsgroup-reads nil
1465 "Alist of read articles and article marks in the current newsgroup.")
1467 (defvar gnus-newsgroup-marked nil
1468 "List of ticked articles in the current newsgroup (a subset of unread art).")
1470 (defvar gnus-newsgroup-killed nil
1471 "List of ranges of articles that have been through the scoring process.")
1473 (defvar gnus-newsgroup-kill-headers nil)
1475 (defvar gnus-newsgroup-replied nil
1476 "List of articles that have been replied to in the current newsgroup.")
1478 (defvar gnus-newsgroup-expirable nil
1479 "List of articles in the current newsgroup that can be expired.")
1481 (defvar gnus-newsgroup-processable nil
1482 "List of articles in the current newsgroup that can be processed.")
1484 (defvar gnus-newsgroup-bookmarks nil
1485 "List of articles in the current newsgroup that have bookmarks.")
1487 (defvar gnus-newsgroup-dormant nil
1488 "List of dormant articles in the current newsgroup.")
1490 (defvar gnus-newsgroup-scored nil
1491 "List of scored articles in the current newsgroup.")
1493 (defvar gnus-newsgroup-headers nil
1494 "List of article headers in the current newsgroup.")
1495 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1497 (defvar gnus-newsgroup-ancient nil
1498 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1500 (defvar gnus-current-article nil)
1501 (defvar gnus-article-current nil)
1502 (defvar gnus-current-headers nil)
1503 (defvar gnus-have-all-headers nil)
1504 (defvar gnus-last-article nil)
1505 (defvar gnus-newsgroup-history nil)
1506 (defvar gnus-current-kill-article nil)
1508 ;; Save window configuration.
1509 (defvar gnus-prev-winconf nil)
1512 (defvar gnus-summary-line-format-spec nil)
1513 (defvar gnus-summary-dummy-line-format-spec nil)
1514 (defvar gnus-group-line-format-spec nil)
1515 (defvar gnus-summary-mode-line-format-spec nil)
1516 (defvar gnus-article-mode-line-format-spec nil)
1517 (defvar gnus-group-mode-line-format-spec nil)
1518 (defvar gnus-summary-mark-positions nil)
1519 (defvar gnus-group-mark-positions nil)
1521 (defvar gnus-summary-expunge-below nil)
1522 (defvar gnus-reffed-article-number nil)
1524 ; Let the byte-compiler know that we know about this variable.
1525 (defvar rmail-default-rmail-file)
1527 (defvar gnus-cache-removable-articles nil)
1529 (defconst gnus-summary-local-variables
1530 '(gnus-newsgroup-name
1531 gnus-newsgroup-begin gnus-newsgroup-end
1532 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1533 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1534 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1535 gnus-newsgroup-unselected gnus-newsgroup-marked
1536 gnus-newsgroup-reads
1537 gnus-newsgroup-replied gnus-newsgroup-expirable
1538 gnus-newsgroup-processable gnus-newsgroup-killed
1539 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1540 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1541 gnus-current-article gnus-current-headers gnus-have-all-headers
1542 gnus-last-article gnus-article-internal-prepare-hook
1543 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1544 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1545 gnus-newsgroup-threads gnus-newsgroup-async
1546 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1547 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1548 gnus-newsgroup-history gnus-newsgroup-ancient
1549 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1550 gnus-cache-removable-articles)
1551 "Variables that are buffer-local to the summary buffers.")
1553 (defconst gnus-bug-message
1554 "Sending a bug report to the Gnus Towers.
1555 ========================================
1557 The buffer below is a mail buffer. When you press `C-c C-c', it will
1558 be sent to the Gnus Bug Exterminators.
1560 At the bottom of the buffer you'll see lots of variable settings.
1561 Please do not delete those. They will tell the Bug People what your
1562 environment is, so that it will be easier to locate the bugs.
1564 If you have found a bug that makes Emacs go \"beep\", set
1565 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1566 and include the backtrace in your bug report.
1568 Please describe the bug in annoying, painstaking detail.
1570 Thank you for your help in stamping out bugs.
1573 ;;; End of variables.
1575 ;; Define some autoload functions Gnus might use.
1579 (autoload 'metamail-buffer "metamail")
1580 (autoload 'Info-goto-node "info")
1581 (autoload 'hexl-hex-string-to-integer "hexl")
1583 (autoload 'pp-to-string "pp")
1584 (autoload 'pp-eval-expression "pp")
1585 (autoload 'mail-extract-address-components "mail-extr")
1587 (autoload 'nnmail-split-fancy "nnmail")
1588 (autoload 'nnvirtual-catchup-group "nnvirtual")
1591 (autoload 'timezone-make-date-arpa-standard "timezone")
1592 (autoload 'timezone-fix-time "timezone")
1593 (autoload 'timezone-make-sortable-date "timezone")
1594 (autoload 'timezone-make-time-string "timezone")
1597 (autoload 'mail-position-on-field "sendmail")
1598 (autoload 'mail-setup "sendmail")
1599 (autoload 'rmail-output "rmailout")
1600 (autoload 'news-mail-other-window "rnewspost")
1601 (autoload 'news-reply-yank-original "rnewspost")
1602 (autoload 'news-caesar-buffer-body "rnewspost")
1603 (autoload 'rmail-insert-rmail-file-header "rmail")
1604 (autoload 'rmail-count-new-messages "rmail")
1605 (autoload 'rmail-show-message "rmail")
1608 ;;(autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1609 ;;(autoload 'gnus-brew-soup "gnus-soup" nil t)
1610 ;;(autoload 'gnus-soup-add-article "gnus-soup" nil t)
1611 ;;(autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1612 ;;(autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1613 ;;(autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1614 ;;(autoload 'nnsoup-pack-replies "nnsoup" nil t)
1617 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1618 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1619 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1620 (autoload 'gnus-summary-save-in-folder "gnus-mh" nil t)
1621 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1622 (autoload 'gnus-Folder-save-name "gnus-mh")
1623 (autoload 'gnus-folder-save-name "gnus-mh")
1626 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1627 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1628 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1629 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1630 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1631 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1632 (autoload 'gnus-summary-highlight-line "gnus-vis")
1633 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1636 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1637 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1638 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1639 (autoload 'gnus-article-highlight-some "gnus-vis" nil t)
1640 (autoload 'gnus-article-hide "gnus-vis" nil t)
1641 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1642 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1643 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1644 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1645 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1646 (autoload 'gnus-article-add-button "gnus-vis")
1649 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1650 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1651 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1654 (autoload 'gnus-kill "gnus-kill")
1655 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1656 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1657 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1658 (autoload 'gnus-execute "gnus-kill")
1659 (autoload 'gnus-expunge "gnus-kill")
1662 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1663 (autoload 'gnus-cache-save-buffers "gnus-cache")
1664 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1665 (autoload 'gnus-cache-request-article "gnus-cache")
1666 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1667 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1668 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1669 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1672 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1673 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1674 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1675 (autoload 'gnus-score-save "gnus-score")
1676 (autoload 'gnus-score-headers "gnus-score")
1677 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1678 (autoload 'gnus-score-adaptive "gnus-score")
1679 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1680 (autoload 'gnus-score-find-trace "gnus-score")
1683 (autoload 'gnus-score-customize "gnus-edit" nil t)
1686 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1687 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1688 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1689 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1690 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1691 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1692 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1693 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1694 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1695 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1696 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1697 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1698 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1699 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1700 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1701 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1702 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1703 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1704 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1705 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1706 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1707 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1710 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1711 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1712 (autoload 'gnus-group-mail "gnus-msg" nil t)
1713 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1714 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1715 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1716 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1717 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1718 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1719 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1720 (autoload 'gnus-post-news "gnus-msg" nil t)
1721 (autoload 'gnus-inews-news "gnus-msg" nil t)
1722 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1723 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1724 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1725 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1726 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1727 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1728 (autoload 'gnus-mail-yank-original "gnus-msg")
1729 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1730 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1731 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1732 (autoload 'gnus-article-mail "gnus-msg")
1733 (autoload 'gnus-bug "gnus-msg" nil t)
1736 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1737 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1738 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1739 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1740 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1741 (autoload 'gnus-yank-article "gnus-vm" nil t)
1747 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1748 ;; If you want the cursor to go somewhere else, set these two
1749 ;; functions in some startup hook to whatever you want.
1750 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1751 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1753 ;;; Various macros and substs.
1755 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1756 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1757 (` (let ((GnusStartBufferWindow (selected-window)))
1760 (pop-to-buffer (, buffer))
1762 (select-window GnusStartBufferWindow)))))
1764 (defmacro gnus-gethash (string hashtable)
1765 "Get hash value of STRING in HASHTABLE."
1766 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1767 ;;(` (abbrev-expansion (, string) (, hashtable)))
1768 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1770 (defmacro gnus-sethash (string value hashtable)
1771 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1772 ;; We cannot use define-abbrev since it only accepts string as value.
1773 ;; (set (intern string hashtable) value))
1774 (` (set (intern (, string) (, hashtable)) (, value))))
1776 (defsubst gnus-buffer-substring (beg end)
1777 (buffer-substring (match-beginning beg) (match-end end)))
1779 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1780 ;; function `substring' might cut on a middle of multi-octet
1782 (defun gnus-truncate-string (str width)
1783 (substring str 0 width))
1785 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1786 ;; to limit the length of a string. This function is necessary since
1787 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1788 (defsubst gnus-limit-string (str width)
1789 (if (> (length str) width)
1790 (substring str 0 width)
1793 (defsubst gnus-simplify-subject-re (subject)
1794 "Remove \"Re:\" from subject lines."
1795 (let ((case-fold-search t))
1796 (if (string-match "^re: *" subject)
1797 (substring subject (match-end 0))
1800 (defsubst gnus-goto-char (point)
1801 (and point (goto-char point)))
1803 (defmacro gnus-buffer-exists-p (buffer)
1805 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1808 (defmacro gnus-kill-buffer (buffer)
1809 (` (if (gnus-buffer-exists-p (, buffer))
1810 (kill-buffer (, buffer)))))
1812 (defsubst gnus-point-at-bol ()
1813 "Return point at the beginning of line."
1820 (defsubst gnus-point-at-eol ()
1821 "Return point at the beginning of line."
1828 ;; Delete the current line (and the next N lines.);
1829 (defmacro gnus-delete-line (&optional n)
1830 (` (delete-region (progn (beginning-of-line) (point))
1831 (progn (forward-line (, (or n 1))) (point)))))
1833 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1834 (defvar gnus-init-inhibit nil)
1835 (defun gnus-read-init-file (&optional inhibit-next)
1836 (if gnus-init-inhibit
1837 (setq gnus-init-inhibit nil)
1838 (setq gnus-init-inhibit inhibit-next)
1840 (or (and (file-exists-p gnus-init-file)
1841 ;; Don't try to load a directory.
1842 (not (file-directory-p gnus-init-file)))
1843 (file-exists-p (concat gnus-init-file ".el"))
1844 (file-exists-p (concat gnus-init-file ".elc")))
1845 (load gnus-init-file nil t))))
1847 ;;; Load the user startup file.
1848 ;; (eval '(gnus-read-init-file 'inhibit))
1850 ;;; Load the compatibility functions.
1857 ;;; Gnus Utility Functions
1860 (defun gnus-extract-address-components (from)
1862 ;; First find the address - the thing with the @ in it. This may
1863 ;; not be accurate in mail addresses, but does the trick most of
1864 ;; the time in news messages.
1865 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1866 (setq address (substring from (match-beginning 0) (match-end 0))))
1867 ;; Then we check whether the "name <address>" format is used.
1869 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1870 ;; Linear white space is not required.
1871 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
1872 (and (setq name (substring from 0 (match-beginning 0)))
1873 ;; Strip any quotes from the name.
1874 (string-match "\".*\"" name)
1875 (setq name (substring name 1 (1- (match-end 0))))))
1876 ;; If not, then "address (name)" is used.
1878 (and (string-match "(.+)" from)
1879 (setq name (substring from (1+ (match-beginning 0))
1880 (1- (match-end 0)))))
1881 (and (string-match "()" from)
1882 (setq name address))
1883 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1884 ;; XOVER might not support folded From headers.
1885 (and (string-match "(.*" from)
1886 (setq name (substring from (1+ (match-beginning 0))
1888 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1889 (list (or name from) (or address from))))
1891 (defun gnus-fetch-field (field)
1892 "Return the value of the header FIELD of current article."
1895 (let ((case-fold-search t))
1896 (gnus-narrow-to-headers)
1897 (mail-fetch-field field)))))
1899 (defun gnus-goto-colon ()
1901 (search-forward ":" (gnus-point-at-eol) t))
1903 (defun gnus-narrow-to-headers ()
1907 (goto-char (point-min))
1908 (if (search-forward "\n\n" nil t)
1912 (defvar gnus-old-specs nil)
1914 (defun gnus-update-format-specifications ()
1915 (gnus-make-thread-indent-array)
1917 (let ((formats '(summary summary-dummy group
1918 summary-mode group-mode article-mode))
1919 old-format new-format)
1921 (setq new-format (symbol-value
1922 (intern (format "gnus-%s-line-format" (car formats)))))
1923 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs)))
1924 (equal old-format new-format))
1925 (set (intern (format "gnus-%s-line-format-spec" (car formats)))
1929 (intern (format "gnus-%s-line-format-alist"
1930 (if (eq (car formats) 'article-mode)
1931 'summary-mode (car formats))))))))
1932 (setq gnus-old-specs (cons (cons (car formats) new-format)
1933 (delq (car formats) gnus-old-specs)))
1934 (setq formats (cdr formats))))
1936 (gnus-update-group-mark-positions)
1937 (gnus-update-summary-mark-positions)
1939 (if (and (string-match "%D" gnus-group-line-format)
1940 (not gnus-description-hashtb)
1941 gnus-read-active-file)
1942 (gnus-read-all-descriptions-files)))
1944 (defun gnus-update-summary-mark-positions ()
1946 (let ((gnus-replied-mark 129)
1947 (gnus-score-below-mark 130)
1948 (gnus-score-over-mark 130)
1951 (gnus-set-work-buffer)
1952 (gnus-summary-insert-line
1953 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1954 (goto-char (point-min))
1955 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1957 (goto-char (point-min))
1958 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1959 (- (point) 2))) pos))
1960 (goto-char (point-min))
1961 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1962 (- (point) 2))) pos))
1963 (setq gnus-summary-mark-positions pos))))
1965 (defun gnus-update-group-mark-positions ()
1967 (let ((gnus-process-mark 128)
1968 (gnus-group-marked '("dummy.group")))
1969 (gnus-sethash "dummy.group" '(0 . 0) gnus-active-hashtb)
1970 (gnus-set-work-buffer)
1971 (gnus-group-insert-group-line nil "dummy.group" 0 nil 0 nil)
1972 (goto-char (point-min))
1973 (setq gnus-group-mark-positions
1974 (list (cons 'process (and (search-forward "\200" nil t)
1975 (- (point) 2))))))))
1977 (defun gnus-mouse-face-function (form)
1978 (` (let ((string (, form)))
1979 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1982 (defun gnus-max-width-function (el max-width)
1983 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
1984 (` (let* ((val (eval (, el)))
1985 (valstr (if (numberp val)
1986 (int-to-string val) val)))
1987 (if (> (length valstr) (, max-width))
1988 (substring valstr 0 (, max-width))
1991 (defun gnus-parse-format (format spec-alist)
1992 ;; This function parses the FORMAT string with the help of the
1993 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1994 ;; string. If the FORMAT string contains the specifiers %( and %)
1995 ;; the text between them will have the mouse-face text property.
1996 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1997 (if (and gnus-visual gnus-mouse-face)
1998 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1999 (button (substring format (match-beginning 2) (match-end 2)))
2000 (post (substring format (match-beginning 3) (match-end 3))))
2002 (gnus-parse-simple-format pre spec-alist)
2003 (gnus-mouse-face-function
2004 (gnus-parse-simple-format button spec-alist))
2005 (gnus-parse-simple-format post spec-alist)))
2006 (gnus-parse-simple-format
2007 (concat (substring format (match-beginning 1) (match-end 1))
2008 (substring format (match-beginning 2) (match-end 2))
2009 (substring format (match-beginning 3) (match-end 3)))
2011 (gnus-parse-simple-format format spec-alist)))
2013 (defun gnus-parse-simple-format (format spec-alist)
2014 ;; This function parses the FORMAT string with the help of the
2015 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2016 ;; string. The list will consist of the symbol `format', a format
2017 ;; specification string, and a list of forms depending on the
2020 spec flist fstring newspec elem beg)
2022 (gnus-set-work-buffer)
2024 (goto-char (point-min))
2025 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?" nil t)
2026 (setq spec (string-to-char (buffer-substring (match-beginning 2)
2028 ;; First check if there are any specs that look anything like
2029 ;; "%12,12A", ie. with a "max width specification". These have
2030 ;; to be treated specially.
2031 (if (setq beg (match-beginning 1))
2034 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
2036 (setq beg (match-beginning 2)))
2037 ;; Find the specification from `spec-alist'.
2038 (if (not (setq elem (cdr (assq spec spec-alist))))
2039 (setq elem '("*" ?s)))
2040 ;; Treat user defined format specifiers specially
2041 (and (eq (car elem) 'user-defined)
2044 (list (intern (concat "gnus-user-format-function-"
2050 (delete-region (match-beginning 3) (match-end 3)))
2051 (if (not (zerop max-width))
2052 (let ((el (car elem)))
2053 (cond ((= (car (cdr elem)) ?c)
2054 (setq el (list 'char-to-string el)))
2055 ((= (car (cdr elem)) ?d)
2056 (numberp el) (setq el (list 'int-to-string el))))
2057 (setq flist (cons (gnus-max-width-function el max-width)
2060 (setq flist (cons (car elem) flist))
2061 (setq newspec (car (cdr elem))))
2062 ;; Remove the old specification (and possibly a ",12" string).
2063 (delete-region beg (match-end 2))
2064 ;; Insert the new specification.
2067 (setq fstring (buffer-substring 1 (point-max))))
2068 (cons 'format (cons fstring (nreverse flist)))))
2070 (defun gnus-set-work-buffer ()
2071 (if (get-buffer gnus-work-buffer)
2073 (set-buffer gnus-work-buffer)
2075 (set-buffer (get-buffer-create gnus-work-buffer))
2076 (kill-all-local-variables)
2077 (buffer-disable-undo (current-buffer))
2078 (gnus-add-current-to-buffer-list)))
2080 ;; Article file names when saving.
2082 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2083 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2084 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2085 Otherwise, it is like ~/News/news/group/num."
2088 (concat (if (gnus-use-long-file-name 'not-save)
2089 (gnus-capitalize-newsgroup newsgroup)
2090 (gnus-newsgroup-directory-form newsgroup))
2091 "/" (int-to-string (mail-header-number headers)))
2092 (or gnus-article-save-directory "~/News"))))
2094 (string-equal (file-name-directory default)
2095 (file-name-directory last-file))
2096 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2098 (or last-file default))))
2100 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2101 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2102 If variable `gnus-use-long-file-name' is non-nil, it is
2103 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2106 (concat (if (gnus-use-long-file-name 'not-save)
2108 (gnus-newsgroup-directory-form newsgroup))
2109 "/" (int-to-string (mail-header-number headers)))
2110 (or gnus-article-save-directory "~/News"))))
2112 (string-equal (file-name-directory default)
2113 (file-name-directory last-file))
2114 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2116 (or last-file default))))
2118 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2119 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2120 If variable `gnus-use-long-file-name' is non-nil, it is
2121 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2124 (if (gnus-use-long-file-name 'not-save)
2125 (gnus-capitalize-newsgroup newsgroup)
2126 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2127 (or gnus-article-save-directory "~/News"))))
2129 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2130 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2131 If variable `gnus-use-long-file-name' is non-nil, it is
2132 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2135 (if (gnus-use-long-file-name 'not-save)
2137 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2138 (or gnus-article-save-directory "~/News"))))
2140 ;; For subscribing new newsgroup
2142 (defun gnus-subscribe-hierarchical-interactive (groups)
2143 (let ((groups (sort groups 'string<))
2144 prefixes prefix start ans group starts)
2146 (setq prefixes (list "^"))
2147 (while (and groups prefixes)
2148 (while (not (string-match (car prefixes) (car groups)))
2149 (setq prefixes (cdr prefixes)))
2150 (setq prefix (car prefixes))
2151 (setq start (1- (length prefix)))
2152 (if (and (string-match "[^\\.]\\." (car groups) start)
2155 (concat "^" (substring (car groups) 0 (match-end 0))))
2156 (string-match prefix (car (cdr groups))))
2158 (setq prefixes (cons prefix prefixes))
2159 (message "Descend hierarchy %s? ([y]nsq): "
2160 (substring prefix 1 (1- (length prefix))))
2161 (setq ans (read-char))
2164 (string-match prefix
2165 (setq group (car groups))))
2166 (setq gnus-killed-list
2167 (cons group gnus-killed-list))
2168 (gnus-sethash group group gnus-killed-hashtb)
2169 (setq groups (cdr groups)))
2170 (setq starts (cdr starts)))
2173 (string-match prefix
2174 (setq group (car groups))))
2175 (gnus-sethash group group gnus-killed-hashtb)
2176 (gnus-subscribe-alphabetically (car groups))
2177 (setq groups (cdr groups)))
2178 (setq starts (cdr starts)))
2181 (setq group (car groups))
2182 (setq gnus-killed-list (cons group gnus-killed-list))
2183 (gnus-sethash group group gnus-killed-hashtb)
2184 (setq groups (cdr groups))))
2186 (message "Subscribe %s? ([n]yq)" (car groups))
2187 (setq ans (read-char))
2188 (setq group (car groups))
2190 (gnus-subscribe-alphabetically (car groups))
2191 (gnus-sethash group group gnus-killed-hashtb))
2194 (setq group (car groups))
2195 (setq gnus-killed-list (cons group gnus-killed-list))
2196 (gnus-sethash group group gnus-killed-hashtb)
2197 (setq groups (cdr groups))))
2199 (setq gnus-killed-list (cons group gnus-killed-list))
2200 (gnus-sethash group group gnus-killed-hashtb)))
2201 (setq groups (cdr groups)))))))
2203 (defun gnus-subscribe-randomly (newsgroup)
2204 "Subscribe new NEWSGROUP by making it the first newsgroup."
2205 (gnus-subscribe-newsgroup newsgroup))
2207 (defun gnus-subscribe-alphabetically (newgroup)
2208 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2209 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2210 (let ((groups (cdr gnus-newsrc-alist))
2212 (while (and (not before) groups)
2213 (if (string< newgroup (car (car groups)))
2214 (setq before (car (car groups)))
2215 (setq groups (cdr groups))))
2216 (gnus-subscribe-newsgroup newgroup before)))
2218 (defun gnus-subscribe-hierarchically (newgroup)
2219 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2220 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2222 (set-buffer (find-file-noselect gnus-current-startup-file))
2223 (let ((groupkey newgroup)
2225 (while (and (not before) groupkey)
2226 (goto-char (point-min))
2228 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2229 (while (and (re-search-forward groupkey-re nil t)
2231 (setq before (buffer-substring
2232 (match-beginning 1) (match-end 1)))
2233 (string< before newgroup)))))
2234 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2236 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2237 (substring groupkey (match-beginning 1) (match-end 1)))))
2238 (gnus-subscribe-newsgroup newgroup before))))
2240 (defun gnus-subscribe-interactively (newsgroup)
2241 "Subscribe new NEWSGROUP interactively.
2242 It is inserted in hierarchical newsgroup order if subscribed. If not,
2244 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2245 (gnus-subscribe-hierarchically newsgroup)
2246 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2248 (defun gnus-subscribe-zombies (newsgroup)
2249 "Make new NEWSGROUP a zombie group."
2250 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2252 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2253 "Subscribe new NEWSGROUP.
2254 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2255 the first newsgroup."
2256 ;; We subscribe the group by changing its level to `subscribed'.
2257 (gnus-group-change-level
2258 newsgroup gnus-level-default-subscribed
2259 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2260 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2264 (defun gnus-newsgroup-directory-form (newsgroup)
2265 "Make hierarchical directory name from NEWSGROUP name."
2266 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2267 (len (length newsgroup))
2269 ;; If this is a foreign group, we don't want to translate the
2271 (if (setq idx (string-match ":" newsgroup))
2272 (aset newsgroup idx ?/)
2274 ;; Replace all occurrences of `.' with `/'.
2276 (if (= (aref newsgroup idx) ?.)
2277 (aset newsgroup idx ?/))
2278 (setq idx (1+ idx)))
2281 (defun gnus-newsgroup-savable-name (group)
2282 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2284 (gnus-replace-chars-in-string group ?/ ?.))
2286 (defun gnus-make-directory (dir)
2287 "Make DIRECTORY recursively."
2288 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2289 ;; of the many mysteries of the universe.
2290 (let* ((dir (expand-file-name dir default-directory))
2292 (if (string-match "/$" dir)
2293 (setq dir (substring dir 0 (match-beginning 0))))
2294 ;; First go down the path until we find a directory that exists.
2295 (while (not (file-exists-p dir))
2296 (setq dirs (cons dir dirs))
2297 (string-match "/[^/]+$" dir)
2298 (setq dir (substring dir 0 (match-beginning 0))))
2299 ;; Then create all the subdirs.
2300 (while (and dirs (not err))
2302 (make-directory (car dirs))
2303 (error (setq err t)))
2304 (setq dirs (cdr dirs)))
2305 ;; We return whether we were successful or not.
2308 (defun gnus-capitalize-newsgroup (newsgroup)
2309 "Capitalize NEWSGROUP name."
2310 (and (not (zerop (length newsgroup)))
2311 (concat (char-to-string (upcase (aref newsgroup 0)))
2312 (substring newsgroup 1))))
2316 (defun gnus-simplify-subject (subject &optional re-only)
2317 "Remove `Re:' and words in parentheses.
2318 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2319 (let ((case-fold-search t)) ;Ignore case.
2320 ;; Remove `Re:' and `Re^N:'.
2321 (if (string-match "^re:[ \t]*" subject)
2322 (setq subject (substring subject (match-end 0))))
2323 ;; Remove words in parentheses from end.
2325 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2326 (setq subject (substring subject 0 (match-beginning 0)))))
2327 ;; Return subject string.
2330 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2332 (defun gnus-simplify-subject-fuzzy (subject)
2333 (let ((case-fold-search t))
2335 (gnus-set-work-buffer)
2337 (inline (gnus-simplify-buffer-fuzzy))
2340 (defun gnus-simplify-buffer-fuzzy ()
2341 (goto-char (point-min))
2342 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2343 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2345 (replace-match "" t t))
2346 (goto-char (point-min))
2347 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2348 (replace-match "" t t))
2349 (goto-char (point-min))
2350 (while (re-search-forward "[ \t]+" nil t)
2351 (replace-match " " t t))
2352 (goto-char (point-min))
2353 (while (re-search-forward "[ \t]+$" nil t)
2354 (replace-match "" t t))
2355 (goto-char (point-min))
2356 (while (re-search-forward "^[ \t]+" nil t)
2357 (replace-match "" t t))
2358 (if gnus-simplify-subject-fuzzy-regexp
2359 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2360 (replace-match "" t t))))
2362 ;; Add the current buffer to the list of buffers to be killed on exit.
2363 (defun gnus-add-current-to-buffer-list ()
2364 (or (memq (current-buffer) gnus-buffer-list)
2365 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2367 (defun gnus-string> (s1 s2)
2368 (not (or (string< s1 s2)
2371 ;; Functions accessing headers.
2372 ;; Functions are more convenient than macros in some cases.
2374 (defun gnus-header-number (header)
2375 (mail-header-number header))
2377 (defun gnus-header-subject (header)
2378 (mail-header-subject header))
2380 (defun gnus-header-from (header)
2381 (mail-header-from header))
2383 (defun gnus-header-xref (header)
2384 (mail-header-xref header))
2386 (defun gnus-header-lines (header)
2387 (mail-header-lines header))
2389 (defun gnus-header-date (header)
2390 (mail-header-date header))
2392 (defun gnus-header-id (header)
2393 (mail-header-id header))
2395 (defun gnus-header-message-id (header)
2396 (mail-header-id header))
2398 (defun gnus-header-chars (header)
2399 (mail-header-chars header))
2401 (defun gnus-header-references (header)
2402 (mail-header-references header))
2404 ;;; General various misc type functions.
2406 (defun gnus-clear-system ()
2407 "Clear all variables and buffers."
2408 ;; Clear Gnus variables.
2409 (let ((variables gnus-variable-list))
2411 (set (car variables) nil)
2412 (setq variables (cdr variables))))
2413 ;; Clear other internal variables.
2414 (setq gnus-list-of-killed-groups nil
2415 gnus-have-read-active-file nil
2416 gnus-newsrc-alist nil
2417 gnus-newsrc-hashtb nil
2418 gnus-killed-list nil
2419 gnus-zombie-list nil
2420 gnus-killed-hashtb nil
2421 gnus-active-hashtb nil
2422 gnus-moderated-list nil
2423 gnus-description-hashtb nil
2424 gnus-newsgroup-headers nil
2425 gnus-newsgroup-headers-hashtb-by-number nil
2426 gnus-newsgroup-name nil
2427 gnus-server-alist nil
2428 gnus-current-select-method nil)
2429 ;; Reset any score variables.
2430 (and (boundp 'gnus-score-cache)
2431 (set 'gnus-score-cache nil))
2432 (and (boundp 'gnus-internal-global-score-files)
2433 (set 'gnus-internal-global-score-files nil))
2434 ;; Kill the startup file.
2435 (and gnus-current-startup-file
2436 (get-file-buffer gnus-current-startup-file)
2437 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2438 ;; Save any cache buffers.
2439 (and gnus-use-cache (gnus-cache-save-buffers))
2440 ;; Clear the dribble buffer.
2441 (gnus-dribble-clear)
2442 ;; Kill global KILL file buffer.
2443 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2444 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2445 (gnus-kill-buffer nntp-server-buffer)
2446 ;; Kill Gnus buffers.
2447 (while gnus-buffer-list
2448 (gnus-kill-buffer (car gnus-buffer-list))
2449 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2451 (defun gnus-windows-old-to-new (setting)
2452 ;; First we take care of the really, really old Gnus 3 actions.
2453 (if (symbolp setting)
2455 (cond ((memq setting '(SelectArticle))
2457 ((memq setting '(SelectSubject ExpandSubject))
2459 ((memq setting '(SelectNewsgroup ExitNewsgroup))
2462 (if (or (listp setting)
2463 (not (and gnus-window-configuration
2464 (memq setting '(group summary article)))))
2466 (let* ((setting (if (eq setting 'group)
2467 (if (assq 'newsgroup gnus-window-configuration)
2469 'newsgroups) setting))
2470 (elem (car (cdr (assq setting gnus-window-configuration))))
2471 (total (apply '+ elem))
2472 (types '(group summary article))
2473 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2478 (or (not (numberp (nth i elem)))
2479 (zerop (nth i elem))
2481 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2482 (setq out (cons (if (eq pbuf (nth i types))
2483 (vector (nth i types) perc 'point)
2484 (vector (nth i types) perc))
2487 (list (nreverse out)))))
2489 (defun gnus-add-configuration (conf)
2490 (setq gnus-buffer-configuration
2491 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2492 gnus-buffer-configuration))))
2494 (defun gnus-configure-windows (setting &optional force)
2495 (setq setting (gnus-windows-old-to-new setting))
2496 (let ((r (if (symbolp setting)
2497 (cdr (assq setting gnus-buffer-configuration))
2499 (in-buf (current-buffer))
2500 rule val w height hor ohor heights sub jump-buffer
2501 rel total to-buf all-visible)
2502 (or r (error "No such setting: %s" setting))
2504 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r)))
2505 ;; All the windows mentioned are already visible, so we just
2506 ;; put point in the assigned buffer, and do not touch the
2508 (select-window (get-buffer-window all-visible t))
2511 ;; Either remove all windows or just remove all Gnus windows.
2512 (if gnus-use-full-window
2513 (delete-other-windows)
2514 (gnus-remove-some-windows)
2515 (switch-to-buffer nntp-server-buffer))
2521 ;; We have to do the (possible) horizontal splitting before the
2523 (if (and (listp (car hor))
2524 (eq (car (car hor)) 'horizontal))
2528 (if (integerp (nth 1 (car hor)))
2530 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2532 (setq hor (cdr hor))))
2534 ;; Go through the rules and eval the elements that are to be
2537 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2539 ;; Expand short buffer name.
2540 (setq w (aref val 0))
2541 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2543 (setq val (apply 'vector (mapcar 'identity val)))
2545 (setq ohor (cons val ohor))))
2546 (setq hor (cdr hor)))
2547 (setq rule (cons (nreverse ohor) rule))
2549 (setq rule (nreverse rule))
2551 ;; We tally the window sizes.
2552 (setq total (window-height))
2554 (setq hor (car rule))
2555 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2556 (setq hor (cdr hor)))
2559 (setq rel (aref (car hor) 1)
2561 (cond ((and (floatp rel) (= 1.0 rel))
2566 (max (floor (* total rel)) 4)))
2568 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2570 (setq heights (nreverse heights)
2573 ;; We then go through these heights and create windows for them.
2575 (setq height (car heights)
2576 heights (cdr heights))
2578 (setq height (- total sub)))
2580 (split-window nil height))
2581 (setq to-buf (aref (car hor) 0))
2586 (symbol-value (aref (car hor) 0)))
2588 (aref (car hor) 0))))
2589 (and (> (length (car hor)) 2)
2590 (eq (aref (car hor) 2) 'point)
2591 (setq jump-buffer (current-buffer)))
2593 (setq hor (cdr hor)))
2595 (setq rule (cdr rule)))
2597 ;; Finally, we pop to the buffer that's supposed to have point.
2598 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2600 (select-window (get-buffer-window jump-buffer t))
2601 (set-buffer jump-buffer))))
2603 (defun gnus-all-windows-visible-p (rule)
2604 (let (invisible hor jump-buffer val buffer)
2605 ;; Go through the rules and eval the elements that are to be
2607 (while (and rule (not invisible))
2608 (setq hor (car rule)
2610 (while (and hor (not invisible))
2611 (if (setq val (if (vectorp (car hor))
2613 (if (not (eq (car (car hor)) 'horizontal))
2616 ;; Expand short buffer name.
2617 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer))
2619 (setq buffer (if (symbolp buffer) (symbol-value buffer)
2621 (and (> (length val) 2) (eq 'point (aref val 2))
2622 (setq jump-buffer buffer))
2623 (setq invisible (not (and buffer (get-buffer-window buffer))))))
2624 (setq hor (cdr hor))))
2625 (and (not invisible) jump-buffer)))
2627 (defun gnus-window-top-edge (&optional window)
2628 (nth 1 (window-edges window)))
2630 (defun gnus-remove-some-windows ()
2631 (let ((buffers gnus-window-to-buffer)
2632 buf bufs lowest-buf lowest)
2634 ;; Remove windows on all known Gnus buffers.
2636 (setq buf (cdr (car buffers)))
2638 (setq buf (and (boundp buf) (symbol-value buf))))
2640 (get-buffer-window buf)
2642 (setq bufs (cons buf bufs))
2644 (if (or (not lowest)
2645 (< (gnus-window-top-edge) lowest))
2647 (setq lowest (gnus-window-top-edge))
2648 (setq lowest-buf buf)))))
2649 (setq buffers (cdr buffers)))
2650 ;; Remove windows on *all* summary buffers.
2654 (let ((buf (window-buffer win)))
2655 (if (string-match "^\\*Summary" (buffer-name buf))
2657 (setq bufs (cons buf bufs))
2659 (if (or (not lowest)
2660 (< (gnus-window-top-edge) lowest))
2662 (setq lowest-buf buf)
2663 (setq lowest (gnus-window-top-edge))))))))))
2666 (pop-to-buffer lowest-buf)
2667 (switch-to-buffer nntp-server-buffer)))
2669 (and (not (eq (car bufs) lowest-buf))
2670 (delete-windows-on (car bufs)))
2671 (setq bufs (cdr bufs))))))
2673 (defun gnus-version ()
2674 "Version numbers of this version of Gnus."
2676 (let ((methods gnus-valid-select-methods)
2679 ;; Go through all the legal select methods and add their version
2680 ;; numbers to the total version string. Only the backends that are
2681 ;; currently in use will have their message numbers taken into
2684 (setq meth (intern (concat (car (car methods)) "-version")))
2686 (stringp (symbol-value meth))
2687 (setq mess (concat mess "; " (symbol-value meth))))
2688 (setq methods (cdr methods)))
2689 (gnus-message 2 mess)))
2691 (defun gnus-info-find-node ()
2692 "Find Info documentation of Gnus."
2694 ;; Enlarge info window if needed.
2695 (let ((mode major-mode))
2696 (gnus-configure-windows 'info)
2697 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2699 (defun gnus-overload-functions (&optional overloads)
2700 "Overload functions specified by optional argument OVERLOADS.
2701 If nothing is specified, use the variable gnus-overload-functions."
2703 (overloads (or overloads gnus-overload-functions)))
2705 (setq defs (car overloads))
2706 (setq overloads (cdr overloads))
2707 ;; Load file before overloading function if necessary. Make
2708 ;; sure we cannot use `require' always.
2709 (and (not (fboundp (car defs)))
2710 (car (cdr (cdr defs)))
2711 (load (car (cdr (cdr defs))) nil 'nomessage))
2712 (fset (car defs) (car (cdr defs))))))
2714 (defun gnus-replace-chars-in-string (string &rest pairs)
2715 "Replace characters in STRING from FROM to TO."
2716 (let ((string (substring string 0)) ;Copy string.
2717 (len (length string))
2720 (or (zerop (% (length pairs) 2))
2721 (error "Odd number of translation pairs"))
2722 (setplist 'sym pairs)
2723 ;; Replace all occurrences of FROM with TO.
2725 (if (setq to (get 'sym (aref string idx)))
2726 (aset string idx to))
2727 (setq idx (1+ idx)))
2730 (defun gnus-days-between (date1 date2)
2731 ;; Return the number of days between date1 and date2.
2732 (- (gnus-day-number date1) (gnus-day-number date2)))
2734 (defun gnus-day-number (date)
2735 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2736 (timezone-parse-date date))))
2737 (timezone-absolute-from-gregorian
2738 (nth 1 dat) (nth 2 dat) (car dat))))
2740 ;; Returns a floating point number that says how many seconds have
2741 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2742 (defun gnus-seconds-since-epoch (date)
2743 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2744 (timezone-parse-date date)))
2745 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2746 (timezone-parse-time
2747 (aref (timezone-parse-date date) 3))))
2748 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2749 (timezone-parse-date "Jan 1 12:00:00 1970")))
2750 (tday (- (timezone-absolute-from-gregorian
2751 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2752 (timezone-absolute-from-gregorian
2753 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2755 (* (nth 1 ttime) 60)
2756 (* 1.0 (nth 0 ttime) 60 60)
2757 (* 1.0 tday 60 60 24))))
2759 (defun gnus-file-newer-than (file date)
2760 (let ((fdate (nth 5 (file-attributes file))))
2761 (or (> (car fdate) (car date))
2762 (and (= (car fdate) (car date))
2763 (> (nth 1 fdate) (nth 1 date))))))
2765 (defun gnus-group-read-only-p (&optional group)
2766 "Check whether GROUP supports editing or not.
2767 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
2768 that that variable is buffer-local to the summary buffers."
2769 (let ((group (or group gnus-newsgroup-name)))
2770 (not (gnus-check-backend-function 'request-replace-article group))))
2772 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2774 (defun gnus-y-or-n-p (prompt)
2779 (defun gnus-yes-or-no-p (prompt)
2781 (yes-or-no-p prompt)
2784 ;; Check whether to use long file names.
2785 (defun gnus-use-long-file-name (symbol)
2786 ;; The variable has to be set...
2787 (and gnus-use-long-file-name
2788 ;; If it isn't a list, then we return t.
2789 (or (not (listp gnus-use-long-file-name))
2790 ;; If it is a list, and the list contains `symbol', we
2792 (not (memq symbol gnus-use-long-file-name)))))
2794 ;; I suspect there's a better way, but I haven't taken the time to do
2795 ;; it yet. -erik selberg@cs.washington.edu
2796 (defun gnus-dd-mmm (messy-date)
2797 "Return a string like DD-MMM from a big messy string"
2798 (let ((datevec (timezone-parse-date messy-date)))
2800 (or (aref datevec 2) "??")
2803 (nth (1- (string-to-number (aref datevec 1)))
2804 timezone-months-assoc))
2807 ;; Make a hash table (default and minimum size is 255).
2808 ;; Optional argument HASHSIZE specifies the table size.
2809 (defun gnus-make-hashtable (&optional hashsize)
2810 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2812 ;; Make a number that is suitable for hashing; bigger than MIN and one
2814 (defun gnus-create-hash-size (min)
2820 ;; Show message if message has a lower level than `gnus-verbose'.
2821 ;; Guide-line for numbers:
2822 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2823 ;; for things that take a long time, 7 - not very important messages
2824 ;; on stuff, 9 - messages inside loops.
2825 (defun gnus-message (level &rest args)
2826 (if (<= level gnus-verbose)
2827 (apply 'message args)
2828 ;; We have to do this format thingy here even if the result isn't
2829 ;; shown - the return value has to be the same as the return value
2831 (apply 'format args)))
2833 ;; Generate a unique new group name.
2834 (defun gnus-generate-new-group-name (leaf)
2837 (while (gnus-gethash name gnus-newsrc-hashtb)
2838 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2841 (defun gnus-ephemeral-group-p (group)
2842 "Say whether GROUP is ephemeral or not."
2843 (assoc 'quit-config (gnus-find-method-for-group group)))
2845 (defun gnus-group-quit-config (group)
2846 "Return the quit-config of GROUP."
2847 (nth 1 (assoc 'quit-config (gnus-find-method-for-group group))))
2849 (defun gnus-simplify-mode-line ()
2850 "Make mode lines a bit simpler."
2851 (setq mode-line-modified "-- ")
2852 (if (listp mode-line-format)
2854 (make-local-variable 'mode-line-format)
2855 (setq mode-line-format (copy-sequence mode-line-format))
2856 (and (equal (nth 3 mode-line-format) " ")
2857 (setcar (nthcdr 3 mode-line-format) "")))))
2859 ;;; List and range functions
2861 (defun gnus-last-element (list)
2862 "Return last element of LIST."
2864 (setq list (cdr list)))
2867 (defun gnus-copy-sequence (list)
2868 "Do a complete, total copy of a list."
2869 (if (and (consp list) (not (consp (cdr list))))
2870 (cons (car list) (cdr list))
2871 (mapcar (lambda (elem) (if (consp elem)
2872 (if (consp (cdr elem))
2873 (gnus-copy-sequence elem)
2874 (cons (car elem) (cdr elem)))
2878 (defun gnus-set-difference (list1 list2)
2879 "Return a list of elements of LIST1 that do not appear in LIST2."
2880 (let ((list1 (copy-sequence list1)))
2882 (setq list1 (delq (car list2) list1))
2883 (setq list2 (cdr list2)))
2886 (defun gnus-sorted-complement (list1 list2)
2887 "Return a list of elements of LIST1 that do not appear in LIST2.
2888 Both lists have to be sorted over <."
2890 (if (or (null list1) (null list2))
2892 (while (and list1 list2)
2893 (cond ((= (car list1) (car list2))
2894 (setq list1 (cdr list1)
2896 ((< (car list1) (car list2))
2897 (setq out (cons (car list1) out))
2898 (setq list1 (cdr list1)))
2900 (setq out (cons (car list2) out))
2901 (setq list2 (cdr list2)))))
2902 (nconc (nreverse out) (or list1 list2)))))
2904 (defun gnus-intersection (list1 list2)
2907 (if (memq (car list2) list1)
2908 (setq result (cons (car list2) result)))
2909 (setq list2 (cdr list2)))
2912 (defun gnus-sorted-intersection (list1 list2)
2913 ;; LIST1 and LIST2 have to be sorted over <.
2915 (while (and list1 list2)
2916 (cond ((= (car list1) (car list2))
2917 (setq out (cons (car list1) out)
2920 ((< (car list1) (car list2))
2921 (setq list1 (cdr list1)))
2923 (setq list2 (cdr list2)))))
2926 (defun gnus-set-sorted-intersection (list1 list2)
2927 ;; LIST1 and LIST2 have to be sorted over <.
2928 ;; This function modifies LIST1.
2929 (let* ((top (cons nil list1))
2931 (while (and list1 list2)
2932 (cond ((= (car list1) (car list2))
2936 ((< (car list1) (car list2))
2937 (setcdr prev (cdr list1))
2938 (setq list1 (cdr list1)))
2940 (setq list2 (cdr list2)))))
2944 (defun gnus-compress-sequence (numbers &optional always-list)
2945 "Convert list of numbers to a list of ranges or a single range.
2946 If ALWAYS-LIST is non-nil, this function will always release a list of
2948 (let* ((first (car numbers))
2949 (last (car numbers))
2953 (if (not (listp (cdr numbers)))
2956 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2957 ((= (1+ last) (car numbers)) ;Still in sequence
2958 (setq last (car numbers)))
2959 (t ;End of one sequence
2961 (cons (if (= first last) first
2962 (cons first last)) result))
2963 (setq first (car numbers))
2964 (setq last (car numbers))))
2965 (setq numbers (cdr numbers)))
2966 (if (and (not always-list) (null result))
2967 (if (= first last) (list first) (cons first last))
2968 (nreverse (cons (if (= first last) first (cons first last))
2971 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2972 (defun gnus-uncompress-range (ranges)
2973 "Expand a list of ranges into a list of numbers.
2974 RANGES is either a single range on the form `(num . num)' or a list of
2976 (let (first last result)
2980 ((not (listp (cdr ranges)))
2981 (setq first (car ranges))
2982 (setq last (cdr ranges))
2983 (while (<= first last)
2984 (setq result (cons first result))
2985 (setq first (1+ first)))
2989 (if (atom (car ranges))
2990 (if (numberp (car ranges))
2991 (setq result (cons (car ranges) result)))
2992 (setq first (car (car ranges)))
2993 (setq last (cdr (car ranges)))
2994 (while (<= first last)
2995 (setq result (cons first result))
2996 (setq first (1+ first))))
2997 (setq ranges (cdr ranges)))
2998 (nreverse result)))))
3000 (defun gnus-add-to-range (ranges list)
3001 "Return a list of ranges that has all articles from both RANGES and LIST.
3002 Note: LIST has to be sorted over `<'."
3004 (gnus-compress-sequence list t)
3005 (setq list (copy-sequence list))
3006 (or (listp (cdr ranges))
3007 (setq ranges (list ranges)))
3009 ilist lowest highest temp)
3010 (while (and ranges list)
3012 (setq lowest (or (and (atom (car ranges)) (car ranges))
3013 (car (car ranges))))
3014 (while (and list (cdr list) (< (car (cdr list)) lowest))
3015 (setq list (cdr list)))
3016 (if (< (car ilist) lowest)
3019 (setq list (cdr list))
3021 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3022 (setq highest (or (and (atom (car ranges)) (car ranges))
3023 (cdr (car ranges))))
3024 (while (and list (<= (car list) highest))
3025 (setq list (cdr list)))
3026 (setq ranges (cdr ranges)))
3028 (setq out (nconc (gnus-compress-sequence list t) out)))
3029 (setq out (sort out (lambda (r1 r2)
3030 (< (or (and (atom r1) r1) (car r1))
3031 (or (and (atom r2) r2) (car r2))))))
3034 (if (atom (car ranges))
3036 (if (atom (car (cdr ranges)))
3037 (if (= (1+ (car ranges)) (car (cdr ranges)))
3039 (setcar ranges (cons (car ranges)
3040 (car (cdr ranges))))
3041 (setcdr ranges (cdr (cdr ranges)))))
3042 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
3044 (setcar (car (cdr ranges)) (car ranges))
3045 (setcar ranges (car (cdr ranges)))
3046 (setcdr ranges (cdr (cdr ranges)))))))
3048 (if (atom (car (cdr ranges)))
3049 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
3051 (setcdr (car ranges) (car (cdr ranges)))
3052 (setcdr ranges (cdr (cdr ranges)))))
3053 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
3055 (setcdr (car ranges) (cdr (car (cdr ranges))))
3056 (setcdr ranges (cdr (cdr ranges))))))))
3057 (setq ranges (cdr ranges)))
3060 (defun gnus-remove-from-range (ranges list)
3061 "Return a list of ranges that has all articles from LIST removed from RANGES.
3062 Note: LIST has to be sorted over `<'."
3063 ;; !!! This function shouldn't look like this, but I've got a headache.
3064 (gnus-compress-sequence
3065 (gnus-sorted-complement
3066 (gnus-uncompress-range ranges) list)))
3068 (defun gnus-member-of-range (number ranges)
3069 (if (not (listp (cdr ranges)))
3070 (and (>= number (car ranges))
3071 (<= number (cdr ranges)))
3074 (if (numberp (car ranges))
3075 (>= number (car ranges))
3076 (>= number (car (car ranges))))
3078 (if (if (numberp (car ranges))
3079 (= number (car ranges))
3080 (and (>= number (car (car ranges)))
3081 (<= number (cdr (car ranges)))))
3082 (setq not-stop nil))
3083 (setq ranges (cdr ranges)))
3091 (defvar gnus-group-mode-map nil)
3092 (defvar gnus-group-group-map nil)
3093 (defvar gnus-group-mark-map nil)
3094 (defvar gnus-group-list-map nil)
3095 (defvar gnus-group-help-map nil)
3096 (defvar gnus-group-sub-map nil)
3097 (put 'gnus-group-mode 'mode-class 'special)
3099 (if gnus-group-mode-map
3101 (setq gnus-group-mode-map (make-keymap))
3102 (suppress-keymap gnus-group-mode-map)
3103 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
3104 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
3105 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
3106 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
3107 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
3108 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
3109 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
3110 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
3111 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
3112 (define-key gnus-group-mode-map
3113 "\M-n" 'gnus-group-next-unread-group-same-level)
3114 (define-key gnus-group-mode-map
3115 "\M-p" 'gnus-group-prev-unread-group-same-level)
3116 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
3117 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
3118 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3119 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3120 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3121 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3122 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3123 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3124 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3125 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3126 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3127 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3128 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3129 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3130 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3131 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3132 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3133 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3134 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3135 (define-key gnus-group-mode-map "\C-c\M-\C-a" 'gnus-group-description-apropos)
3136 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3137 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3138 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3139 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3140 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3141 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3142 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3143 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3144 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3145 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3146 (define-key gnus-group-mode-map "V" 'gnus-version)
3147 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3148 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3149 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3150 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3151 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3152 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3153 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3154 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3155 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3156 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3157 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3158 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3159 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3160 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3162 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3163 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3164 (define-prefix-command 'gnus-group-mark-map)
3165 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3166 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3167 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3168 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3170 (define-prefix-command 'gnus-group-group-map)
3171 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3172 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3173 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3174 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3175 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3176 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3177 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3178 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3179 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3180 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3181 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3182 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3183 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3184 ;;(define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3185 ;;(define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3186 ;;(define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3187 ;;(define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3188 ;;(define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3190 (define-prefix-command 'gnus-group-list-map)
3191 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3192 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3193 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3194 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3195 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3196 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3197 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3198 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3199 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3201 (define-prefix-command 'gnus-group-help-map)
3202 (define-key gnus-group-mode-map "H" 'gnus-group-help-map)
3203 (define-key gnus-group-help-map "f" 'gnus-group-fetch-faq)
3205 (define-prefix-command 'gnus-group-sub-map)
3206 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3207 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3208 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3209 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3210 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3211 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3212 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3213 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3215 (defun gnus-group-mode ()
3216 "Major mode for reading news.
3218 All normal editing commands are switched off.
3219 \\<gnus-group-mode-map>
3220 The group buffer lists (some of) the groups available. For instance,
3221 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3222 lists all zombie groups.
3224 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3225 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3227 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3229 The following commands are available:
3231 \\{gnus-group-mode-map}"
3233 (if gnus-visual (gnus-group-make-menu-bar))
3234 (kill-all-local-variables)
3235 (gnus-simplify-mode-line)
3236 (setq major-mode 'gnus-group-mode)
3237 (setq mode-name "Group")
3238 (gnus-group-set-mode-line)
3239 (setq mode-line-process nil)
3240 (use-local-map gnus-group-mode-map)
3241 (buffer-disable-undo (current-buffer))
3242 (setq truncate-lines t)
3243 (setq buffer-read-only t)
3244 (run-hooks 'gnus-group-mode-hook))
3246 (defun gnus-mouse-pick-group (e)
3249 (gnus-group-read-group nil))
3251 ;; Look at LEVEL and find out what the level is really supposed to be.
3252 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
3253 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
3254 (defun gnus-group-default-level (&optional level number-or-nil)
3256 (gnus-group-use-permanent-levels
3257 (setq gnus-group-default-list-level
3258 (or level gnus-group-default-list-level))
3259 (or gnus-group-default-list-level gnus-level-subscribed))
3263 (or level gnus-group-default-list-level gnus-level-subscribed))))
3266 (defvar gnus-tmp-prev-perm nil)
3269 (defun gnus-no-server (&optional arg)
3271 If ARG is a positive number, Gnus will use that as the
3272 startup level. If ARG is nil, Gnus will be started at level 2.
3273 If ARG is non-nil and not a positive number, Gnus will
3274 prompt the user for the name of an NNTP server to use.
3275 As opposed to `gnus', this command will not connect to the local server."
3278 (cons gnus-group-use-permanent-levels gnus-group-default-list-level)))
3279 (setq gnus-tmp-prev-perm nil)
3280 (setq gnus-group-use-permanent-levels t)
3281 (gnus (or arg (1- gnus-level-default-subscribed)) t)
3282 (setq gnus-tmp-prev-perm perm)))
3285 (defun read-news (&optional arg dont-connect)
3286 "Read network news. This is an alias for the `gnus' command."
3287 (gnus arg dont-connect))
3290 (defun gnus (&optional arg dont-connect)
3292 If ARG is non-nil and a positive number, Gnus will use that as the
3293 startup level. If ARG is non-nil and not a positive number, Gnus will
3294 prompt the user for the name of an NNTP server to use."
3296 (if (get-buffer gnus-group-buffer)
3298 (switch-to-buffer gnus-group-buffer)
3299 (gnus-group-get-new-news))
3303 (nnheader-init-server-buffer)
3304 ;; We do this if `gnus-no-server' has been run.
3305 (if gnus-tmp-prev-perm
3306 (setq gnus-group-use-permanent-levels (car gnus-tmp-prev-perm)
3307 gnus-group-default-list-level (cdr gnus-tmp-prev-perm)
3308 gnus-tmp-prev-perm nil))
3309 (gnus-read-init-file)
3311 (gnus-group-setup-buffer)
3312 (let ((buffer-read-only nil))
3314 (if (not gnus-inhibit-startup-message)
3316 (gnus-group-startup-message)
3319 (let ((level (and arg (numberp arg) (> arg 0) arg))
3325 (gnus-start-news-server (and arg (not level))))))
3326 (if (and (not dont-connect)
3329 (run-hooks 'gnus-startup-hook)
3330 ;; NNTP server is successfully open.
3332 ;; Find the current startup file name.
3333 (setq gnus-current-startup-file
3334 (gnus-make-newsrc-file gnus-startup-file))
3336 ;; Read the dribble file.
3337 (and gnus-use-dribble-file (gnus-dribble-read-file))
3339 (gnus-summary-make-display-table)
3340 (gnus-setup-news nil level)
3341 (gnus-group-list-groups level)
3342 (gnus-configure-windows 'group))))))
3344 (defun gnus-unload ()
3345 "Unload all Gnus features."
3347 (or (boundp 'load-history)
3348 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
3349 (let ((history load-history)
3352 (and (string-match "^gnus" (car (car history)))
3353 (setq feature (cdr (assq 'provide (car history))))
3354 (unload-feature feature 'force))
3355 (setq history (cdr history)))))
3357 (defun gnus-group-startup-message (&optional x y)
3358 "Insert startup message in current buffer."
3359 ;; Insert the message.
3364 _ ___ __ ___ __ _ ___
3382 Gnus * A newsreader for Emacsen
3383 A Praxis release * larsi@ifi.uio.no
3386 ;; And then hack it.
3387 ;; 18 is the longest line.
3388 (indent-rigidly (point-min) (point-max)
3389 (/ (max (- (window-width) (or x 46)) 0) 2))
3390 (goto-char (point-min))
3391 (let* ((pheight (count-lines (point-min) (point-max)))
3392 (wheight (window-height))
3393 (rest (- wheight pheight)))
3394 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
3399 (goto-char (point-min))
3400 (search-forward "Praxis")
3401 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3402 (goto-char (point-min)))
3404 (defun gnus-group-startup-message-old (&optional x y)
3405 "Insert startup message in current buffer."
3406 ;; Insert the message.
3422 ;; And then hack it.
3423 ;; 18 is the longest line.
3424 (indent-rigidly (point-min) (point-max)
3425 (/ (max (- (window-width) (or x 28)) 0) 2))
3426 (goto-char (point-min))
3427 ;; +4 is fuzzy factor.
3428 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3431 (goto-char (point-min))
3432 (search-forward "Praxis")
3433 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3434 (goto-char (point-min)))
3436 (defun gnus-group-setup-buffer ()
3437 (or (get-buffer gnus-group-buffer)
3439 (switch-to-buffer gnus-group-buffer)
3440 (gnus-add-current-to-buffer-list)
3442 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3444 (defun gnus-group-list-groups (&optional level unread)
3445 "List newsgroups with level LEVEL or lower that have unread articles.
3446 Default is all subscribed groups.
3447 If argument UNREAD is non-nil, groups with no unread articles are also
3449 (interactive (list (if current-prefix-arg
3450 (prefix-numeric-value current-prefix-arg)
3452 (gnus-group-default-level nil t)
3453 gnus-group-default-list-level
3454 gnus-level-subscribed))))
3456 (setq level (car gnus-group-list-mode)
3457 unread (cdr gnus-group-list-mode)))
3458 (setq level (gnus-group-default-level level))
3459 (gnus-group-setup-buffer) ;May call from out of group buffer
3460 (let ((case-fold-search nil)
3461 (group (gnus-group-group-name)))
3462 (funcall gnus-group-prepare-function level unread nil)
3463 (if (zerop (buffer-size))
3464 (gnus-message 5 gnus-no-groups-message)
3465 (goto-char (point-min))
3467 ;; Go to the first group with unread articles.
3468 (gnus-group-search-forward nil nil nil t)
3469 ;; Find the right group to put point on. If the current group
3470 ;; has disappeared in the new listing, try to find the next
3471 ;; one. If no next one can be found, just leave point at the
3472 ;; first newsgroup in the buffer.
3473 (if (not (gnus-goto-char
3474 (text-property-any (point-min) (point-max)
3475 'gnus-group (intern group))))
3476 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3478 (not (gnus-goto-char
3480 (point-min) (point-max) 'gnus-group
3481 (intern (car (car newsrc)))))))
3482 (setq newsrc (cdr newsrc)))
3483 (or newsrc (progn (goto-char (point-max))
3484 (forward-line -1))))))
3485 ;; Adjust cursor point.
3486 (gnus-group-position-cursor))))
3488 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3489 "List all newsgroups with unread articles of level LEVEL or lower.
3490 If ALL is non-nil, list groups that have no unread articles.
3491 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3492 If REGEXP, only list groups matching REGEXP."
3493 (set-buffer gnus-group-buffer)
3494 (let ((buffer-read-only nil)
3495 (newsrc (cdr gnus-newsrc-alist))
3496 (lowest (or lowest 1))
3497 info clevel unread group)
3499 (if (< lowest gnus-level-zombie)
3500 ;; List living groups.
3502 (setq info (car newsrc)
3505 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3506 (and unread ; This group might be bogus
3508 (string-match regexp group))
3509 (<= (setq clevel (car (cdr info))) level)
3511 (or all ; We list all groups?
3512 (eq unread t) ; We list unactivated groups
3513 (> unread 0) ; We list groups with unread articles
3514 (cdr (assq 'tick (nth 3 info)))) ; And ticked groups
3515 (gnus-group-insert-group-line
3516 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3518 ;; List dead groups.
3519 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3520 (gnus-group-prepare-flat-list-dead
3521 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3522 gnus-level-zombie ?Z
3524 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3525 (gnus-group-prepare-flat-list-dead
3526 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3527 gnus-level-killed ?K regexp))
3529 (gnus-group-set-mode-line)
3530 (setq gnus-group-list-mode (cons level all))
3531 (run-hooks 'gnus-group-prepare-hook)))
3533 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3534 ;; List zombies and killed lists somewhat faster, which was
3535 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3536 ;; this by ignoring the group format specification altogether.
3539 (setq group (car groups)
3540 groups (cdr groups))
3541 (if (or (not regexp)
3542 (string-match regexp group))
3545 (insert (format " %c *: %s\n" mark group))
3546 (add-text-properties
3548 (list 'gnus-group (intern group)
3550 'gnus-level level)))))))
3552 (defun gnus-group-real-name (group)
3553 "Find the real name of a foreign newsgroup."
3554 (if (string-match ":[^:]+$" group)
3555 (substring group (1+ (match-beginning 0)))
3558 (defun gnus-group-prefixed-name (group method)
3559 "Return the whole name from GROUP and METHOD."
3560 (and (stringp method) (setq method (gnus-server-to-method method)))
3561 (concat (format "%s" (car method))
3563 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3564 (not (string= (nth 1 method) "")))
3565 (concat "+" (nth 1 method)))
3568 (defun gnus-group-real-prefix (group)
3569 "Return the prefix of the current group name."
3570 (if (string-match "^[^:]+:" group)
3571 (substring group 0 (match-end 0))
3574 (defun gnus-group-method-name (group)
3575 "Return the method used for selecting GROUP."
3576 (let ((prefix (gnus-group-real-prefix group)))
3577 (if (equal prefix "")
3579 (if (string-match "^[^\\+]+\\+" prefix)
3580 (list (intern (substring prefix 0 (1- (match-end 0))))
3581 (substring prefix (match-end 0) (1- (length prefix))))
3582 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3584 (defun gnus-group-foreign-p (group)
3585 "Return nil if GROUP is native, non-nil if it is foreign."
3586 (string-match ":" group))
3588 (defun gnus-group-set-info (info &optional method-only-group part)
3589 (let* ((entry (gnus-gethash
3590 (or method-only-group (car info)) gnus-newsrc-hashtb))
3592 (info (if method-only-group (nth 2 entry) info)))
3593 (if (not method-only-group)
3596 (error "Trying to change non-existent group %s" method-only-group))
3597 ;; We have received parts of the actual group info - either the
3598 ;; select method or the group parameters. We first check
3599 ;; whether we have to extend the info, and if so, do that.
3600 (let ((len (length info))
3601 (total (if (eq part 'method) 5 6)))
3603 (setcdr (nthcdr (1- len) info)
3604 (make-list (- total len) nil)))
3605 ;; Then we enter the new info.
3606 (setcar (nthcdr (1- total) info) part-info)))
3607 ;; We uncompress some lists of marked articles.
3609 (if (not (setq marked (nth 3 info)))
3612 (or (eq 'score (car (car marked)))
3613 (eq 'bookmark (car (car marked)))
3614 (eq 'killed (car (car marked)))
3615 (setcdr (car marked)
3616 (gnus-uncompress-range (cdr (car marked)))))
3617 (setq marked (cdr marked)))))
3620 ;; This is a new group, so we just create it.
3622 (set-buffer gnus-group-buffer)
3624 ;; It's a foreign group...
3625 (gnus-group-make-group
3626 (gnus-group-real-name (car info))
3627 (prin1-to-string (car (nth 4 info)))
3628 (nth 1 (nth 4 info)))
3629 ;; It's a native group.
3630 (gnus-group-make-group (car info)))
3631 (gnus-message 6 "Note: New group created")
3633 (gnus-gethash (gnus-group-prefixed-name
3634 (gnus-group-real-name (car info))
3635 (or (nth 4 info) gnus-select-method))
3636 gnus-newsrc-hashtb))))
3637 ;; Whether it was a new group or not, we now have the entry, so we
3638 ;; can do the update.
3641 (setcar (nthcdr 2 entry) info)
3642 (if (and (not (eq (car entry) t))
3643 (gnus-gethash (car info) gnus-active-hashtb))
3644 (let ((marked (nth 3 info)))
3646 (max 0 (- (length (gnus-list-of-unread-articles
3648 (length (cdr (assq 'tick marked)))
3649 (length (cdr (assq 'dormant marked)))))))))
3650 (error "No such group: %s" (car info)))))
3652 (defun gnus-group-set-method-info (group select-method)
3653 (gnus-group-set-info select-method group 'method))
3655 (defun gnus-group-set-params-info (group params)
3656 (gnus-group-set-info params group 'params))
3658 (defun gnus-group-update-group-line ()
3659 "This function updates the current line in the newsgroup buffer and
3660 moves the point to the colon."
3661 (let* ((buffer-read-only nil)
3662 (group (gnus-group-group-name))
3663 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3664 (if (and entry (not (gnus-ephemeral-group-p group)))
3666 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3669 (delete-region (point) (progn (forward-line 1) (point)))
3670 (gnus-group-insert-group-line-info group)
3672 (gnus-group-position-cursor)))
3674 (defun gnus-group-insert-group-line-info (group)
3675 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3679 (setq info (nth 2 entry))
3680 (gnus-group-insert-group-line
3681 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3682 (setq active (gnus-gethash group gnus-active-hashtb))
3683 (gnus-group-insert-group-line
3685 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3686 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3688 (defun gnus-group-insert-group-line (gformat group level marked number method)
3689 (let* ((gformat (or gformat gnus-group-line-format-spec))
3690 (active (gnus-gethash group gnus-active-hashtb))
3691 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3692 (number-of-dormant (length (cdr (assq 'dormant marked))))
3693 (number-of-ticked (length (cdr (assq 'tick marked))))
3694 (number-of-ticked-and-dormant
3695 (+ number-of-ticked number-of-dormant))
3696 (number-of-unread-unticked
3697 (if (numberp number) (int-to-string (max 0 number))
3700 (if (numberp number)
3701 (max 0 (- number-total number))
3703 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3704 ((<= level gnus-level-unsubscribed) ?U)
3705 ((= level gnus-level-zombie) ?Z)
3707 (qualified-group (gnus-group-real-name group))
3708 (newsgroup-description
3709 (if gnus-description-hashtb
3710 (or (gnus-gethash group gnus-description-hashtb) "")
3712 (moderated (if (member group gnus-moderated-list) ?m ? ))
3713 (moderated-string (if (eq moderated ?m) "(m)" ""))
3714 (method (gnus-server-get-method group method))
3715 (news-server (or (car (cdr method)) ""))
3716 (news-method (or (car method) ""))
3718 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3722 (> number-of-ticked 0))
3724 (number (if (eq number t) "*" (+ number number-of-dormant
3726 (process-marked (if (member group gnus-group-marked)
3727 gnus-process-mark ? ))
3728 (buffer-read-only nil)
3729 header ; passed as parameter to user-funcs.
3734 (insert (eval gformat))
3736 (add-text-properties
3737 b (1+ b) (list 'gnus-group (intern group)
3738 'gnus-unread (if (numberp number)
3739 (string-to-int number-of-unread-unticked)
3742 'gnus-level level))))
3744 (defun gnus-group-update-group (group &optional visible-only)
3745 "Update newsgroup info of GROUP.
3746 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3748 (set-buffer gnus-group-buffer)
3749 (let ((buffer-read-only nil)
3751 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3753 (not (gnus-ephemeral-group-p group)))
3755 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3757 ;; Buffer may be narrowed.
3760 ;; Search a line to modify. If the buffer is large, the search
3761 ;; takes long time. In most cases, current point is on the line
3762 ;; we are looking for. So, first of all, check current line.
3765 (eq (get-text-property (point) 'gnus-group)
3770 (point-min) (point-max) 'gnus-group (intern group)))))
3771 ;; GROUP is listed in current buffer. So, delete old line.
3775 (delete-region (point) (progn (forward-line 1) (point))))
3776 ;; No such line in the buffer, find out where it's supposed to
3777 ;; go, and insert it there (or at the end of the buffer).
3778 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3781 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3787 (point-min) (point-max)
3788 'gnus-group (intern (car (car entry)))))))
3789 (setq entry (cdr entry)))
3790 (or entry (goto-char (point-max)))))))
3791 (if (or visible (not visible-only))
3792 (gnus-group-insert-group-line-info group))
3793 (gnus-group-set-mode-line))))
3795 (defun gnus-group-set-mode-line ()
3796 (if (memq 'group gnus-updated-mode-lines)
3797 (let* ((gformat (or gnus-group-mode-line-format-spec
3798 (setq gnus-group-mode-line-format-spec
3800 gnus-group-mode-line-format
3801 gnus-group-mode-line-format-alist))))
3802 (news-server (car (cdr gnus-select-method)))
3803 (news-method (car gnus-select-method))
3805 header ;Dummy binding for user-defined specs.
3806 (mode-string (eval gformat)))
3807 (setq mode-string (eval gformat))
3808 (if (> (length mode-string) max-len)
3809 (setq mode-string (substring mode-string 0 (- max-len 4))))
3810 (setq mode-line-buffer-identification mode-string)
3811 (set-buffer-modified-p t))))
3813 (defun gnus-group-group-name ()
3814 "Get the name of the newsgroup on the current line."
3815 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3816 (and group (symbol-name group))))
3818 (defun gnus-group-group-level ()
3819 "Get the level of the newsgroup on the current line."
3820 (get-text-property (gnus-point-at-bol) 'gnus-level))
3822 (defun gnus-group-group-unread ()
3823 "Get the number of unread articles of the newsgroup on the current line."
3824 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3826 (defun gnus-group-search-forward (&optional backward all level first-too)
3827 "Find the next newsgroup with unread articles.
3828 If BACKWARD is non-nil, find the previous newsgroup instead.
3829 If ALL is non-nil, just find any newsgroup.
3830 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3832 If FIRST-TOO, the current line is also eligible as a target."
3833 (let ((way (if backward -1 1))
3834 (low gnus-level-killed)
3837 (if (and backward (progn (beginning-of-line)) (bobp))
3839 (or first-too (forward-line way))
3847 (get-text-property (point) 'gnus-unread)))
3848 (or (eq unread t) (and unread (> unread 0))))
3849 (setq lev (get-text-property (point)
3851 (<= lev gnus-level-subscribed)))
3853 (and (setq lev (get-text-property (point)
3862 (zerop (forward-line way)))))
3864 (progn (gnus-group-position-cursor) t)
3865 (goto-char (or pos beg))
3868 ;;; Gnus group mode commands
3872 (defun gnus-group-mark-group (n &optional unmark no-advance)
3873 "Mark the current group."
3875 (let ((buffer-read-only nil)
3879 (setq group (gnus-group-group-name))
3883 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
3888 (setq gnus-group-marked (delete group gnus-group-marked)))
3890 (setq gnus-group-marked
3891 (cons group (delete group gnus-group-marked))))
3893 (or no-advance (zerop (gnus-group-next-group 1))))
3895 (gnus-summary-position-cursor)
3898 (defun gnus-group-unmark-group (n)
3899 "Remove the mark from the current group."
3901 (gnus-group-mark-group n 'unmark))
3903 (defun gnus-group-mark-region (unmark beg end)
3904 "Mark all groups between point and mark.
3905 If UNMARK, remove the mark instead."
3906 (interactive "P\nr")
3907 (let ((num (count-lines beg end)))
3910 (- num (gnus-group-mark-group num unmark)))))
3912 (defun gnus-group-remove-mark (group)
3913 (and (gnus-group-goto-group group)
3915 (gnus-group-mark-group 1 'unmark t))))
3917 ;; Return a list of groups to work on. Take into consideration N (the
3918 ;; prefix) and the list of marked groups.
3919 (defun gnus-group-process-prefix (n)
3921 (setq n (prefix-numeric-value n))
3922 ;; There is a prefix, so we return a list of the N next
3924 (let ((way (if (< n 0) -1 1))
3929 (setq group (gnus-group-group-name)))
3930 (setq groups (cons group groups))
3932 (forward-line way)))
3935 ;; No prefix, but a list of marked articles.
3936 (reverse gnus-group-marked))
3938 ;; Neither marked articles or a prefix, so we return the
3940 (let ((group (gnus-group-group-name)))
3941 (and group (list group))))))
3943 ;; Selecting groups.
3945 (defun gnus-group-read-group (&optional all no-article group)
3946 "Read news in this newsgroup.
3947 If the prefix argument ALL is non-nil, already read articles become
3948 readable. If the optional argument NO-ARTICLE is non-nil, no article
3949 will be auto-selected upon group entry."
3951 (let ((group (or group (gnus-group-group-name)))
3952 number active marked entry)
3953 (or group (error "No group on current line"))
3955 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3956 ;; This group might be a dead group. In that case we have to get
3957 ;; the number of unread articles from `gnus-active-hashtb'.
3959 (setq number (car entry))
3960 (if (setq active (gnus-gethash group gnus-active-hashtb))
3961 (setq number (- (1+ (cdr active)) (car active)))))
3962 (gnus-summary-read-group
3963 group (or all (and (numberp number)
3964 (zerop (+ number (length (cdr (assq 'tick marked)))
3965 (length (cdr (assq 'dormant marked)))))))
3968 (defun gnus-group-select-group (&optional all)
3969 "Select this newsgroup.
3970 No article is selected automatically.
3971 If argument ALL is non-nil, already read articles become readable."
3973 (gnus-group-read-group all t))
3975 (defun gnus-group-select-group-all ()
3976 "Select the current group and display all articles in it."
3978 (gnus-group-select-group 'all))
3980 ;; Enter a group that is not in the group buffer. Non-nil is returned
3981 ;; if selection was successful.
3982 (defun gnus-group-read-ephemeral-group
3983 (group method &optional activate quit-config)
3984 (let ((group (if (gnus-group-foreign-p group) group
3985 (gnus-group-prefixed-name group method))))
3988 (list t nil (list group gnus-level-default-subscribed nil nil
3992 (if quit-config quit-config
3993 (cons (current-buffer) 'summary)))))))
3995 (set-buffer gnus-group-buffer)
3996 (or (gnus-check-server method)
3997 (error "Unable to contact server: %s" (gnus-status-message method)))
3998 (if activate (or (gnus-request-group group)
3999 (error "Couldn't request group")))
4001 (gnus-group-read-group t t group)
4004 (not (equal major-mode 'gnus-group-mode))))
4006 (defun gnus-group-jump-to-group (group)
4007 "Jump to newsgroup GROUP."
4009 (list (completing-read
4010 "Group: " gnus-active-hashtb nil
4011 (memq gnus-select-method gnus-have-read-active-file))))
4013 (if (equal group "")
4014 (error "Empty group name"))
4016 (let ((b (text-property-any
4017 (point-min) (point-max) 'gnus-group (intern group))))
4019 ;; Either go to the line in the group buffer...
4021 ;; ... or insert the line.
4023 (gnus-gethash group gnus-active-hashtb)
4024 (gnus-activate-group group)
4025 (error "%s error: %s" group (gnus-status-message group)))
4027 (gnus-group-update-group group)
4028 (goto-char (text-property-any
4029 (point-min) (point-max) 'gnus-group (intern group)))))
4030 ;; Adjust cursor point.
4031 (gnus-group-position-cursor))
4033 (defun gnus-group-goto-group (group)
4034 "Goto to newsgroup GROUP."
4035 (let ((b (text-property-any (point-min) (point-max)
4036 'gnus-group (intern group))))
4037 (and b (goto-char b))))
4039 (defun gnus-group-next-group (n)
4040 "Go to next N'th newsgroup.
4041 If N is negative, search backward instead.
4042 Returns the difference between N and the number of skips actually
4045 (gnus-group-next-unread-group n t))
4047 (defun gnus-group-next-unread-group (n &optional all level)
4048 "Go to next N'th unread newsgroup.
4049 If N is negative, search backward instead.
4050 If ALL is non-nil, choose any newsgroup, unread or not.
4051 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
4052 such group can be found, the next group with a level higher than
4054 Returns the difference between N and the number of skips actually
4057 (let ((backward (< n 0))
4060 (gnus-group-search-forward
4061 backward (or (not gnus-group-goto-unread) all) level))
4063 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
4064 (if level " on this level or higher" "")))
4067 (defun gnus-group-prev-group (n)
4068 "Go to previous N'th newsgroup.
4069 Returns the difference between N and the number of skips actually
4072 (gnus-group-next-unread-group (- n) t))
4074 (defun gnus-group-prev-unread-group (n)
4075 "Go to previous N'th unread newsgroup.
4076 Returns the difference between N and the number of skips actually
4079 (gnus-group-next-unread-group (- n)))
4081 (defun gnus-group-next-unread-group-same-level (n)
4082 "Go to next N'th unread newsgroup on the same level.
4083 If N is negative, search backward instead.
4084 Returns the difference between N and the number of skips actually
4087 (gnus-group-next-unread-group n t (gnus-group-group-level))
4088 (gnus-group-position-cursor))
4090 (defun gnus-group-prev-unread-group-same-level (n)
4091 "Go to next N'th unread newsgroup on the same level.
4092 Returns the difference between N and the number of skips actually
4095 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
4096 (gnus-group-position-cursor))
4098 (defun gnus-group-best-unread-group (&optional exclude-group)
4099 "Go to the group with the highest level.
4100 If EXCLUDE-GROUP, do not go to that group."
4102 (goto-char (point-min))
4105 (while (setq unread (get-text-property (point) 'gnus-unread))
4106 (if (and (numberp unread) (> unread 0))
4108 (if (and (< (get-text-property (point) 'gnus-level) best)
4109 (or (not exclude-group)
4110 (not (equal exclude-group (gnus-group-group-name)))))
4112 (setq best (get-text-property (point) 'gnus-level))
4113 (setq best-point (point))))))
4115 (if best-point (goto-char best-point))
4116 (gnus-summary-position-cursor)
4117 (and best-point (gnus-group-group-name))))
4119 (defun gnus-group-first-unread-group ()
4120 "Go to the first group with unread articles."
4123 (let ((opoint (point))
4125 (goto-char (point-min))
4126 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
4127 (not (zerop unread)) ; Has unread articles.
4128 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
4131 nil)) ; Not success.
4132 (gnus-group-position-cursor)))
4134 (defun gnus-group-enter-server-mode ()
4135 "Jump to the server buffer."
4137 (gnus-server-setup-buffer)
4138 (gnus-configure-windows 'server)
4139 (gnus-server-prepare))
4141 (defun gnus-group-make-group (name &optional method address)
4142 "Add a new newsgroup.
4143 The user will be prompted for a NAME, for a select METHOD, and an
4147 (read-string "Group name: ")
4150 "Method: " (append gnus-valid-select-methods gnus-server-alist)
4152 (if (assoc method gnus-valid-select-methods)
4154 (if (memq 'prompt-address
4155 (assoc method gnus-valid-select-methods))
4156 (read-string "Address: ")
4158 (list method nil)))))
4160 (let* ((meth (and method (if address (list (intern method) address) method)))
4161 (nname (if method (gnus-group-prefixed-name name meth) name))
4163 (and (gnus-gethash nname gnus-newsrc-hashtb)
4164 (error "Group %s already exists" nname))
4165 (gnus-group-change-level
4166 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
4167 gnus-level-default-subscribed gnus-level-killed
4168 (and (gnus-group-group-name)
4169 (gnus-gethash (gnus-group-group-name)
4170 gnus-newsrc-hashtb))
4172 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
4173 (or (gnus-ephemeral-group-p name)
4175 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
4176 (gnus-group-insert-group-line-info nname)
4178 (if (assoc method gnus-valid-select-methods)
4179 (require (intern method)))
4180 (and (gnus-check-backend-function 'request-create-group nname)
4181 (gnus-request-create-group nname))))
4183 (defun gnus-group-edit-group (group &optional part)
4184 "Edit the group on the current line."
4185 (interactive (list (gnus-group-group-name)))
4186 (let ((done-func '(lambda ()
4187 "Exit editing mode and update the information."
4189 (gnus-group-edit-group-done 'part 'group)))
4190 (part (or part 'info))
4191 (winconf (current-window-configuration))
4193 (or group (error "No group on current line"))
4194 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4195 (error "Killed group; can't be edited"))
4196 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4197 (gnus-configure-windows 'edit-group)
4198 (gnus-add-current-to-buffer-list)
4200 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4201 (use-local-map (copy-keymap emacs-lisp-mode-map))
4202 (local-set-key "\C-c\C-c" done-func)
4203 (make-local-variable 'gnus-prev-winconf)
4204 (setq gnus-prev-winconf winconf)
4205 ;; We modify the func to let it know what part it is editing.
4206 (setcar (cdr (nth 4 done-func)) (list 'quote part))
4207 (setcar (cdr (cdr (nth 4 done-func))) group)
4212 ";; Type `C-c C-c' after editing the select method.\n\n")
4214 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4216 ";; Type `C-c C-c' after editing the group info.\n\n")))
4217 (let ((cinfo (gnus-copy-sequence info))
4219 (if (not (setq marked (nth 3 cinfo)))
4222 (or (eq 'score (car (car marked)))
4223 (eq 'bookmark (car (car marked)))
4224 (eq 'killed (car (car marked)))
4225 (not (numberp (car (cdr (car marked)))))
4226 (setcdr (car marked)
4227 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4228 (setq marked (cdr marked))))
4231 (cond ((eq part 'method)
4232 (or (nth 4 info) "native"))
4239 (defun gnus-group-edit-group-method (group)
4240 "Edit the select method of GROUP."
4241 (interactive (list (gnus-group-group-name)))
4242 (gnus-group-edit-group group 'method))
4244 (defun gnus-group-edit-group-parameters (group)
4245 "Edit the group parameters of GROUP."
4246 (interactive (list (gnus-group-group-name)))
4247 (gnus-group-edit-group group 'params))
4249 (defun gnus-group-edit-group-done (part group)
4250 "Get info from buffer, update variables and jump to the group buffer."
4251 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4252 (goto-char (point-min))
4253 (let ((form (read (current-buffer)))
4254 (winconf gnus-prev-winconf))
4256 (gnus-group-set-info form)
4257 (gnus-group-set-info form group part))
4258 (kill-buffer (current-buffer))
4259 (and winconf (set-window-configuration winconf))
4260 (set-buffer gnus-group-buffer)
4261 (gnus-group-update-group (gnus-group-group-name))
4262 (gnus-group-position-cursor)))
4264 (defun gnus-group-make-help-group ()
4265 "Create the Gnus documentation group."
4267 (let ((path (if installation-directory
4268 (cons (concat installation-directory "etc/") load-path)
4269 (cons data-directory load-path)))
4270 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
4272 (and (gnus-gethash name gnus-newsrc-hashtb)
4273 (error "Documentation group already exists"))
4276 (setq file (concat (file-name-as-directory (car path))
4278 (setq path (cdr path)))
4280 (message "Couldn't find doc group")
4281 (gnus-group-make-group
4282 (gnus-group-real-name name)
4284 (list 'nndoc-address file)
4285 (list 'nndoc-article-type 'mbox)))))
4286 (gnus-group-position-cursor))
4288 (defun gnus-group-make-doc-group (file type)
4289 "Create a group that uses a single file as the source."
4291 (list (read-file-name "File name: ")
4295 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4296 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4297 ((= char ?b) 'babyl)
4298 ((= char ?d) 'digest)
4299 (t (setq err (format "%c unknown. " char))
4302 (let* ((file (expand-file-name file))
4303 (name (gnus-generate-new-group-name
4304 (gnus-group-prefixed-name
4305 (file-name-nondirectory file) '(nndoc "")))))
4306 (gnus-group-make-group
4307 (gnus-group-real-name name)
4309 (list 'nndoc-address file)
4310 (list 'nndoc-article-type type)))))
4312 (defun gnus-group-make-archive-group (&optional all)
4313 "Create the (ding) Gnus archive group of the most recent articles.
4314 Given a prefix, create a full group."
4316 (let ((group (gnus-group-prefixed-name
4317 (if all "ding.archives" "ding.recent") '(nndir ""))))
4318 (and (gnus-gethash group gnus-newsrc-hashtb)
4319 (error "Archive group already exists"))
4320 (gnus-group-make-group
4321 (gnus-group-real-name group)
4323 (if all gnus-group-archive-directory
4324 gnus-group-recent-archive-directory)))
4325 (gnus-group-position-cursor))
4327 (defun gnus-group-make-directory-group (dir)
4328 "Create an nndir group.
4329 The user will be prompted for a directory. The contents of this
4330 directory will be used as a newsgroup. The directory should contain
4331 mail messages or news articles in files that have numeric names."
4333 (list (read-file-name "Create group from directory: ")))
4334 (or (file-exists-p dir) (error "No such directory"))
4335 (or (file-directory-p dir) (error "Not a directory"))
4336 (gnus-group-make-group dir "nndir" dir)
4337 (gnus-group-position-cursor))
4339 (defun gnus-group-make-kiboze-group (group address scores)
4340 "Create an nnkiboze group.
4341 The user will be prompted for a name, a regexp to match groups, and
4342 score file entries for articles to include in the group."
4345 (read-string "nnkiboze group name: ")
4346 (read-string "Source groups (regexp): ")
4347 (let ((headers (mapcar (lambda (group) (list group))
4348 '("subject" "from" "number" "date" "message-id"
4349 "references" "chars" "lines" "xref")))
4350 scores header regexp regexps)
4351 (while (not (equal "" (setq header (completing-read
4352 "Match on header: " headers nil t))))
4354 (while (not (equal "" (setq regexp (read-string
4355 (format "Match on %s (string): "
4357 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4358 (setq scores (cons (cons header regexps) scores)))
4360 (gnus-group-make-group group "nnkiboze" address)
4362 (gnus-set-work-buffer)
4363 (let (emacs-lisp-mode-hook)
4364 (pp scores (current-buffer)))
4365 (write-region (point-min) (point-max)
4366 (concat (or gnus-kill-files-directory "~/News")
4367 "nnkiboze:" group "." gnus-score-file-suffix)))
4368 (gnus-group-position-cursor))
4370 (defun gnus-group-add-to-virtual (n vgroup)
4371 "Add the current group to a virtual group."
4373 (list current-prefix-arg
4374 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4376 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4377 (error "%s is not an nnvirtual group" vgroup))
4378 (let* ((groups (gnus-group-process-prefix n))
4379 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4380 (setcar (cdr method)
4382 (nth 1 method) "\\|"
4385 (gnus-group-remove-mark s)
4386 (concat "\\(^" (regexp-quote s) "$\\)"))
4388 (gnus-group-position-cursor))
4390 (defun gnus-group-make-empty-virtual (group)
4391 "Create a new, fresh, empty virtual group."
4392 (interactive "sCreate new, empty virtual group: ")
4393 (let* ((method (list 'nnvirtual "^$"))
4394 (pgroup (gnus-group-prefixed-name group method)))
4395 ;; Check whether it exists already.
4396 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4397 (error "Group %s already exists." pgroup))
4398 ;; Subscribe the new group after the group on the current line.
4399 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4400 (gnus-group-update-group pgroup)
4402 (gnus-group-position-cursor)))
4404 (defun gnus-group-enter-directory (dir)
4405 "Enter an ephemeral nneething group."
4406 (interactive "DDirectory to read: ")
4407 (let* ((method (list 'nneething dir))
4408 (leaf (gnus-group-prefixed-name
4409 (file-name-nondirectory (directory-file-name dir))
4411 (name (gnus-generate-new-group-name leaf)))
4412 (let ((nneething-read-only t))
4413 (or (gnus-group-read-ephemeral-group
4415 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4417 (error "Couldn't enter %s" dir)))))
4419 ;; Group sorting commands
4420 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4422 (defun gnus-group-sort-groups ()
4423 "Sort the group buffer using `gnus-group-sort-function'."
4425 (setq gnus-newsrc-alist
4426 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4427 (gnus-make-hashtable-from-newsrc-alist)
4428 (gnus-group-list-groups))
4430 (defun gnus-group-sort-by-alphabet (info1 info2)
4431 (string< (car info1) (car info2)))
4433 (defun gnus-group-sort-by-unread (info1 info2)
4434 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4435 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4436 (< (or (and (numberp n1) n1) 0)
4437 (or (and (numberp n2) n2) 0))))
4439 (defun gnus-group-sort-by-level (info1 info2)
4440 (< (nth 1 info1) (nth 1 info2)))
4442 ;; Group catching up.
4444 (defun gnus-group-catchup-current (&optional n all)
4445 "Mark all articles not marked as unread in current newsgroup as read.
4446 If prefix argument N is numeric, the ARG next newsgroups will be
4447 caught up. If ALL is non-nil, marked articles will also be marked as
4448 read. Cross references (Xref: header) of articles are ignored.
4449 The difference between N and actual number of newsgroups that were
4450 caught up is returned."
4452 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4456 "Do you really want to mark all articles as read? "
4457 "Mark all unread articles as read? "))))
4459 (let ((groups (gnus-group-process-prefix n))
4462 ;; Virtual groups have to be given special treatment.
4463 (let ((method (gnus-find-method-for-group (car groups))))
4464 (if (eq 'nnvirtual (car method))
4465 (nnvirtual-catchup-group
4466 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4467 (gnus-group-remove-mark (car groups))
4469 (gnus-group-goto-group (car groups))
4470 (gnus-group-catchup (car groups) all))
4471 (gnus-group-update-group-line)
4472 (setq ret (1+ ret)))
4473 (setq groups (cdr groups)))
4474 (gnus-group-next-unread-group 1)
4477 (defun gnus-group-catchup-current-all (&optional n)
4478 "Mark all articles in current newsgroup as read.
4479 Cross references (Xref: header) of articles are ignored."
4481 (gnus-group-catchup-current n 'all))
4483 (defun gnus-group-catchup (group &optional all)
4484 "Mark all articles in GROUP as read.
4485 If ALL is non-nil, all articles are marked as read.
4486 The return value is the number of articles that were marked as read,
4487 or nil if no action could be taken."
4488 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4490 (marked (nth 3 (nth 2 entry))))
4491 (if (not (numberp (car entry)))
4492 (gnus-message 1 "Can't catch up; non-active group")
4493 ;; Do the updating only if the newsgroup isn't killed.
4496 (gnus-update-read-articles
4497 group (and (not all) (append (cdr (assq 'tick marked))
4498 (cdr (assq 'dormant marked))))
4499 nil (and (not all) (cdr (assq 'tick marked))))
4501 (setq marked (nth 3 (nth 2 entry)))
4502 (setcar (nthcdr 3 (nth 2 entry))
4503 (delq (assq 'dormant marked)
4504 (nth 3 (nth 2 entry)))))))
4507 (defun gnus-group-expire-articles (&optional n)
4508 "Expire all expirable articles in the current newsgroup."
4510 (let ((groups (gnus-group-process-prefix n))
4512 (or groups (error "No groups to expire"))
4514 (setq group (car groups)
4515 groups (cdr groups))
4516 (gnus-group-remove-mark group)
4517 (if (not (gnus-check-backend-function 'request-expire-articles group))
4519 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4520 (expirable (if (memq 'total-expire (nth 5 info))
4521 (cons nil (gnus-list-of-read-articles group))
4522 (assq 'expire (nth 3 info)))))
4525 (gnus-request-expire-articles
4526 (cdr expirable) group))))))))
4528 (defun gnus-group-expire-all-groups ()
4529 "Expire all expirable articles in all newsgroups."
4532 (gnus-message 5 "Expiring...")
4533 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4534 (cdr gnus-newsrc-alist))))
4535 (gnus-group-expire-articles nil)))
4536 (gnus-group-position-cursor)
4537 (gnus-message 5 "Expiring...done"))
4539 (defun gnus-group-set-current-level (n level)
4540 "Set the level of the next N groups to LEVEL."
4541 (interactive "P\nnLevel: ")
4542 (or (and (>= level 1) (<= level gnus-level-killed))
4543 (error "Illegal level: %d" level))
4544 (let ((groups (gnus-group-process-prefix n))
4547 (setq group (car groups)
4548 groups (cdr groups))
4549 (gnus-group-remove-mark group)
4550 (gnus-message 6 "Changed level of %s from %d to %d"
4551 group (gnus-group-group-level) level)
4552 (gnus-group-change-level group level
4553 (gnus-group-group-level))
4554 (gnus-group-update-group-line)))
4555 (gnus-group-position-cursor))
4557 (defun gnus-group-unsubscribe-current-group (&optional n)
4558 "Toggle subscription of the current group.
4559 If given numerical prefix, toggle the N next groups."
4561 (let ((groups (gnus-group-process-prefix n))
4564 (setq group (car groups)
4565 groups (cdr groups))
4566 (gnus-group-remove-mark group)
4567 (gnus-group-unsubscribe-group
4568 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4569 gnus-level-default-unsubscribed
4570 gnus-level-default-subscribed))
4571 (gnus-group-update-group-line))
4572 (gnus-group-next-group 1)))
4574 (defun gnus-group-unsubscribe-group (group &optional level)
4575 "Toggle subscribe from/to unsubscribe GROUP.
4576 New newsgroup is added to .newsrc automatically."
4578 (list (completing-read
4579 "Group: " gnus-active-hashtb nil
4580 (memq gnus-select-method gnus-have-read-active-file))))
4581 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4583 ((string-match "^[ \t]$" group)
4584 (error "Empty group name"))
4586 ;; Toggle subscription flag.
4587 (gnus-group-change-level
4588 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4589 gnus-level-subscribed)
4590 (1+ gnus-level-subscribed)
4591 gnus-level-default-subscribed)))
4592 (gnus-group-update-group group))
4593 ((and (stringp group)
4594 (or (not (memq gnus-select-method gnus-have-read-active-file))
4595 (gnus-gethash group gnus-active-hashtb)))
4596 ;; Add new newsgroup.
4597 (gnus-group-change-level
4599 (if level level gnus-level-default-subscribed)
4600 (or (and (member group gnus-zombie-list)
4603 (and (gnus-group-group-name)
4604 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4605 (gnus-group-update-group group))
4606 (t (error "No such newsgroup: %s" group)))
4607 (gnus-group-position-cursor)))
4609 (defun gnus-group-transpose-groups (n)
4610 "Move the current newsgroup up N places.
4611 If given a negative prefix, move down instead. The difference between
4612 N and the number of steps taken is returned."
4614 (or (gnus-group-group-name)
4615 (error "No group on current line"))
4616 (gnus-group-kill-group 1)
4618 (forward-line (- n))
4619 (gnus-group-yank-group)
4620 (gnus-group-position-cursor)))
4622 (defun gnus-group-kill-all-zombies ()
4623 "Kill all zombie newsgroups."
4625 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4626 (setq gnus-zombie-list nil)
4627 (gnus-group-list-groups))
4629 (defun gnus-group-kill-region (begin end)
4630 "Kill newsgroups in current region (excluding current point).
4631 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4646 (beginning-of-line) ;Important when LINES < 1
4647 (gnus-group-kill-group lines)))
4649 (defun gnus-group-kill-group (&optional n)
4650 "The the next N groups.
4651 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4652 However, only groups that were alive can be yanked; already killed
4653 groups or zombie groups can't be yanked.
4654 The return value is the name of the (last) group that was killed."
4656 (let ((buffer-read-only nil)
4657 (groups (gnus-group-process-prefix n))
4660 (setq group (car groups)
4661 groups (cdr groups))
4662 (gnus-group-remove-mark group)
4663 (setq level (gnus-group-group-level))
4665 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4666 (setq gnus-list-of-killed-groups
4667 (cons (cons (car entry) (nth 2 entry))
4668 gnus-list-of-killed-groups)))
4669 (gnus-group-change-level
4670 (if entry entry group) gnus-level-killed (if entry nil level)))
4671 (gnus-group-position-cursor)
4674 (defun gnus-group-yank-group (&optional arg)
4675 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4676 inserting it before the current newsgroup. The numeric ARG specifies
4677 how many newsgroups are to be yanked. The name of the (last)
4678 newsgroup yanked is returned."
4680 (if (not arg) (setq arg 1))
4681 (let (info group prev)
4682 (while (>= (setq arg (1- arg)) 0)
4683 (if (not (setq info (car gnus-list-of-killed-groups)))
4684 (error "No more newsgroups to yank"))
4685 (setq group (nth 2 info))
4686 ;; Find which newsgroup to insert this one before - search
4687 ;; backward until something suitable is found. If there are no
4688 ;; other newsgroups in this buffer, just make this newsgroup the
4690 (setq prev (gnus-group-group-name))
4691 (gnus-group-change-level
4692 info (nth 2 info) gnus-level-killed
4693 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4695 (gnus-group-insert-group-line-info (nth 1 info))
4696 (setq gnus-list-of-killed-groups
4697 (cdr gnus-list-of-killed-groups)))
4699 (gnus-group-position-cursor)
4702 (defun gnus-group-list-all-groups (&optional arg)
4703 "List all newsgroups with level ARG or lower.
4704 Default is gnus-level-unsubscribed, which lists all subscribed and most
4705 unsubscribed groups."
4707 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
4709 (defun gnus-group-list-killed ()
4710 "List all killed newsgroups in the group buffer."
4712 (if (not gnus-killed-list)
4713 (gnus-message 6 "No killed groups")
4714 (let (gnus-group-list-mode)
4715 (funcall gnus-group-prepare-function
4716 gnus-level-killed t gnus-level-killed))
4717 (goto-char (point-min)))
4718 (gnus-group-position-cursor))
4720 (defun gnus-group-list-zombies ()
4721 "List all zombie newsgroups in the group buffer."
4723 (if (not gnus-zombie-list)
4724 (gnus-message 6 "No zombie groups")
4725 (let (gnus-group-list-mode)
4726 (funcall gnus-group-prepare-function
4727 gnus-level-zombie t gnus-level-zombie))
4728 (goto-char (point-min)))
4729 (gnus-group-position-cursor))
4731 (defun gnus-group-get-new-news (&optional arg)
4732 "Get newly arrived articles.
4733 If ARG is non-nil, it should be a number between one and nine to
4734 specify which levels you are interested in re-scanning."
4736 (run-hooks 'gnus-get-new-news-hook)
4737 (setq arg (gnus-group-default-level arg t))
4738 (if (and gnus-read-active-file (not arg))
4740 (gnus-read-active-file)
4741 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4742 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
4743 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4744 (gnus-group-list-groups))
4746 (defun gnus-group-get-new-news-this-group (&optional n)
4747 "Check for newly arrived news in the current group (and the N-1 next groups).
4748 The difference between N and the number of newsgroup checked is returned.
4749 If N is negative, this group and the N-1 previous groups will be checked."
4751 (let* ((groups (gnus-group-process-prefix n))
4752 (ret (if (numberp n) (- n (length groups)) 0))
4755 (setq group (car groups)
4756 groups (cdr groups))
4757 (gnus-group-remove-mark group)
4758 (or (gnus-get-new-news-in-group group)
4761 (message "%s error: %s" group (gnus-status-message group))
4763 (gnus-group-next-unread-group 1 t)
4764 (gnus-summary-position-cursor)
4767 (defun gnus-get-new-news-in-group (group)
4769 (gnus-activate-group group)
4771 (gnus-get-unread-articles-in-group
4772 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4773 (gnus-gethash group gnus-active-hashtb))
4774 (gnus-group-update-group-line)
4777 (defun gnus-group-fetch-faq (group)
4778 "Fetch the FAQ for the current group."
4779 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4780 (or group (error "No group name given"))
4781 (let ((file (concat gnus-group-faq-directory (gnus-group-real-name group))))
4782 (if (not (file-exists-p file))
4783 (error "No such file: %s" file)
4786 (defun gnus-group-describe-group (force &optional group)
4787 "Display a description of the current newsgroup."
4788 (interactive (list current-prefix-arg (gnus-group-group-name)))
4789 (and force (setq gnus-description-hashtb nil))
4790 (let ((method (gnus-find-method-for-group group))
4792 (or group (error "No group name given"))
4793 (and (or (and gnus-description-hashtb
4794 ;; We check whether this group's method has been
4795 ;; queried for a description file.
4797 (gnus-group-prefixed-name "" method)
4798 gnus-description-hashtb))
4799 (setq desc (gnus-group-get-description group))
4800 (gnus-read-descriptions-file method))
4802 (or desc (gnus-gethash group gnus-description-hashtb)
4803 "No description available")))))
4805 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4806 (defun gnus-group-describe-all-groups (&optional force)
4807 "Pop up a buffer with descriptions of all newsgroups."
4809 (and force (setq gnus-description-hashtb nil))
4810 (if (not (or gnus-description-hashtb
4811 (gnus-read-all-descriptions-files)))
4812 (error "Couldn't request descriptions file"))
4813 (let ((buffer-read-only nil)
4819 (insert (format " *: %-20s %s\n" (symbol-name group)
4820 (symbol-value group)))
4821 (add-text-properties
4822 b (1+ b) (list 'gnus-group group
4823 'gnus-unread t 'gnus-marked nil
4824 'gnus-level (1+ gnus-level-subscribed))))
4825 gnus-description-hashtb)
4826 (goto-char (point-min))
4827 (gnus-group-position-cursor)))
4829 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4830 (defun gnus-group-apropos (regexp &optional search-description)
4831 "List all newsgroups that have names that match a regexp."
4832 (interactive "sGnus apropos (regexp): ")
4834 (obuf (current-buffer))
4836 ;; Go through all newsgroups that are known to Gnus.
4839 (and (symbol-name group)
4840 (string-match regexp (symbol-name group))
4841 (setq groups (cons (symbol-name group) groups))))
4843 ;; Go through all descriptions that are known to Gnus.
4844 (if search-description
4847 (and (string-match regexp (symbol-value group))
4848 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4849 (setq groups (cons (symbol-name group) groups))))
4850 gnus-description-hashtb))
4852 (gnus-message 3 "No groups matched \"%s\"." regexp)
4853 ;; Print out all the groups.
4855 (pop-to-buffer "*Gnus Help*")
4856 (buffer-disable-undo (current-buffer))
4858 (setq groups (sort groups 'string<))
4860 ;; Groups may be entered twice into the list of groups.
4861 (if (not (string= (car groups) prev))
4863 (insert (setq prev (car groups)) "\n")
4864 (if (and gnus-description-hashtb
4865 (setq des (gnus-gethash (car groups)
4866 gnus-description-hashtb)))
4867 (insert " " des "\n"))))
4868 (setq groups (cdr groups)))
4869 (goto-char (point-min))))
4870 (pop-to-buffer obuf)))
4872 (defun gnus-group-description-apropos (regexp)
4873 "List all newsgroups that have names or descriptions that match a regexp."
4874 (interactive "sGnus description apropos (regexp): ")
4875 (if (not (or gnus-description-hashtb
4876 (gnus-read-all-descriptions-files)))
4877 (error "Couldn't request descriptions file"))
4878 (gnus-group-apropos regexp t))
4880 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4881 (defun gnus-group-list-matching (level regexp &optional all lowest)
4882 "List all groups with unread articles that match REGEXP.
4883 If the prefix LEVEL is non-nil, it should be a number that says which
4884 level to cut off listing groups.
4885 If ALL, also list groups with no unread articles.
4886 If LOWEST, don't list groups with level lower than LOWEST."
4887 (interactive "P\nsList newsgroups matching: ")
4888 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4889 all (or lowest 1) regexp)
4890 (goto-char (point-min))
4891 (gnus-group-position-cursor))
4893 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4894 "List all groups that match REGEXP.
4895 If the prefix LEVEL is non-nil, it should be a number that says which
4896 level to cut off listing groups.
4897 If LOWEST, don't list groups with level lower than LOWEST."
4898 (interactive "P\nsList newsgroups matching: ")
4899 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4901 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4902 (defun gnus-group-save-newsrc ()
4903 "Save the Gnus startup files."
4905 (gnus-save-newsrc-file))
4907 (defun gnus-group-restart (&optional arg)
4908 "Force Gnus to read the .newsrc file."
4910 (gnus-save-newsrc-file)
4911 (gnus-setup-news 'force)
4912 (gnus-group-list-groups arg))
4914 (defun gnus-group-read-init-file ()
4915 "Read the Gnus elisp init file."
4917 (gnus-read-init-file))
4919 (defun gnus-group-check-bogus-groups (&optional silent)
4920 "Check bogus newsgroups.
4921 If given a prefix, don't ask for confirmation before removing a bogus
4924 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4925 (gnus-group-list-groups))
4927 (defun gnus-group-edit-global-kill (&optional article group)
4928 "Edit the global kill file.
4929 If GROUP, edit that local kill file instead."
4931 (setq gnus-current-kill-article article)
4932 (gnus-kill-file-edit-file group)
4935 (substitute-command-keys
4936 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4938 (defun gnus-group-edit-local-kill (article group)
4939 "Edit a local kill file."
4940 (interactive (list nil (gnus-group-group-name)))
4941 (gnus-group-edit-global-kill article group))
4943 (defun gnus-group-force-update ()
4944 "Update `.newsrc' file."
4946 (gnus-save-newsrc-file))
4948 (defun gnus-group-suspend ()
4949 "Suspend the current Gnus session.
4950 In fact, cleanup buffers except for group mode buffer.
4951 The hook gnus-suspend-gnus-hook is called before actually suspending."
4953 (run-hooks 'gnus-suspend-gnus-hook)
4954 ;; Kill Gnus buffers except for group mode buffer.
4955 (let ((group-buf (get-buffer gnus-group-buffer)))
4956 ;; Do this on a separate list in case the user does a ^G before we finish
4957 (let ((gnus-buffer-list
4958 (delq group-buf (delq gnus-dribble-buffer
4959 (append gnus-buffer-list nil)))))
4960 (while gnus-buffer-list
4961 (gnus-kill-buffer (car gnus-buffer-list))
4962 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4965 (setq gnus-buffer-list (list group-buf))
4966 (bury-buffer group-buf)
4967 (delete-windows-on group-buf t)))))
4969 (defun gnus-group-clear-dribble ()
4970 "Clear all information from the dribble buffer."
4972 (gnus-dribble-clear))
4974 (defun gnus-group-exit ()
4975 "Quit reading news after updating .newsrc.eld and .newsrc.
4976 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4978 (if (or noninteractive ;For gnus-batch-kill
4979 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4980 (not gnus-interactive-exit) ;Without confirmation
4982 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4984 (run-hooks 'gnus-exit-gnus-hook)
4985 ;; Offer to save data from non-quitted summary buffers.
4986 (gnus-offer-save-summaries)
4987 ;; Save the newsrc file(s).
4988 (gnus-save-newsrc-file)
4990 (gnus-close-backends)
4991 ;; Reset everything.
4992 (gnus-clear-system))))
4994 (defun gnus-close-backends ()
4995 ;; Send a close request to all backends that support such a request.
4996 (let ((methods gnus-valid-select-methods)
4999 (if (fboundp (setq func (intern (concat (car (car methods))
5000 "-request-close"))))
5002 (setq methods (cdr methods)))))
5004 (defun gnus-group-quit ()
5005 "Quit reading news without updating .newsrc.eld or .newsrc.
5006 The hook `gnus-exit-gnus-hook' is called before actually exiting."
5008 (if (or noninteractive ;For gnus-batch-kill
5009 (zerop (buffer-size))
5010 (not (gnus-server-opened gnus-select-method))
5012 (not gnus-current-startup-file)
5014 (format "Quit reading news without saving %s? "
5015 (file-name-nondirectory gnus-current-startup-file))))
5017 (run-hooks 'gnus-exit-gnus-hook)
5018 (if gnus-use-full-window
5019 (delete-other-windows)
5020 (gnus-remove-some-windows))
5022 (gnus-close-backends)
5023 (gnus-clear-system))))
5025 (defun gnus-offer-save-summaries ()
5027 (let ((buflist (buffer-list))
5030 (and (setq bufname (buffer-name (car buflist)))
5031 (string-match "Summary" bufname)
5033 (set-buffer bufname)
5034 ;; We check that this is, indeed, a summary buffer.
5035 (eq major-mode 'gnus-summary-mode))
5036 (setq buffers (cons bufname buffers)))
5037 (setq buflist (cdr buflist)))
5040 "Update summary buffer %s? "
5043 (gnus-summary-exit))
5046 (defun gnus-group-describe-briefly ()
5047 "Give a one line description of the group mode commands."
5049 (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")))
5051 (defun gnus-group-browse-foreign-server (method)
5052 "Browse a foreign news server.
5053 If called interactively, this function will ask for a select method
5054 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
5055 If not, METHOD should be a list where the first element is the method
5056 and the second element is the address."
5058 (list (let ((how (completing-read
5060 (append gnus-valid-select-methods gnus-server-alist)
5062 ;; We either got a backend name or a virtual server name.
5063 ;; If the first, we also need an address.
5064 (if (assoc how gnus-valid-select-methods)
5066 ;; Suggested by mapjph@bath.ac.uk.
5069 (mapcar (lambda (server) (list server))
5070 gnus-secondary-servers)))
5071 ;; We got a server name, so we find the method.
5072 (gnus-server-to-method how)))))
5073 (gnus-browse-foreign-server method))
5077 ;;; Browse Server Mode
5080 (defvar gnus-browse-mode-hook nil)
5081 (defvar gnus-browse-mode-map nil)
5082 (put 'gnus-browse-mode 'mode-class 'special)
5084 (if gnus-browse-mode-map
5086 (setq gnus-browse-mode-map (make-keymap))
5087 (suppress-keymap gnus-browse-mode-map)
5088 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
5089 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
5090 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
5091 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
5092 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
5093 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
5094 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
5095 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
5096 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
5097 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
5098 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
5099 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
5100 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
5101 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
5102 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
5103 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
5104 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
5105 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
5108 (defvar gnus-browse-current-method nil)
5109 (defvar gnus-browse-return-buffer nil)
5111 (defvar gnus-browse-buffer "*Gnus Browse Server*")
5113 (defun gnus-browse-foreign-server (method &optional return-buffer)
5114 (setq gnus-browse-current-method method)
5115 (setq gnus-browse-return-buffer return-buffer)
5116 (let ((gnus-select-method method)
5118 (gnus-message 5 "Connecting to %s..." (nth 1 method))
5119 (or (gnus-check-server method)
5120 (error "Unable to contact server: %s" (gnus-status-message method)))
5121 (or (gnus-request-list method)
5122 (error "Couldn't request list: %s" (gnus-status-message method)))
5123 (get-buffer-create gnus-browse-buffer)
5124 (gnus-add-current-to-buffer-list)
5125 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
5126 (gnus-configure-windows 'browse)
5127 (buffer-disable-undo (current-buffer))
5128 (let ((buffer-read-only nil))
5131 (setq mode-line-buffer-identification
5133 "Gnus Browse Server {%s:%s}" (car method) (car (cdr method))))
5135 (set-buffer nntp-server-buffer)
5136 (let ((cur (current-buffer)))
5137 (goto-char (point-min))
5138 (or (string= gnus-ignored-newsgroups "")
5139 (delete-matching-lines gnus-ignored-newsgroups))
5140 (while (re-search-forward
5141 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
5142 (goto-char (match-end 1))
5143 (setq groups (cons (cons (buffer-substring (match-beginning 1)
5145 (max 0 (- (1+ (read cur)) (read cur))))
5147 (setq groups (sort groups
5149 (string< (car l1) (car l2)))))
5150 (let ((buffer-read-only nil))
5152 (setq group (car groups))
5154 (format "K%7d: %s\n" (cdr group) (car group)))
5155 (setq groups (cdr groups))))
5156 (switch-to-buffer (current-buffer))
5157 (goto-char (point-min))
5158 (gnus-group-position-cursor)))
5160 (defun gnus-browse-mode ()
5161 "Major mode for browsing a foreign server.
5163 All normal editing commands are switched off.
5165 \\<gnus-browse-mode-map>
5166 The only things you can do in this buffer is
5168 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
5169 The group will be inserted into the group buffer upon exit from this
5172 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
5174 3) `\\[gnus-browse-exit]' to return to the group buffer."
5176 (kill-all-local-variables)
5177 (if gnus-visual (gnus-browse-make-menu-bar))
5178 (gnus-simplify-mode-line)
5179 (setq major-mode 'gnus-browse-mode)
5180 (setq mode-name "Browse Server")
5181 (setq mode-line-process nil)
5182 (use-local-map gnus-browse-mode-map)
5183 (buffer-disable-undo (current-buffer))
5184 (setq truncate-lines t)
5185 (setq buffer-read-only t)
5186 (run-hooks 'gnus-browse-mode-hook))
5188 (defun gnus-browse-read-group (&optional no-article)
5189 "Enter the group at the current line."
5191 (let ((group (gnus-browse-group-name)))
5192 (or (gnus-group-read-ephemeral-group
5193 group gnus-browse-current-method nil
5194 (cons (current-buffer) 'browse))
5195 (error "Couldn't enter %s" group))))
5197 (defun gnus-browse-select-group ()
5198 "Select the current group."
5200 (gnus-browse-read-group 'no))
5202 (defun gnus-browse-next-group (n)
5203 "Go to the next group."
5207 (gnus-group-position-cursor)))
5209 (defun gnus-browse-prev-group (n)
5210 "Go to the next group."
5212 (gnus-browse-next-group (- n)))
5214 (defun gnus-browse-unsubscribe-current-group (arg)
5215 "(Un)subscribe to the next ARG groups."
5218 (error "No group at current line."))
5219 (let ((ward (if (< arg 0) -1 1))
5221 (while (and (> arg 0)
5223 (gnus-browse-unsubscribe-group)
5224 (zerop (gnus-browse-next-group ward)))
5225 (setq arg (1- arg)))
5226 (gnus-group-position-cursor)
5227 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5230 (defun gnus-browse-group-name ()
5233 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5235 (gnus-group-prefixed-name
5236 (buffer-substring (match-beginning 1) (match-end 1))
5237 gnus-browse-current-method))))
5239 (defun gnus-browse-unsubscribe-group ()
5240 "Toggle subscription of the current group in the browse buffer."
5242 (buffer-read-only nil)
5246 ;; If this group it killed, then we want to subscribe it.
5247 (if (= (following-char) ?K) (setq sub t))
5248 (setq group (gnus-browse-group-name))
5252 (gnus-group-change-level
5253 (list t group gnus-level-default-subscribed
5254 nil nil gnus-browse-current-method)
5255 gnus-level-default-subscribed gnus-level-killed
5256 (and (car (nth 1 gnus-newsrc-alist))
5257 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5258 gnus-newsrc-hashtb))
5261 (gnus-group-change-level
5262 group gnus-level-killed gnus-level-default-subscribed)
5266 (defun gnus-browse-exit ()
5267 "Quit browsing and return to the group buffer."
5269 (if (eq major-mode 'gnus-browse-mode)
5270 (kill-buffer (current-buffer)))
5271 (if gnus-browse-return-buffer
5272 (gnus-configure-windows 'server 'force)
5273 (gnus-configure-windows 'group 'force)
5274 (gnus-group-list-groups nil)))
5276 (defun gnus-browse-describe-briefly ()
5277 "Give a one line description of the group mode commands."
5280 (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")))
5284 ;;; Gnus summary mode
5287 (defvar gnus-summary-mode-map nil)
5288 (defvar gnus-summary-mark-map nil)
5289 (defvar gnus-summary-mscore-map nil)
5290 (defvar gnus-summary-article-map nil)
5291 (defvar gnus-summary-thread-map nil)
5292 (defvar gnus-summary-goto-map nil)
5293 (defvar gnus-summary-exit-map nil)
5294 (defvar gnus-summary-interest-map nil)
5295 (defvar gnus-summary-sort-map nil)
5296 (defvar gnus-summary-backend-map nil)
5297 (defvar gnus-summary-save-map nil)
5298 (defvar gnus-summary-wash-map nil)
5299 (defvar gnus-summary-wash-hide-map nil)
5300 (defvar gnus-summary-wash-highlight-map nil)
5301 (defvar gnus-summary-wash-time-map nil)
5302 (defvar gnus-summary-help-map nil)
5304 (put 'gnus-summary-mode 'mode-class 'special)
5306 (if gnus-summary-mode-map
5308 (setq gnus-summary-mode-map (make-keymap))
5309 (suppress-keymap gnus-summary-mode-map)
5311 ;; Non-orthogonal keys
5313 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5314 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5315 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5316 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5317 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5318 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5319 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5320 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5321 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5322 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5323 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5324 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5325 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5326 (define-key gnus-summary-mode-map
5327 "\M-s" 'gnus-summary-search-article-forward)
5328 (define-key gnus-summary-mode-map
5329 "\M-r" 'gnus-summary-search-article-backward)
5330 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5331 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5332 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5333 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5334 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5335 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5336 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5337 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5338 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5339 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5340 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5341 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5342 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5343 (define-key gnus-summary-mode-map
5344 "k" 'gnus-summary-kill-same-subject-and-select)
5345 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5346 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5347 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5348 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5349 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5350 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5351 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5352 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5353 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5354 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5355 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5356 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5357 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5358 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5359 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5360 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5361 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5362 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5363 (define-key gnus-summary-mode-map
5364 "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5365 (define-key gnus-summary-mode-map
5366 "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5367 (define-key gnus-summary-mode-map
5368 "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5369 (define-key gnus-summary-mode-map
5370 "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5371 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5372 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5373 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5374 (define-key gnus-summary-mode-map
5375 "\C-x\C-s" 'gnus-summary-reselect-current-group)
5376 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5377 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5378 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5379 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5380 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5381 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5382 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5383 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5384 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5385 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5386 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5387 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5388 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5389 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5390 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5391 (define-key gnus-summary-mode-map "V" 'gnus-version)
5392 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5393 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5394 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5395 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5396 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5397 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5398 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5399 (define-key gnus-summary-mode-map
5400 "x" 'gnus-summary-remove-lines-marked-as-read)
5401 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5402 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5403 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5404 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5405 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5406 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5407 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5408 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5409 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5410 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5413 ;; Sort of orthogonal keymap
5414 (define-prefix-command 'gnus-summary-mark-map)
5415 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5416 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5417 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5418 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5419 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5420 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5421 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5422 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5423 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5424 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5425 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5426 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5427 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5428 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5429 (define-key gnus-summary-mark-map
5430 "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5431 (define-key gnus-summary-mark-map
5432 "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5433 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5434 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5435 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5436 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5437 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5438 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5439 (define-key gnus-summary-mark-map
5440 "k" 'gnus-summary-kill-same-subject-and-select)
5441 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5443 (define-prefix-command 'gnus-summary-mscore-map)
5444 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map)
5445 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5446 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5447 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5448 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5450 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map)
5452 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5454 (define-prefix-command 'gnus-summary-goto-map)
5455 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5456 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5457 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5458 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5459 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5460 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5461 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5462 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5463 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5464 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5465 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5466 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5467 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5468 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5471 (define-prefix-command 'gnus-summary-thread-map)
5472 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5473 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5474 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5475 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5476 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5477 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5478 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5479 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5480 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5481 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5482 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5483 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5484 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5485 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5488 (define-prefix-command 'gnus-summary-exit-map)
5489 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5490 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5491 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5492 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5493 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5494 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5495 (define-key gnus-summary-exit-map
5496 "n" 'gnus-summary-catchup-and-goto-next-group)
5497 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5498 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5499 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5500 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5503 (define-prefix-command 'gnus-summary-article-map)
5504 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5505 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5506 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5507 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5508 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5509 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5510 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5511 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5512 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5513 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5514 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5515 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5516 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5517 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5521 (define-prefix-command 'gnus-summary-wash-map)
5522 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5524 (define-prefix-command 'gnus-summary-wash-hide-map)
5525 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map)
5526 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide)
5527 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers)
5528 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature)
5529 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation)
5530 (define-key gnus-summary-wash-hide-map
5531 "\C-c" 'gnus-article-hide-citation-maybe)
5533 (define-prefix-command 'gnus-summary-wash-highlight-map)
5534 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map)
5535 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight)
5536 (define-key gnus-summary-wash-highlight-map
5537 "h" 'gnus-article-highlight-headers)
5538 (define-key gnus-summary-wash-highlight-map
5539 "c" 'gnus-article-highlight-citation)
5540 (define-key gnus-summary-wash-highlight-map
5541 "s" 'gnus-article-highlight-signature)
5543 (define-prefix-command 'gnus-summary-wash-time-map)
5544 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map)
5545 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut)
5546 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut)
5547 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local)
5548 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed)
5550 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5551 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5552 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5553 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr)
5554 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5555 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5556 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
5557 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
5558 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header)
5559 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
5562 (define-prefix-command 'gnus-summary-help-map)
5563 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5564 (define-key gnus-summary-help-map "v" 'gnus-version)
5565 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5566 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5567 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5568 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5571 (define-prefix-command 'gnus-summary-backend-map)
5572 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5573 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5574 (define-key gnus-summary-backend-map "\M-\C-e"
5575 'gnus-summary-expire-articles-now)
5576 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5577 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5578 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5579 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5580 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5581 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5582 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5585 (define-prefix-command 'gnus-summary-save-map)
5586 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5587 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5588 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5589 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5590 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5591 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5592 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5593 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5594 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5596 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5598 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
5599 ; (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5600 ; (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5601 ; (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5602 ; (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5603 ; (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5604 ; (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5605 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
5606 ; (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5607 ; (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5609 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map)
5611 ; (define-prefix-command 'gnus-summary-sort-map)
5612 ; (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5613 ; (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5614 ; (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5615 ; (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5616 ; (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5617 ; (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5619 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5620 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5626 (defun gnus-summary-mode (&optional group)
5627 "Major mode for reading articles.
5629 All normal editing commands are switched off.
5630 \\<gnus-summary-mode-map>
5631 Each line in this buffer represents one article. To read an
5632 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5633 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5636 You can also post articles and send mail from this buffer. To
5637 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5638 of an article, type `\\[gnus-summary-reply]'.
5640 There are approx. one gazillion commands you can execute in this
5641 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5643 The following commands are available:
5645 \\{gnus-summary-mode-map}"
5647 (if gnus-visual (gnus-summary-make-menu-bar))
5648 (kill-all-local-variables)
5649 (let ((locals gnus-summary-local-variables))
5651 (if (consp (car locals))
5653 (make-local-variable (car (car locals)))
5654 (set (car (car locals)) (eval (cdr (car locals)))))
5655 (make-local-variable (car locals))
5656 (set (car locals) nil))
5657 (setq locals (cdr locals))))
5658 (gnus-make-thread-indent-array)
5659 (gnus-simplify-mode-line)
5660 (setq major-mode 'gnus-summary-mode)
5661 (setq mode-name "Summary")
5662 (make-local-variable 'minor-mode-alist)
5663 (use-local-map gnus-summary-mode-map)
5664 (buffer-disable-undo (current-buffer))
5665 (setq buffer-read-only t) ;Disable modification
5666 (setq truncate-lines t)
5667 (setq selective-display t)
5668 (setq selective-display-ellipses t) ;Display `...'
5669 (setq buffer-display-table gnus-summary-display-table)
5670 (setq gnus-newsgroup-name group)
5671 (run-hooks 'gnus-summary-mode-hook))
5673 (defun gnus-summary-make-display-table ()
5674 ;; Change the display table. Odd characters have a tendency to mess
5675 ;; up nicely formatted displays - we make all possible glyphs
5676 ;; display only a single character.
5678 ;; We start from the standard display table, if any.
5679 (setq gnus-summary-display-table
5680 (or (copy-sequence standard-display-table)
5681 (make-display-table)))
5682 ;; Nix out all the control chars...
5684 (while (>= (setq i (1- i)) 0)
5685 (aset gnus-summary-display-table i [??])))
5686 ;; ... but not newline and cr, of course. (cr is necessary for the
5687 ;; selective display).
5688 (aset gnus-summary-display-table ?\n nil)
5689 (aset gnus-summary-display-table ?\r nil)
5690 ;; We nix out any glyphs over 126 that are not set already.
5692 (while (>= (setq i (1- i)) 127)
5693 ;; Only modify if the entry is nil.
5694 (or (aref gnus-summary-display-table i)
5695 (aset gnus-summary-display-table i [??])))))
5697 (defun gnus-summary-clear-local-variables ()
5698 (let ((locals gnus-summary-local-variables))
5700 (if (consp (car locals))
5701 (and (vectorp (car (car locals)))
5702 (set (car (car locals)) nil))
5703 (and (vectorp (car locals))
5704 (set (car locals) nil)))
5705 (setq locals (cdr locals)))))
5707 ;; Some summary mode macros.
5709 ;; Return a header specified by a NUMBER.
5710 (defun gnus-get-header-by-number (number)
5712 (set-buffer gnus-summary-buffer)
5713 (or gnus-newsgroup-headers-hashtb-by-number
5714 (gnus-make-headers-hashtable-by-number))
5715 (gnus-gethash (int-to-string number)
5716 gnus-newsgroup-headers-hashtb-by-number)))
5718 ;; Fast version of the function above.
5719 (defmacro gnus-get-header-by-num (number)
5720 (` (gnus-gethash (int-to-string (, number))
5721 gnus-newsgroup-headers-hashtb-by-number)))
5723 (defmacro gnus-summary-search-forward (&optional unread subject backward)
5724 "Search for article forward.
5725 If UNREAD is non-nil, only unread articles are selected.
5726 If SUBJECT is non-nil, the article which has the same subject will be
5728 If BACKWARD is non-nil, the search will be performed backwards instead."
5729 (` (gnus-summary-search-subject (, backward) (, unread) (, subject))))
5731 (defmacro gnus-summary-search-backward (&optional unread subject)
5732 "Search for article backward.
5733 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5734 If 2nd optional argument SUBJECT is non-nil, the article which has
5735 the same subject will be searched for."
5736 (` (gnus-summary-search-forward (, unread) (, subject) t)))
5738 (defmacro gnus-summary-article-number (&optional number-or-nil)
5739 "The article number of the article on the current line.
5740 If there isn's an article number here, then we return the current
5743 '(get-text-property (gnus-point-at-bol) 'gnus-number)
5744 '(or (get-text-property (gnus-point-at-bol) 'gnus-number)
5745 gnus-current-article)))
5747 (defmacro gnus-summary-thread-level ()
5748 "The thread level of the article on the current line."
5749 '(or (get-text-property (gnus-point-at-bol) 'gnus-level)
5752 (defmacro gnus-summary-article-mark ()
5753 "The mark on the current line."
5754 '(get-text-property (gnus-point-at-bol) 'gnus-mark))
5756 (defun gnus-summary-subject-string ()
5757 "Return current subject string or nil if nothing."
5758 (let ((article (gnus-summary-article-number))
5761 (setq header (gnus-get-header-by-num article))
5763 (mail-header-subject header))))
5765 ;; Various summary mode internalish functions.
5767 (defun gnus-mouse-pick-article (e)
5770 (gnus-summary-next-page nil t))
5772 (defun gnus-summary-setup-buffer (group)
5773 "Initialize summary buffer."
5774 (let ((buffer (concat "*Summary " group "*")))
5775 (if (get-buffer buffer)
5778 (not gnus-newsgroup-begin))
5779 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5780 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5781 (gnus-add-current-to-buffer-list)
5782 (gnus-summary-mode group)
5783 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5784 (setq gnus-newsgroup-name group)
5787 (defun gnus-set-global-variables ()
5788 ;; Set the global equivalents of the summary buffer-local variables
5789 ;; to the latest values they had. These reflect the summary buffer
5790 ;; that was in action when the last article was fetched.
5791 (if (eq major-mode 'gnus-summary-mode)
5793 (setq gnus-summary-buffer (current-buffer))
5794 (let ((name gnus-newsgroup-name)
5795 (marked gnus-newsgroup-marked)
5796 (unread gnus-newsgroup-unreads)
5797 (headers gnus-current-headers)
5798 (score-file gnus-current-score-file))
5800 (set-buffer gnus-group-buffer)
5801 (setq gnus-newsgroup-name name)
5802 (setq gnus-newsgroup-marked marked)
5803 (setq gnus-newsgroup-unreads unread)
5804 (setq gnus-current-headers headers)
5805 (setq gnus-current-score-file score-file))))))
5807 (defun gnus-summary-insert-dummy-line (sformat subject number)
5809 (setq sformat gnus-summary-dummy-line-format-spec))
5813 (insert (eval sformat))
5814 (add-text-properties
5816 (list 'gnus-number number
5817 'gnus-mark gnus-dummy-mark
5820 (defvar gnus-thread-indent-array nil)
5821 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5822 (defun gnus-make-thread-indent-array ()
5824 (if (and gnus-thread-indent-array
5825 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5827 (setq gnus-thread-indent-array (make-vector 201 "")
5828 gnus-thread-indent-array-level gnus-thread-indent-level)
5830 (aset gnus-thread-indent-array n
5831 (make-string (* n gnus-thread-indent-level) ? ))
5834 (defun gnus-summary-insert-line
5835 (sformat header level current unread replied expirable subject-or-nil
5836 &optional dummy score process)
5837 (or sformat (setq sformat gnus-summary-line-format-spec))
5838 (let* ((indentation (aref gnus-thread-indent-array level))
5839 (lines (mail-header-lines header))
5840 (score (or score gnus-summary-default-score 0))
5842 (if (or (null gnus-summary-default-score)
5843 (<= (abs (- score gnus-summary-default-score))
5844 gnus-summary-zcore-fuzz)) ?
5845 (if (< score gnus-summary-default-score)
5846 gnus-score-below-mark gnus-score-over-mark)))
5847 (replied (cond (process gnus-process-mark)
5848 (replied gnus-replied-mark)
5849 (t gnus-unread-mark)))
5850 (from (mail-header-from header))
5852 ((string-match "(.+)" from)
5853 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
5854 ((string-match "<[^>]+> *$" from)
5855 (let ((beg (match-beginning 0)))
5856 (or (and (string-match "^\"[^\"]*\"" from)
5857 (substring from (1+ (match-beginning 0))
5858 (1- (match-end 0))))
5859 (substring from 0 beg))))
5861 (subject (mail-header-subject header))
5862 (number (mail-header-number header))
5863 (opening-bracket (if dummy ?\< ?\[))
5864 (closing-bracket (if dummy ?\> ?\]))
5865 (buffer-read-only nil)
5866 (b (progn (beginning-of-line) (point))))
5867 (or (numberp lines) (setq lines 0))
5868 (insert (eval sformat))
5869 (add-text-properties
5870 b (1+ b) (list 'gnus-number number
5871 'gnus-mark (or unread gnus-unread-mark)
5872 'gnus-level level))))
5874 (defun gnus-summary-update-line (&optional dont-update)
5875 ;; Update summary line after change.
5876 (or (not gnus-summary-default-score)
5877 gnus-summary-inhibit-highlight
5878 (let ((gnus-summary-inhibit-highlight t)
5879 (article (gnus-summary-article-number)))
5882 (if (and gnus-summary-mark-below
5883 (< (gnus-summary-article-score)
5884 gnus-summary-mark-below))
5885 (and (not (memq article gnus-newsgroup-marked))
5886 (not (memq article gnus-newsgroup-dormant))
5887 (memq article gnus-newsgroup-unreads)
5888 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5889 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5890 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
5892 (run-hooks 'gnus-summary-update-hook))))))
5894 (defun gnus-summary-update-lines (&optional beg end)
5895 ;; Mark article as read (or not) by taking into account scores.
5896 (let ((beg (or beg (point-min)))
5897 (end (or end (point-max))))
5898 (if (or (not gnus-summary-default-score)
5899 gnus-summary-inhibit-highlight)
5901 (let ((gnus-summary-inhibit-highlight t)
5904 (set-buffer gnus-summary-buffer)
5907 (while (and (not (eobp)) (< (point) end))
5908 (if (and gnus-summary-mark-below
5910 (setq article (get-text-property
5911 (point) 'gnus-number))
5912 gnus-newsgroup-scored))
5913 gnus-summary-default-score 0)
5914 gnus-summary-mark-below))
5915 ;; We want to possibly mark it as read...
5916 (and (not (memq article gnus-newsgroup-marked))
5917 (not (memq article gnus-newsgroup-dormant))
5918 (memq article gnus-newsgroup-unreads)
5919 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5920 ;; We want to possibly mark it as unread.
5921 (and (eq (get-text-property (point) 'gnus-mark)
5922 gnus-low-score-mark)
5923 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
5924 ;; Do the visual highlights at the same time.
5925 (and gnus-visual (run-hooks 'gnus-summary-update-hook))
5926 (forward-line 1)))))))
5928 (defvar gnus-tmp-gathered nil)
5930 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5931 ;; Sum up all elements (and sub-elements) in a list.
5933 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
5934 (if (and (consp thread) (cdr thread))
5937 'gnus-summary-number-of-articles-in-thread
5941 (if (> number 1) gnus-not-empty-thread-mark
5942 gnus-empty-thread-mark)
5945 (defun gnus-summary-read-group
5946 (group &optional show-all no-article kill-buffer)
5947 "Start reading news in newsgroup GROUP.
5948 If SHOW-ALL is non-nil, already read articles are also listed.
5949 If NO-ARTICLE is non-nil, no article is selected initially."
5950 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5951 (let* ((new-group (gnus-summary-setup-buffer group))
5952 (quit-config (gnus-group-quit-config group))
5953 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5956 (gnus-set-global-variables)
5957 (gnus-kill-buffer kill-buffer)
5958 (gnus-configure-windows 'summary 'force)
5959 (gnus-set-mode-line 'summary)
5960 (gnus-summary-position-cursor)
5964 (and (eq major-mode 'gnus-summary-mode)
5965 (not (equal (current-buffer) kill-buffer))
5967 (kill-buffer (current-buffer))
5968 (if (not quit-config)
5970 (set-buffer gnus-group-buffer)
5971 (gnus-group-jump-to-group group)
5972 (gnus-group-next-unread-group 1))
5973 (if (not (buffer-name (car quit-config)))
5974 (gnus-configure-windows 'group 'force)
5975 (set-buffer (car quit-config))
5976 (and (eq major-mode 'gnus-summary-mode)
5977 (gnus-set-global-variables))
5978 (gnus-configure-windows (cdr quit-config))))))
5979 (message "Can't select group")
5981 ((eq did-select 'quit)
5982 (and (eq major-mode 'gnus-summary-mode)
5983 (not (equal (current-buffer) kill-buffer))
5984 (kill-buffer (current-buffer)))
5985 (gnus-kill-buffer kill-buffer)
5986 (if (not quit-config)
5988 (set-buffer gnus-group-buffer)
5989 (gnus-group-jump-to-group group)
5990 (gnus-group-next-unread-group 1)
5991 (gnus-configure-windows 'group 'force))
5992 (if (not (buffer-name (car quit-config)))
5993 (gnus-configure-windows 'group 'force)
5994 (set-buffer (car quit-config))
5995 (and (eq major-mode 'gnus-summary-mode)
5996 (gnus-set-global-variables))
5997 (gnus-configure-windows (cdr quit-config))))
6000 (gnus-set-global-variables)
6001 ;; Save the active value in effect when the group was entered.
6002 (setq gnus-newsgroup-active
6004 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6005 ;; You can change the subjects in this hook.
6006 (run-hooks 'gnus-select-group-hook)
6007 ;; Do score processing.
6008 (and gnus-use-scoring (gnus-possibly-score-headers))
6009 (gnus-update-format-specifications)
6010 ;; Generate the summary buffer.
6011 (gnus-summary-prepare)
6012 (if (zerop (buffer-size))
6013 (cond (gnus-newsgroup-dormant
6014 (gnus-summary-show-all-dormant))
6015 ((and gnus-newsgroup-scored show-all)
6016 (gnus-summary-show-all-expunged))))
6017 ;; Function `gnus-apply-kill-file' must be called in this hook.
6018 (run-hooks 'gnus-apply-kill-hook)
6019 (if (zerop (buffer-size))
6021 ;; This newsgroup is empty.
6022 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
6023 (gnus-message 6 "No unread news")
6024 (gnus-kill-buffer kill-buffer)
6028 ;; (let ((gnus-summary-buffer kill-buffer))
6029 ;; (gnus-configure-windows 'group))))
6030 ;; Hide conversation thread subtrees. We cannot do this in
6031 ;; gnus-summary-prepare-hook since kill processing may not
6032 ;; work with hidden articles.
6033 (and gnus-show-threads
6034 gnus-thread-hide-subtree
6035 (gnus-summary-hide-all-threads))
6036 ;; Show first unread article if requested.
6037 (goto-char (point-min))
6038 (if (and (not no-article)
6039 gnus-auto-select-first
6040 (gnus-summary-first-unread-article))
6042 (gnus-configure-windows 'summary 'force))
6043 (gnus-set-mode-line 'summary)
6044 (gnus-summary-position-cursor)
6045 ;; If in async mode, we send some info to the backend.
6046 (and gnus-newsgroup-async
6047 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
6048 (gnus-request-asynchronous
6050 (if (and gnus-asynchronous-article-function
6051 (fboundp gnus-asynchronous-article-function))
6052 (funcall gnus-asynchronous-article-function
6053 gnus-newsgroup-threads)
6054 gnus-newsgroup-threads)))
6055 (gnus-kill-buffer kill-buffer)
6056 (if (not (get-buffer-window gnus-group-buffer))
6058 ;; gotta use windows, because recenter does weird stuff if
6059 ;; the current buffer ain't the displayed window.
6060 (let ((owin (selected-window)))
6061 (select-window (get-buffer-window gnus-group-buffer))
6062 (and (gnus-group-goto-group group)
6064 (select-window owin))))
6067 (defun gnus-summary-prepare ()
6068 ;; Generate the summary buffer.
6069 (let ((buffer-read-only nil))
6071 (gnus-summary-prepare-threads
6072 (if gnus-show-threads
6073 (gnus-gather-threads
6075 (if (and gnus-summary-expunge-below
6076 (not gnus-fetch-old-headers))
6077 (gnus-make-threads-and-expunge)
6078 (gnus-make-threads))))
6079 gnus-newsgroup-headers)
6081 (gnus-summary-update-lines)
6082 ;; Create the header hashtb.
6083 (gnus-make-headers-hashtable-by-number)
6084 ;; Call hooks for modifying summary buffer.
6085 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
6086 (goto-char (point-min))
6087 (run-hooks 'gnus-summary-prepare-hook)))
6089 (defun gnus-gather-threads (threads)
6090 "Gather threads that have lost their roots."
6091 (if (not gnus-summary-make-false-root)
6093 (let ((hashtb (gnus-make-hashtable 1023))
6096 subject hthread whole-subject)
6099 (setq subject (mail-header-subject (car (car threads)))))
6100 (if gnus-summary-gather-subject-limit
6101 (or (and (numberp gnus-summary-gather-subject-limit)
6102 (> (length subject) gnus-summary-gather-subject-limit)
6104 (substring subject 0
6105 gnus-summary-gather-subject-limit)))
6106 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
6107 (setq subject (gnus-simplify-subject-fuzzy subject))))
6108 (setq subject (gnus-simplify-subject-re subject)))
6110 (gnus-gethash subject hashtb))
6112 (or (stringp (car (car hthread)))
6113 (setcar hthread (list whole-subject (car hthread))))
6114 (setcdr (car hthread) (nconc (cdr (car hthread))
6115 (list (car threads))))
6116 (setcdr prev (cdr threads))
6117 (setq threads prev))
6118 (gnus-sethash subject threads hashtb))
6120 (setq threads (cdr threads)))
6123 (defun gnus-make-threads ()
6124 ;; This function takes the dependencies already made by
6125 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6126 ;; through the dependencies in the hash table and finds all the
6127 ;; roots. Roots do not refer back to any valid articles.
6128 (gnus-message 6 "Threading...")
6129 (let (roots new-roots)
6130 (and gnus-fetch-old-headers
6131 (eq gnus-headers-retrieved-by 'nov)
6132 (gnus-build-old-threads))
6135 (if (not (car (symbol-value refs)))
6136 (setq roots (append (cdr (symbol-value refs)) roots))
6137 ;; Ok, these refer back to valid articles, but if
6138 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6139 ;; the root has the same subject as its children. The children
6140 ;; that do not are made into roots and removed from the list
6142 (or gnus-thread-ignore-subject
6143 (let* ((prev (symbol-value refs))
6144 (subject (gnus-simplify-subject-re
6145 (mail-header-subject (car prev))))
6146 (headers (cdr prev)))
6148 (if (not (string= subject
6149 (gnus-simplify-subject-re
6150 (mail-header-subject (car headers)))))
6152 (setq new-roots (cons (car headers) new-roots))
6153 (setcdr prev (cdr headers)))
6154 (setq prev headers))
6155 (setq headers (cdr headers)))))))
6156 gnus-newsgroup-dependencies)
6158 ;; We enter the new roots into the dependencies structure to
6159 ;; ensure that any possible later thread-regeneration will be
6161 (let ((r new-roots))
6163 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6164 (list nil (car r)) gnus-newsgroup-dependencies)
6167 (setq roots (nconc new-roots roots))
6170 (mapcar 'gnus-trim-thread
6172 (mapcar 'gnus-cut-thread
6173 (mapcar 'gnus-make-sub-thread roots))))
6174 (gnus-message 6 "Threading...done"))))
6177 (defun gnus-make-threads-and-expunge ()
6178 ;; This function takes the dependencies already made by
6179 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6180 ;; through the dependencies in the hash table and finds all the
6181 ;; roots. Roots do not refer back to any valid articles.
6182 (gnus-message 6 "Threading...")
6183 (let ((default (or gnus-summary-default-score 0))
6184 (below gnus-summary-expunge-below)
6185 roots article new-roots)
6186 (and gnus-fetch-old-headers
6187 (eq gnus-headers-retrieved-by 'nov)
6188 (gnus-build-old-threads))
6191 (if (not (car (symbol-value refs)))
6192 ;; These articles do not refer back to any other articles -
6194 (let ((headers (cdr (symbol-value refs))))
6195 ;; We weed out the low-scored articles.
6197 (if (not (< (or (cdr (assq (mail-header-number (car headers))
6198 gnus-newsgroup-scored)) default)
6201 (setq roots (cons (car headers) roots))
6202 ;; It is below, so we mark it as read.
6203 (setq gnus-newsgroup-unreads
6204 (delq (mail-header-number (car headers))
6205 gnus-newsgroup-unreads))
6206 (setq gnus-newsgroup-reads
6207 (cons (cons (mail-header-number (car headers))
6208 gnus-low-score-mark)
6209 gnus-newsgroup-reads)))
6210 (setq headers (cdr headers))))
6211 ;; Ok, these refer back to valid articles, but if
6212 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6213 ;; the root has the same subject as its children. The children
6214 ;; that do not are made into roots and removed from the list
6216 (or gnus-thread-ignore-subject
6217 (let* ((prev (symbol-value refs))
6218 (subject (gnus-simplify-subject-re
6219 (mail-header-subject (car prev))))
6220 (headers (cdr prev)))
6222 (if (not (string= subject
6223 (gnus-simplify-subject-re
6224 (mail-header-subject (car headers)))))
6226 (if (not (< (or (cdr (assq (mail-header-number
6228 gnus-newsgroup-scored))
6230 (setq new-roots (cons (car headers) new-roots))
6231 (setq gnus-newsgroup-unreads
6232 (delq (mail-header-number (car headers))
6233 gnus-newsgroup-unreads))
6234 (setq gnus-newsgroup-reads
6235 (cons (cons (mail-header-number (car headers))
6236 gnus-low-score-mark)
6237 gnus-newsgroup-reads)))
6238 (setcdr prev (cdr headers)))
6239 (setq prev headers))
6240 (setq headers (cdr headers)))))
6241 ;; If this article is expunged, some of the children might be
6243 (if (< (or (cdr (assq (mail-header-number (car (symbol-value refs)))
6244 gnus-newsgroup-scored)) default)
6246 (let* ((prev (symbol-value refs))
6247 (headers (cdr prev)))
6249 (setq article (mail-header-number (car headers)))
6250 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6252 (progn (setq new-roots (cons (car headers) new-roots))
6253 (setq prev headers))
6254 (setq gnus-newsgroup-unreads
6255 (delq article gnus-newsgroup-unreads))
6256 (setq gnus-newsgroup-reads
6257 (cons (cons article gnus-low-score-mark)
6258 gnus-newsgroup-reads))
6259 (setcdr prev (cdr headers)))
6260 (setq headers (cdr headers))))
6261 ;; It was not expunged, but we look at expunged children.
6262 (let* ((prev (symbol-value refs))
6263 (headers (cdr prev))
6266 (setq article (mail-header-number (car headers)))
6267 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6270 (setq gnus-newsgroup-unreads
6271 (delq article gnus-newsgroup-unreads))
6272 (setq gnus-newsgroup-reads
6273 (cons (cons article gnus-low-score-mark)
6274 gnus-newsgroup-reads))
6275 (setcdr prev (cdr headers)))
6276 (setq headers (cdr headers)))))))
6277 gnus-newsgroup-dependencies)
6279 ;; We enter the new roots into the dependencies structure to
6280 ;; ensure that any possible later thread-regeneration will be
6282 (let ((r new-roots))
6284 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6285 (list nil (car r)) gnus-newsgroup-dependencies)
6288 (setq roots (nconc new-roots roots))
6291 (mapcar 'gnus-trim-thread
6293 (mapcar 'gnus-cut-thread
6294 (mapcar 'gnus-make-sub-thread roots))))
6295 (gnus-message 6 "Threading...done"))))
6298 (defun gnus-cut-thread (thread)
6299 ;; Remove leaf dormant or ancient articles from THREAD.
6300 (let ((head (car thread))
6301 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6302 (if (and (null tail)
6303 (let ((number (mail-header-number head)))
6304 (or (memq number gnus-newsgroup-ancient)
6305 (memq number gnus-newsgroup-dormant)
6306 (and gnus-summary-expunge-below
6307 (eq gnus-fetch-old-headers 'some)
6308 (< (or (cdr (assq number gnus-newsgroup-scored))
6309 gnus-summary-default-score 0)
6310 gnus-summary-expunge-below)
6312 (setq gnus-newsgroup-unreads
6313 (delq number gnus-newsgroup-unreads))
6314 (setq gnus-newsgroup-reads
6315 (cons (cons number gnus-low-score-mark)
6316 gnus-newsgroup-reads))
6319 (list (cons head tail)))))
6321 (defun gnus-trim-thread (thread)
6322 ;; Remove root ancient articles with only one child from THREAD.
6323 (if (and (eq gnus-fetch-old-headers 'some)
6324 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient)
6325 (= (length thread) 2))
6326 (gnus-trim-thread (nth 1 thread))
6329 (defun gnus-make-sub-thread (root)
6330 ;; This function makes a sub-tree for a node in the tree.
6331 (let ((children (reverse (cdr (gnus-gethash (downcase (mail-header-id root))
6332 gnus-newsgroup-dependencies)))))
6333 (cons root (mapcar 'gnus-make-sub-thread children))))
6335 (defun gnus-build-old-threads ()
6336 ;; Look at all the articles that refer back to old articles, and
6337 ;; fetch the headers for the articles that aren't there. This will
6338 ;; build complete threads - if the roots haven't been expired by the
6343 (if (not (car (symbol-value refs)))
6345 (setq heads (cdr (symbol-value refs)))
6347 (if (not (memq (mail-header-number (car heads))
6348 gnus-newsgroup-dormant))
6350 (setq id (symbol-name refs))
6351 (while (and (setq id (gnus-build-get-header id))
6352 (not (car (gnus-gethash
6353 id gnus-newsgroup-dependencies)))))
6355 (setq heads (cdr heads)))))))
6356 gnus-newsgroup-dependencies)))
6358 (defun gnus-build-get-header (id)
6359 ;; Look through the buffer of NOV lines and find the header to
6360 ;; ID. Enter this line into the dependencies hash table, and return
6361 ;; the id of the parent article (if any).
6362 (let ((deps gnus-newsgroup-dependencies)
6366 (set-buffer nntp-server-buffer)
6367 (goto-char (point-min))
6368 (while (and (not found) (search-forward id nil t))
6370 (setq found (looking-at
6371 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6372 (regexp-quote id))))
6373 (or found (beginning-of-line 2)))
6378 (setq header (gnus-nov-parse-line
6379 (read (current-buffer)) deps))
6380 (setq ref (mail-header-references header))
6381 (string-match "\\(<[^>]+>\\) *$" ref)
6382 (substring ref (match-beginning 1) (match-end 1))))))
6384 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6385 gnus-newsgroup-ancient (cons (mail-header-number header)
6386 gnus-newsgroup-ancient))))))
6388 ;; Re-build the thread containing ID.
6389 (defun gnus-rebuild-thread (id)
6390 (let ((dep gnus-newsgroup-dependencies)
6391 (buffer-read-only nil)
6392 parent headers refs thread art)
6393 (while (and id (setq headers
6394 (car (setq art (gnus-gethash (downcase id) dep)))))
6396 (setq id (and (setq refs (mail-header-references headers))
6397 (string-match "\\(<[^>]+>\\) *$" refs)
6398 (substring refs (match-beginning 1) (match-end 1)))))
6399 (setq thread (gnus-make-sub-thread (car parent)))
6400 (gnus-rebuild-remove-articles thread)
6401 (let ((beg (point)))
6402 (gnus-summary-prepare-threads (list thread))
6403 (gnus-summary-update-lines beg (point)))))
6405 ;; Delete all lines in the summary buffer that correspond to articles
6407 (defun gnus-rebuild-remove-articles (thread)
6408 (and (gnus-summary-goto-subject (mail-header-number (car thread)))
6410 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6412 (defun gnus-sort-threads (threads)
6413 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6414 (let ((fun gnus-thread-sort-functions))
6416 (gnus-message 6 "Sorting with %S..." fun)
6417 (setq threads (sort threads (car fun))
6419 (if gnus-thread-sort-functions
6420 (gnus-message 6 "Sorting...done"))
6423 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6424 (defmacro gnus-thread-header (thread)
6425 ;; Return header of first article in THREAD.
6426 ;; Note that THREAD must never, evr be anything else than a variable -
6427 ;; using some other form will lead to serious barfage.
6428 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
6429 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6430 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6433 (defun gnus-thread-sort-by-number (h1 h2)
6434 "Sort threads by root article number."
6435 (< (mail-header-number (gnus-thread-header h1))
6436 (mail-header-number (gnus-thread-header h2))))
6438 (defun gnus-thread-sort-by-author (h1 h2)
6439 "Sort threads by root author."
6441 (let ((extract (funcall
6442 gnus-extract-address-components
6443 (mail-header-from (gnus-thread-header h1)))))
6444 (or (car extract) (cdr extract)))
6445 (let ((extract (funcall
6446 gnus-extract-address-components
6447 (mail-header-from (gnus-thread-header h2)))))
6448 (or (car extract) (cdr extract)))))
6450 (defun gnus-thread-sort-by-subject (h1 h2)
6451 "Sort threads by root subject."
6453 (downcase (gnus-simplify-subject-re
6454 (mail-header-subject (gnus-thread-header h1))))
6455 (downcase (gnus-simplify-subject-re
6456 (mail-header-subject (gnus-thread-header h2))))))
6458 (defun gnus-thread-sort-by-date (h1 h2)
6459 "Sort threads by root article date."
6461 (gnus-sortable-date (mail-header-date (gnus-thread-header h1)))
6462 (gnus-sortable-date (mail-header-date (gnus-thread-header h2)))))
6464 (defun gnus-thread-sort-by-score (h1 h2)
6465 "Sort threads by root article score.
6466 Unscored articles will be counted as having a score of zero."
6467 (> (or (cdr (assq (mail-header-number (gnus-thread-header h1))
6468 gnus-newsgroup-scored))
6469 gnus-summary-default-score 0)
6470 (or (cdr (assq (mail-header-number (gnus-thread-header h2))
6471 gnus-newsgroup-scored))
6472 gnus-summary-default-score 0)))
6474 (defun gnus-thread-sort-by-total-score (h1 h2)
6475 "Sort threads by the sum of all scores in the thread.
6476 Unscored articles will be counted as having a score of zero."
6477 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6479 (defun gnus-thread-total-score (thread)
6480 ;; This function find the total score of THREAD.
6482 (if (stringp (car thread))
6483 (apply gnus-thread-score-function 0
6484 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6485 (gnus-thread-total-score-1 thread))
6486 (gnus-thread-total-score-1 (list thread))))
6488 (defun gnus-thread-total-score-1 (root)
6489 ;; This function find the total score of the thread below ROOT.
6490 (setq root (car root))
6491 (apply gnus-thread-score-function
6492 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
6493 gnus-summary-default-score 0)
6494 (mapcar 'gnus-thread-total-score
6495 (cdr (gnus-gethash (downcase (mail-header-id root))
6496 gnus-newsgroup-dependencies)))))
6498 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6499 (defvar gnus-tmp-prev-subject "")
6501 (defun gnus-summary-prepare-threads (threads &optional cull)
6502 "Prepare summary buffer from THREADS and indentation LEVEL.
6503 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6504 or a straight list of headers."
6505 (message "Generating summary...")
6507 thread header number subject stack state gnus-tmp-gathered)
6508 (if (vectorp (car threads))
6509 ;; If this is a straight (sic) list of headers, then a
6510 ;; threaded summary display isn't required, so we just create
6511 ;; an unthreaded one.
6512 (gnus-summary-prepare-unthreaded threads cull)
6514 ;; Do the threaded display.
6516 (while (or threads stack)
6519 ;; If there are some threads, we do them before the
6520 ;; threads on the stack.
6521 (setq thread threads
6522 header (car (car thread)))
6523 ;; There were no current threads, so we pop something off
6525 (setq state (car stack)
6529 header (car (car thread))))
6531 (if (stringp header)
6533 ;; The header is a dummy root.
6535 ((eq gnus-summary-make-false-root 'adopt)
6536 ;; We let the first article adopt the rest.
6537 (let ((th (car (cdr (car thread)))))
6540 (setcdr th (cdr (cdr (car thread))))
6541 (setq gnus-tmp-gathered
6543 (lambda (h) (mail-header-number (car h)))
6544 (cdr (cdr (car thread))))
6546 (setcdr (cdr (car thread)) nil))
6548 ((eq gnus-summary-make-false-root 'empty)
6549 ;; We print adopted articles with empty subject fields.
6550 (setq gnus-tmp-gathered
6552 (lambda (h) (mail-header-number (car h)))
6553 (cdr (cdr (car thread))))
6556 ((eq gnus-summary-make-false-root 'dummy)
6557 ;; We output a dummy root.
6558 (gnus-summary-insert-dummy-line
6559 nil header (mail-header-number
6560 (car (car (cdr (car thread)))))))
6562 ;; We do not make a root for the gathered
6563 ;; sub-threads at all.
6566 (setq number (mail-header-number header)
6567 subject (mail-header-subject header))
6569 ;; Do the async thing.
6570 (and gnus-newsgroup-async
6571 (setq gnus-newsgroup-threads
6572 (cons (cons number (mail-header-lines header))
6573 gnus-newsgroup-threads)))
6575 ;; We may have to root out some bad articles...
6578 (cond ((and (memq (setq number (mail-header-number header))
6579 gnus-newsgroup-dormant)
6582 ((and gnus-summary-expunge-below
6583 (< (or (cdr (assq number gnus-newsgroup-scored))
6584 gnus-summary-default-score 0)
6585 gnus-summary-expunge-below))
6587 (setq gnus-newsgroup-unreads
6588 (delq number gnus-newsgroup-unreads))
6589 (setq gnus-newsgroup-reads
6590 (cons (cons number gnus-low-score-mark)
6591 gnus-newsgroup-reads)))))
6597 (gnus-summary-insert-line
6598 nil header level nil
6600 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6601 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6602 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6603 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6604 (t (or (cdr (assq number gnus-newsgroup-reads))
6605 gnus-ancient-mark)))
6606 (memq number gnus-newsgroup-replied)
6607 (memq number gnus-newsgroup-expirable)
6609 ((and gnus-thread-ignore-subject
6611 (gnus-simplify-subject-re gnus-tmp-prev-subject)
6612 (gnus-simplify-subject-re subject))))
6615 (if (and (eq gnus-summary-make-false-root 'empty)
6616 (memq number gnus-tmp-gathered))
6617 gnus-summary-same-subject
6619 (t gnus-summary-same-subject))
6620 (and (eq gnus-summary-make-false-root 'adopt)
6621 (memq number gnus-tmp-gathered))
6622 (cdr (assq number gnus-newsgroup-scored))
6623 (memq number gnus-newsgroup-processable))
6625 (setq gnus-tmp-prev-subject subject)))))
6628 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6629 (setq level (1+ level))
6630 (setq threads (cdr (car thread))))))
6631 (message "Generating summary...done"))
6635 (defun gnus-summary-prepare-unthreaded (headers &optional cull)
6636 (let (header number)
6638 ;; Do the async thing, if that is required.
6639 (if gnus-newsgroup-async
6640 (setq gnus-newsgroup-threads
6642 (cons (mail-header-number h) (mail-header-lines h)))
6646 (setq header (car headers)
6647 headers (cdr headers)
6648 number (mail-header-number header))
6650 ;; We may have to root out some bad articles...
6653 (memq (setq number (mail-header-number header))
6654 gnus-newsgroup-dormant)))
6655 ((and cull gnus-summary-expunge-below
6656 (< (or (cdr (assq number gnus-newsgroup-scored))
6657 gnus-summary-default-score 0)
6658 gnus-summary-expunge-below))
6659 (setq gnus-newsgroup-unreads
6660 (delq number gnus-newsgroup-unreads))
6661 (setq gnus-newsgroup-reads
6662 (cons (cons number gnus-low-score-mark)
6663 gnus-newsgroup-reads)))
6665 (gnus-summary-insert-line
6667 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6668 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6669 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6670 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6671 (t (or (cdr (assq number gnus-newsgroup-reads))
6672 gnus-ancient-mark)))
6673 (memq number gnus-newsgroup-replied)
6674 (memq number gnus-newsgroup-expirable)
6675 (mail-header-subject header) nil
6676 (cdr (assq number gnus-newsgroup-scored))
6677 (memq number gnus-newsgroup-processable)))))))
6679 (defun gnus-select-newsgroup (group &optional read-all)
6680 "Select newsgroup GROUP.
6681 If READ-ALL is non-nil, all articles in the group are selected."
6682 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6683 (info (nth 2 entry))
6686 (or (gnus-check-server
6687 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6688 (error "Couldn't open server"))
6690 (or (and entry (not (eq (car entry) t))) ; Either it's active...
6691 (gnus-activate-group group) ; Or we can activate it...
6692 (progn ; Or we bug out.
6693 (kill-buffer (current-buffer))
6694 (error "Couldn't request group %s: %s"
6695 group (gnus-status-message group))))
6697 (setq gnus-newsgroup-name group)
6698 (setq gnus-newsgroup-unselected nil)
6699 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6701 (and gnus-asynchronous
6702 (gnus-check-backend-function
6703 'request-asynchronous gnus-newsgroup-name)
6704 (setq gnus-newsgroup-async
6705 (gnus-request-asynchronous gnus-newsgroup-name)))
6707 (setq articles (gnus-articles-to-read group read-all))
6711 (gnus-message 3 "Couldn't select newsgroup")
6713 ((eq articles 0) nil)
6715 ;; Init the dependencies hash table.
6716 (setq gnus-newsgroup-dependencies
6717 (gnus-make-hashtable (length articles)))
6718 ;; Retrieve the headers and read them in.
6719 (gnus-message 5 "Fetching headers...")
6720 (setq gnus-newsgroup-headers
6721 (if (eq 'nov (setq gnus-headers-retrieved-by
6722 ;; This is a naughty hack. To get the
6723 ;; retrieval of old headers to work, we
6724 ;; set `nntp-nov-gap' to nil (locally),
6725 ;; and then just retrieve the headers.
6727 (if gnus-fetch-old-headers
6729 (gnus-retrieve-headers
6730 (if (not (eq 1 (car articles)))
6733 gnus-newsgroup-name))
6734 (gnus-retrieve-headers
6735 articles gnus-newsgroup-name))))
6737 (gnus-get-newsgroup-headers-xover articles))
6738 ;; If we were to fetch old headers, but the backend didn't
6739 ;; support XOVER, then it is possible we fetched one article
6740 ;; that we shouldn't have. If that's the case, we remove it.
6741 (if (or (not gnus-fetch-old-headers)
6742 (eq 1 (car articles)))
6745 (set-buffer nntp-server-buffer)
6746 (goto-char (point-min))
6748 (looking-at "[0-9]+[ \t]+1[ \t]") ; This is not a NOV line.
6749 (delete-region ; So we delete this head.
6751 (search-forward "\n.\n" nil t)))))
6752 (gnus-get-newsgroup-headers)))
6753 (gnus-message 5 "Fetching headers...done")
6754 ;; Remove canceled articles from the list of unread articles.
6755 (setq gnus-newsgroup-unreads
6756 (gnus-set-sorted-intersection
6757 gnus-newsgroup-unreads
6758 (mapcar (lambda (headers) (mail-header-number headers))
6759 gnus-newsgroup-headers)))
6760 ;; Adjust and set lists of article marks.
6763 (gnus-adjust-marked-articles info)
6764 (setq gnus-newsgroup-marked
6766 (cdr (assq 'tick (setq marked (nth 3 info))))))
6767 (setq gnus-newsgroup-replied
6768 (copy-sequence (cdr (assq 'reply marked))))
6769 (setq gnus-newsgroup-expirable
6770 (copy-sequence (cdr (assq 'expire marked))))
6771 (setq gnus-newsgroup-killed
6772 (copy-sequence (cdr (assq 'killed marked))))
6773 (setq gnus-newsgroup-bookmarks
6774 (copy-sequence (cdr (assq 'bookmark marked))))
6775 (setq gnus-newsgroup-dormant
6776 (copy-sequence (cdr (assq 'dormant marked))))
6777 (setq gnus-newsgroup-scored
6778 (copy-sequence (cdr (assq 'score marked))))
6779 (setq gnus-newsgroup-processable nil)))
6780 ;; Check whether auto-expire is to be done in this group.
6781 (setq gnus-newsgroup-auto-expire
6782 (or (and (stringp gnus-auto-expirable-newsgroups)
6783 (string-match gnus-auto-expirable-newsgroups group))
6784 (memq 'auto-expire (nth 5 info))))
6785 ;; First and last article in this newsgroup.
6786 (and gnus-newsgroup-headers
6787 (setq gnus-newsgroup-begin
6788 (mail-header-number (car gnus-newsgroup-headers)))
6789 (setq gnus-newsgroup-end
6791 (gnus-last-element gnus-newsgroup-headers))))
6792 (setq gnus-reffed-article-number -1)
6793 ;; GROUP is successfully selected.
6794 (or gnus-newsgroup-headers t)))))
6796 (defun gnus-articles-to-read (group read-all)
6797 ;; Find out what articles the user wants to read.
6799 ;; Select all articles if `read-all' is non-nil, or if all the
6800 ;; unread articles are dormant articles.
6802 (= (length gnus-newsgroup-unreads)
6803 (length gnus-newsgroup-dormant)))
6804 (gnus-uncompress-range
6805 (gnus-gethash group gnus-active-hashtb))
6806 gnus-newsgroup-unreads))
6807 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6808 (scored (length scored-list))
6809 (number (length articles))
6810 (marked (+ (length gnus-newsgroup-marked)
6811 (length gnus-newsgroup-dormant)))
6818 (cond ((and (or (<= scored marked)
6820 (numberp gnus-large-newsgroup)
6821 (> number gnus-large-newsgroup))
6825 "How many articles from %s (default %d): "
6826 gnus-newsgroup-name number))))
6827 (if (string-match "^[ \t]*$" input)
6829 ((and (> scored marked) (< scored number))
6833 "%s %s (%d scored, %d total): "
6834 "How many articles from"
6835 group scored number))))
6836 (if (string-match "^[ \t]*$" input)
6840 (setq select (if (stringp select) (string-to-number select) select))
6841 (if (or (null select) (zerop select))
6843 (if (and (not (zerop scored)) (<= (abs select) scored))
6845 (setq articles (sort scored-list '<))
6846 (setq number (length articles)))
6847 (setq articles (copy-sequence articles)))
6849 (if (< (abs select) number)
6851 ;; Select the N oldest articles.
6852 (setcdr (nthcdr (1- (abs select)) articles) nil)
6853 ;; Select the N most recent articles.
6854 (setq articles (nthcdr (- number select) articles))))
6855 (setq gnus-newsgroup-unselected
6856 (gnus-sorted-intersection
6857 gnus-newsgroup-unreads
6858 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6861 (defun gnus-killed-articles (killed articles)
6864 (if (inline (gnus-member-of-range (car articles) killed))
6865 (setq out (cons (car articles) out)))
6866 (setq articles (cdr articles)))
6869 (defun gnus-adjust-marked-articles (info &optional active)
6870 "Remove all marked articles that are no longer legal."
6871 (let ((marked-lists (nth 3 info))
6872 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6874 ;; There are many types of marked articles.
6876 (setq m (cdr (setq prev (car marked-lists))))
6877 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6878 ;; Make sure that all ticked articles are a subset of the
6879 ;; unread/unselected articles.
6881 (if (or (memq (car m) gnus-newsgroup-unreads)
6882 (memq (car m) gnus-newsgroup-unselected))
6884 (setcdr prev (cdr m)))
6886 ((eq 'score (car prev))
6887 ;; Scored articles should be a subset of
6888 ;; unread/unselected articles.
6890 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6891 (memq (car (car m)) gnus-newsgroup-unreads))
6893 (setcdr prev (cdr m)))
6895 ((eq 'bookmark (car prev))
6896 ;; Bookmarks should be a subset of active articles.
6898 (if (< (car (car m)) (car active))
6899 (setcdr prev (cdr m))
6902 ((eq 'killed (car prev))
6903 ;; Articles that have been through the kill process are
6904 ;; to be a subset of active articles.
6905 (while (and m (< (or (and (numberp (car m)) (car m))
6908 (setcdr prev (cdr m))
6910 (if (and m (< (or (and (numberp (car m)) (car m))
6913 (setcar (if (numberp (car m)) m (car m)) (car active))))
6914 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6915 ;; The replied and expirable articles have to be articles
6918 (if (< (car m) (car active))
6919 (setcdr prev (cdr m))
6922 (setq marked-lists (cdr marked-lists)))
6923 ;; Remove all lists that are empty.
6924 (setq marked-lists (nth 3 info))
6927 (while (= 1 (length (car marked-lists)))
6928 (setq marked-lists (cdr marked-lists)))
6929 (setq m (cdr (setq prev marked-lists)))
6931 (if (= 1 (length (car m)))
6932 (setcdr prev (cdr m))
6935 (setcar (nthcdr 3 info) marked-lists)))
6936 ;; Finally, if there are no marked lists at all left, and if there
6937 ;; are no elements after the lists in the info list, we just chop
6938 ;; the info list off before the marked lists.
6939 (and (null marked-lists)
6940 (not (nthcdr 4 info))
6941 (setcdr (nthcdr 2 info) nil)))
6944 (defun gnus-set-marked-articles
6945 (info ticked replied expirable killed dormant bookmark score)
6946 "Enter the various lists of marked articles into the newsgroup info list."
6948 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6949 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6950 (and expirable (setq newmarked (cons (cons 'expire expirable)
6952 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6953 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6954 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6956 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6959 (setcar (nthcdr 3 info) newmarked)
6960 (and (not newmarked)
6961 (not (nthcdr 4 info))
6962 (setcdr (nthcdr 2 info) nil)))
6964 (setcdr (nthcdr 2 info) (list newmarked))))))
6966 (defun gnus-add-marked-articles (group type articles &optional info force)
6967 ;; Add ARTICLES of TYPE to the info of GROUP.
6968 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6969 ;; add, but replace marked articles of TYPE with ARTICLES.
6970 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6973 (and (not (setq marked (nthcdr 3 info)))
6974 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6975 (and (not (setq m (assq type (car marked))))
6976 (setcar marked (cons (cons type articles) (car marked))))
6979 (nconc m articles)))))
6981 (defun gnus-set-mode-line (where)
6982 "This function sets the mode line of the article or summary buffers.
6983 If WHERE is `summary', the summary mode line format will be used."
6984 (if (memq where gnus-updated-mode-lines)
6987 (set-buffer gnus-summary-buffer)
6988 (let* ((mformat (if (eq where 'article)
6989 gnus-article-mode-line-format-spec
6990 gnus-summary-mode-line-format-spec))
6991 (buffer-name (if (eq where 'article)
6993 (get-buffer gnus-article-buffer))
6995 (group-name gnus-newsgroup-name)
6996 (article-number (or gnus-current-article 0))
6997 (unread (- (length gnus-newsgroup-unreads)
6998 (length gnus-newsgroup-dormant)))
6999 (unread-and-unticked
7000 (- unread (length gnus-newsgroup-marked)))
7001 (unselected (length gnus-newsgroup-unselected))
7002 (unread-and-unselected
7003 (cond ((and (zerop unread-and-unticked)
7004 (zerop unselected)) "")
7006 (format "{%d more}" unread-and-unticked))
7007 (t (format "{%d(+%d) more}"
7008 unread-and-unticked unselected))))
7010 (if gnus-current-headers
7011 (mail-header-subject gnus-current-headers) ""))
7012 (max-len (and gnus-mode-non-string-length
7013 (- (frame-width) gnus-mode-non-string-length)))
7014 header);; passed as argument to any user-format-funcs
7015 (setq mode-string (eval mformat))
7016 (or (numberp max-len)
7017 (setq max-len (length mode-string)))
7018 (if (< max-len 4) (setq max-len 4))
7019 (if (> (length mode-string) max-len)
7020 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
7021 ;; function `substring' might cut on a middle
7022 ;; of multi-octet character.
7024 (concat (gnus-truncate-string mode-string (- max-len 3))
7026 (setq mode-string (format (format "%%-%ds" max-len)
7028 (setq mode-line-buffer-identification mode-string)
7029 (set-buffer-modified-p t))))
7031 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
7032 "Go through the HEADERS list and add all Xrefs to a hash table.
7033 The resulting hash table is returned, or nil if no Xrefs were found."
7034 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
7036 (gnus-group-foreign-p from-newsgroup)
7038 (assoc (symbol-name (car from-method))
7039 gnus-valid-select-methods))))
7040 (gnus-group-real-prefix from-newsgroup)))
7041 (xref-hashtb (make-vector 63 0))
7042 start group entry number xrefs header)
7044 (setq header (car headers))
7045 (if (and (setq xrefs (mail-header-xref header))
7046 (not (memq (mail-header-number header) unreads)))
7049 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
7050 (setq start (match-end 0))
7051 (setq group (concat prefix (substring xrefs (match-beginning 1)
7054 (string-to-int (substring xrefs (match-beginning 2)
7056 (if (setq entry (gnus-gethash group xref-hashtb))
7057 (setcdr entry (cons number (cdr entry)))
7058 (gnus-sethash group (cons number nil) xref-hashtb)))))
7059 (setq headers (cdr headers)))
7060 (if start xref-hashtb nil)))
7062 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
7063 "Look through all the headers and mark the Xrefs as read."
7064 (let ((virtual (memq 'virtual
7065 (assoc (symbol-name (car (gnus-find-method-for-group
7067 gnus-valid-select-methods)))
7068 name entry info xref-hashtb idlist method
7071 (set-buffer gnus-group-buffer)
7072 (if (setq xref-hashtb
7073 (gnus-create-xref-hashtb from-newsgroup headers unreads))
7076 (if (string= from-newsgroup (setq name (symbol-name group)))
7078 (setq idlist (symbol-value group))
7079 ;; Dead groups are not updated.
7081 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
7083 (if (stringp (setq nth4 (nth 4 info)))
7084 (setq nth4 (gnus-server-to-method nth4))))
7085 ;; Only do the xrefs if the group has the same
7086 ;; select method as the group we have just read.
7087 (or (gnus-methods-equal-p
7088 nth4 (gnus-find-method-for-group from-newsgroup))
7091 (setq method (gnus-find-method-for-group
7093 (and (equal (car nth4) (car method))
7094 (equal (nth 1 nth4) (nth 1 method))))
7095 gnus-use-cross-reference
7096 (or (not (eq gnus-use-cross-reference t))
7098 ;; Only do cross-references on subscribed
7099 ;; groups, if that is what is wanted.
7100 (<= (nth 1 info) gnus-level-subscribed)))
7101 (gnus-group-make-articles-read name idlist expirable))))
7104 (defun gnus-group-make-articles-read (group articles expirable)
7106 (entry (gnus-gethash group gnus-newsrc-hashtb))
7107 (info (nth 2 entry))
7108 (active (gnus-gethash group gnus-active-hashtb))
7109 exps expirable range)
7110 ;; First peel off all illegal article numbers.
7112 (let ((ids articles)
7113 (ticked (cdr (assq 'tick (nth 3 info))))
7114 (dormant (cdr (assq 'dormant (nth 3 info))))
7119 (if (and first (> id (cdr active)))
7121 ;; We'll end up in this situation in one particular
7122 ;; obscure situation. If you re-scan a group and get
7123 ;; a new article that is cross-posted to a different
7124 ;; group that has not been re-scanned, you might get
7125 ;; crossposted article that has a higher number than
7126 ;; Gnus believes possible. So we re-activate this
7127 ;; group as well. This might mean doing the
7128 ;; crossposting thingy will *increase* the number
7129 ;; of articles in some groups. Tsk, tsk.
7130 (setq active (or (gnus-activate-group group) active))))
7131 (if (or (> id (cdr active))
7135 (setq articles (delq id articles)))
7136 (and (memq id expirable)
7137 (setq exps (cons id exps)))
7138 (setq ids (cdr ids)))))
7139 ;; Update expirable articles.
7140 (gnus-add-marked-articles nil 'expirable exps info)
7144 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
7145 (setcar (nthcdr 2 info)
7149 (setq articles (sort articles '<)))))
7150 ;; Then we have to re-compute how many unread
7151 ;; articles there are in this group.
7156 (setq num (- (1+ (cdr active)) (car active))))
7157 ((not (listp (cdr range)))
7158 (setq num (- (cdr active) (- (1+ (cdr range))
7162 (if (numberp (car range))
7164 (setq num (+ num (- (1+ (cdr (car range)))
7165 (car (car range))))))
7166 (setq range (cdr range)))
7167 (setq num (- (cdr active) num))))
7168 ;; Update the number of unread articles.
7172 (length (cdr (assq 'tick (nth 3 info))))
7174 (cdr (assq 'dormant (nth 3 info)))))))
7175 ;; Update the group buffer.
7176 (gnus-group-update-group group t)))))
7178 (defun gnus-methods-equal-p (m1 m2)
7179 (let ((m1 (or m1 gnus-select-method))
7180 (m2 (or m2 gnus-select-method)))
7182 (and (eq (car m1) (car m2))
7183 (or (not (memq 'address (assoc (symbol-name (car m1))
7184 gnus-valid-select-methods)))
7185 (equal (nth 1 m1) (nth 1 m2)))))))
7187 (defsubst gnus-header-value ()
7188 (buffer-substring (match-end 0) (gnus-point-at-eol)))
7190 (defvar gnus-newsgroup-none-id 0)
7192 (defun gnus-get-newsgroup-headers ()
7193 (setq gnus-article-internal-prepare-hook nil)
7194 (let ((cur nntp-server-buffer)
7195 (dependencies gnus-newsgroup-dependencies)
7196 headers id dep end ref)
7198 (set-buffer nntp-server-buffer)
7199 ;; Allow the user to mangle the headers before parsing them.
7200 (run-hooks 'gnus-parse-headers-hook)
7201 (goto-char (point-min))
7202 ;; Search to the beginning of the next header. Error messages
7203 ;; do not begin with 2 or 3.
7204 (while (re-search-forward "^[23][0-9]+ " nil t)
7205 (let ((header (make-vector 9 nil))
7206 (case-fold-search t)
7211 (mail-header-set-number header (read cur))
7212 ;; This implementation of this function, with nine
7213 ;; search-forwards instead of the one re-search-forward and
7214 ;; a case (which basically was the old function) is actually
7215 ;; about twice as fast, even though it looks messier. You
7216 ;; can't have everything, I guess. Speed and elegance
7217 ;; doesn't always come hand in hand.
7219 (narrow-to-region (point) (or (save-excursion
7220 (search-forward "\n.\n" nil t))
7222 (if (search-forward "\nfrom: " nil t)
7223 (mail-header-set-from header (gnus-header-value))
7224 (mail-header-set-from header "(nobody)"))
7226 (if (search-forward "\nsubject: " nil t)
7227 (mail-header-set-subject header (gnus-header-value))
7228 (mail-header-set-subject header "(none)"))
7230 (and (search-forward "\nxref: " nil t)
7231 (mail-header-set-xref header (gnus-header-value)))
7233 (or (numberp (and (search-forward "\nlines: " nil t)
7234 (mail-header-set-lines header (read cur))))
7235 (mail-header-set-lines header 0))
7237 (and (search-forward "\ndate: " nil t)
7238 (mail-header-set-date header (gnus-header-value)))
7240 (if (search-forward "\nmessage-id: " nil t)
7241 (mail-header-set-id header (setq id (gnus-header-value)))
7242 ;; If there was no message-id, we just fake one to make
7243 ;; subsequent routines simpler.
7246 (setq id (concat "none+"
7248 (setq gnus-newsgroup-none-id
7249 (1+ gnus-newsgroup-none-id)))))))
7251 (if (search-forward "\nreferences: " nil t)
7253 (mail-header-set-references header (gnus-header-value))
7254 (setq end (match-end 0))
7261 (search-backward ">" end t)
7264 (search-backward "<" end t)
7266 ;; Get the references from the in-reply-to header if there
7267 ;; ware no references and the in-reply-to header looks
7269 (if (and (search-forward "\nin-reply-to: " nil t)
7270 (setq in-reply-to (gnus-header-value))
7271 (string-match "<[^>]+>" in-reply-to))
7273 (mail-header-set-references
7275 (setq ref (substring in-reply-to (match-beginning 0)
7277 (setq ref (downcase ref)))
7279 ;; We do some threading while we read the headers. The
7280 ;; message-id and the last reference are both entered into
7281 ;; the same hash table. Some tippy-toeing around has to be
7282 ;; done in case an article has arrived before the article
7283 ;; which it refers to.
7284 (if (boundp (setq dep (intern (downcase id) dependencies)))
7285 (if (car (symbol-value dep))
7286 ;; An article with this Message-ID has already
7287 ;; been seen, so we ignore this one, except we add
7288 ;; any additional Xrefs (in case the two articles
7289 ;; came from different servers.
7291 (mail-header-set-xref
7292 (car (symbol-value dep))
7293 (concat (or (mail-header-xref
7294 (car (symbol-value dep))) "")
7295 (or (mail-header-xref header) "")))
7297 (setcar (symbol-value dep) header))
7298 (set dep (list header)))
7301 (if (boundp (setq dep (intern ref dependencies)))
7302 (setcdr (symbol-value dep)
7303 (cons header (cdr (symbol-value dep))))
7304 (set dep (list nil header)))
7305 (setq headers (cons header headers))))
7306 (goto-char (point-max))))))
7307 (nreverse headers)))
7309 ;; The following macros and functions were written by Felix Lee
7310 ;; <flee@cse.psu.edu>.
7312 (defmacro gnus-nov-read-integer ()
7314 (if (= (following-char) ?\t)
7316 (let ((num (condition-case nil (read buffer) (error nil))))
7317 (if (numberp num) num 0)))
7318 (or (eobp) (forward-char 1))))
7320 (defmacro gnus-nov-skip-field ()
7321 '(search-forward "\t" eol 'move))
7323 (defmacro gnus-nov-field ()
7324 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
7326 ;; Goes through the xover lines and returns a list of vectors
7327 (defun gnus-get-newsgroup-headers-xover (sequence)
7328 "Parse the news overview data in the server buffer, and return a
7329 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7330 ;; Get the Xref when the users reads the articles since most/some
7331 ;; NNTP servers do not include Xrefs when using XOVER.
7332 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
7333 (let ((cur nntp-server-buffer)
7334 (dependencies gnus-newsgroup-dependencies)
7335 number headers header)
7337 (set-buffer nntp-server-buffer)
7338 ;; Allow the user to mangle the headers before parsing them.
7339 (run-hooks 'gnus-parse-headers-hook)
7340 (goto-char (point-min))
7341 (while (and sequence (not (eobp)))
7342 (setq number (read cur))
7343 (while (and sequence (< (car sequence) number))
7344 (setq sequence (cdr sequence)))
7346 (eq number (car sequence))
7348 (setq sequence (cdr sequence))
7350 (inline (gnus-nov-parse-line number dependencies)))
7351 (setq headers (cons header headers)))))
7353 (setq headers (nreverse headers)))
7356 ;; This function has to be called with point after the article number
7357 ;; on the beginning of the line.
7358 (defun gnus-nov-parse-line (number dependencies)
7360 (eol (gnus-point-at-eol))
7361 (buffer (current-buffer))
7364 ;; overview: [num subject from date id refs chars lines misc]
7365 (narrow-to-region (point) eol)
7366 (or (eobp) (forward-char))
7372 (gnus-nov-field) ; subject
7373 (gnus-nov-field) ; from
7374 (gnus-nov-field) ; date
7375 (setq id (or (gnus-nov-field)
7378 (setq none (1+ none)))))) ; id
7381 (let ((beg (point)))
7382 (search-forward "\t" eol)
7383 (if (search-backward ">" beg t)
7389 (search-backward "<" beg t)
7392 (gnus-nov-field)) ; refs
7393 (gnus-nov-read-integer) ; chars
7394 (gnus-nov-read-integer) ; lines
7395 (if (= (following-char) ?\n)
7397 (gnus-nov-field)) ; misc
7401 (message "Strange nov line.")
7407 ;; We build the thread tree.
7409 (if (boundp (setq dep (intern (downcase id) dependencies)))
7410 (if (car (symbol-value dep))
7411 ;; An article with this Message-ID has already been seen,
7412 ;; so we ignore this one, except we add any additional
7413 ;; Xrefs (in case the two articles came from different
7416 (mail-header-set-xref
7417 (car (symbol-value dep))
7418 (concat (or (mail-header-xref (car (symbol-value dep))) "")
7419 (or (mail-header-xref header) "")))
7421 (setcar (symbol-value dep) header))
7422 (set dep (list header))))
7425 (if (boundp (setq dep (intern (or ref "none")
7427 (setcdr (symbol-value dep)
7428 (cons header (cdr (symbol-value dep))))
7429 (set dep (list nil header)))))
7432 (defun gnus-article-get-xrefs ()
7433 "Fill in the Xref value in `gnus-current-headers', if necessary.
7434 This is meant to be called in `gnus-article-internal-prepare-hook'."
7435 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7436 gnus-current-headers)))
7437 (or (not gnus-use-cross-reference)
7439 (and (mail-header-xref headers)
7440 (not (string= (mail-header-xref headers) "")))
7441 (let ((case-fold-search t)
7444 (gnus-narrow-to-headers)
7445 (goto-char (point-min))
7446 (if (or (and (eq (downcase (following-char)) ?x)
7447 (looking-at "Xref:"))
7448 (search-forward "\nXref:" nil t))
7450 (goto-char (1+ (match-end 0)))
7451 (setq xref (buffer-substring (point)
7452 (progn (end-of-line) (point))))
7453 (mail-header-set-xref headers xref))))))))
7455 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
7456 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
7458 (defun gnus-make-headers-hashtable-by-number ()
7459 "Make hashtable for the variable gnus-newsgroup-headers by number."
7461 (set-buffer gnus-summary-buffer)
7462 (let ((headers gnus-newsgroup-headers)
7464 (setq gnus-newsgroup-headers-hashtb-by-number
7465 (gnus-make-hashtable (length headers)))
7467 (setq header (car headers))
7468 (gnus-sethash (int-to-string (mail-header-number header))
7469 header gnus-newsgroup-headers-hashtb-by-number)
7470 (setq headers (cdr headers))))))
7472 (defun gnus-more-header-backward ()
7473 "Find new header backward."
7474 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7475 (artnum gnus-newsgroup-begin)
7477 (while (and (not header)
7479 (setq artnum (1- artnum))
7480 (setq header (gnus-read-header artnum)))
7483 (defun gnus-more-header-forward (&optional backward)
7484 "Find new header forward.
7485 If BACKWARD, find new header backward instead."
7487 (gnus-more-header-backward)
7488 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7489 (artnum gnus-newsgroup-end)
7491 (while (and (not header)
7493 (setq artnum (1+ artnum))
7494 (setq header (gnus-read-header artnum)))
7497 (defun gnus-extend-newsgroup (header &optional backward)
7498 "Extend newsgroup selection with HEADER.
7499 Optional argument BACKWARD means extend toward backward."
7501 (let ((artnum (mail-header-number header)))
7502 (setq gnus-newsgroup-headers
7504 (cons header gnus-newsgroup-headers)
7505 (nconc gnus-newsgroup-headers (list header))))
7506 (setq gnus-newsgroup-unselected
7507 (delq artnum gnus-newsgroup-unselected))
7508 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
7509 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
7511 (defun gnus-summary-work-articles (n)
7512 "Return a list of articles to be worked upon. The prefix argument,
7513 the list of process marked articles, and the current article will be
7514 taken into consideration."
7516 (if (and n (numberp n))
7517 (let ((backward (< n 0))
7521 (setq articles (cons (gnus-summary-article-number)
7523 (gnus-summary-search-forward nil nil backward))
7525 (sort articles (function <)))
7526 (or (reverse gnus-newsgroup-processable)
7527 (list (gnus-summary-article-number))))))
7529 (defun gnus-summary-search-group (&optional backward use-level)
7530 "Search for next unread newsgroup.
7531 If optional argument BACKWARD is non-nil, search backward instead."
7533 (set-buffer gnus-group-buffer)
7534 (if (gnus-group-search-forward
7535 backward nil (if use-level (gnus-group-group-level) nil))
7536 (gnus-group-group-name))))
7538 (defun gnus-summary-best-group (&optional exclude-group)
7539 "Find the name of the best unread group.
7540 If EXCLUDE-GROUP, do not go to this group."
7542 (set-buffer gnus-group-buffer)
7544 (gnus-group-best-unread-group exclude-group))))
7546 (defun gnus-subject-equal (s1 s2)
7548 ((null gnus-summary-gather-subject-limit)
7549 (equal (gnus-simplify-subject-re s1)
7550 (gnus-simplify-subject-re s2)))
7551 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7552 (equal (gnus-simplify-subject-fuzzy s1)
7553 (gnus-simplify-subject-fuzzy s2)))
7554 ((numberp gnus-summary-gather-subject-limit)
7555 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7556 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7560 (defun gnus-summary-search-subject (&optional backward unread subject)
7561 "Search for article forward.
7562 If BACKWARD is non-nil, search backward.
7563 If UNREAD is non-nil, only unread articles are selected.
7564 If SUBJECT is non-nil, the article which has the same subject will be
7566 (let ((func (if backward 'previous-single-property-change
7567 'next-single-property-change))
7572 (and gnus-summary-check-current unread
7573 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7577 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7580 (setq pos (funcall func (point) 'gnus-number))
7581 (goto-char (if backward (1- pos) pos))
7585 (eq (get-text-property (point) 'gnus-mark)
7589 (inline (gnus-summary-subject-string)))
7591 (gnus-subject-equal subject psubject)))))))
7592 (if backward (if (bobp) nil (forward-char -1) t)
7593 (if (eobp) nil (forward-char 1) t)))))
7595 (progn (goto-char beg) nil)
7597 (get-text-property (point) 'gnus-number)
7598 (gnus-summary-show-thread)
7599 (gnus-summary-position-cursor)))))
7601 (defun gnus-summary-pseudo-article ()
7602 "The thread level of the article on the current line."
7603 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7605 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7606 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7607 (defun gnus-summary-article-score ()
7608 "Return current article score."
7609 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7610 gnus-summary-default-score 0))
7612 (defun gnus-summary-recenter ()
7613 "Center point in the summary window.
7614 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7615 displayed, no centering will be performed."
7616 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7617 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7618 (let* ((top (cond ((< (window-height) 4) 0)
7619 ((< (window-height) 7) 1)
7621 (height (1- (window-height)))
7622 (bottom (save-excursion (goto-char (point-max))
7623 (forward-line (- height))
7625 (window (get-buffer-window (current-buffer))))
7627 ;; The user has to want it,
7628 gnus-auto-center-summary
7629 ;; the article buffer must be displayed,
7630 (get-buffer-window gnus-article-buffer)
7631 ;; Set the window start to either `bottom', which is the biggest
7632 ;; possible valid number, or the second line from the top,
7633 ;; whichever is the least.
7635 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7637 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7638 (defun gnus-short-group-name (group &optional levels)
7639 "Collapse GROUP name LEVELS."
7640 (let* ((name "") (foreign "") (depth -1) (skip 1)
7643 (while (string-match "\\." group skip)
7644 (setq skip (match-end 0)
7647 (if (string-match ":" group)
7648 (setq foreign (substring group 0 (match-end 0))
7649 group (substring group (match-end 0))))
7651 (if (and (string-match "\\." group) (> levels 0))
7652 (setq name (concat name (substring group 0 1))
7653 group (substring group (match-end 0))
7655 name (concat name "."))
7656 (setq name (concat foreign name group)
7660 (defun gnus-summary-jump-to-group (newsgroup)
7661 "Move point to NEWSGROUP in group mode buffer."
7662 ;; Keep update point of group mode buffer if visible.
7663 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7664 (save-window-excursion
7665 ;; Take care of tree window mode.
7666 (if (get-buffer-window gnus-group-buffer)
7667 (pop-to-buffer gnus-group-buffer))
7668 (gnus-group-jump-to-group newsgroup))
7670 ;; Take care of tree window mode.
7671 (if (get-buffer-window gnus-group-buffer)
7672 (pop-to-buffer gnus-group-buffer)
7673 (set-buffer gnus-group-buffer))
7674 (gnus-group-jump-to-group newsgroup))))
7676 ;; This function returns a list of article numbers based on the
7677 ;; difference between the ranges of read articles in this group and
7678 ;; the range of active articles.
7679 (defun gnus-list-of-unread-articles (group)
7680 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7681 (active (gnus-gethash group gnus-active-hashtb))
7684 ;; If none are read, then all are unread.
7686 (setq first (car active))
7687 ;; If the range of read articles is a single range, then the
7688 ;; first unread article is the article after the last read
7689 ;; article. Sounds logical, doesn't it?
7690 (if (not (listp (cdr read)))
7691 (setq first (1+ (cdr read)))
7692 ;; `read' is a list of ranges.
7693 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7694 (car (car read)))) 1)
7698 (while (< first nlast)
7699 (setq unread (cons first unread))
7700 (setq first (1+ first))))
7701 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7702 (setq nlast (if (atom (car (cdr read)))
7704 (car (car (cdr read)))))
7705 (setq read (cdr read)))))
7706 ;; And add the last unread articles.
7707 (while (<= first last)
7708 (setq unread (cons first unread))
7709 (setq first (1+ first)))
7710 ;; Return the list of unread articles.
7713 (defun gnus-list-of-read-articles (group)
7714 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7715 (active (gnus-gethash group gnus-active-hashtb)))
7717 (gnus-sorted-complement
7718 (gnus-uncompress-range active)
7719 (gnus-list-of-unread-articles group)))))
7721 ;; Various summary commands
7723 (defun gnus-summary-universal-argument ()
7724 "Perform any operation on all articles marked with the process mark."
7726 (gnus-set-global-variables)
7727 (let ((articles (reverse gnus-newsgroup-processable))
7729 (or articles (error "No articles marked"))
7730 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7731 (error "Undefined key"))
7733 (gnus-summary-goto-subject (car articles))
7734 (command-execute func)
7735 (gnus-summary-remove-process-mark (car articles))
7736 (setq articles (cdr articles)))))
7738 (defun gnus-summary-toggle-truncation (&optional arg)
7739 "Toggle truncation of summary lines.
7740 With arg, turn line truncation on iff arg is positive."
7742 (setq truncate-lines
7743 (if (null arg) (not truncate-lines)
7744 (> (prefix-numeric-value arg) 0)))
7747 (defun gnus-summary-reselect-current-group (&optional all)
7748 "Once exit and then reselect the current newsgroup.
7749 The prefix argument ALL means to select all articles."
7751 (gnus-set-global-variables)
7752 (let ((current-subject (gnus-summary-article-number))
7753 (group gnus-newsgroup-name))
7754 (setq gnus-newsgroup-begin nil)
7755 (gnus-summary-exit t)
7756 ;; We have to adjust the point of group mode buffer because the
7757 ;; current point was moved to the next unread newsgroup by
7759 (gnus-summary-jump-to-group group)
7760 (gnus-group-read-group all t)
7761 (gnus-summary-goto-subject current-subject)))
7763 (defun gnus-summary-rescan-group (&optional all)
7764 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7766 (gnus-set-global-variables)
7767 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7768 (let ((group gnus-newsgroup-name))
7770 (gnus-summary-jump-to-group group)
7772 (set-buffer gnus-group-buffer)
7773 (gnus-group-get-new-news-this-group 1))
7774 (gnus-summary-jump-to-group group)
7775 (gnus-group-read-group all)))
7777 (defun gnus-summary-update-info ()
7778 (let* ((group gnus-newsgroup-name))
7779 (if gnus-newsgroup-kill-headers
7780 (setq gnus-newsgroup-killed
7781 (gnus-compress-sequence
7783 (gnus-set-sorted-intersection
7784 (gnus-uncompress-range gnus-newsgroup-killed)
7785 (setq gnus-newsgroup-unselected
7786 (sort gnus-newsgroup-unselected '<)))
7787 (setq gnus-newsgroup-unreads
7788 (sort gnus-newsgroup-unreads '<))) t)))
7789 (or (listp (cdr gnus-newsgroup-killed))
7790 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7791 (let ((headers gnus-newsgroup-headers))
7792 (gnus-close-group group)
7793 (run-hooks 'gnus-exit-group-hook)
7794 (gnus-update-read-articles
7795 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7796 gnus-newsgroup-marked
7797 t gnus-newsgroup-replied gnus-newsgroup-expirable
7798 gnus-newsgroup-killed gnus-newsgroup-dormant
7799 gnus-newsgroup-bookmarks
7800 (and gnus-save-score gnus-newsgroup-scored))
7801 (and gnus-use-cross-reference
7802 (gnus-mark-xrefs-as-read
7803 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7804 ;; Do adaptive scoring, and possibly save score files.
7805 (and gnus-newsgroup-adaptive
7806 (gnus-score-adaptive))
7807 (and gnus-use-scoring
7808 (fboundp 'gnus-score-save)
7809 (funcall 'gnus-score-save))
7810 ;; Do not switch windows but change the buffer to work.
7811 (set-buffer gnus-group-buffer)
7812 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
7813 (gnus-group-update-group group)))))
7815 (defun gnus-summary-exit (&optional temporary)
7816 "Exit reading current newsgroup, and then return to group selection mode.
7817 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7819 (gnus-set-global-variables)
7820 (gnus-kill-save-kill-buffer)
7821 (let* ((group gnus-newsgroup-name)
7822 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7824 (buf (current-buffer)))
7825 (run-hooks 'gnus-summary-prepare-exit-hook)
7826 ;; Make all changes in this group permanent.
7827 (gnus-summary-update-info)
7829 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7830 ;; Make sure where I was, and go to next newsgroup.
7831 (set-buffer gnus-group-buffer)
7834 (gnus-group-jump-to-group group)
7835 (gnus-group-next-unread-group 1)))
7838 ;; We set all buffer-local variables to nil. It is unclear why
7839 ;; this is needed, but if we don't, buffer-local variables are
7840 ;; not garbage-collected, it seems. This would the lead to en
7841 ;; ever-growing Emacs.
7843 (gnus-summary-clear-local-variables)
7844 ;; We clear the global counterparts of the buffer-local
7845 ;; variables as well, just to be on the safe side.
7846 (gnus-configure-windows 'group 'force)
7847 (gnus-summary-clear-local-variables)
7848 ;; Return to group mode buffer.
7849 (if (eq mode 'gnus-summary-mode)
7850 (gnus-kill-buffer buf))
7851 (if (get-buffer gnus-article-buffer)
7852 (bury-buffer gnus-article-buffer))
7853 (setq gnus-current-select-method gnus-select-method)
7854 (pop-to-buffer gnus-group-buffer)
7855 (if (not quit-config)
7857 (gnus-group-jump-to-group group)
7858 (gnus-group-next-unread-group 1))
7859 (if (not (buffer-name (car quit-config)))
7860 (gnus-configure-windows 'group 'force)
7861 (set-buffer (car quit-config))
7862 (and (eq major-mode 'gnus-summary-mode)
7863 (gnus-set-global-variables))
7864 (gnus-configure-windows (cdr quit-config))))
7865 (run-hooks 'gnus-summary-exit-hook))))
7867 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7868 (defun gnus-summary-exit-no-update (&optional no-questions)
7869 "Quit reading current newsgroup without updating read article info."
7871 (gnus-set-global-variables)
7872 (let* ((group gnus-newsgroup-name)
7873 (quit-config (gnus-group-quit-config group)))
7874 (if (or no-questions
7876 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7878 (gnus-close-group group)
7879 (gnus-summary-clear-local-variables)
7880 (set-buffer gnus-group-buffer)
7881 (gnus-summary-clear-local-variables)
7882 ;; Return to group selection mode.
7883 (gnus-configure-windows 'group 'force)
7884 (if (get-buffer gnus-summary-buffer)
7885 (kill-buffer gnus-summary-buffer))
7886 (if (get-buffer gnus-article-buffer)
7887 (bury-buffer gnus-article-buffer))
7888 (if (equal (gnus-group-group-name) group)
7889 (gnus-group-next-unread-group 1))
7892 (if (not (buffer-name (car quit-config)))
7893 (gnus-configure-windows 'group 'force)
7894 (set-buffer (car quit-config))
7895 (and (eq major-mode 'gnus-summary-mode)
7896 (gnus-set-global-variables))
7897 (gnus-configure-windows (cdr quit-config)))))))))
7899 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7900 (defun gnus-summary-fetch-faq (group)
7901 "Fetch the FAQ for the current group."
7902 (interactive (list gnus-newsgroup-name))
7903 (let (gnus-faq-buffer)
7904 (and (setq gnus-faq-buffer (gnus-group-fetch-faq group))
7905 (gnus-configure-windows 'summary-faq))))
7907 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7908 (defun gnus-summary-describe-group (&optional force)
7909 "Describe the current newsgroup."
7911 (gnus-group-describe-group force gnus-newsgroup-name))
7913 (defun gnus-summary-describe-briefly ()
7914 "Describe summary mode commands briefly."
7917 (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")))
7919 ;; Walking around group mode buffer from summary mode.
7921 (defun gnus-summary-next-group (&optional no-article target-group backward)
7922 "Exit current newsgroup and then select next unread newsgroup.
7923 If prefix argument NO-ARTICLE is non-nil, no article is selected
7924 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7925 previous group instead."
7927 (gnus-set-global-variables)
7928 (let ((current-group gnus-newsgroup-name)
7929 (current-buffer (current-buffer))
7931 ;; First we semi-exit this group to update Xrefs and all variables.
7932 ;; We can't do a real exit, because the window conf must remain
7933 ;; the same in case the user is prompted for info, and we don't
7934 ;; want the window conf to change before that...
7935 (gnus-summary-exit t)
7936 (while (not entered)
7937 ;; Then we find what group we are supposed to enter.
7938 (set-buffer gnus-group-buffer)
7939 (gnus-group-jump-to-group current-group)
7942 (if (eq gnus-keep-same-level 'best)
7943 (gnus-summary-best-group gnus-newsgroup-name)
7944 (gnus-summary-search-group backward gnus-keep-same-level))))
7945 (if (not target-group)
7946 ;; There are no further groups, so we return to the group
7949 (gnus-message 5 "Returning to the group buffer")
7951 (set-buffer current-buffer)
7952 (gnus-summary-exit))
7953 ;; We try to enter the target group.
7954 (gnus-group-jump-to-group target-group)
7955 (let ((unreads (gnus-group-group-unread)))
7956 (if (and (or (eq t unreads)
7957 (and unreads (not (zerop unreads))))
7958 (gnus-summary-read-group
7959 target-group nil no-article current-buffer))
7961 (setq current-group target-group
7962 target-group nil)))))))
7964 (defun gnus-summary-next-group-old (&optional no-article group backward)
7965 "Exit current newsgroup and then select next unread newsgroup.
7966 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7967 If BACKWARD, go to previous group instead."
7969 (gnus-set-global-variables)
7970 (let ((ingroup gnus-newsgroup-name)
7971 (sumbuf (current-buffer))
7973 (set-buffer gnus-group-buffer)
7975 (or (and (numberp (setq num (car (gnus-gethash
7976 group gnus-newsrc-hashtb))))
7980 (gnus-group-jump-to-group group)
7982 (gnus-group-jump-to-group ingroup))
7983 (gnus-summary-search-group backward)
7984 (let ((group (or group (gnus-summary-search-group backward))))
7986 (gnus-summary-exit t) ;Update all information.
7988 (gnus-summary-exit-no-update t)
7989 (gnus-group-jump-to-group ingroup)
7990 (setq group (gnus-summary-search-group backward))
7991 (gnus-message 5 "Selecting %s..." group)
7992 (set-buffer gnus-group-buffer)
7993 ;; We are now in group mode buffer.
7994 ;; Make sure group mode buffer point is on GROUP.
7995 (gnus-group-jump-to-group group)
7996 (if (not (eq gnus-auto-select-next 'quietly))
7998 (gnus-summary-read-group group nil no-article sumbuf)
7999 (and (string= gnus-newsgroup-name ingroup)
8000 (bufferp sumbuf) (buffer-name sumbuf)
8002 (set-buffer (setq gnus-summary-buffer sumbuf))
8003 (gnus-summary-exit-no-update t))))
8004 (let ((prevgroup group))
8005 (gnus-group-jump-to-group ingroup)
8006 (setq group (gnus-summary-search-group backward))
8007 (gnus-summary-read-group group nil no-article sumbuf)
8008 (while (and (string= gnus-newsgroup-name ingroup)
8010 (buffer-name sumbuf)
8011 (not (string= prevgroup (gnus-group-group-name))))
8012 (set-buffer gnus-group-buffer)
8013 (gnus-summary-read-group
8014 (setq prevgroup (gnus-group-group-name))
8015 nil no-article sumbuf))
8016 (and (string= prevgroup (gnus-group-group-name))
8017 ;; We have reached the final group in the group
8020 (if (buffer-name sumbuf)
8023 (gnus-summary-exit)))))))))))
8025 (defun gnus-summary-prev-group (&optional no-article)
8026 "Exit current newsgroup and then select previous unread newsgroup.
8027 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
8029 (gnus-summary-next-group no-article nil t))
8031 ;; Walking around summary lines.
8033 (defun gnus-summary-first-subject (&optional unread)
8034 "Go to the first unread subject.
8035 If UNREAD is non-nil, go to the first unread article.
8036 Returns nil if there are no unread articles."
8040 (goto-char (point-min)))
8043 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
8046 ;; There are no unread articles.
8047 (gnus-message 3 "No more unread articles")
8049 (gnus-summary-position-cursor)))
8051 (defun gnus-summary-next-subject (n &optional unread dont-display)
8052 "Go to next N'th summary line.
8053 If N is negative, go to the previous N'th subject line.
8054 If UNREAD is non-nil, only unread articles are selected.
8055 The difference between N and the actual number of steps taken is
8058 (let ((backward (< n 0))
8061 (gnus-summary-search-forward unread nil backward))
8063 (if (/= 0 n) (gnus-message 7 "No more%s articles"
8064 (if unread " unread" "")))
8067 (gnus-summary-recenter)
8068 (gnus-summary-position-cursor)))
8071 (defun gnus-summary-next-unread-subject (n)
8072 "Go to next N'th unread summary line."
8074 (gnus-summary-next-subject n t))
8076 (defun gnus-summary-prev-subject (n &optional unread)
8077 "Go to previous N'th summary line.
8078 If optional argument UNREAD is non-nil, only unread article is selected."
8080 (gnus-summary-next-subject (- n) unread))
8082 (defun gnus-summary-prev-unread-subject (n)
8083 "Go to previous N'th unread summary line."
8085 (gnus-summary-next-subject (- n) t))
8087 (defun gnus-summary-goto-subject (article)
8088 "Go the subject line of ARTICLE."
8092 (completing-read "Article number: "
8096 (int-to-string (mail-header-number headers))))
8097 gnus-newsgroup-headers)
8098 nil 'require-match))))
8099 (or article (error "No article number"))
8101 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
8102 'gnus-number article)))
8104 (gnus-summary-show-thread)
8105 ;; Skip dummy articles.
8106 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8113 (gnus-summary-position-cursor)))))
8115 ;; Walking around summary lines with displaying articles.
8117 (defun gnus-summary-expand-window (&optional arg)
8118 "Make the summary buffer take up the entire Emacs frame.
8119 Given a prefix, will force an `article' buffer configuration."
8121 (gnus-set-global-variables)
8123 (gnus-configure-windows 'article 'force)
8124 (gnus-configure-windows 'summary 'force)))
8126 (defun gnus-summary-display-article (article &optional all-header)
8127 "Display ARTICLE in article buffer."
8128 (gnus-set-global-variables)
8132 (gnus-article-prepare article all-header)
8133 (gnus-summary-show-thread)
8134 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8137 (gnus-summary-position-cursor)))
8138 (run-hooks 'gnus-select-article-hook)
8139 (gnus-summary-recenter)
8140 (gnus-summary-goto-subject article)
8141 ;; Successfully display article.
8142 (gnus-summary-update-line)
8143 (gnus-article-set-window-start
8144 (cdr (assq article gnus-newsgroup-bookmarks)))
8147 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
8148 "Select the current article.
8149 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
8150 non-nil, the article will be re-fetched even if it already present in
8151 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
8153 (and (not pseudo) (gnus-summary-pseudo-article)
8154 (error "This is a pseudo-article."))
8155 (let ((article (or article (gnus-summary-article-number)))
8156 (all-headers (not (not all-headers))) ;Must be T or NIL.
8160 (set-buffer gnus-summary-buffer)
8161 (if (or (null gnus-current-article)
8162 (null gnus-article-current)
8163 (null (get-buffer gnus-article-buffer))
8164 (not (eq article (cdr gnus-article-current)))
8165 (not (equal (car gnus-article-current) gnus-newsgroup-name))
8167 ;; The requested article is different from the current article.
8169 (gnus-summary-display-article article all-headers)
8171 (if (or all-headers gnus-show-all-headers)
8172 (gnus-article-show-all-headers))
8175 (gnus-article-set-window-start
8176 (cdr (assq article gnus-newsgroup-bookmarks)))))))
8178 (defun gnus-summary-set-current-mark (&optional current-mark)
8179 "Obsolete function."
8182 (defun gnus-summary-next-article (&optional unread subject backward)
8183 "Select the next article.
8184 If UNREAD, only unread articles are selected.
8185 If SUBJECT, only articles with SUBJECT are selected.
8186 If BACKWARD, the previous article is selected instead of the next."
8188 (gnus-set-global-variables)
8191 ;; Is there such an article?
8192 ((and (gnus-summary-search-forward unread subject backward)
8193 (or (gnus-summary-display-article (gnus-summary-article-number))
8194 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8195 (gnus-summary-position-cursor))
8196 ;; If not, we try the first unread, if that is wanted.
8198 gnus-auto-select-same
8199 (or (gnus-summary-first-unread-article)
8200 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8201 (gnus-summary-position-cursor)
8202 (gnus-message 6 "Wrapped"))
8203 ;; Try to get next/previous article not displayed in this group.
8204 ((and gnus-auto-extend-newsgroup
8205 (not unread) (not subject)
8206 (setq header (gnus-more-header-forward backward)))
8207 (gnus-extend-newsgroup header backward)
8208 (let ((buffer-read-only nil))
8209 (goto-char (if backward (point-min) (point-max)))
8210 (gnus-summary-prepare-threads (list header)))
8211 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
8212 gnus-newsgroup-end)))
8213 ;; Go to next/previous group.
8215 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
8216 (gnus-summary-jump-to-group gnus-newsgroup-name))
8217 (let ((cmd last-command-char)
8219 (if (eq gnus-keep-same-level 'best)
8220 (gnus-summary-best-group gnus-newsgroup-name)
8221 (gnus-summary-search-group backward gnus-keep-same-level))))
8222 ;; For some reason, the group window gets selected. We change
8224 (select-window (get-buffer-window (current-buffer)))
8225 ;; Keep just the event type of CMD.
8226 ;(and (listp cmd) (setq cmd (car cmd)))
8227 ;; Select next unread newsgroup automagically.
8229 ((not gnus-auto-select-next)
8230 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
8231 ((eq gnus-auto-select-next 'quietly)
8233 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
8235 (gnus-message 7 "No more%s articles (%s)..."
8236 (if unread " unread" "")
8237 (if group (concat "selecting " group)
8239 (gnus-summary-next-group nil group backward)))
8241 (let ((keystrokes '(?\C-n ?\C-p))
8243 (while (or (null key) (memq key keystrokes))
8245 7 "No more%s articles%s" (if unread " unread" "")
8247 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
8248 (format " (Type %s for %s [%s])"
8249 (single-key-description cmd) group
8250 (car (gnus-gethash group gnus-newsrc-hashtb)))
8251 (format " (Type %s to exit %s)"
8252 (single-key-description cmd)
8253 gnus-newsgroup-name)))
8254 ;; Confirm auto selection.
8255 (let* ((event (read-char)))
8256 (setq key (if (listp event) (car event) event))
8257 (if (memq key keystrokes)
8258 (let ((obuf (current-buffer)))
8259 (switch-to-buffer gnus-group-buffer)
8261 (gnus-group-jump-to-group group))
8263 (execute-kbd-macro (char-to-string key))
8265 (setq group (gnus-group-group-name))
8266 (switch-to-buffer obuf)))))
8269 (gnus-ephemeral-group-p gnus-newsgroup-name))
8271 (gnus-summary-next-group nil group backward))
8272 (execute-kbd-macro (char-to-string key)))))))))))
8274 (defun gnus-summary-next-unread-article ()
8275 "Select unread article after current one."
8277 (gnus-summary-next-article t (and gnus-auto-select-same
8278 (gnus-summary-subject-string))))
8280 (defun gnus-summary-prev-article (&optional unread subject)
8281 "Select the article after the current one.
8282 If UNREAD is non-nil, only unread articles are selected."
8284 (gnus-summary-next-article unread subject t))
8286 (defun gnus-summary-prev-unread-article ()
8287 "Select unred article before current one."
8289 (gnus-summary-prev-article t (and gnus-auto-select-same
8290 (gnus-summary-subject-string))))
8292 (defun gnus-summary-next-page (&optional lines circular)
8293 "Show next page of selected article.
8294 If end of article, select next article.
8295 Argument LINES specifies lines to be scrolled up.
8296 If CIRCULAR is non-nil, go to the start of the article instead of
8297 instead of selecting the next article when reaching the end of the
8300 (setq gnus-summary-buffer (current-buffer))
8301 (gnus-set-global-variables)
8302 (let ((article (gnus-summary-article-number))
8304 (gnus-configure-windows 'article)
8305 (if (or (null gnus-current-article)
8306 (null gnus-article-current)
8307 (/= article (cdr gnus-article-current))
8308 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8309 ;; Selected subject is different from current article's.
8310 (gnus-summary-display-article article)
8311 (gnus-eval-in-buffer-window
8313 (setq endp (gnus-article-next-page lines)))
8316 (gnus-summary-beginning-of-article))
8318 (gnus-message 3 "End of message"))
8320 (gnus-summary-next-unread-article)))))
8321 (gnus-summary-recenter)
8322 (gnus-summary-position-cursor)))
8324 (defun gnus-summary-prev-page (&optional lines)
8325 "Show previous page of selected article.
8326 Argument LINES specifies lines to be scrolled down."
8328 (gnus-set-global-variables)
8329 (let ((article (gnus-summary-article-number)))
8330 (gnus-configure-windows 'article)
8331 (if (or (null gnus-current-article)
8332 (null gnus-article-current)
8333 (/= article (cdr gnus-article-current))
8334 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8335 ;; Selected subject is different from current article's.
8336 (gnus-summary-display-article article)
8337 (gnus-summary-recenter)
8338 (gnus-eval-in-buffer-window gnus-article-buffer
8339 (gnus-article-prev-page lines))))
8340 (gnus-summary-position-cursor))
8342 (defun gnus-summary-scroll-up (lines)
8343 "Scroll up (or down) one line current article.
8344 Argument LINES specifies lines to be scrolled up (or down if negative)."
8346 (gnus-set-global-variables)
8347 (gnus-configure-windows 'article)
8348 (or (gnus-summary-select-article nil nil 'pseudo)
8349 (gnus-eval-in-buffer-window
8352 (if (gnus-article-next-page lines)
8353 (gnus-message 3 "End of message")))
8355 (gnus-article-prev-page (- lines))))))
8356 (gnus-summary-recenter)
8357 (gnus-summary-position-cursor))
8359 (defun gnus-summary-next-same-subject ()
8360 "Select next article which has the same subject as current one."
8362 (gnus-set-global-variables)
8363 (gnus-summary-next-article nil (gnus-summary-subject-string)))
8365 (defun gnus-summary-prev-same-subject ()
8366 "Select previous article which has the same subject as current one."
8368 (gnus-set-global-variables)
8369 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
8371 (defun gnus-summary-next-unread-same-subject ()
8372 "Select next unread article which has the same subject as current one."
8374 (gnus-set-global-variables)
8375 (gnus-summary-next-article t (gnus-summary-subject-string)))
8377 (defun gnus-summary-prev-unread-same-subject ()
8378 "Select previous unread article which has the same subject as current one."
8380 (gnus-set-global-variables)
8381 (gnus-summary-prev-article t (gnus-summary-subject-string)))
8383 (defun gnus-summary-first-unread-article ()
8384 "Select the first unread article.
8385 Return nil if there are no unread articles."
8387 (gnus-set-global-variables)
8389 (if (gnus-summary-first-subject t)
8391 (gnus-summary-show-thread)
8392 (gnus-summary-first-subject t)
8393 (gnus-summary-display-article (gnus-summary-article-number))))
8394 (gnus-summary-position-cursor)))
8396 (defun gnus-summary-best-unread-article ()
8397 "Select the unread article with the highest score."
8399 (gnus-set-global-variables)
8400 (let ((best -1000000)
8403 (or (gnus-summary-first-subject t)
8404 (error "No unread articles"))
8408 (and (> (setq score (gnus-summary-article-score)) best)
8410 article (gnus-summary-article-number)))
8412 (gnus-summary-search-subject nil t))))
8414 (error "No unread articles")
8415 (gnus-summary-goto-article article))
8416 (gnus-summary-position-cursor)))
8418 (defun gnus-summary-goto-article (article &optional all-headers)
8419 "Fetch ARTICLE and display it if it exists.
8420 If ALL-HEADERS is non-nil, no header lines are hidden."
8426 (mapcar (lambda (headers)
8427 (list (int-to-string (mail-header-number headers))))
8428 gnus-newsgroup-headers)
8429 nil 'require-match))))
8431 (and (gnus-summary-goto-subject article)
8432 (gnus-summary-display-article article all-headers))
8433 (gnus-summary-position-cursor)))
8435 (defun gnus-summary-goto-last-article ()
8436 "Go to the previously read article."
8439 (and gnus-last-article
8440 (gnus-summary-goto-article gnus-last-article))
8441 (gnus-summary-position-cursor)))
8443 (defun gnus-summary-pop-article (number)
8444 "Pop one article off the history and go to the previous.
8445 NUMBER articles will be popped off."
8448 (setq gnus-newsgroup-history
8449 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8451 (gnus-summary-goto-article (car to))
8452 (error "Article history empty")))
8453 (gnus-summary-position-cursor))
8455 ;; Summary article oriented commands
8457 (defun gnus-summary-refer-parent-article (n)
8458 "Refer parent article N times.
8459 The difference between N and the number of articles fetched is returned."
8461 (gnus-set-global-variables)
8465 (let ((ref (mail-header-references (gnus-get-header-by-num
8466 (gnus-summary-article-number)))))
8467 (if (and ref (not (equal ref ""))
8468 (string-match "<[^<>]*>[ \t]*$" ref))
8469 (gnus-summary-refer-article
8470 (substring ref (match-beginning 0) (match-end 0)))
8471 (gnus-message 1 "No references in article %d"
8472 (gnus-summary-article-number))
8475 (gnus-summary-position-cursor)
8478 (defun gnus-summary-refer-article (message-id)
8479 "Refer article specified by MESSAGE-ID.
8480 NOTE: This command only works with newsgroups that use real or simulated NNTP."
8481 (interactive "sMessage-ID: ")
8482 (if (or (not (stringp message-id))
8483 (zerop (length message-id)))
8485 ;; Construct the correct Message-ID if necessary.
8486 ;; Suggested by tale@pawl.rpi.edu.
8487 (or (string-match "^<" message-id)
8488 (setq message-id (concat "<" message-id)))
8489 (or (string-match ">$" message-id)
8490 (setq message-id (concat message-id ">")))
8491 (let ((header (car (gnus-gethash (downcase message-id)
8492 gnus-newsgroup-dependencies))))
8494 (or (gnus-summary-goto-article (mail-header-number header))
8495 ;; The header has been read, but the article had been
8496 ;; expunged, so we insert it again.
8498 (gnus-summary-insert-line
8499 nil header 0 nil gnus-read-mark nil nil
8500 (mail-header-subject header))
8502 (mail-header-number header)))
8503 (let ((gnus-override-method gnus-refer-article-method)
8504 (gnus-ancient-mark gnus-read-mark)
8505 (tmp-point (window-start
8506 (get-buffer-window gnus-article-buffer)))
8508 (and gnus-refer-article-method
8509 (gnus-check-server gnus-refer-article-method))
8510 ;; Save the old article buffer.
8512 (set-buffer (gnus-article-setup-buffer))
8513 (gnus-kill-buffer " *temp Article*")
8514 (setq tmp-buf (rename-buffer " *temp Article*")))
8516 (if (gnus-article-prepare
8517 message-id nil (gnus-read-header message-id))
8519 (setq number (mail-header-number gnus-current-headers))
8520 (gnus-rebuild-thread message-id)
8521 (gnus-summary-goto-subject number)
8522 (if (null gnus-use-full-window)
8524 (delete-windows-on tmp-buf)
8525 (gnus-configure-windows 'article 'force)))
8526 (gnus-summary-recenter)
8527 (gnus-article-set-window-start
8528 (cdr (assq number gnus-newsgroup-bookmarks)))
8530 (run-hooks 'gnus-visual-mark-article-hook))
8532 ;; We restore the old article buffer.
8534 (kill-buffer gnus-article-buffer)
8535 (set-buffer tmp-buf)
8536 (rename-buffer gnus-article-buffer)
8537 (let ((buffer-read-only nil))
8539 (set-window-start (get-buffer-window (current-buffer))
8540 tmp-point)))))))))))
8542 (defun gnus-summary-enter-digest-group ()
8543 "Enter a digest group based on the current article."
8545 (gnus-set-global-variables)
8546 (gnus-summary-select-article)
8547 ;; We do not want a narrowed article.
8548 (gnus-summary-stop-page-breaking)
8549 (let ((name (format "%s-%d"
8550 (gnus-group-prefixed-name
8551 gnus-newsgroup-name (list 'nndoc ""))
8552 gnus-current-article))
8553 (ogroup gnus-newsgroup-name)
8554 (buf (current-buffer)))
8555 (if (gnus-group-read-ephemeral-group
8556 name (list 'nndoc name
8557 (list 'nndoc-address (get-buffer gnus-article-buffer))
8558 '(nndoc-article-type digest))
8560 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8561 (list (list (cons 'to-group ogroup))))
8562 (switch-to-buffer buf)
8563 (gnus-set-global-variables)
8564 (gnus-configure-windows 'summary)
8565 (gnus-message 3 "Article not a digest?"))))
8567 (defun gnus-summary-isearch-article ()
8568 "Do incremental search forward on current article."
8570 (gnus-set-global-variables)
8571 (gnus-summary-select-article)
8572 (gnus-eval-in-buffer-window
8573 gnus-article-buffer (isearch-forward)))
8575 (defun gnus-summary-search-article-forward (regexp &optional backward)
8576 "Search for an article containing REGEXP forward.
8577 If BACKWARD, search backward instead."
8580 (format "Search article %s (regexp%s): "
8581 (if current-prefix-arg "backward" "forward")
8582 (if gnus-last-search-regexp
8583 (concat ", default " gnus-last-search-regexp)
8585 current-prefix-arg))
8586 (gnus-set-global-variables)
8587 (if (string-equal regexp "")
8588 (setq regexp (or gnus-last-search-regexp ""))
8589 (setq gnus-last-search-regexp regexp))
8590 (if (gnus-summary-search-article regexp backward)
8591 (gnus-article-set-window-start
8592 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8593 (error "Search failed: \"%s\"" regexp)))
8595 (defun gnus-summary-search-article-backward (regexp)
8596 "Search for an article containing REGEXP backward."
8599 (format "Search article backward (regexp%s): "
8600 (if gnus-last-search-regexp
8601 (concat ", default " gnus-last-search-regexp)
8603 (gnus-summary-search-article-forward regexp 'backward))
8605 (defun gnus-summary-search-article (regexp &optional backward)
8606 "Search for an article containing REGEXP.
8607 Optional argument BACKWARD means do search for backward.
8608 gnus-select-article-hook is not called during the search."
8609 (let ((gnus-select-article-hook nil) ;Disable hook.
8610 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8613 (function re-search-backward) (function re-search-forward)))
8616 ;; Hidden thread subtrees must be searched for ,too.
8617 (gnus-summary-show-all-threads)
8618 (if (eobp) (forward-line -1))
8619 ;; First of all, search current article.
8620 ;; We don't want to read article again from NNTP server nor reset
8622 (gnus-summary-select-article)
8623 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8624 (setq last gnus-current-article)
8625 (gnus-eval-in-buffer-window
8629 ;; Begin search from current point.
8630 (setq found (funcall re-search regexp nil t))))
8631 ;; Then search next articles.
8632 (while (and (not found)
8633 (gnus-summary-display-article
8634 (gnus-summary-search-subject backward nil nil)))
8635 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8636 (gnus-eval-in-buffer-window
8640 (goto-char (if backward (point-max) (point-min)))
8641 (setq found (funcall re-search regexp nil t)))))
8643 ;; Adjust article pointer.
8644 (or (eq last gnus-current-article)
8645 (setq gnus-last-article last))
8646 ;; Return T if found such article.
8649 (defun gnus-summary-execute-command (header regexp command &optional backward)
8650 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8651 If HEADER is an empty string (or nil), the match is done on the entire
8652 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8654 (list (let ((completion-ignore-case t))
8657 (mapcar (lambda (string) (list string))
8658 '("Number" "Subject" "From" "Lines" "Date"
8659 "Message-ID" "Xref" "References"))
8660 nil 'require-match))
8661 (read-string "Regexp: ")
8662 (read-key-sequence "Command: ")
8663 current-prefix-arg))
8664 (gnus-set-global-variables)
8665 ;; Hidden thread subtrees must be searched as well.
8666 (gnus-summary-show-all-threads)
8667 ;; We don't want to change current point nor window configuration.
8669 (save-window-excursion
8670 (gnus-message 6 "Executing %s..." (key-description command))
8671 ;; We'd like to execute COMMAND interactively so as to give arguments.
8672 (gnus-execute header regexp
8674 (call-interactively '(, (key-binding command)))))
8676 (gnus-message 6 "Executing %s...done" (key-description command)))))
8678 (defun gnus-summary-beginning-of-article ()
8679 "Scroll the article back to the beginning."
8681 (gnus-set-global-variables)
8682 (gnus-summary-select-article)
8683 (gnus-configure-windows 'article)
8684 (gnus-eval-in-buffer-window
8687 (goto-char (point-min))
8688 (and gnus-break-pages (gnus-narrow-to-page))))
8690 (defun gnus-summary-end-of-article ()
8691 "Scroll to the end of the article."
8693 (gnus-set-global-variables)
8694 (gnus-summary-select-article)
8695 (gnus-configure-windows 'article)
8696 (gnus-eval-in-buffer-window
8699 (goto-char (point-max))
8701 (and gnus-break-pages (gnus-narrow-to-page))))
8703 (defun gnus-summary-show-article ()
8704 "Force re-fetching of the current article."
8706 (gnus-set-global-variables)
8707 (gnus-summary-select-article nil 'force)
8708 (gnus-configure-windows 'article)
8709 (gnus-summary-position-cursor))
8711 (defun gnus-summary-verbose-headers (&optional arg)
8712 "Toggle permanent full header display.
8713 If ARG is a positive number, turn header display on.
8714 If ARG is a negative number, turn header display off."
8716 (gnus-set-global-variables)
8717 (gnus-summary-toggle-header arg)
8718 (setq gnus-show-all-headers
8719 (cond ((or (not (numberp arg))
8721 (not gnus-show-all-headers))
8725 (defun gnus-summary-toggle-header (&optional arg)
8726 "Show the headers if they are hidden, or hide them if they are shown.
8727 If ARG is a positive number, show the entire header.
8728 If ARG is a negative number, hide the unwanted header lines."
8730 (gnus-set-global-variables)
8732 (set-buffer gnus-article-buffer)
8733 (let ((buffer-read-only nil))
8735 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8736 gnus-hidden-properties)
8737 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8738 (if (text-property-any (point-min) (point-max) 'invisible t)
8739 (remove-text-properties
8740 (point-min) (point-max) gnus-hidden-properties)
8741 ;; We hide the headers. This song and dance act below is
8742 ;; done because `gnus-have-all-headers' is buffer-local to
8743 ;; the summary buffer, and we only want to temporarily
8744 ;; change it in that buffer. Ugh.
8745 (let ((have gnus-have-all-headers))
8747 (set-buffer gnus-summary-buffer)
8748 (setq gnus-have-all-headers nil)
8750 (set-buffer gnus-article-buffer)
8751 (run-hooks 'gnus-article-display-hook))
8752 (setq gnus-have-all-headers have)))))
8753 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8755 (defun gnus-summary-show-all-headers ()
8756 "Make all header lines visible."
8758 (gnus-set-global-variables)
8759 (gnus-article-show-all-headers))
8761 (defun gnus-summary-toggle-mime (&optional arg)
8762 "Toggle MIME processing.
8763 If ARG is a positive number, turn MIME processing on."
8765 (gnus-set-global-variables)
8766 (setq gnus-show-mime
8767 (if (null arg) (not gnus-show-mime)
8768 (> (prefix-numeric-value arg) 0)))
8769 (gnus-summary-select-article t 'force))
8771 (defun gnus-summary-caesar-message (&optional arg)
8772 "Caesar rotate the current article by 13.
8773 The numerical prefix specifies how manu places to rotate each letter
8776 (gnus-set-global-variables)
8777 (gnus-summary-select-article)
8778 (let ((mail-header-separator ""))
8779 (gnus-eval-in-buffer-window
8783 (let ((start (window-start)))
8784 (news-caesar-buffer-body arg)
8785 (set-window-start (get-buffer-window (current-buffer)) start))))))
8787 (defun gnus-summary-stop-page-breaking ()
8788 "Stop page breaking in the current article."
8790 (gnus-set-global-variables)
8791 (gnus-summary-select-article)
8792 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8794 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8796 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
8797 "Move the current article to a different newsgroup.
8798 If N is a positive number, move the N next articles.
8799 If N is a negative number, move the N previous articles.
8800 If N is nil and any articles have been marked with the process mark,
8801 move those articles instead.
8802 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8803 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8804 re-spool using this method.
8805 For this function to work, both the current newsgroup and the
8806 newsgroup that you want to move to have to support the `request-move'
8807 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8809 (gnus-set-global-variables)
8810 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8811 (error "The current newsgroup does not support article moving"))
8812 (let ((articles (gnus-summary-work-articles n))
8813 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8814 art-group to-method sel-met)
8815 (if (and (not to-newsgroup) (not select-method))
8818 (format "Where do you want to move %s? %s"
8819 (if (> (length articles) 1)
8820 (format "these %d articles" (length articles))
8822 (if gnus-current-move-group
8823 (format "(%s default) " gnus-current-move-group)
8825 gnus-active-hashtb nil nil prefix)))
8828 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8829 (setq to-newsgroup (or gnus-current-move-group "")))
8830 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8831 (gnus-activate-group to-newsgroup)
8832 (error "No such group: %s" to-newsgroup))
8833 (setq gnus-current-move-group to-newsgroup)))
8834 (setq to-method (if select-method (list select-method "")
8835 (gnus-find-method-for-group to-newsgroup)))
8836 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8837 (error "%s does not support article copying" (car to-method)))
8838 (or (gnus-check-server to-method)
8839 (error "Can't open server %s" (car to-method)))
8840 (gnus-message 6 "Moving to %s: %s..."
8841 (or select-method to-newsgroup) articles)
8844 (gnus-request-move-article
8845 (car articles) ; Article to move
8846 gnus-newsgroup-name ; From newsgroup
8847 (nth 1 (gnus-find-method-for-group
8848 gnus-newsgroup-name)) ; Server
8849 (list 'gnus-request-accept-article
8851 (list 'quote select-method)
8853 (not (cdr articles))) ; Accept form
8854 (not (cdr articles)))) ; Only save nov last time
8855 (let* ((buffer-read-only nil)
8858 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8860 (gnus-group-prefixed-name
8862 (if select-method (list select-method "")
8863 (gnus-find-method-for-group to-newsgroup)))
8864 gnus-newsrc-hashtb)))
8865 (info (nth 2 entry))
8866 (article (car articles)))
8867 (gnus-summary-goto-subject article)
8869 (delete-region (point) (progn (forward-line 1) (point)))
8870 ;; Update the group that has been moved to.
8872 () ; This group does not exist yet.
8873 (if (not (memq article gnus-newsgroup-unreads))
8874 (setcar (cdr (cdr info))
8875 (gnus-add-to-range (nth 2 info)
8876 (list (cdr art-group)))))
8877 ;; Copy any marks over to the new group.
8878 (let ((marks '((tick . gnus-newsgroup-marked)
8879 (dormant . gnus-newsgroup-dormant)
8880 (expire . gnus-newsgroup-expirable)
8881 (bookmark . gnus-newsgroup-bookmarks)
8882 (reply . gnus-newsgroup-replied)))
8883 (to-article (cdr art-group)))
8885 (if (memq article (symbol-value (cdr (car marks))))
8886 (gnus-add-marked-articles
8887 (car info) (car (car marks)) (list to-article) info))
8888 (setq marks (cdr marks)))))
8890 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8891 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8892 (setq gnus-newsgroup-dormant
8893 (delq article gnus-newsgroup-dormant))
8894 (setq gnus-newsgroup-reads
8895 (cons (cons article gnus-canceled-mark)
8896 gnus-newsgroup-reads)))
8897 (gnus-message 1 "Couldn't move article %s" (car articles)))
8898 (gnus-summary-remove-process-mark (car articles))
8899 (setq articles (cdr articles)))
8900 (gnus-set-mode-line 'summary)))
8902 (defun gnus-summary-respool-article (&optional n respool-method)
8903 "Respool the current article.
8904 The article will be squeezed through the mail spooling process again,
8905 which means that it will be put in some mail newsgroup or other
8906 depending on `nnmail-split-methods'.
8907 If N is a positive number, respool the N next articles.
8908 If N is a negative number, respool the N previous articles.
8909 If N is nil and any articles have been marked with the process mark,
8910 respool those articles instead.
8912 Respooling can be done both from mail groups and \"real\" newsgroups.
8913 In the former case, the articles in question will be moved from the
8914 current group into whatever groups they are destined to. In the
8915 latter case, they will be copied into the relevant groups."
8917 (gnus-set-global-variables)
8918 (let ((respool-methods (gnus-methods-using 'respool))
8920 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8922 (setq respool-method
8924 "What method do you want to use when respooling? "
8925 respool-methods nil t methname)))
8926 (or (string= respool-method "")
8927 (if (assoc (symbol-name
8928 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8930 (gnus-summary-move-article n nil (intern respool-method))
8931 (gnus-summary-copy-article n nil (intern respool-method))))))
8933 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8934 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8935 "Move the current article to a different newsgroup.
8936 If N is a positive number, move the N next articles.
8937 If N is a negative number, move the N previous articles.
8938 If N is nil and any articles have been marked with the process mark,
8939 move those articles instead.
8940 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8941 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8942 re-spool using this method.
8943 For this function to work, the newsgroup that you want to move to have
8944 to support the `request-move' and `request-accept'
8945 functions. (Ie. mail newsgroups at present.)"
8947 (gnus-set-global-variables)
8948 (let ((articles (gnus-summary-work-articles n))
8949 (copy-buf (get-buffer-create "*copy work*"))
8950 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8951 art-group to-method)
8952 (buffer-disable-undo copy-buf)
8953 (if (and (not to-newsgroup) (not select-method))
8956 (format "Where do you want to copy %s? %s"
8957 (if (> (length articles) 1)
8958 (format "these %d articles" (length articles))
8960 (if gnus-current-move-group
8961 (format "(%s default) " gnus-current-move-group)
8963 gnus-active-hashtb nil nil prefix)))
8966 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8967 (setq to-newsgroup (or gnus-current-move-group "")))
8968 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8969 (gnus-activate-group to-newsgroup)
8970 (error "No such group: %s" to-newsgroup))
8971 (setq gnus-current-move-group to-newsgroup)))
8972 (setq to-method (if select-method (list select-method "")
8973 (gnus-find-method-for-group to-newsgroup)))
8974 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8975 (error "%s does not support article copying" (car to-method)))
8976 (or (gnus-check-server to-method)
8977 (error "Can't open server %s" (car to-method)))
8979 (gnus-message 6 "Copying to %s: %s..."
8980 (or select-method to-newsgroup) articles)
8983 (set-buffer copy-buf)
8984 (gnus-request-article-this-buffer
8985 (car articles) gnus-newsgroup-name)
8986 (gnus-request-accept-article
8987 (if select-method (list 'quote select-method) to-newsgroup)
8988 (not (cdr articles)))))
8991 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8993 (gnus-group-prefixed-name
8995 (if select-method (list select-method "")
8996 (gnus-find-method-for-group to-newsgroup)))
8997 gnus-newsrc-hashtb)))
8998 (info (nth 2 entry))
8999 (article (car articles)))
9000 ;; We copy the info over to the new group.
9002 () ; This group does not exist (yet).
9003 (if (not (memq article gnus-newsgroup-unreads))
9004 (setcar (cdr (cdr info))
9005 (gnus-add-to-range (nth 2 info)
9006 (list (cdr art-group)))))
9007 ;; Copy any marks over to the new group.
9008 (let ((marks '((tick . gnus-newsgroup-marked)
9009 (dormant . gnus-newsgroup-dormant)
9010 (expire . gnus-newsgroup-expirable)
9011 (bookmark . gnus-newsgroup-bookmarks)
9012 (reply . gnus-newsgroup-replied)))
9013 (to-article (cdr art-group)))
9015 (if (memq article (symbol-value (cdr (car marks))))
9016 (gnus-add-marked-articles
9017 (car info) (car (car marks)) (list to-article) info))
9018 (setq marks (cdr marks))))))
9019 (gnus-message 1 "Couldn't copy article %s" (car articles)))
9020 (gnus-summary-remove-process-mark (car articles))
9021 (setq articles (cdr articles)))
9022 (kill-buffer copy-buf)))
9024 (defun gnus-summary-import-article (file)
9025 "Import a random file into a mail newsgroup."
9026 (interactive "fImport file: ")
9027 (let ((group gnus-newsgroup-name)
9029 (or (gnus-check-backend-function 'request-accept-article group)
9030 (error "%s does not support article importing" group))
9031 (or (file-readable-p file)
9032 (not (file-regular-p file))
9033 (error "Can't read %s" file))
9035 (set-buffer (get-buffer-create " *import file*"))
9036 (buffer-disable-undo (current-buffer))
9038 (insert-file-contents file)
9039 (goto-char (point-min))
9040 (if (nnheader-article-p)
9042 (setq atts (file-attributes file))
9043 (insert "From: " (read-string "From: ") "\n"
9044 "Subject: " (read-string "Subject: ") "\n"
9045 "Date: " (current-time-string (nth 5 atts)) "\n"
9046 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9047 (gnus-request-accept-article group t)
9048 (kill-buffer (current-buffer)))))
9050 (defun gnus-summary-expire-articles ()
9051 "Expire all articles that are marked as expirable in the current group."
9053 (if (not (gnus-check-backend-function
9054 'request-expire-articles gnus-newsgroup-name))
9056 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
9057 gnus-newsrc-hashtb)))
9058 (total (memq 'total-expire (nth 5 info)))
9059 (expirable (if total
9060 (gnus-list-of-read-articles gnus-newsgroup-name)
9061 (setq gnus-newsgroup-expirable
9062 (sort gnus-newsgroup-expirable '<))))
9066 (gnus-message 6 "Expiring articles...")
9067 ;; The list of articles that weren't expired is returned.
9068 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
9069 (or total (setq gnus-newsgroup-expirable es))
9070 ;; We go through the old list of expirable, and mark all
9071 ;; really expired articles as nonexistent.
9072 (or (eq es expirable) ;If nothing was expired, we don't mark.
9073 (let ((gnus-use-cache nil))
9075 (or (memq (car expirable) es)
9076 (gnus-summary-mark-article
9077 (car expirable) gnus-canceled-mark))
9078 (setq expirable (cdr expirable)))))
9079 (gnus-message 6 "Expiring articles...done")))))
9081 (defun gnus-summary-expire-articles-now ()
9082 "Expunge all expirable articles in the current group.
9083 This means that *all* articles that are marked as expirable will be
9084 deleted forever, right now."
9086 (or gnus-expert-user
9088 "Are you really, really, really sure you want to expunge? ")
9090 (let ((nnmail-expiry-wait -1)
9091 (nnmail-expiry-wait-function nil))
9092 (gnus-summary-expire-articles)))
9094 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9095 (defun gnus-summary-delete-article (&optional n)
9096 "Delete the N next (mail) articles.
9097 This command actually deletes articles. This is not a marking
9098 command. The article will disappear forever from you life, never to
9100 If N is negative, delete backwards.
9101 If N is nil and articles have been marked with the process mark,
9102 delete these instead."
9104 (or (gnus-check-backend-function 'request-expire-articles
9105 gnus-newsgroup-name)
9106 (error "The current newsgroup does not support article deletion."))
9107 ;; Compute the list of articles to delete.
9108 (let ((articles (gnus-summary-work-articles n))
9110 (if (and gnus-novice-user
9112 (format "Do you really want to delete %s forever? "
9113 (if (> (length articles) 1) "these articles"
9116 ;; Delete the articles.
9117 (setq not-deleted (gnus-request-expire-articles
9118 articles gnus-newsgroup-name 'force))
9120 (gnus-summary-remove-process-mark (car articles))
9121 ;; The backend might not have been able to delete the article
9123 (or (memq (car articles) not-deleted)
9124 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9125 (setq articles (cdr articles))))
9126 (gnus-summary-position-cursor)
9127 (gnus-set-mode-line 'summary)
9130 (defun gnus-summary-edit-article (&optional force)
9131 "Enter into a buffer and edit the current article.
9132 This will have permanent effect only in mail groups.
9133 If FORCE is non-nil, allow editing of articles even in read-only
9137 (not (gnus-group-read-only-p))
9138 (error "The current newsgroup does not support article editing."))
9139 (gnus-summary-select-article t)
9140 (gnus-configure-windows 'article)
9141 (select-window (get-buffer-window gnus-article-buffer))
9142 (gnus-message 6 "C-c C-c to end edits")
9143 (setq buffer-read-only nil)
9145 (use-local-map (copy-keymap (current-local-map)))
9146 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
9147 (buffer-enable-undo)
9149 (goto-char (point-min))
9150 (search-forward "\n\n" nil t))
9152 (defun gnus-summary-edit-article-done ()
9153 "Make edits to the current article permanent."
9155 (if (gnus-group-read-only-p)
9157 (gnus-summary-edit-article-postpone)
9158 (message "The current newsgroup does not support article editing.")
9160 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
9163 (if (not (gnus-request-replace-article
9164 (cdr gnus-article-current) (car gnus-article-current)
9166 (error "Couldn't replace article.")
9168 (use-local-map gnus-article-mode-map)
9169 (setq buffer-read-only t)
9170 (buffer-disable-undo (current-buffer))
9171 (gnus-configure-windows 'summary))
9172 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))))
9174 (defun gnus-summary-edit-article-postpone ()
9175 "Postpone changes to the current article."
9178 (use-local-map gnus-article-mode-map)
9179 (setq buffer-read-only t)
9180 (buffer-disable-undo (current-buffer))
9181 (gnus-configure-windows 'summary)
9182 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))
9184 (defun gnus-summary-fancy-query ()
9185 "Query where the fancy respool algorithm would put this article."
9187 (gnus-summary-select-article)
9189 (set-buffer gnus-article-buffer)
9191 (goto-char (point-min))
9192 (search-forward "\n\n")
9193 (narrow-to-region (point-min) (point))
9194 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
9196 ;; Summary score commands.
9198 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
9200 (defun gnus-summary-raise-score (n)
9201 "Raise the score of the current article by N."
9203 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
9205 (defun gnus-summary-set-score (n)
9206 "Set the score of the current article to N."
9208 ;; Skip dummy header line.
9210 (gnus-summary-show-thread)
9211 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
9213 (let ((buffer-read-only nil))
9215 (gnus-summary-update-mark
9216 (if (= n (or gnus-summary-default-score 0)) ?
9217 (if (< n (or gnus-summary-default-score 0))
9218 gnus-score-below-mark gnus-score-over-mark)) 'score))
9219 (let* ((article (gnus-summary-article-number))
9220 (score (assq article gnus-newsgroup-scored)))
9221 (if score (setcdr score n)
9222 (setq gnus-newsgroup-scored
9223 (cons (cons article n) gnus-newsgroup-scored))))
9224 (gnus-summary-update-line)))
9226 (defun gnus-summary-current-score ()
9227 "Return the score of the current article."
9229 (message "%s" (gnus-summary-article-score)))
9231 ;; Summary marking commands.
9233 (defun gnus-summary-raise-same-subject-and-select (score)
9234 "Raise articles which has the same subject with SCORE and select the next."
9236 (let ((subject (gnus-summary-subject-string)))
9237 (gnus-summary-raise-score score)
9238 (while (gnus-summary-search-subject nil nil subject)
9239 (gnus-summary-raise-score score))
9240 (gnus-summary-next-article t)))
9242 (defun gnus-summary-raise-same-subject (score)
9243 "Raise articles which has the same subject with SCORE."
9245 (let ((subject (gnus-summary-subject-string)))
9246 (gnus-summary-raise-score score)
9247 (while (gnus-summary-search-subject nil nil subject)
9248 (gnus-summary-raise-score score))
9249 (gnus-summary-next-subject 1 t)))
9251 (defun gnus-score-default (level)
9252 (if level (prefix-numeric-value level)
9253 gnus-score-interactive-default-score))
9255 (defun gnus-summary-raise-thread (&optional score)
9256 "Raise the score of the articles in the current thread with SCORE."
9258 (setq score (gnus-score-default score))
9261 (let ((level (gnus-summary-thread-level)))
9262 (gnus-summary-raise-score score)
9263 (while (and (zerop (gnus-summary-next-subject 1 nil t))
9264 (> (gnus-summary-thread-level) level))
9265 (gnus-summary-raise-score score))
9267 (let ((gnus-summary-check-current t))
9268 (or (zerop (gnus-summary-next-subject 1 t))
9270 (gnus-summary-recenter)
9271 (gnus-summary-position-cursor)
9272 (gnus-set-mode-line 'summary))
9274 (defun gnus-summary-lower-same-subject-and-select (score)
9275 "Raise articles which has the same subject with SCORE and select the next."
9277 (gnus-summary-raise-same-subject-and-select (- score)))
9279 (defun gnus-summary-lower-same-subject (score)
9280 "Raise articles which has the same subject with SCORE."
9282 (gnus-summary-raise-same-subject (- score)))
9284 (defun gnus-summary-lower-thread (&optional score)
9285 "Lower score of articles in the current thread with SCORE."
9287 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
9289 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9290 "Mark articles which has the same subject as read, and then select the next.
9291 If UNMARK is positive, remove any kind of mark.
9292 If UNMARK is negative, tick articles."
9295 (setq unmark (prefix-numeric-value unmark)))
9297 (gnus-summary-mark-same-subject
9298 (gnus-summary-subject-string) unmark)))
9299 ;; Select next unread article. If auto-select-same mode, should
9300 ;; select the first unread article.
9301 (gnus-summary-next-article t (and gnus-auto-select-same
9302 (gnus-summary-subject-string)))
9303 (gnus-message 7 "%d article%s marked as %s"
9304 count (if (= count 1) " is" "s are")
9305 (if unmark "unread" "read"))))
9307 (defun gnus-summary-kill-same-subject (&optional unmark)
9308 "Mark articles which has the same subject as read.
9309 If UNMARK is positive, remove any kind of mark.
9310 If UNMARK is negative, tick articles."
9313 (setq unmark (prefix-numeric-value unmark)))
9315 (gnus-summary-mark-same-subject
9316 (gnus-summary-subject-string) unmark)))
9317 ;; If marked as read, go to next unread subject.
9319 ;; Go to next unread subject.
9320 (gnus-summary-next-subject 1 t))
9321 (gnus-message 7 "%d articles are marked as %s"
9322 count (if unmark "unread" "read"))))
9324 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9325 "Mark articles with same SUBJECT as read, and return marked number.
9326 If optional argument UNMARK is positive, remove any kinds of marks.
9327 If optional argument UNMARK is negative, mark articles as unread instead."
9331 ((null unmark) ; Mark as read.
9334 (gnus-summary-mark-article-as-read gnus-killed-mark)
9335 (gnus-summary-show-thread) t)
9336 (gnus-summary-search-forward nil subject))
9337 (setq count (1+ count))))
9338 ((> unmark 0) ; Tick.
9341 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9342 (gnus-summary-show-thread) t)
9343 (gnus-summary-search-forward nil subject))
9344 (setq count (1+ count))))
9345 (t ; Mark as unread.
9348 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9349 (gnus-summary-show-thread) t)
9350 (gnus-summary-search-forward nil subject))
9351 (setq count (1+ count)))))
9352 (gnus-set-mode-line 'summary)
9353 ;; Return the number of marked articles.
9356 (defun gnus-summary-mark-as-processable (n &optional unmark)
9357 "Set the process mark on the next N articles.
9358 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9359 the process mark instead. The difference between N and the actual
9360 number of articles marked is returned."
9362 (let ((backward (< n 0))
9367 (gnus-summary-remove-process-mark
9368 (gnus-summary-article-number))
9369 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9370 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9372 (if (/= 0 n) (gnus-message 7 "No more articles"))
9373 (gnus-summary-recenter)
9374 (gnus-summary-position-cursor)
9377 (defun gnus-summary-unmark-as-processable (n)
9378 "Remove the process mark from the next N articles.
9379 If N is negative, mark backward instead. The difference between N and
9380 the actual number of articles marked is returned."
9382 (gnus-summary-mark-as-processable n t))
9384 (defun gnus-summary-unmark-all-processable ()
9385 "Remove the process mark from all articles."
9388 (while gnus-newsgroup-processable
9389 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9390 (gnus-summary-position-cursor))
9392 (defun gnus-summary-mark-as-expirable (n)
9393 "Mark N articles forward as expirable.
9394 If N is negative, mark backward instead. The difference between N and
9395 the actual number of articles marked is returned."
9397 (gnus-summary-mark-forward n gnus-expirable-mark))
9399 (defun gnus-summary-mark-article-as-replied (article)
9400 "Mark ARTICLE replied and update the summary line."
9401 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
9402 (let ((buffer-read-only nil))
9403 (if (gnus-summary-goto-subject article)
9405 (gnus-summary-update-mark gnus-replied-mark 'replied)
9408 (defun gnus-summary-set-bookmark (article)
9409 "Set a bookmark in current article."
9410 (interactive (list (gnus-summary-article-number)))
9411 (if (or (not (get-buffer gnus-article-buffer))
9412 (not gnus-current-article)
9413 (not gnus-article-current)
9414 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9415 (error "No current article selected"))
9416 ;; Remove old bookmark, if one exists.
9417 (let ((old (assq article gnus-newsgroup-bookmarks)))
9418 (if old (setq gnus-newsgroup-bookmarks
9419 (delq old gnus-newsgroup-bookmarks))))
9420 ;; Set the new bookmark, which is on the form
9421 ;; (article-number . line-number-in-body).
9422 (setq gnus-newsgroup-bookmarks
9426 (set-buffer gnus-article-buffer)
9430 (goto-char (point-min))
9431 (search-forward "\n\n" nil t)
9434 gnus-newsgroup-bookmarks))
9435 (gnus-message 6 "A bookmark has been added to the current article."))
9437 (defun gnus-summary-remove-bookmark (article)
9438 "Remove the bookmark from the current article."
9439 (interactive (list (gnus-summary-article-number)))
9440 ;; Remove old bookmark, if one exists.
9441 (let ((old (assq article gnus-newsgroup-bookmarks)))
9444 (setq gnus-newsgroup-bookmarks
9445 (delq old gnus-newsgroup-bookmarks))
9446 (gnus-message 6 "Removed bookmark."))
9447 (gnus-message 6 "No bookmark in current article."))))
9449 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9450 (defun gnus-summary-mark-as-dormant (n)
9451 "Mark N articles forward as dormant.
9452 If N is negative, mark backward instead. The difference between N and
9453 the actual number of articles marked is returned."
9455 (gnus-summary-mark-forward n gnus-dormant-mark))
9457 (defun gnus-summary-set-process-mark (article)
9458 "Set the process mark on ARTICLE and update the summary line."
9459 (setq gnus-newsgroup-processable
9461 (delq article gnus-newsgroup-processable)))
9462 (let ((buffer-read-only nil))
9463 (if (gnus-summary-goto-subject article)
9465 (gnus-summary-show-thread)
9466 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9468 (gnus-summary-update-mark gnus-process-mark 'replied)
9471 (defun gnus-summary-remove-process-mark (article)
9472 "Remove the process mark from ARTICLE and update the summary line."
9473 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9474 (let ((buffer-read-only nil))
9475 (if (gnus-summary-goto-subject article)
9477 (gnus-summary-show-thread)
9478 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9480 (gnus-summary-update-mark ? 'replied)
9481 (if (memq article gnus-newsgroup-replied)
9482 (gnus-summary-update-mark gnus-replied-mark 'replied))
9485 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9486 "Mark N articles as read forwards.
9487 If N is negative, mark backwards instead.
9488 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9490 The difference between N and the actual number of articles marked is
9493 (gnus-set-global-variables)
9494 (let ((backward (< n 0))
9495 (gnus-summary-goto-unread
9496 (and gnus-summary-goto-unread
9497 (not (memq mark (list gnus-unread-mark
9498 gnus-ticked-mark gnus-dormant-mark)))))
9500 (mark (or mark gnus-del-mark)))
9502 (gnus-summary-mark-article nil mark no-expire)
9503 (zerop (gnus-summary-next-subject
9504 (if backward -1 1) gnus-summary-goto-unread t)))
9506 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9507 (gnus-summary-recenter)
9508 (gnus-summary-position-cursor)
9509 (gnus-set-mode-line 'summary)
9512 (defun gnus-summary-mark-article-as-read (mark)
9513 "Mark the current article quickly as read with MARK."
9514 (let ((article (gnus-summary-article-number)))
9515 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9516 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9517 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9518 (setq gnus-newsgroup-reads
9519 (cons (cons article mark) gnus-newsgroup-reads))
9520 ;; Possibly remove from cache, if that is used.
9521 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9522 (and gnus-newsgroup-auto-expire
9523 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9524 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9525 (= mark gnus-read-mark))
9527 (setq mark gnus-expirable-mark)
9528 (setq gnus-newsgroup-expirable
9529 (cons article gnus-newsgroup-expirable))))
9530 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9533 (gnus-summary-update-mark mark 'unread)
9536 (defun gnus-summary-mark-article-as-unread (mark)
9537 "Mark the current article quickly as unread with MARK."
9538 (let ((article (gnus-summary-article-number)))
9539 (or (memq article gnus-newsgroup-unreads)
9540 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9541 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9542 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9543 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9544 (setq gnus-newsgroup-reads
9545 (delq (assq article gnus-newsgroup-reads)
9546 gnus-newsgroup-reads))
9547 (if (= mark gnus-ticked-mark)
9548 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9549 (if (= mark gnus-dormant-mark)
9550 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
9552 ;; See whether the article is to be put in the cache.
9554 (vectorp (gnus-get-header-by-num article))
9556 (gnus-cache-possibly-enter-article
9557 gnus-newsgroup-name article
9558 (gnus-get-header-by-num article)
9559 (= mark gnus-ticked-mark)
9560 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9562 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9565 (gnus-summary-update-mark mark 'unread)
9568 (defun gnus-summary-mark-article (&optional article mark no-expire)
9569 "Mark ARTICLE with MARK. MARK can be any character.
9570 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
9571 (dormant) and `?E' (expirable).
9572 If MARK is nil, then the default character `?D' is used.
9573 If ARTICLE is nil, then the article on the current line will be
9576 (setq mark (aref mark 0)))
9577 ;; If no mark is given, then we check auto-expiring.
9578 (and (not no-expire)
9579 gnus-newsgroup-auto-expire
9582 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9583 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9584 (= mark gnus-read-mark))))
9585 (setq mark gnus-expirable-mark))
9586 (let* ((mark (or mark gnus-del-mark))
9587 (article (or article (gnus-summary-article-number))))
9588 (or article (error "No article on current line"))
9589 (if (or (= mark gnus-unread-mark)
9590 (= mark gnus-ticked-mark)
9591 (= mark gnus-dormant-mark))
9592 (gnus-mark-article-as-unread article mark)
9593 (gnus-mark-article-as-read article mark))
9595 ;; See whether the article is to be put in the cache.
9597 (not (= mark gnus-canceled-mark))
9598 (vectorp (gnus-get-header-by-num article))
9600 (gnus-cache-possibly-enter-article
9601 gnus-newsgroup-name article
9602 (gnus-get-header-by-num article)
9603 (= mark gnus-ticked-mark)
9604 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9606 (if (gnus-summary-goto-subject article)
9607 (let ((buffer-read-only nil))
9608 (gnus-summary-show-thread)
9609 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9612 (gnus-summary-update-mark mark 'unread)
9615 (defun gnus-summary-update-mark (mark type)
9617 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9618 (buffer-read-only nil)
9622 (forward-char forward)
9623 (setq plist (text-properties-at (point)))
9626 (and plist (add-text-properties (1- (point)) (point) plist))
9627 (and (eq type 'unread)
9629 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark))
9630 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9632 (defun gnus-mark-article-as-read (article &optional mark)
9633 "Enter ARTICLE in the pertinent lists and remove it from others."
9634 ;; Make the article expirable.
9635 (let ((mark (or mark gnus-del-mark)))
9636 (if (= mark gnus-expirable-mark)
9637 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9638 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9639 ;; Remove from unread and marked lists.
9640 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9641 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9642 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9643 (setq gnus-newsgroup-reads
9644 (cons (cons article mark) gnus-newsgroup-reads))
9645 ;; Possibly remove from cache, if that is used.
9646 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9648 (defun gnus-mark-article-as-unread (article &optional mark)
9649 "Enter ARTICLE in the pertinent lists and remove it from others."
9650 (let ((mark (or mark gnus-ticked-mark)))
9651 ;; Add to unread list.
9652 (or (memq article gnus-newsgroup-unreads)
9653 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9654 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9655 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9656 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9657 (setq gnus-newsgroup-reads
9658 (delq (assq article gnus-newsgroup-reads)
9659 gnus-newsgroup-reads))
9660 (if (= mark gnus-ticked-mark)
9661 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9662 (if (= mark gnus-dormant-mark)
9663 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9665 (defalias 'gnus-summary-mark-as-unread-forward
9666 'gnus-summary-tick-article-forward)
9667 (make-obsolete 'gnus-summary-mark-as-unread-forward
9668 'gnus-summary-tick-article-forward)
9669 (defun gnus-summary-tick-article-forward (n)
9670 "Tick N articles forwards.
9671 If N is negative, tick backwards instead.
9672 The difference between N and the number of articles ticked is returned."
9674 (gnus-summary-mark-forward n gnus-ticked-mark))
9676 (defalias 'gnus-summary-mark-as-unread-backward
9677 'gnus-summary-tick-article-backward)
9678 (make-obsolete 'gnus-summary-mark-as-unread-backward
9679 'gnus-summary-tick-article-backward)
9680 (defun gnus-summary-tick-article-backward (n)
9681 "Tick N articles backwards.
9682 The difference between N and the number of articles ticked is returned."
9684 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9686 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9687 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9688 (defun gnus-summary-tick-article (&optional article clear-mark)
9689 "Mark current article as unread.
9690 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9691 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9692 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9695 (defun gnus-summary-mark-as-read-forward (n)
9696 "Mark N articles as read forwards.
9697 If N is negative, mark backwards instead.
9698 The difference between N and the actual number of articles marked is
9701 (gnus-summary-mark-forward n gnus-del-mark t))
9703 (defun gnus-summary-mark-as-read-backward (n)
9704 "Mark the N articles as read backwards.
9705 The difference between N and the actual number of articles marked is
9708 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9710 (defun gnus-summary-mark-as-read (&optional article mark)
9711 "Mark current article as read.
9712 ARTICLE specifies the article to be marked as read.
9713 MARK specifies a string to be inserted at the beginning of the line."
9714 (gnus-summary-mark-article article mark))
9716 (defun gnus-summary-clear-mark-forward (n)
9717 "Clear marks from N articles forward.
9718 If N is negative, clear backward instead.
9719 The difference between N and the number of marks cleared is returned."
9721 (gnus-summary-mark-forward n gnus-unread-mark))
9723 (defun gnus-summary-clear-mark-backward (n)
9724 "Clear marks from N articles backward.
9725 The difference between N and the number of marks cleared is returned."
9727 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9729 (defun gnus-summary-mark-unread-as-read ()
9730 "Intended to be used by `gnus-summary-mark-article-hook'."
9731 (or (memq gnus-current-article gnus-newsgroup-marked)
9732 (memq gnus-current-article gnus-newsgroup-dormant)
9733 (memq gnus-current-article gnus-newsgroup-expirable)
9734 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9736 (defun gnus-summary-mark-region-as-read (point mark all)
9737 "Mark all unread articles between point and mark as read.
9738 If given a prefix, mark all articles between point and mark as read,
9739 even ticked and dormant ones."
9740 (interactive "r\nP")
9750 (not (memq (gnus-summary-article-number)
9751 gnus-newsgroup-marked))
9752 (not (memq (gnus-summary-article-number)
9753 gnus-newsgroup-dormant))))
9754 (gnus-summary-mark-article
9755 (gnus-summary-article-number) gnus-del-mark))
9757 (zerop (forward-line 1))))))
9759 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9760 (defalias 'gnus-summary-delete-marked-as-read
9761 'gnus-summary-remove-lines-marked-as-read)
9762 (make-obsolete 'gnus-summary-delete-marked-as-read
9763 'gnus-summary-remove-lines-marked-as-read)
9764 (defun gnus-summary-remove-lines-marked-as-read ()
9765 "Remove lines that are marked as read."
9767 (gnus-summary-remove-lines-marked-with
9769 (lambda (char) (char-to-string (symbol-value char)))
9770 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9771 gnus-killed-mark gnus-kill-file-mark
9772 gnus-low-score-mark gnus-expirable-mark
9773 gnus-canceled-mark gnus-catchup-mark)
9776 (defalias 'gnus-summary-delete-marked-with
9777 'gnus-summary-remove-lines-marked-with)
9778 (make-obsolete 'gnus-summary-delete-marked-with
9779 'gnus-summary-remove-lines-marked-with)
9780 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9781 (defun gnus-summary-remove-lines-marked-with (marks)
9782 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9783 (interactive "sMarks: ")
9784 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9785 (gnus-set-global-variables)
9786 (let ((buffer-read-only nil)
9788 (let ((gnus-summary-check-current t))
9789 (gnus-summary-search-forward t)
9790 (gnus-summary-article-number)))
9791 (marks (concat "^[" marks "]")))
9792 (goto-char (point-min))
9793 (if gnus-newsgroup-adaptive
9794 (gnus-score-remove-lines-adaptive marks)
9795 (while (re-search-forward marks nil t)
9796 (gnus-delete-line)))
9797 ;; If we use dummy roots, we have to do an additional sweep over
9799 (if (not (eq gnus-summary-make-false-root 'dummy))
9801 (goto-char (point-min))
9802 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9803 (while (re-search-forward marks nil t)
9804 (if (gnus-subject-equal
9805 (gnus-summary-subject-string)
9808 (gnus-summary-subject-string)))
9811 (gnus-delete-line))))
9812 (or (zerop (buffer-size))
9813 (gnus-summary-goto-subject orig-article)
9815 (gnus-summary-prev-subject 1)
9816 (gnus-summary-position-cursor)))))
9818 (defun gnus-summary-expunge-below (&optional score)
9819 "Remove articles with score less than SCORE."
9821 (gnus-set-global-variables)
9822 (setq score (if score
9823 (prefix-numeric-value score)
9824 (or gnus-summary-default-score 0)))
9826 (set-buffer gnus-summary-buffer)
9827 (goto-char (point-min))
9828 (let ((buffer-read-only nil)
9831 (if (< (gnus-summary-article-score) score)
9835 (delete-region beg (point)))
9838 (or (zerop (buffer-size))
9840 (gnus-summary-prev-subject 1)
9841 (gnus-summary-position-cursor))))))
9843 (defun gnus-summary-mark-below (score mark)
9844 "Mark articles with score less than SCORE with MARK."
9845 (interactive "P\ncMark: ")
9846 (gnus-set-global-variables)
9847 (setq score (if score
9848 (prefix-numeric-value score)
9849 (or gnus-summary-default-score 0)))
9851 (set-buffer gnus-summary-buffer)
9852 (goto-char (point-min))
9854 (and (< (gnus-summary-article-score) score)
9855 (gnus-summary-mark-article nil mark))
9858 (defun gnus-summary-kill-below (&optional score)
9859 "Mark articles with score below SCORE as read."
9861 (gnus-set-global-variables)
9862 (gnus-summary-mark-below score gnus-killed-mark))
9864 (defun gnus-summary-clear-above (&optional score)
9865 "Clear all marks from articles with score above SCORE."
9867 (gnus-set-global-variables)
9868 (gnus-summary-mark-above score gnus-unread-mark))
9870 (defun gnus-summary-tick-above (&optional score)
9871 "Tick all articles with score above SCORE."
9873 (gnus-set-global-variables)
9874 (gnus-summary-mark-above score gnus-ticked-mark))
9876 (defun gnus-summary-mark-above (score mark)
9877 "Mark articles with score over SCORE with MARK."
9878 (interactive "P\ncMark: ")
9879 (gnus-set-global-variables)
9880 (setq score (if score
9881 (prefix-numeric-value score)
9882 (or gnus-summary-default-score 0)))
9884 (set-buffer gnus-summary-buffer)
9885 (goto-char (point-min))
9887 (if (> (gnus-summary-article-score) score)
9889 (gnus-summary-mark-article nil mark)
9891 (forward-line 1)))))
9893 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9894 (defun gnus-summary-show-all-expunged ()
9895 "Display all the hidden articles that were expunged for low scores."
9897 (gnus-set-global-variables)
9898 (let ((buffer-read-only nil))
9899 (let ((scored gnus-newsgroup-scored)
9902 (or (gnus-summary-goto-subject (car (car scored)))
9903 (and (setq h (gnus-get-header-by-num (car (car scored))))
9904 (< (cdr (car scored)) gnus-summary-expunge-below)
9905 (setq headers (cons h headers))))
9906 (setq scored (cdr scored)))
9907 (or headers (error "No expunged articles hidden."))
9908 (goto-char (point-min))
9910 (gnus-summary-update-lines
9913 (gnus-summary-prepare-unthreaded (nreverse headers))
9915 (goto-char (point-min))
9916 (gnus-summary-position-cursor)))
9918 (defun gnus-summary-show-all-dormant ()
9919 "Display all the hidden articles that are marked as dormant."
9921 (gnus-set-global-variables)
9922 (let ((buffer-read-only nil))
9923 (let ((dormant gnus-newsgroup-dormant)
9926 (or (gnus-summary-goto-subject (car dormant))
9927 (and (setq h (gnus-get-header-by-num (car dormant)))
9928 (setq headers (cons h headers))))
9929 (setq dormant (cdr dormant)))
9930 (or headers (error "No dormant articles hidden."))
9931 (goto-char (point-min))
9933 (gnus-summary-update-lines
9936 (gnus-summary-prepare-unthreaded (nreverse headers))
9938 (goto-char (point-min))
9939 (gnus-summary-position-cursor)))
9941 (defun gnus-summary-hide-all-dormant ()
9942 "Hide all dormant articles."
9944 (gnus-set-global-variables)
9945 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9946 (gnus-summary-position-cursor))
9948 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
9949 "Mark all articles not marked as unread in this newsgroup as read.
9950 If prefix argument ALL is non-nil, all articles are marked as read.
9951 If QUIETLY is non-nil, no questions will be asked.
9952 If TO-HERE is non-nil, it should be a point in the buffer. All
9953 articles before this point will be marked as read.
9954 The number of articles marked as read is returned."
9956 (gnus-set-global-variables)
9959 (not gnus-interactive-catchup) ;Without confirmation?
9963 "Mark absolutely all articles as read? "
9964 "Mark all unread articles as read? ")))
9966 (not gnus-newsgroup-adaptive)
9967 (not gnus-newsgroup-auto-expire))
9969 (and all (setq gnus-newsgroup-marked nil
9970 gnus-newsgroup-dormant nil))
9971 (setq gnus-newsgroup-unreads
9972 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9973 ;; We actually mark all articles as canceled, which we
9974 ;; have to do when using auto-expiry or adaptive scoring.
9975 (gnus-summary-show-all-threads)
9976 (if (gnus-summary-first-subject (not all))
9978 (if to-here (< (point) to-here) t)
9979 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9980 (gnus-summary-search-subject nil (not all)))))
9982 (setq gnus-newsgroup-unreads
9983 (append gnus-newsgroup-marked
9984 gnus-newsgroup-dormant)))))
9985 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9986 (if (and (not to-here) (eq 'nnvirtual (car method)))
9987 (nnvirtual-catchup-group
9988 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9989 (gnus-summary-position-cursor)))
9991 (defun gnus-summary-catchup-to-here (&optional all)
9992 "Mark all unticked articles before the current one as read.
9993 If ALL is non-nil, also mark ticked and dormant articles as read."
9995 (gnus-set-global-variables)
9997 (and (zerop (forward-line -1))
10000 (gnus-summary-catchup all t (point))
10001 (gnus-set-mode-line 'summary))))
10002 (gnus-summary-position-cursor))
10004 (defun gnus-summary-catchup-all (&optional quietly)
10005 "Mark all articles in this newsgroup as read."
10007 (gnus-set-global-variables)
10008 (gnus-summary-catchup t quietly))
10010 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10011 "Mark all articles not marked as unread in this newsgroup as read, then exit.
10012 If prefix argument ALL is non-nil, all articles are marked as read."
10014 (gnus-set-global-variables)
10015 (gnus-summary-catchup all quietly nil 'fast)
10016 ;; Select next newsgroup or exit.
10017 (if (and (eq gnus-auto-select-next 'quietly)
10018 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10019 (gnus-summary-next-group nil)
10020 (gnus-summary-exit)))
10022 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10023 "Mark all articles in this newsgroup as read, and then exit."
10025 (gnus-set-global-variables)
10026 (gnus-summary-catchup-and-exit t quietly))
10028 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
10029 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10030 "Mark all articles in this group as read and select the next group.
10031 If given a prefix, mark all articles, unread as well as ticked, as
10034 (gnus-set-global-variables)
10035 (gnus-summary-catchup all)
10036 (gnus-summary-next-group))
10038 ;; Thread-based commands.
10040 (defun gnus-summary-toggle-threads (&optional arg)
10041 "Toggle showing conversation threads.
10042 If ARG is positive number, turn showing conversation threads on."
10044 (gnus-set-global-variables)
10045 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10046 (setq gnus-show-threads
10047 (if (null arg) (not gnus-show-threads)
10048 (> (prefix-numeric-value arg) 0)))
10049 (gnus-summary-prepare)
10050 (gnus-summary-goto-subject current)
10051 (gnus-summary-position-cursor)))
10053 (defun gnus-summary-show-all-threads ()
10054 "Show all threads."
10056 (gnus-set-global-variables)
10058 (let ((buffer-read-only nil))
10059 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10060 (gnus-summary-position-cursor))
10062 (defun gnus-summary-show-thread ()
10063 "Show thread subtrees.
10064 Returns nil if no thread was there to be shown."
10066 (gnus-set-global-variables)
10067 (let ((buffer-read-only nil)
10068 (orig (prog1 (point) (gnus-summary-hide-thread)))
10069 ;; first goto end then to beg, to have point at beg after let
10070 (end (progn (end-of-line) (point)))
10071 (beg (progn (beginning-of-line) (point))))
10073 ;; Any hidden lines here?
10074 (search-forward "\r" end t)
10075 (subst-char-in-region beg end ?\^M ?\n t)
10077 (gnus-summary-position-cursor))))
10079 (defun gnus-summary-hide-all-threads ()
10080 "Hide all thread subtrees."
10082 (gnus-set-global-variables)
10084 (goto-char (point-min))
10085 (gnus-summary-hide-thread)
10086 (while (and (not (eobp)) (zerop (forward-line 1)))
10087 (gnus-summary-hide-thread)))
10088 (gnus-summary-position-cursor))
10090 (defun gnus-summary-hide-thread ()
10091 "Hide thread subtrees.
10092 Returns nil if no threads were there to be hidden."
10094 (gnus-set-global-variables)
10095 (let ((buffer-read-only nil)
10097 (level (gnus-summary-thread-level))
10099 ;; Go forward until either the buffer ends or the subthread
10103 (while (and (zerop (forward-line 1))
10104 (> (gnus-summary-thread-level) level))
10105 (setq end (point)))
10109 (search-backward "\n" start t))
10110 (subst-char-in-region start end ?\n ?\^M t)
10112 (gnus-summary-position-cursor)))))
10114 (defun gnus-summary-go-to-next-thread (&optional previous)
10115 "Go to the same level (or less) next thread.
10116 If PREVIOUS is non-nil, go to previous thread instead.
10117 Return the article number moved to, or nil if moving was impossible."
10118 (let ((level (gnus-summary-thread-level))
10119 (article (gnus-summary-article-number)))
10121 (while (and (zerop (forward-line -1))
10122 (> (gnus-summary-thread-level) level)))
10123 (while (and (save-excursion
10126 (zerop (forward-line 1))
10127 (> (gnus-summary-thread-level) level))))
10128 (gnus-summary-recenter)
10129 (gnus-summary-position-cursor)
10130 (let ((oart (gnus-summary-article-number)))
10131 (and (/= oart article) oart))))
10133 (defun gnus-summary-next-thread (n)
10134 "Go to the same level next N'th thread.
10135 If N is negative, search backward instead.
10136 Returns the difference between N and the number of skips actually
10139 (gnus-set-global-variables)
10140 (let ((backward (< n 0))
10142 (while (and (> n 0)
10143 (gnus-summary-go-to-next-thread backward))
10145 (gnus-summary-position-cursor)
10146 (if (/= 0 n) (gnus-message 7 "No more threads"))
10149 (defun gnus-summary-prev-thread (n)
10150 "Go to the same level previous N'th thread.
10151 Returns the difference between N and the number of skips actually
10154 (gnus-set-global-variables)
10155 (gnus-summary-next-thread (- n)))
10157 (defun gnus-summary-go-down-thread (&optional same)
10158 "Go down one level in the current thread.
10159 If SAME is non-nil, also move to articles of the same level."
10160 (let ((level (gnus-summary-thread-level))
10162 (if (and (zerop (forward-line 1))
10163 (> (gnus-summary-thread-level) level))
10168 (defun gnus-summary-go-up-thread ()
10169 "Go up one level in the current thread."
10170 (let ((level (gnus-summary-thread-level))
10172 (while (and (zerop (forward-line -1))
10173 (>= (gnus-summary-thread-level) level)))
10174 (if (>= (gnus-summary-thread-level) level)
10180 (defun gnus-summary-down-thread (n)
10181 "Go down thread N steps.
10182 If N is negative, go up instead.
10183 Returns the difference between N and how many steps down that were
10186 (gnus-set-global-variables)
10189 (while (and (> n 0)
10190 (if up (gnus-summary-go-up-thread)
10191 (gnus-summary-go-down-thread)))
10193 (gnus-summary-position-cursor)
10194 (if (/= 0 n) (gnus-message 7 "Can't go further"))
10197 (defun gnus-summary-up-thread (n)
10198 "Go up thread N steps.
10199 If N is negative, go up instead.
10200 Returns the difference between N and how many steps down that were
10203 (gnus-set-global-variables)
10204 (gnus-summary-down-thread (- n)))
10206 (defun gnus-summary-kill-thread (&optional unmark)
10207 "Mark articles under current thread as read.
10208 If the prefix argument is positive, remove any kinds of marks.
10209 If the prefix argument is negative, tick articles instead."
10211 (gnus-set-global-variables)
10213 (setq unmark (prefix-numeric-value unmark)))
10215 (level (gnus-summary-thread-level)))
10217 ;; Expand the thread.
10218 (gnus-summary-show-thread)
10220 ;; Mark the article...
10221 (cond ((null unmark) (gnus-summary-mark-article-as-read
10223 ((> unmark 0) (gnus-summary-mark-article-as-unread
10225 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10226 ;; ...and go forward until either the buffer ends or the subtree
10228 (if (not (and (zerop (forward-line 1))
10229 (> (gnus-summary-thread-level) level)))
10230 (setq killing nil))))
10231 ;; Hide killed subtrees.
10233 gnus-thread-hide-killed
10234 (gnus-summary-hide-thread))
10235 ;; If marked as read, go to next unread subject.
10237 ;; Go to next unread subject.
10238 (gnus-summary-next-subject 1 t)))
10239 (gnus-set-mode-line 'summary))
10241 ;; Summary sorting commands
10243 (defun gnus-summary-sort-by-number (&optional reverse)
10244 "Sort summary buffer by article number.
10245 Argument REVERSE means reverse order."
10247 (gnus-set-global-variables)
10249 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
10250 ;; a function, so we wrap it.
10251 (cons (lambda () (gnus-summary-article-number))
10252 'gnus-thread-sort-by-number) reverse))
10254 (defun gnus-summary-sort-by-author (&optional reverse)
10255 "Sort summary buffer by author name alphabetically.
10256 If case-fold-search is non-nil, case of letters is ignored.
10257 Argument REVERSE means reverse order."
10259 (gnus-set-global-variables)
10263 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10265 (if (not (vectorp header))
10267 (setq extract (funcall gnus-extract-address-components
10268 (mail-header-from header)))
10269 (concat (or (car extract) (cdr extract))
10270 "\r" (int-to-string (mail-header-number header))
10271 "\r" (mail-header-subject header)))))
10272 'gnus-thread-sort-by-author)
10275 (defun gnus-summary-sort-by-subject (&optional reverse)
10276 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10277 If case-fold-search is non-nil, case of letters is ignored.
10278 Argument REVERSE means reverse order."
10280 (gnus-set-global-variables)
10284 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10286 (if (not (vectorp header))
10288 (setq extract (funcall gnus-extract-address-components
10289 (mail-header-from header)))
10291 (downcase (gnus-simplify-subject (gnus-summary-subject-string) t))
10292 "\r" (int-to-string (mail-header-number header))
10293 "\r" (or (car extract) (cdr extract))))))
10294 'gnus-thread-sort-by-subject)
10297 (defun gnus-summary-sort-by-date (&optional reverse)
10298 "Sort summary buffer by date.
10299 Argument REVERSE means reverse order."
10301 (gnus-set-global-variables)
10305 (gnus-sortable-date
10307 (gnus-get-header-by-num (gnus-summary-article-number)))))
10308 'gnus-thread-sort-by-date)
10311 (defun gnus-summary-sort-by-score (&optional reverse)
10312 "Sort summary buffer by score.
10313 Argument REVERSE means reverse order."
10315 (gnus-set-global-variables)
10317 (cons (lambda () (gnus-summary-article-score))
10318 'gnus-thread-sort-by-score)
10321 (defvar gnus-summary-already-sorted nil)
10322 (defun gnus-summary-sort (predicate reverse)
10323 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10324 (if gnus-summary-already-sorted
10326 (let (buffer-read-only)
10327 (if (not gnus-show-threads)
10328 ;; We do untreaded sorting...
10330 (goto-char (point-min))
10331 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
10332 ;; ... or we do threaded sorting.
10333 (let ((gnus-thread-sort-functions (list (cdr predicate)))
10334 (gnus-summary-prepare-hook nil)
10335 (gnus-summary-already-sorted nil))
10336 ;; We do that by simply regenerating the threads.
10337 (gnus-summary-prepare)
10338 (and gnus-show-threads
10339 gnus-thread-hide-subtree
10340 (gnus-summary-hide-all-threads))
10341 ;; If in async mode, we send some info to the backend.
10342 (and gnus-newsgroup-async
10343 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
10344 (gnus-request-asynchronous
10345 gnus-newsgroup-name
10346 (if (and gnus-asynchronous-article-function
10347 (fboundp gnus-asynchronous-article-function))
10348 (funcall gnus-asynchronous-article-function
10349 gnus-newsgroup-threads)
10350 gnus-newsgroup-threads))))))))
10353 (defun gnus-sortable-date (date)
10354 "Make sortable string by string-lessp from DATE.
10355 Timezone package is used."
10356 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
10357 (year (aref date 0))
10358 (month (aref date 1))
10359 (day (aref date 2)))
10360 (timezone-make-sortable-date
10362 (timezone-make-time-string
10363 (aref date 3) (aref date 4) (aref date 5)))))
10366 ;; Summary saving commands.
10368 (defun gnus-summary-save-article (&optional n)
10369 "Save the current article using the default saver function.
10370 If N is a positive number, save the N next articles.
10371 If N is a negative number, save the N previous articles.
10372 If N is nil and any articles have been marked with the process mark,
10373 save those articles instead.
10374 The variable `gnus-default-article-saver' specifies the saver function."
10376 (gnus-set-global-variables)
10377 (let ((articles (gnus-summary-work-articles n)))
10379 (let ((header (gnus-get-header-by-num (car articles))))
10380 (if (vectorp header)
10382 (save-window-excursion
10383 (gnus-summary-select-article t nil nil (car articles)))
10384 (or gnus-save-all-headers
10385 (gnus-article-hide-headers t))
10386 ;; Remove any X-Gnus lines.
10389 (set-buffer gnus-article-buffer)
10390 (let ((buffer-read-only nil))
10391 (goto-char (point-min))
10392 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
10394 (while (re-search-forward "^X-Gnus" nil t)
10395 (beginning-of-line)
10396 (delete-region (point)
10397 (progn (forward-line 1) (point))))
10399 (save-window-excursion
10400 (if gnus-default-article-saver
10401 (funcall gnus-default-article-saver)
10402 (error "No default saver is defined."))))
10403 (if (assq 'name header)
10404 (gnus-copy-file (cdr (assq 'name header)))
10405 (gnus-message 1 "Article %d is unsavable" (car articles)))))
10406 (gnus-summary-remove-process-mark (car articles))
10407 (setq articles (cdr articles)))
10408 (gnus-summary-position-cursor)
10411 (defun gnus-summary-pipe-output (&optional arg)
10412 "Pipe the current article to a subprocess.
10413 If N is a positive number, pipe the N next articles.
10414 If N is a negative number, pipe the N previous articles.
10415 If N is nil and any articles have been marked with the process mark,
10416 pipe those articles instead."
10418 (gnus-set-global-variables)
10419 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10420 (gnus-summary-save-article arg)))
10422 (defun gnus-summary-save-article-mail (&optional arg)
10423 "Append the current article to an mail file.
10424 If N is a positive number, save the N next articles.
10425 If N is a negative number, save the N previous articles.
10426 If N is nil and any articles have been marked with the process mark,
10427 save those articles instead."
10429 (gnus-set-global-variables)
10430 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10431 (gnus-summary-save-article arg)))
10433 (defun gnus-summary-save-article-rmail (&optional arg)
10434 "Append the current article to an rmail file.
10435 If N is a positive number, save the N next articles.
10436 If N is a negative number, save the N previous articles.
10437 If N is nil and any articles have been marked with the process mark,
10438 save those articles instead."
10440 (gnus-set-global-variables)
10441 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10442 (gnus-summary-save-article arg)))
10444 (defun gnus-summary-save-article-file (&optional arg)
10445 "Append the current article to a file.
10446 If N is a positive number, save the N next articles.
10447 If N is a negative number, save the N previous articles.
10448 If N is nil and any articles have been marked with the process mark,
10449 save those articles instead."
10451 (gnus-set-global-variables)
10452 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10453 (gnus-summary-save-article arg)))
10455 (defun gnus-read-save-file-name (prompt default-name)
10456 (let ((methods gnus-split-methods)
10458 (if (not gnus-split-methods)
10461 (set-buffer gnus-article-buffer)
10462 (gnus-narrow-to-headers)
10464 (goto-char (point-min))
10465 (and (condition-case ()
10466 (re-search-forward (car (car methods)) nil t)
10468 (setq split-name (cons (nth 1 (car methods)) split-name)))
10469 (setq methods (cdr methods)))
10471 (cond ((null split-name)
10473 (concat prompt " (default "
10474 (file-name-nondirectory default-name) ") ")
10475 (file-name-directory default-name)
10477 ((= 1 (length split-name))
10479 (concat prompt " (default " (car split-name) ") ")
10480 gnus-article-save-directory
10481 (concat gnus-article-save-directory (car split-name))))
10483 (setq split-name (mapcar (lambda (el) (list el))
10484 (nreverse split-name)))
10485 (let ((result (completing-read
10486 (concat prompt " ")
10487 split-name nil nil)))
10488 (concat gnus-article-save-directory
10489 (if (string= result "")
10490 (car (car split-name))
10493 (defun gnus-summary-save-in-rmail (&optional filename)
10494 "Append this article to Rmail file.
10495 Optional argument FILENAME specifies file name.
10496 Directory to save to is default to `gnus-article-save-directory' which
10497 is initialized from the SAVEDIR environment variable."
10499 (gnus-set-global-variables)
10500 (let ((default-name
10501 (funcall gnus-rmail-save-name gnus-newsgroup-name
10502 gnus-current-headers gnus-newsgroup-last-rmail)))
10504 (setq filename (gnus-read-save-file-name
10505 "Save in rmail file:" default-name)))
10506 (gnus-make-directory (file-name-directory filename))
10507 (gnus-eval-in-buffer-window
10508 gnus-article-buffer
10512 (gnus-output-to-rmail filename))))
10513 ;; Remember the directory name to save articles
10514 (setq gnus-newsgroup-last-rmail filename)))
10516 (defun gnus-summary-save-in-mail (&optional filename)
10517 "Append this article to Unix mail file.
10518 Optional argument FILENAME specifies file name.
10519 Directory to save to is default to `gnus-article-save-directory' which
10520 is initialized from the SAVEDIR environment variable."
10522 (gnus-set-global-variables)
10523 (let ((default-name
10524 (funcall gnus-mail-save-name gnus-newsgroup-name
10525 gnus-current-headers gnus-newsgroup-last-mail)))
10527 (setq filename (gnus-read-save-file-name
10528 "Save in Unix mail file:" default-name)))
10530 (expand-file-name filename
10532 (file-name-directory default-name))))
10533 (gnus-make-directory (file-name-directory filename))
10534 (gnus-eval-in-buffer-window
10535 gnus-article-buffer
10539 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
10540 (gnus-output-to-rmail filename)
10541 (rmail-output filename 1 t t)))))
10542 ;; Remember the directory name to save articles.
10543 (setq gnus-newsgroup-last-mail filename)))
10545 (defun gnus-summary-save-in-file (&optional filename)
10546 "Append this article to file.
10547 Optional argument FILENAME specifies file name.
10548 Directory to save to is default to `gnus-article-save-directory' which
10549 is initialized from the SAVEDIR environment variable."
10551 (gnus-set-global-variables)
10552 (let ((default-name
10553 (funcall gnus-file-save-name gnus-newsgroup-name
10554 gnus-current-headers gnus-newsgroup-last-file)))
10556 (setq filename (gnus-read-save-file-name
10557 "Save in file:" default-name)))
10558 (gnus-make-directory (file-name-directory filename))
10559 (gnus-eval-in-buffer-window
10560 gnus-article-buffer
10564 (gnus-output-to-file filename))))
10565 ;; Remember the directory name to save articles.
10566 (setq gnus-newsgroup-last-file filename)))
10568 (defun gnus-summary-save-in-pipe (&optional command)
10569 "Pipe this article to subprocess."
10571 (gnus-set-global-variables)
10572 (let ((command (read-string "Shell command on article: "
10573 gnus-last-shell-command)))
10574 (if (string-equal command "")
10575 (setq command gnus-last-shell-command))
10576 (gnus-eval-in-buffer-window
10577 gnus-article-buffer
10580 (shell-command-on-region (point-min) (point-max) command nil)))
10581 (setq gnus-last-shell-command command)))
10583 ;; Summary extract commands
10585 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10586 (let ((buffer-read-only nil)
10587 (article (gnus-summary-article-number))
10589 (or (gnus-summary-goto-subject article)
10590 (error (format "No such article: %d" article)))
10591 (gnus-summary-position-cursor)
10592 ;; If all commands are to be bunched up on one line, we collect
10594 (if gnus-view-pseudos-separately
10596 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10599 (setq action (cdr (assq 'action (car ps))))
10600 (setq files (list (cdr (assq 'name (car ps)))))
10601 (while (and ps (cdr ps)
10602 (string= (or action "1")
10603 (or (cdr (assq 'action (car (cdr ps)))) "2")))
10604 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
10605 (setcdr ps (cdr (cdr ps))))
10608 (if (not (string-match "%s" action))
10609 (setq files (cons " " files)))
10610 (setq files (cons " " files))
10611 (and (assq 'execute (car ps))
10612 (setcdr (assq 'execute (car ps))
10613 (funcall (if (string-match "%s" action)
10616 (mapconcat (lambda (f) f) files " ")))))
10617 (setq ps (cdr ps)))))
10618 (if (and gnus-view-pseudos (not not-view))
10620 (and (assq 'execute (car pslist))
10621 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10622 (eq gnus-view-pseudos 'not-confirm)))
10623 (setq pslist (cdr pslist)))
10626 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
10627 (gnus-summary-article-number)))
10630 (insert " " (file-name-nondirectory
10631 (cdr (assq 'name (car pslist))))
10632 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10633 (add-text-properties
10634 b (1+ b) (list 'gnus-number gnus-reffed-article-number
10635 'gnus-mark gnus-unread-mark
10637 'gnus-pseudo (car pslist)))
10639 (gnus-sethash (int-to-string gnus-reffed-article-number)
10640 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
10641 (setq gnus-newsgroup-unreads
10642 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
10643 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10644 (setq pslist (cdr pslist)))))))
10646 (defun gnus-pseudos< (p1 p2)
10647 (let ((c1 (cdr (assq 'action p1)))
10648 (c2 (cdr (assq 'action p2))))
10649 (and c1 c2 (string< c1 c2))))
10651 (defun gnus-request-pseudo-article (props)
10652 (cond ((assq 'execute props)
10653 (gnus-execute-command (cdr (assq 'execute props)))))
10654 (let ((gnus-current-article (gnus-summary-article-number)))
10655 (run-hooks 'gnus-mark-article-hook)))
10657 (defun gnus-execute-command (command &optional automatic)
10659 (gnus-article-setup-buffer)
10660 (set-buffer gnus-article-buffer)
10661 (let ((command (if automatic command (read-string "Command: " command)))
10662 (buffer-read-only nil))
10664 (insert "$ " command "\n\n")
10665 (if gnus-view-pseudo-asynchronously
10666 (start-process "gnus-execute" nil "sh" "-c" command)
10667 (call-process "sh" nil t nil "-c" command)))))
10669 (defun gnus-copy-file (file &optional to)
10672 (list (read-file-name "Copy file: " default-directory)
10673 (read-file-name "Copy file to: " default-directory)))
10674 (gnus-set-global-variables)
10675 (or to (setq to (read-file-name "Copy file to: " default-directory)))
10676 (and (file-directory-p to)
10677 (setq to (concat (file-name-as-directory to)
10678 (file-name-nondirectory file))))
10679 (copy-file file to))
10681 ;; Summary kill commands.
10683 (defun gnus-summary-edit-global-kill (article)
10684 "Edit the \"global\" kill file."
10685 (interactive (list (gnus-summary-article-number)))
10686 (gnus-set-global-variables)
10687 (gnus-group-edit-global-kill article))
10689 (defun gnus-summary-edit-local-kill ()
10690 "Edit a local kill file applied to the current newsgroup."
10692 (gnus-set-global-variables)
10693 (setq gnus-current-headers
10695 (int-to-string (gnus-summary-article-number))
10696 gnus-newsgroup-headers-hashtb-by-number))
10697 (gnus-set-global-variables)
10698 (gnus-group-edit-local-kill
10699 (gnus-summary-article-number) gnus-newsgroup-name))
10703 ;;; Gnus article mode
10706 (put 'gnus-article-mode 'mode-class 'special)
10708 (defvar gnus-bugaboo nil)
10710 (if gnus-article-mode-map
10712 (setq gnus-article-mode-map (make-keymap))
10713 (suppress-keymap gnus-article-mode-map)
10714 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10715 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10716 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10717 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10718 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10719 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10720 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10721 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10722 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10723 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10724 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10726 ;; Duplicate almost all summary keystrokes in the article mode map.
10729 "p" "N" "P" "\M-\C-n" "\M-\C-p"
10730 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
10731 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10732 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10733 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10734 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10735 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10736 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10737 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10738 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
10739 "\C-c\C-v\C-v" "\C-d" "v"
10740 ;; "Mt" "M!" "Md" "Mr"
10741 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10742 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10743 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10744 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10745 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10746 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10747 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10748 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10749 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10750 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10751 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10753 (while (and gnus-bugaboo commands) ; disabled
10754 (define-key gnus-article-mode-map (car commands)
10755 'gnus-article-summary-command)
10756 (setq commands (cdr commands))))
10758 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10759 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10760 "=" "n" "^" "\M-^")))
10761 (while (and gnus-bugaboo commands) ; disabled
10762 (define-key gnus-article-mode-map (car commands)
10763 'gnus-article-summary-command-nosave)
10764 (setq commands (cdr commands)))))
10767 (defun gnus-article-mode ()
10768 "Major mode for displaying an article.
10770 All normal editing commands are switched off.
10772 The following commands are available:
10774 \\<gnus-article-mode-map>
10775 \\[gnus-article-next-page]\t Scroll the article one page forwards
10776 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10777 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10778 \\[gnus-article-show-summary]\t Display the summary buffer
10779 \\[gnus-article-mail]\t Send a reply to the address near point
10780 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10781 \\[gnus-info-find-node]\t Go to the Gnus info node"
10783 (if gnus-visual (gnus-article-make-menu-bar))
10784 (kill-all-local-variables)
10785 (gnus-simplify-mode-line)
10786 (setq mode-name "Article")
10787 (setq major-mode 'gnus-article-mode)
10788 (make-local-variable 'minor-mode-alist)
10789 (or (assq 'gnus-show-mime minor-mode-alist)
10790 (setq minor-mode-alist
10791 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10792 (use-local-map gnus-article-mode-map)
10793 (make-local-variable 'page-delimiter)
10794 (setq page-delimiter gnus-page-delimiter)
10795 (buffer-disable-undo (current-buffer))
10796 (setq buffer-read-only t) ;Disable modification
10797 (run-hooks 'gnus-article-mode-hook))
10799 (defun gnus-article-setup-buffer ()
10800 "Initialize article mode buffer."
10801 ;; Returns the article buffer.
10802 (if (get-buffer gnus-article-buffer)
10804 (set-buffer gnus-article-buffer)
10805 (buffer-disable-undo (current-buffer))
10806 (setq buffer-read-only t)
10807 (gnus-add-current-to-buffer-list)
10808 (or (eq major-mode 'gnus-article-mode)
10809 (gnus-article-mode))
10812 (set-buffer (get-buffer-create gnus-article-buffer))
10813 (gnus-add-current-to-buffer-list)
10814 (gnus-article-mode)
10815 (current-buffer))))
10817 ;; Set article window start at LINE, where LINE is the number of lines
10818 ;; from the head of the article.
10819 (defun gnus-article-set-window-start (&optional line)
10821 (get-buffer-window gnus-article-buffer)
10823 (set-buffer gnus-article-buffer)
10824 (goto-char (point-min))
10827 (gnus-message 6 "Moved to bookmark")
10828 (search-forward "\n\n" nil t)
10829 (forward-line line)
10832 (defun gnus-request-article-this-buffer (article group)
10833 "Get an article and insert it into this buffer."
10834 (setq group (or group gnus-newsgroup-name))
10836 ;; Open server if it has closed.
10837 (gnus-check-server (gnus-find-method-for-group group))
10839 ;; Using `gnus-request-article' directly will insert the article into
10840 ;; `nntp-server-buffer' - so we'll save some time by not having to
10841 ;; copy it from the server buffer into the article buffer.
10843 ;; We only request an article by message-id when we do not have the
10844 ;; headers for it, so we'll have to get those.
10845 (and (stringp article)
10846 (let ((gnus-override-method gnus-refer-article-method))
10847 (gnus-read-header article)))
10849 ;; If the article number is negative, that means that this article
10850 ;; doesn't belong in this newsgroup (possibly), so we find its
10851 ;; message-id and request it by id instead of number.
10852 (if (not (numberp article))
10855 (set-buffer gnus-summary-buffer)
10856 (let ((header (gnus-get-header-by-num article)))
10858 (if (vectorp header)
10859 ;; It's a real article.
10860 (setq article (mail-header-id header))
10861 ;; It is an extracted pseudo-article.
10862 (setq article 'pseudo)
10863 (gnus-request-pseudo-article header)))
10865 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10866 (if (not (eq (car method) 'nneething))
10868 (let ((dir (concat (file-name-as-directory (nth 1 method))
10869 (mail-header-subject header))))
10870 (if (file-directory-p dir)
10872 (setq article 'nneething)
10873 (gnus-group-enter-directory dir)))))))))
10875 ;; Check the cache.
10876 (if (and gnus-use-cache
10878 (gnus-cache-request-article article group))
10880 ;; Get the article and put into the article buffer.
10881 (if (or (stringp article) (numberp article))
10884 ;; There may be some overlays that we have to kill...
10886 (let ((overlays (and (fboundp 'overlays-at)
10887 (overlays-at (point-min)))))
10889 (delete-overlay (car overlays))
10890 (setq overlays (cdr overlays))))
10892 (let ((gnus-override-method
10893 (and (stringp article) gnus-refer-article-method)))
10894 (and (gnus-request-article article group (current-buffer))
10898 (defun gnus-read-header (id)
10899 "Read the headers of article ID and enter them into the Gnus system."
10901 (if (not (setq header
10902 (car (if (let ((gnus-nov-is-evil t))
10903 (gnus-retrieve-headers
10904 (list id) gnus-newsgroup-name))
10905 (gnus-get-newsgroup-headers)))))
10908 (mail-header-set-number header gnus-reffed-article-number))
10909 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10910 (gnus-sethash (int-to-string (mail-header-number header)) header
10911 gnus-newsgroup-headers-hashtb-by-number)
10913 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10914 (setq gnus-current-headers header)
10917 (defun gnus-article-prepare (article &optional all-headers header)
10918 "Prepare ARTICLE in article mode buffer.
10919 ARTICLE should either be an article number or a Message-ID.
10920 If ARTICLE is an id, HEADER should be the article headers.
10921 If ALL-HEADERS is non-nil, no headers are hidden."
10923 ;; Make sure we start in a summary buffer.
10924 (or (eq major-mode 'gnus-summary-mode)
10925 (set-buffer gnus-summary-buffer))
10926 (setq gnus-summary-buffer (current-buffer))
10927 ;; Make sure the connection to the server is alive.
10928 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10931 (gnus-find-method-for-group gnus-newsgroup-name))
10932 (gnus-request-group gnus-newsgroup-name t)))
10933 (let* ((article (if header (mail-header-number header) article))
10934 (summary-buffer (current-buffer))
10935 (internal-hook gnus-article-internal-prepare-hook)
10936 (group gnus-newsgroup-name)
10939 (gnus-article-setup-buffer)
10940 (set-buffer gnus-article-buffer)
10941 (if (not (setq result (let ((buffer-read-only nil))
10942 (gnus-request-article-this-buffer
10944 ;; There is no such article.
10946 (if (not (numberp article))
10948 (setq gnus-article-current
10949 (cons gnus-newsgroup-name article))
10950 (set-buffer gnus-summary-buffer)
10951 (setq gnus-current-article article)
10952 (gnus-summary-mark-article article gnus-canceled-mark))
10953 (gnus-message 1 "No such article (may be canceled)")
10956 (if (or (eq result 'pseudo) (eq result 'nneething))
10959 (set-buffer summary-buffer)
10960 (setq gnus-last-article gnus-current-article
10961 gnus-newsgroup-history (cons gnus-current-article
10962 gnus-newsgroup-history)
10963 gnus-current-article 0
10964 gnus-current-headers nil
10965 gnus-article-current nil)
10966 (if (eq result 'nneething)
10967 (gnus-configure-windows 'summary)
10968 (gnus-configure-windows 'article))
10969 (gnus-set-global-variables))
10970 (gnus-set-mode-line 'article))
10971 ;; The result from the `request' was an actual article -
10972 ;; or at least some text that is now displayed in the
10974 (if (and (numberp article)
10975 (not (eq article gnus-current-article)))
10976 ;; Seems like a new article has been selected.
10977 ;; `gnus-current-article' must be an article number.
10979 (set-buffer summary-buffer)
10980 (setq gnus-last-article gnus-current-article
10981 gnus-newsgroup-history (cons gnus-current-article
10982 gnus-newsgroup-history)
10983 gnus-current-article article
10984 gnus-current-headers
10985 (gnus-get-header-by-num gnus-current-article)
10986 gnus-article-current
10987 (cons gnus-newsgroup-name gnus-current-article))
10988 (gnus-summary-show-thread)
10989 (run-hooks 'gnus-mark-article-hook)
10990 (gnus-set-mode-line 'summary)
10992 (run-hooks 'gnus-visual-mark-article-hook))
10993 ;; Set the global newsgroup variables here.
10994 ;; Suggested by Jim Sisolak
10995 ;; <sisolak@trans4.neep.wisc.edu>.
10996 (gnus-set-global-variables)
10997 (setq gnus-have-all-headers
10998 (or all-headers gnus-show-all-headers))
10999 (and gnus-use-cache
11000 (vectorp (gnus-get-header-by-number article))
11001 (gnus-cache-possibly-enter-article
11003 (gnus-get-header-by-number article)
11004 (memq article gnus-newsgroup-marked)
11005 (memq article gnus-newsgroup-dormant)
11006 (memq article gnus-newsgroup-unreads)))))
11007 ;; Hooks for getting information from the article.
11008 ;; This hook must be called before being narrowed.
11009 (let (buffer-read-only)
11010 (run-hooks 'internal-hook)
11011 (run-hooks 'gnus-article-prepare-hook)
11012 ;; Decode MIME message.
11013 (if (and gnus-show-mime
11014 (or (not gnus-strict-mime)
11015 (gnus-fetch-field "Mime-Version")))
11016 (funcall gnus-show-mime-method))
11017 ;; Perform the article display hooks.
11018 (run-hooks 'gnus-article-display-hook))
11020 (goto-char (point-min))
11021 (and gnus-break-pages (gnus-narrow-to-page))
11022 (gnus-set-mode-line 'article)
11023 (gnus-configure-windows 'article)
11024 (goto-char (point-min))
11027 (defun gnus-article-show-all-headers ()
11028 "Show all article headers in article mode buffer."
11030 (gnus-article-setup-buffer)
11031 (set-buffer gnus-article-buffer)
11032 (let ((buffer-read-only nil))
11033 (remove-text-properties (point-min) (point-max)
11034 gnus-hidden-properties))))
11036 (defun gnus-article-hide-headers-if-wanted ()
11037 "Hide unwanted headers if `gnus-have-all-headers' is nil.
11038 Provided for backwards compatibility."
11039 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
11040 (gnus-article-hide-headers)))
11042 (defun gnus-article-hide-headers (&optional delete)
11043 "Hide unwanted headers and possibly sort them as well."
11046 (set-buffer gnus-article-buffer)
11048 (let ((sorted gnus-sorted-header-list)
11049 (buffer-read-only nil)
11050 want-list beg want-l)
11051 ;; First we narrow to just the headers.
11053 (goto-char (point-min))
11054 ;; Hide any "From " lines at the beginning of (mail) articles.
11055 (while (looking-at "From ")
11058 (add-text-properties (point-min) (point) gnus-hidden-properties))
11059 ;; Then treat the rest of the header lines.
11062 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
11063 ;; Then we use the two regular expressions
11064 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
11065 ;; select which header lines is to remain visible in the
11067 (goto-char (point-min))
11068 (while (re-search-forward "^[^ \t]*:" nil t)
11069 (beginning-of-line)
11070 ;; We add the headers we want to keep to a list and delete
11071 ;; them from the buffer.
11072 (if (or (and (stringp gnus-visible-headers)
11073 (looking-at gnus-visible-headers))
11074 (and (not (stringp gnus-visible-headers))
11075 (stringp gnus-ignored-headers)
11076 (not (looking-at gnus-ignored-headers))))
11080 ;; Be sure to get multi-line headers...
11081 (re-search-forward "^[^ \t]*:" nil t)
11082 (beginning-of-line)
11084 (cons (buffer-substring beg (point)) want-list))
11085 (delete-region beg (point))
11088 ;; Next we perform the sorting by looking at
11089 ;; `gnus-sorted-header-list'.
11090 (goto-char (point-min))
11091 (while (and sorted want-list)
11092 (setq want-l want-list)
11094 (not (string-match (car sorted) (car want-l))))
11095 (setq want-l (cdr want-l)))
11098 (insert (car want-l))
11099 (setq want-list (delq (car want-l) want-list))))
11100 (setq sorted (cdr sorted)))
11101 ;; Any headers that were not matched by the sorted list we
11102 ;; just tack on the end of the visible header list.
11104 (insert (car want-list))
11105 (setq want-list (cdr want-list)))
11106 ;; And finally we make the unwanted headers invisible.
11108 (delete-region (point) (point-max))
11109 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11110 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
11112 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
11113 (defun gnus-article-treat-overstrike ()
11114 "Translate overstrikes into bold text."
11117 (set-buffer gnus-article-buffer)
11118 (let ((buffer-read-only nil))
11119 (while (search-forward "\b" nil t)
11120 (let ((next (following-char))
11121 (previous (char-after (- (point) 2))))
11122 (cond ((eq next previous)
11123 (put-text-property (- (point) 2) (point)
11125 (put-text-property (point) (1+ (point))
11128 (put-text-property (1- (point)) (1+ (point))
11130 (put-text-property (1- (point)) (point)
11133 (put-text-property (- (point) 2) (point)
11135 (put-text-property (point) (1+ (point))
11136 'face 'underline))))))))
11138 (defun gnus-article-word-wrap ()
11139 "Format too long lines."
11142 (set-buffer gnus-article-buffer)
11143 (let ((buffer-read-only nil))
11144 (goto-char (point-min))
11145 (search-forward "\n\n" nil t)
11147 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
11148 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
11149 (adaptive-fill-mode t))
11150 (while (not (eobp))
11151 (and (>= (current-column) (min fill-column (window-width)))
11152 (/= (preceding-char) ?:)
11153 (fill-paragraph nil))
11154 (end-of-line 2))))))
11156 (defun gnus-article-remove-cr ()
11157 "Remove carriage returns from an article."
11160 (set-buffer gnus-article-buffer)
11161 (let ((buffer-read-only nil))
11162 (goto-char (point-min))
11163 (while (search-forward "\r" nil t)
11164 (replace-match "" t t)))))
11166 (defun gnus-article-display-x-face (&optional force)
11167 "Look for an X-Face header and display it if present."
11168 (interactive (list 'force))
11170 (set-buffer gnus-article-buffer)
11171 (let ((inhibit-point-motion-hooks t)
11172 (case-fold-search nil)
11175 (goto-char (point-min))
11176 (search-forward "\n\n")
11177 (narrow-to-region (point-min) (point))
11178 (goto-char (point-min))
11179 (setq from (mail-fetch-field "from"))
11180 (if (not (and gnus-article-x-face-command
11182 (not gnus-article-x-face-too-ugly)
11183 (and gnus-article-x-face-too-ugly from
11184 (not (string-match gnus-article-x-face-too-ugly
11187 (goto-char (point-min))
11188 (re-search-forward "^X-Face: " nil t))))
11190 (let ((beg (point))
11191 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
11192 (if (symbolp gnus-article-x-face-command)
11193 (and (or (fboundp gnus-article-x-face-command)
11194 (error "%s is not a function"
11195 gnus-article-x-face-command))
11196 (funcall gnus-article-x-face-command beg end))
11197 (call-process-region beg end "sh" nil 0 nil
11198 "-c" gnus-article-x-face-command))))))))
11200 (defun gnus-article-de-quoted-unreadable (&optional force)
11201 "Do a naive translation of a quoted-printable-encoded article.
11202 This is in no way, shape or form meant as a replacement for real MIME
11203 processing, but is simply a stop-gap measure until MIME support is
11205 If FORCE, decode the article whether it is marked as quoted-printable
11207 (interactive (list 'force))
11209 (set-buffer gnus-article-buffer)
11210 (let ((case-fold-search t)
11211 (buffer-read-only nil)
11212 (type (gnus-fetch-field "content-transfer-encoding")))
11213 (if (or force (and type (string-match "quoted-printable" type)))
11215 (goto-char (point-min))
11216 (search-forward "\n\n" nil 'move)
11217 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
11219 (defun gnus-mime-decode-quoted-printable (from to)
11220 ;; Decode quoted-printable from region between FROM and TO.
11223 (while (search-forward "=" to t)
11224 (cond ((eq (following-char) ?\n)
11227 ((looking-at "[0-9A-F][0-9A-F]")
11229 (insert (hexl-hex-string-to-integer
11230 (buffer-substring (point) (+ 2 (point)))))
11234 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
11236 (defvar gnus-article-time-units
11237 (list (cons 'year (* 365.25 24 60 60))
11238 (cons 'week (* 7 24 60 60))
11239 (cons 'day (* 24 60 60))
11240 (cons 'hour (* 60 60))
11244 (defun gnus-article-date-ut (&optional type)
11245 "Convert DATE date to universal time in the current article.
11246 If TYPE is `local', convert to local time; if it is `lapsed', output
11247 how much time has lapsed since DATE."
11248 (interactive (list 'ut))
11249 (let ((date (mail-header-date (or gnus-current-headers
11250 (gnus-get-header-by-number
11251 (gnus-summary-article-number))"")))
11252 (date-regexp "^Date: \\|^X-Sent: "))
11257 (set-buffer gnus-article-buffer)
11258 (let ((buffer-read-only nil))
11259 (goto-char (point-min))
11260 (if (and (re-search-forward date-regexp nil t)
11262 (beginning-of-line)
11263 (looking-at date-regexp)))
11264 (delete-region (gnus-point-at-bol)
11265 (progn (end-of-line) (1+ (point))))
11266 (goto-char (point-min))
11267 (goto-char (- (search-forward "\n\n") 2)))
11271 (concat "Date: " (condition-case ()
11272 (timezone-make-date-arpa-standard date)
11278 (timezone-make-date-arpa-standard date nil "UT")
11282 ;; If the date is seriously mangled, the timezone
11283 ;; functions are liable to bug out, so we condition-case
11284 ;; the entire thing.
11285 (let* ((real-sec (condition-case ()
11286 (- (gnus-seconds-since-epoch
11287 (timezone-make-date-arpa-standard
11288 (current-time-string)
11289 (current-time-zone) "UT"))
11290 (gnus-seconds-since-epoch
11291 (timezone-make-date-arpa-standard
11294 (sec (abs real-sec))
11302 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
11304 (setq sec (- sec (* num (cdr unit))))
11306 (concat (if prev ", " "") (int-to-string
11308 " " (symbol-name (car unit))
11309 (if (> num 1) "s" ""))
11311 gnus-article-time-units "")
11314 " in the future\n")))))
11316 (error "Unknown conversion type: %s" type)))))))))
11318 (defun gnus-article-date-local ()
11319 "Convert the current article date to the local timezone."
11321 (gnus-article-date-ut 'local))
11323 (defun gnus-article-date-lapsed ()
11324 "Convert the current article date to time lapsed since it was sent."
11326 (gnus-article-date-ut 'lapsed))
11328 (defun gnus-article-maybe-highlight ()
11329 "Do some article highlighting if `gnus-visual' is non-nil."
11330 (if gnus-visual (gnus-article-highlight-some)))
11334 (defun gnus-output-to-rmail (file-name)
11335 "Append the current article to an Rmail file named FILE-NAME."
11337 ;; Most of these codes are borrowed from rmailout.el.
11338 (setq file-name (expand-file-name file-name))
11339 (setq rmail-default-rmail-file file-name)
11340 (let ((artbuf (current-buffer))
11341 (tmpbuf (get-buffer-create " *Gnus-output*")))
11343 (or (get-file-buffer file-name)
11344 (file-exists-p file-name)
11345 (if (gnus-yes-or-no-p
11346 (concat "\"" file-name "\" does not exist, create it? "))
11347 (let ((file-buffer (create-file-buffer file-name)))
11349 (set-buffer file-buffer)
11350 (rmail-insert-rmail-file-header)
11351 (let ((require-final-newline nil))
11352 (write-region (point-min) (point-max) file-name t 1)))
11353 (kill-buffer file-buffer))
11354 (error "Output file does not exist")))
11355 (set-buffer tmpbuf)
11356 (buffer-disable-undo (current-buffer))
11358 (insert-buffer-substring artbuf)
11359 (gnus-convert-article-to-rmail)
11360 ;; Decide whether to append to a file or to an Emacs buffer.
11361 (let ((outbuf (get-file-buffer file-name)))
11363 (append-to-file (point-min) (point-max) file-name)
11364 ;; File has been visited, in buffer OUTBUF.
11365 (set-buffer outbuf)
11366 (let ((buffer-read-only nil)
11367 (msg (and (boundp 'rmail-current-message)
11368 (symbol-value 'rmail-current-message))))
11369 ;; If MSG is non-nil, buffer is in RMAIL mode.
11372 (narrow-to-region (point-max) (point-max))))
11373 (insert-buffer-substring tmpbuf)
11376 (goto-char (point-min))
11378 (search-backward "\^_")
11379 (narrow-to-region (point) (point-max))
11380 (goto-char (1+ (point-min)))
11381 (rmail-count-new-messages t)
11382 (rmail-show-message msg)))))))
11383 (kill-buffer tmpbuf)))
11385 (defun gnus-output-to-file (file-name)
11386 "Append the current article to a file named FILE-NAME."
11387 (setq file-name (expand-file-name file-name))
11388 (let ((artbuf (current-buffer))
11389 (tmpbuf (get-buffer-create " *Gnus-output*")))
11391 (set-buffer tmpbuf)
11392 (buffer-disable-undo (current-buffer))
11394 (insert-buffer-substring artbuf)
11395 ;; Append newline at end of the buffer as separator, and then
11396 ;; save it to file.
11397 (goto-char (point-max))
11399 (append-to-file (point-min) (point-max) file-name))
11400 (kill-buffer tmpbuf)))
11402 (defun gnus-convert-article-to-rmail ()
11403 "Convert article in current buffer to Rmail message format."
11404 (let ((buffer-read-only nil))
11405 ;; Convert article directly into Babyl format.
11406 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11407 (goto-char (point-min))
11408 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11409 (while (search-forward "\n\^_" nil t) ;single char
11410 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
11411 (goto-char (point-max))
11414 (defun gnus-narrow-to-page (&optional arg)
11415 "Make text outside current page invisible except for page delimiter.
11416 A numeric arg specifies to move forward or backward by that many pages,
11417 thus showing a page other than the one point was originally in."
11419 (setq arg (if arg (prefix-numeric-value arg) 0))
11421 (forward-page -1) ;Beginning of current page.
11426 (forward-page (1- arg))))
11427 ;; Find the end of the page.
11429 ;; If we stopped due to end of buffer, stay there.
11430 ;; If we stopped after a page delimiter, put end of restriction
11431 ;; at the beginning of that line.
11432 ;; These are commented out.
11433 ;; (if (save-excursion (beginning-of-line)
11434 ;; (looking-at page-delimiter))
11435 ;; (beginning-of-line))
11436 (narrow-to-region (point)
11438 ;; Find the top of the page.
11440 ;; If we found beginning of buffer, stay there.
11441 ;; If extra text follows page delimiter on same line,
11443 ;; Otherwise, show text starting with following line.
11444 (if (and (eolp) (not (bobp)))
11448 (defun gnus-gmt-to-local ()
11449 "Rewrite Date header described in GMT to local in current buffer.
11450 Intended to be used with gnus-article-prepare-hook."
11454 (goto-char (point-min))
11455 (narrow-to-region (point-min)
11456 (progn (search-forward "\n\n" nil 'move) (point)))
11457 (goto-char (point-min))
11458 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
11459 (let ((buffer-read-only nil)
11460 (date (buffer-substring-no-properties
11461 (match-beginning 1) (match-end 1))))
11462 (delete-region (match-beginning 1) (match-end 1))
11464 (timezone-make-date-arpa-standard
11465 date nil (current-time-zone))))))))
11468 ;; Article mode commands
11470 (defun gnus-article-next-page (&optional lines)
11471 "Show next page of current article.
11472 If end of article, return non-nil. Otherwise return nil.
11473 Argument LINES specifies lines to be scrolled up."
11475 (move-to-window-line -1)
11476 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11477 (if (save-excursion
11479 (and (pos-visible-in-window-p) ;Not continuation line.
11481 ;; Nothing in this page.
11482 (if (or (not gnus-break-pages)
11485 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11487 (gnus-narrow-to-page 1) ;Go to next page.
11489 ;; More in this page.
11493 ;; Long lines may cause an end-of-buffer error.
11494 (goto-char (point-max))))
11497 (defun gnus-article-prev-page (&optional lines)
11498 "Show previous page of current article.
11499 Argument LINES specifies lines to be scrolled down."
11501 (move-to-window-line 0)
11502 (if (and gnus-break-pages
11504 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11506 (gnus-narrow-to-page -1) ;Go to previous page.
11507 (goto-char (point-max))
11509 (scroll-down lines)))
11511 (defun gnus-article-refer-article ()
11512 "Read article specified by message-id around point."
11514 (search-forward ">" nil t) ;Move point to end of "<....>".
11515 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11517 (buffer-substring (match-beginning 1) (match-end 1))))
11518 (set-buffer gnus-summary-buffer)
11519 (gnus-summary-refer-article message-id))
11520 (error "No references around point")))
11522 (defun gnus-article-show-summary ()
11523 "Reconfigure windows to show summary buffer."
11525 (gnus-configure-windows 'article)
11526 (gnus-summary-goto-subject gnus-current-article))
11528 (defun gnus-article-describe-briefly ()
11529 "Describe article mode commands briefly."
11532 (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")))
11534 (defun gnus-article-summary-command ()
11535 "Execute the last keystroke in the summary buffer."
11537 (let ((obuf (current-buffer))
11538 (owin (current-window-configuration))
11540 (switch-to-buffer gnus-summary-buffer 'norecord)
11541 (setq func (lookup-key (current-local-map) (this-command-keys)))
11542 (call-interactively func)
11544 (set-window-configuration owin)
11545 (set-window-point (get-buffer-window (current-buffer)) (point))))
11547 (defun gnus-article-summary-command-nosave ()
11548 "Execute the last keystroke in the summary buffer."
11551 (pop-to-buffer gnus-summary-buffer 'norecord)
11552 (setq func (lookup-key (current-local-map) (this-command-keys)))
11553 (call-interactively func)))
11556 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11559 (defalias 'gnus-batch-kill 'gnus-batch-score)
11561 (defun gnus-batch-score ()
11562 "Run batched scoring.
11563 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
11564 Newsgroups is a list of strings in Bnews format. If you want to score
11565 the comp hierarchy, you'd say \"comp.all\". If you would not like to
11566 score the alt hierarchy, you'd say \"!alt.all\"."
11569 (gnus-newsrc-parse-options
11570 (apply (function concat)
11571 (mapcar (lambda (g) (concat g " "))
11572 command-line-args-left))))
11573 (gnus-expert-user t)
11574 (nnmail-spool-file nil)
11575 (gnus-use-dribble-file nil)
11576 (yes (car yes-and-no))
11577 (no (cdr yes-and-no))
11579 ;; Disable verbose message.
11580 gnus-novice-user gnus-large-newsgroup)
11581 ;; Eat all arguments.
11582 (setq command-line-args-left nil)
11585 ;; Apply kills to specified newsgroups in command line arguments.
11586 (setq newsrc (cdr gnus-newsrc-alist))
11588 (setq group (car (car newsrc)))
11589 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
11590 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
11592 (or (eq (car entry) t)
11593 (not (zerop (car entry)))))
11594 (if yes (string-match yes group) t)
11595 (or (null no) (not (string-match no group))))
11597 (gnus-summary-read-group group nil t)
11598 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
11599 (gnus-summary-exit))))
11600 (setq newsrc (cdr newsrc)))
11602 (switch-to-buffer gnus-group-buffer)
11603 (gnus-group-save-newsrc)))
11605 (defun gnus-apply-kill-file ()
11606 "Apply a kill file to the current newsgroup.
11607 Returns the number of articles marked as read."
11608 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
11609 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11610 (gnus-apply-kill-file-internal)
11613 (defun gnus-kill-save-kill-buffer ()
11615 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11616 (if (get-file-buffer file)
11618 (set-buffer (get-file-buffer file))
11619 (and (buffer-modified-p) (save-buffer))
11620 (kill-buffer (current-buffer)))))))
11622 (defvar gnus-kill-file-name "KILL"
11623 "Suffix of the kill files.")
11625 (defun gnus-newsgroup-kill-file (newsgroup)
11626 "Return the name of a kill file name for NEWSGROUP.
11627 If NEWSGROUP is nil, return the global kill file name instead."
11628 (cond ((or (null newsgroup)
11629 (string-equal newsgroup ""))
11630 ;; The global KILL file is placed at top of the directory.
11631 (expand-file-name gnus-kill-file-name
11632 (or gnus-kill-files-directory "~/News")))
11633 ((gnus-use-long-file-name 'not-kill)
11634 ;; Append ".KILL" to newsgroup name.
11635 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
11636 "." gnus-kill-file-name)
11637 (or gnus-kill-files-directory "~/News")))
11639 ;; Place "KILL" under the hierarchical directory.
11640 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
11641 "/" gnus-kill-file-name)
11642 (or gnus-kill-files-directory "~/News")))))
11649 (defvar gnus-dribble-ignore nil)
11650 (defvar gnus-dribble-eval-file nil)
11652 (defun gnus-dribble-file-name ()
11653 (concat gnus-current-startup-file "-dribble"))
11655 (defun gnus-dribble-enter (string)
11656 (if (and (not gnus-dribble-ignore)
11657 gnus-dribble-buffer
11658 (buffer-name gnus-dribble-buffer))
11659 (let ((obuf (current-buffer)))
11660 (set-buffer gnus-dribble-buffer)
11661 (insert string "\n")
11662 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11663 (set-buffer obuf))))
11665 (defun gnus-dribble-read-file ()
11666 (let ((dribble-file (gnus-dribble-file-name)))
11668 (set-buffer (setq gnus-dribble-buffer
11670 (file-name-nondirectory dribble-file))))
11671 (gnus-add-current-to-buffer-list)
11673 (set-visited-file-name dribble-file)
11674 (buffer-disable-undo (current-buffer))
11675 (bury-buffer (current-buffer))
11676 (set-buffer-modified-p nil)
11677 (let ((auto (make-auto-save-file-name))
11678 (gnus-dribble-ignore t))
11679 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11681 (if (file-newer-than-file-p auto dribble-file)
11682 (setq dribble-file auto))
11683 (insert-file-contents dribble-file)
11684 (if (not (zerop (buffer-size)))
11685 (set-buffer-modified-p t))
11687 "Auto-save file exists. Do you want to read it? ")
11688 (setq gnus-dribble-eval-file t))))))))
11690 (defun gnus-dribble-eval-file ()
11691 (if (not gnus-dribble-eval-file)
11693 (setq gnus-dribble-eval-file nil)
11695 (let ((gnus-dribble-ignore t))
11696 (set-buffer gnus-dribble-buffer)
11697 (eval-buffer (current-buffer))))))
11699 (defun gnus-dribble-delete-file ()
11700 (if (file-exists-p (gnus-dribble-file-name))
11701 (delete-file (gnus-dribble-file-name)))
11702 (if gnus-dribble-buffer
11704 (set-buffer gnus-dribble-buffer)
11705 (let ((auto (make-auto-save-file-name)))
11706 (if (file-exists-p auto)
11707 (delete-file auto))
11709 (set-buffer-modified-p nil)))))
11711 (defun gnus-dribble-save ()
11712 (if (and gnus-dribble-buffer
11713 (buffer-name gnus-dribble-buffer))
11715 (set-buffer gnus-dribble-buffer)
11718 (defun gnus-dribble-clear ()
11720 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11722 (set-buffer gnus-dribble-buffer)
11724 (set-buffer-modified-p nil)
11725 (setq buffer-saved-size (buffer-size))))))
11728 ;;; Server Communication
11731 (defun gnus-start-news-server (&optional confirm)
11732 "Open a method for getting news.
11733 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11735 (if gnus-current-select-method
11736 ;; Stream is already opened.
11738 ;; Open NNTP server.
11739 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11742 ;; Read server name with completion.
11743 (setq gnus-nntp-server
11744 (completing-read "NNTP server: "
11745 (mapcar (lambda (server) (list server))
11746 (cons (list gnus-nntp-server)
11747 gnus-secondary-servers))
11748 nil nil gnus-nntp-server))))
11750 (if (and gnus-nntp-server
11751 (stringp gnus-nntp-server)
11752 (not (string= gnus-nntp-server "")))
11753 (setq gnus-select-method
11754 (cond ((or (string= gnus-nntp-server "")
11755 (string= gnus-nntp-server "::"))
11756 (list 'nnspool (system-name)))
11757 ((string-match "^:" gnus-nntp-server)
11758 (list 'nnmh gnus-nntp-server
11759 (list 'nnmh-directory
11760 (file-name-as-directory
11762 (concat "~/" (substring
11763 gnus-nntp-server 1)))))
11764 (list 'nnmh-get-new-mail nil)))
11766 (list 'nntp gnus-nntp-server)))))
11768 (setq how (car gnus-select-method))
11769 (cond ((eq how 'nnspool)
11771 (gnus-message 5 "Looking up local news spool..."))
11774 (gnus-message 5 "Looking up mh spool..."))
11777 (setq gnus-current-select-method gnus-select-method)
11778 (run-hooks 'gnus-open-server-hook)
11780 ;; gnus-open-server-hook might have opened it
11781 (gnus-server-opened gnus-select-method)
11782 (gnus-open-server gnus-select-method)
11785 "%s open error: '%s'. Continue? "
11786 (nth 1 gnus-select-method)
11787 (gnus-status-message gnus-select-method)))
11789 (gnus-message 1 "Couldn't open server on %s"
11790 (nth 1 gnus-select-method))
11794 (defun gnus-check-server (&optional method)
11795 "If the news server is down, start it up again."
11796 (let ((method (if method method gnus-select-method)))
11797 (and (stringp method)
11798 (setq method (gnus-server-to-method method)))
11799 (if (gnus-server-opened method)
11800 ;; Stream is already opened.
11803 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11804 (run-hooks 'gnus-open-server-hook)
11806 (gnus-open-server method)
11809 (defun gnus-nntp-message (&optional message)
11810 "Check the status of the NNTP server.
11811 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11812 is returned insted of the status string."
11813 (let ((status (gnus-status-message (gnus-find-method-for-group
11814 gnus-newsgroup-name)))
11815 (message (or message "")))
11816 (if (and (stringp status) (> (length status) 0))
11819 (defun gnus-get-function (method function)
11820 (and (stringp method)
11821 (setq method (gnus-server-to-method method)))
11822 (let ((func (intern (format "%s-%s" (car method) function))))
11823 (if (not (fboundp func))
11825 (require (car method))
11826 (if (not (fboundp func))
11827 (error "No such function: %s" func))))
11830 ;;; Interface functions to the backends.
11832 (defun gnus-open-server (method)
11833 (funcall (gnus-get-function method 'open-server)
11834 (nth 1 method) (nthcdr 2 method)))
11836 (defun gnus-close-server (method)
11837 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11839 (defun gnus-request-list (method)
11840 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11842 (defun gnus-request-list-newsgroups (method)
11843 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11845 (defun gnus-request-newgroups (date method)
11846 (funcall (gnus-get-function method 'request-newgroups)
11847 date (nth 1 method)))
11849 (defun gnus-server-opened (method)
11850 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11852 (defun gnus-status-message (method)
11853 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11855 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11857 (defun gnus-request-group (group &optional dont-check)
11858 (let ((method (gnus-find-method-for-group group)))
11859 (funcall (gnus-get-function method 'request-group)
11860 (gnus-group-real-name group) (nth 1 method) dont-check)))
11862 (defun gnus-request-asynchronous (group &optional articles)
11863 (let ((method (gnus-find-method-for-group group)))
11864 (funcall (gnus-get-function method 'request-asynchronous)
11865 (gnus-group-real-name group) (nth 1 method) articles)))
11867 (defun gnus-list-active-group (group)
11868 (let ((method (gnus-find-method-for-group group))
11869 (func 'list-active-group))
11870 (and (gnus-check-backend-function func group)
11871 (funcall (gnus-get-function method func)
11872 (gnus-group-real-name group) (nth 1 method)))))
11874 (defun gnus-request-group-description (group)
11875 (let ((method (gnus-find-method-for-group group))
11876 (func 'request-group-description))
11877 (and (gnus-check-backend-function func group)
11878 (funcall (gnus-get-function method func)
11879 (gnus-group-real-name group) (nth 1 method)))))
11881 (defun gnus-close-group (group)
11882 (let ((method (gnus-find-method-for-group group)))
11883 (funcall (gnus-get-function method 'close-group)
11884 (gnus-group-real-name group) (nth 1 method))))
11886 (defun gnus-retrieve-headers (articles group)
11887 (let ((method (gnus-find-method-for-group group)))
11888 (if (and gnus-use-cache (numberp (car articles)))
11889 (gnus-cache-retrieve-headers articles group)
11890 (funcall (gnus-get-function method 'retrieve-headers)
11891 articles (gnus-group-real-name group) (nth 1 method)))))
11893 (defun gnus-retrieve-groups (groups method)
11894 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11896 (defun gnus-request-article (article group &optional buffer)
11897 (let ((method (gnus-find-method-for-group group)))
11898 (funcall (gnus-get-function method 'request-article)
11899 article (gnus-group-real-name group) (nth 1 method) buffer)))
11901 (defun gnus-request-head (article group)
11902 (let ((method (gnus-find-method-for-group group)))
11903 (funcall (gnus-get-function method 'request-head)
11904 article (gnus-group-real-name group) (nth 1 method))))
11906 (defun gnus-request-body (article group)
11907 (let ((method (gnus-find-method-for-group group)))
11908 (funcall (gnus-get-function method 'request-body)
11909 article (gnus-group-real-name group) (nth 1 method))))
11911 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11912 (defun gnus-request-post-buffer (post group subject header artbuf
11913 info follow-to respect-poster)
11914 (let* ((info (or info (and group (nth 2 (gnus-gethash
11915 group gnus-newsrc-hashtb)))))
11917 (if (and gnus-post-method
11918 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11920 (format "%s" (car (gnus-find-method-for-group
11921 gnus-newsgroup-name)))
11922 gnus-valid-select-methods)))
11924 (gnus-find-method-for-group gnus-newsgroup-name))))
11925 (or (gnus-check-server method)
11926 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11927 (let ((mail-self-blind nil)
11928 (mail-archive-file-name nil))
11929 (funcall (gnus-get-function method 'request-post-buffer)
11930 post group subject header artbuf info follow-to
11933 (defun gnus-request-post (method &optional force)
11934 (and (stringp method)
11935 (setq method (gnus-server-to-method method)))
11936 (and (not force) gnus-post-method
11937 (memq 'post (assoc (format "%s" (car method))
11938 gnus-valid-select-methods))
11939 (setq method gnus-post-method))
11940 (funcall (gnus-get-function method 'request-post)
11943 (defun gnus-request-expire-articles (articles group &optional force)
11944 (let ((method (gnus-find-method-for-group group)))
11945 (funcall (gnus-get-function method 'request-expire-articles)
11946 articles (gnus-group-real-name group) (nth 1 method)
11949 (defun gnus-request-move-article
11950 (article group server accept-function &optional last)
11951 (let ((method (gnus-find-method-for-group group)))
11952 (funcall (gnus-get-function method 'request-move-article)
11953 article (gnus-group-real-name group)
11954 (nth 1 method) accept-function last)))
11956 (defun gnus-request-accept-article (group &optional last)
11957 (let ((func (if (symbolp group) group
11958 (car (gnus-find-method-for-group group)))))
11959 (funcall (intern (format "%s-request-accept-article" func))
11960 (if (stringp group) (gnus-group-real-name group) group)
11963 (defun gnus-request-replace-article (article group buffer)
11964 (let ((func (car (gnus-find-method-for-group group))))
11965 (funcall (intern (format "%s-request-replace-article" func))
11966 article (gnus-group-real-name group) buffer)))
11968 (defun gnus-request-create-group (group)
11969 (let ((method (gnus-find-method-for-group group)))
11970 (funcall (gnus-get-function method 'request-create-group)
11971 (gnus-group-real-name group) (nth 1 method))))
11973 (defun gnus-member-of-valid (symbol group)
11974 (memq symbol (assoc
11975 (format "%s" (car (gnus-find-method-for-group group)))
11976 gnus-valid-select-methods)))
11978 (defun gnus-secondary-method-p (method)
11979 (let ((methods gnus-secondary-select-methods)
11980 (gmethod (gnus-server-get-method nil method)))
11981 (while (and methods
11982 (not (equal (gnus-server-get-method nil (car methods))
11984 (setq methods (cdr methods)))
11987 (defun gnus-find-method-for-group (group &optional info)
11988 (or gnus-override-method
11990 gnus-select-method)
11991 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11994 (not (setq method (nth 4 info))))
11995 (setq method gnus-select-method)
11997 (cond ((stringp method)
11998 (gnus-server-to-method method))
11999 ((stringp (car method))
12000 (gnus-server-extend-method group method))
12003 (gnus-server-add-address method))))
12005 (defun gnus-check-backend-function (func group)
12006 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
12008 (fboundp (intern (format "%s-%s" method func)))))
12010 (defun gnus-methods-using (method)
12011 (let ((valids gnus-valid-select-methods)
12014 (if (memq method (car valids))
12015 (setq outs (cons (car valids) outs)))
12016 (setq valids (cdr valids)))
12020 ;;; Active & Newsrc File Handling
12023 ;; Newsrc related functions.
12024 ;; Gnus internal format of gnus-newsrc-alist:
12025 ;; (("alt.general" 3 (1 . 1))
12026 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
12027 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
12028 ;; The first item is the group name; the second is the subscription
12029 ;; level; the third is either a range of a list of ranges of read
12030 ;; articles, the optional fourth element is a list of marked articles,
12031 ;; the optional fifth element is the select method.
12033 ;; Gnus internal format of gnus-newsrc-hashtb:
12034 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12035 ;; This is the entry for "alt.misc". The first element is the number
12036 ;; of unread articles in "alt.misc". The cdr of this entry is the
12037 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
12038 ;; trivial to remove or add new elements into gnus-newsrc-alist
12039 ;; without scanning the entire list. So, to get the actual information
12040 ;; of "alt.misc", you'd say something like
12041 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12043 ;; Gnus internal format of gnus-active-hashtb:
12047 ;; The only element in each entry in this hash table is a range of
12048 ;; (possibly) available articles. (Articles in this range may have
12049 ;; been expired or canceled.)
12051 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12052 ;; ("alt.misc" "alt.test" "alt.general" ...)
12054 (defun gnus-setup-news (&optional rawfile level)
12055 "Setup news information.
12056 If RAWFILE is non-nil, the .newsrc file will also be read.
12057 If LEVEL is non-nil, the news will be set up at level LEVEL."
12058 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
12059 ;; Clear some variables to re-initialize news information.
12060 (if init (setq gnus-newsrc-alist nil
12061 gnus-active-hashtb nil))
12063 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12064 (if init (gnus-read-newsrc-file rawfile))
12066 ;; If we don't read the complete active file, we fill in the
12068 (if (or (null gnus-read-active-file)
12069 (eq gnus-read-active-file 'some))
12070 (gnus-update-active-hashtb-from-killed))
12072 ;; Read the active file and create `gnus-active-hashtb'.
12073 ;; If `gnus-read-active-file' is nil, then we just create an empty
12074 ;; hash table. The partial filling out of the hash table will be
12075 ;; done in `gnus-get-unread-articles'.
12076 (and gnus-read-active-file
12078 (gnus-read-active-file))
12080 (or gnus-active-hashtb
12081 (setq gnus-active-hashtb (make-vector 4095 0)))
12083 ;; Possibly eval the dribble file.
12084 (and init gnus-use-dribble-file (gnus-dribble-eval-file))
12086 (gnus-update-format-specifications)
12088 ;; Find new newsgroups and treat them.
12089 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12090 (gnus-check-server gnus-select-method))
12091 (gnus-find-new-newsgroups))
12093 ;; Find the number of unread articles in each non-dead group.
12094 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
12095 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
12097 (if (and init gnus-check-bogus-newsgroups
12098 gnus-read-active-file (not level)
12099 (gnus-server-opened gnus-select-method))
12100 (gnus-check-bogus-newsgroups))))
12102 (defun gnus-find-new-newsgroups ()
12103 "Search for new newsgroups and add them.
12104 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12105 The `-n' option line from .newsrc is respected."
12107 (or (gnus-check-first-time-used)
12108 (if (or (consp gnus-check-new-newsgroups)
12109 (eq gnus-check-new-newsgroups 'ask-server))
12110 (gnus-ask-server-for-new-groups)
12112 group new-newsgroups)
12113 (gnus-message 5 "Looking for new newsgroups...")
12114 (or gnus-have-read-active-file (gnus-read-active-file))
12115 (setq gnus-newsrc-last-checked-date (current-time-string))
12116 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12117 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12118 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12121 (if (or (null (setq group (symbol-name sym)))
12122 (null (symbol-value sym))
12123 (gnus-gethash group gnus-killed-hashtb)
12124 (gnus-gethash group gnus-newsrc-hashtb))
12126 (let ((do-sub (gnus-matches-options-n group)))
12128 ((eq do-sub 'subscribe)
12129 (setq groups (1+ groups))
12130 (gnus-sethash group group gnus-killed-hashtb)
12131 (funcall gnus-subscribe-options-newsgroup-method group))
12132 ((eq do-sub 'ignore)
12135 (setq groups (1+ groups))
12136 (gnus-sethash group group gnus-killed-hashtb)
12137 (if gnus-subscribe-hierarchical-interactive
12138 (setq new-newsgroups (cons group new-newsgroups))
12139 (funcall gnus-subscribe-newsgroup-method group)))))))
12140 gnus-active-hashtb)
12142 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12143 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12145 (gnus-message 6 "%d new newsgroup%s arrived."
12146 groups (if (> groups 1) "s have" " has"))
12147 (gnus-message 6 "No new newsgroups."))))))
12149 (defun gnus-matches-options-n (group)
12150 ;; Returns `subscribe' if the group is to be unconditionally
12151 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12152 ;; no match for the group.
12154 ;; First we check the two user variables.
12156 ((and gnus-options-subscribe
12157 (string-match gnus-options-subscribe group))
12159 ((and gnus-options-not-subscribe
12160 (string-match gnus-options-not-subscribe group))
12162 ;; Then we go through the list that was retrieved from the .newsrc
12163 ;; file. This list has elements on the form
12164 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12165 ;; is in the reverse order of the options line) is returned.
12167 (let ((regs gnus-newsrc-options-n))
12169 (not (string-match (car (car regs)) group)))
12170 (setq regs (cdr regs)))
12171 (and regs (cdr (car regs)))))))
12173 (defun gnus-ask-server-for-new-groups ()
12174 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12175 (methods (cons gnus-select-method
12177 (and (consp gnus-check-new-newsgroups)
12178 gnus-check-new-newsgroups)
12179 gnus-secondary-select-methods)))
12181 (new-date (current-time-string))
12182 (hashtb (gnus-make-hashtable 100))
12183 group new-newsgroups got-new method)
12184 ;; Go through both primary and secondary select methods and
12185 ;; request new newsgroups.
12187 (setq method (gnus-server-get-method nil (car methods)))
12188 (and (gnus-check-server method)
12189 (gnus-request-newgroups date method)
12192 (set-buffer nntp-server-buffer)
12193 ;; Enter all the new groups in a hashtable.
12194 (gnus-active-to-gnus-format method hashtb 'ignore)))
12195 (setq methods (cdr methods)))
12196 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12197 ;; Now all new groups from all select methods are in `hashtb'.
12199 (lambda (group-sym)
12200 (setq group (symbol-name group-sym))
12201 (if (or (null group)
12202 (null (symbol-value group-sym))
12203 (gnus-gethash group gnus-newsrc-hashtb)
12204 (member group gnus-zombie-list)
12205 (member group gnus-killed-list))
12206 ;; The group is already known.
12208 (and (symbol-value group-sym)
12209 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
12210 (let ((do-sub (gnus-matches-options-n group)))
12211 (cond ((eq do-sub 'subscribe)
12212 (setq groups (1+ groups))
12213 (gnus-sethash group group gnus-killed-hashtb)
12215 gnus-subscribe-options-newsgroup-method group))
12216 ((eq do-sub 'ignore)
12219 (setq groups (1+ groups))
12220 (gnus-sethash group group gnus-killed-hashtb)
12221 (if gnus-subscribe-hierarchical-interactive
12222 (setq new-newsgroups (cons group new-newsgroups))
12223 (funcall gnus-subscribe-newsgroup-method group)))))))
12226 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12227 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12229 (gnus-message 6 "%d new newsgroup%s arrived."
12230 groups (if (> groups 1) "s have" " has")))
12233 (defun gnus-check-first-time-used ()
12234 (if (or (> (length gnus-newsrc-alist) 1)
12235 (file-exists-p gnus-startup-file)
12236 (file-exists-p (concat gnus-startup-file ".el"))
12237 (file-exists-p (concat gnus-startup-file ".eld")))
12239 (gnus-message 6 "First time user; subscribing you to default groups")
12240 (or gnus-have-read-active-file (gnus-read-active-file))
12241 (setq gnus-newsrc-last-checked-date (current-time-string))
12242 (let ((groups gnus-default-subscribed-newsgroups)
12246 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12249 (if (null (setq group (symbol-name sym)))
12251 (let ((do-sub (gnus-matches-options-n group)))
12253 ((eq do-sub 'subscribe)
12254 (gnus-sethash group group gnus-killed-hashtb)
12255 (funcall gnus-subscribe-options-newsgroup-method group))
12256 ((eq do-sub 'ignore)
12259 (setq gnus-killed-list (cons group gnus-killed-list)))))))
12260 gnus-active-hashtb)
12262 (if (gnus-gethash (car groups) gnus-active-hashtb)
12263 (gnus-group-change-level
12264 (car groups) gnus-level-default-subscribed gnus-level-killed))
12265 (setq groups (cdr groups)))
12266 (gnus-group-make-help-group)
12267 (and gnus-novice-user
12268 (gnus-message 7 "`A k' to list killed groups"))))))
12270 (defun gnus-subscribe-group (group previous &optional method)
12271 (gnus-group-change-level
12273 (list t group gnus-level-default-subscribed nil nil method)
12275 gnus-level-default-subscribed gnus-level-killed previous t))
12277 ;; `gnus-group-change-level' is the fundamental function for changing
12278 ;; subscription levels of newsgroups. This might mean just changing
12279 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12280 ;; again, which subscribes/unsubscribes a group, which is equally
12281 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12282 ;; from 8-9 to 1-7 means that you remove the group from the list of
12283 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12284 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12285 ;; which is trivial.
12286 ;; ENTRY can either be a string (newsgroup name) or a list (if
12287 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12288 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12290 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12291 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12293 (defun gnus-group-change-level (entry level &optional oldlevel
12294 previous fromkilled)
12295 (let (group info active num)
12296 ;; Glean what info we can from the arguments
12298 (if fromkilled (setq group (nth 1 entry))
12299 (setq group (car (nth 2 entry))))
12300 (setq group entry))
12301 (if (and (stringp entry)
12303 (< oldlevel gnus-level-zombie))
12304 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12305 (if (and (not oldlevel)
12307 (setq oldlevel (car (cdr (nth 2 entry)))))
12308 (if (stringp previous)
12309 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12311 (if (and (>= oldlevel gnus-level-zombie)
12312 (gnus-gethash group gnus-newsrc-hashtb))
12313 ;; We are trying to subscribe a group that is already
12317 (or (gnus-ephemeral-group-p group)
12318 (gnus-dribble-enter
12319 (format "(gnus-group-change-level %S %S %S %S %S)"
12320 group level oldlevel (car (nth 2 previous)) fromkilled)))
12322 ;; Then we remove the newgroup from any old structures, if needed.
12323 ;; If the group was killed, we remove it from the killed or zombie
12324 ;; list. If not, and it is in fact going to be killed, we remove
12325 ;; it from the newsrc hash table and assoc.
12326 (cond ((>= oldlevel gnus-level-zombie)
12327 (if (= oldlevel gnus-level-zombie)
12328 (setq gnus-zombie-list (delete group gnus-zombie-list))
12329 (setq gnus-killed-list (delete group gnus-killed-list))))
12331 (if (and (>= level gnus-level-zombie)
12334 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
12336 (setcdr (gnus-gethash (car (nth 3 entry))
12337 gnus-newsrc-hashtb)
12339 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12341 ;; Finally we enter (if needed) the list where it is supposed to
12342 ;; go, and change the subscription level. If it is to be killed,
12343 ;; we enter it into the killed or zombie list.
12344 (cond ((>= level gnus-level-zombie)
12345 ;; Remove from the hash table.
12346 (gnus-sethash group nil gnus-newsrc-hashtb)
12347 (or (gnus-group-foreign-p group)
12348 ;; We do not enter foreign groups into the list of dead
12350 (if (= level gnus-level-zombie)
12351 (setq gnus-zombie-list (cons group gnus-zombie-list))
12352 (setq gnus-killed-list (cons group gnus-killed-list)))))
12354 ;; If the list is to be entered into the newsrc assoc, and
12355 ;; it was killed, we have to create an entry in the newsrc
12356 ;; hashtb format and fix the pointers in the newsrc assoc.
12357 (if (>= oldlevel gnus-level-zombie)
12361 (setq info (cdr entry))
12362 (setq num (car entry)))
12363 (setq active (gnus-gethash group gnus-active-hashtb))
12365 (if active (- (1+ (cdr active)) (car active)) t))
12366 ;; Check whether the group is foreign. If so, the
12367 ;; foreign select method has to be entered into the
12369 (let ((method (gnus-group-method-name group)))
12370 (if (eq method gnus-select-method)
12371 (setq info (list group level nil))
12372 (setq info (list group level nil nil method)))))
12375 (let ((p gnus-newsrc-alist))
12376 (while (cdr (cdr p))
12379 (setq entry (cons info (cdr (cdr previous))))
12382 (setcdr (cdr previous) entry)
12383 (gnus-sethash group (cons num (cdr previous))
12384 gnus-newsrc-hashtb))
12385 (setcdr previous entry)
12386 (gnus-sethash group (cons num previous)
12387 gnus-newsrc-hashtb))
12389 (setcdr (gnus-gethash (car (car (cdr entry)))
12390 gnus-newsrc-hashtb)
12392 ;; It was alive, and it is going to stay alive, so we
12393 ;; just change the level and don't change any pointers or
12394 ;; hash table entries.
12395 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
12397 (defun gnus-kill-newsgroup (newsgroup)
12398 "Obsolete function. Kills a newsgroup."
12399 (gnus-group-change-level
12400 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
12402 (defun gnus-check-bogus-newsgroups (&optional confirm)
12403 "Remove bogus newsgroups.
12404 If CONFIRM is non-nil, the user has to confirm the deletion of every
12406 (let ((newsrc (cdr gnus-newsrc-alist))
12408 (gnus-message 5 "Checking bogus newsgroups...")
12409 (or gnus-have-read-active-file (gnus-read-active-file))
12410 ;; Find all bogus newsgroup that are subscribed.
12412 (setq group (car (car newsrc)))
12413 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
12414 (nth 4 (car newsrc)) ; Foreign
12416 (not (gnus-y-or-n-p
12417 (format "Remove bogus newsgroup: %s " group)))))
12420 ;; Found a bogus newsgroup.
12421 (setq bogus (cons group bogus)))
12422 (setq newsrc (cdr newsrc)))
12423 ;; Remove all bogus subscribed groups by first killing them, and
12424 ;; then removing them from the list of killed groups.
12426 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12428 (gnus-group-change-level entry gnus-level-killed)
12429 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12430 (setq bogus (cdr bogus)))
12431 ;; Then we remove all bogus groups from the list of killed and
12432 ;; zombie groups. They are are removed without confirmation.
12433 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12436 (setq killed (symbol-value (car dead-lists)))
12438 (setq group (car killed))
12439 (or (gnus-gethash group gnus-active-hashtb)
12440 ;; The group is bogus.
12441 (set (car dead-lists)
12442 (delete group (symbol-value (car dead-lists)))))
12443 (setq killed (cdr killed)))
12444 (setq dead-lists (cdr dead-lists))))
12445 (gnus-message 5 "Checking bogus newsgroups...done")))
12447 (defun gnus-check-duplicate-killed-groups ()
12448 "Remove duplicates from the list of killed groups."
12450 (let ((killed gnus-killed-list))
12452 (gnus-message 9 "%d" (length killed))
12453 (setcdr killed (delete (car killed) (cdr killed)))
12454 (setq killed (cdr killed)))))
12456 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12457 ;; and compute how many unread articles there are in each group.
12458 (defun gnus-get-unread-articles (&optional level)
12459 (let* ((newsrc (cdr gnus-newsrc-alist))
12460 (level (or level (1+ gnus-level-subscribed)))
12463 (cond ((and gnus-activate-foreign-newsgroups
12464 (not (numberp gnus-activate-foreign-newsgroups)))
12465 (1+ gnus-level-subscribed))
12466 ((numberp gnus-activate-foreign-newsgroups)
12467 gnus-activate-foreign-newsgroups)
12470 info group active virtuals method)
12471 (gnus-message 5 "Checking new news...")
12474 (setq info (car newsrc)
12476 active (gnus-gethash group gnus-active-hashtb))
12478 ;; Check newsgroups. If the user doesn't want to check them, or
12479 ;; they can't be checked (for instance, if the news server can't
12480 ;; be reached) we just set the number of unread articles in this
12481 ;; newsgroup to t. This means that Gnus thinks that there are
12482 ;; unread articles, but it has no idea how many.
12483 (if (and (setq method (nth 4 info))
12484 (not (gnus-server-equal gnus-select-method
12485 (gnus-server-get-method nil method)))
12486 (not (gnus-secondary-method-p method)))
12487 ;; These groups are foreign. Check the level.
12488 (if (<= (nth 1 info) foreign-level)
12489 (if (eq (car (if (stringp method)
12490 (gnus-server-to-method method)
12491 (nth 4 info))) 'nnvirtual)
12492 ;; We have to activate the virtual groups after all
12493 ;; the others, so we just pop them on a list for
12495 (setq virtuals (cons info virtuals))
12496 (and (setq active (gnus-activate-group (car info)))
12497 ;; Close the groups as we look at them!
12498 (gnus-close-group group))))
12500 ;; These groups are native or secondary.
12501 (if (and (not gnus-read-active-file)
12502 (<= (nth 1 info) level))
12504 (or gnus-read-active-file (gnus-check-server method))
12505 (setq active (gnus-activate-group (car info))))))
12508 (gnus-get-unread-articles-in-group info active)
12509 ;; The group couldn't be reached, so we nix out the number of
12510 ;; unread articles and stuff.
12511 (gnus-sethash group nil gnus-active-hashtb)
12512 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
12514 (setq newsrc (cdr newsrc)))
12516 ;; Activate the virtual groups. This has to be done after all the
12518 ;; !!! If one virtual group contains another virtual group, even
12519 ;; doing it this way might cause problems.
12521 (and (setq active (gnus-activate-group (car (car virtuals))))
12522 (gnus-get-unread-articles-in-group (car virtuals) active))
12523 (setq virtuals (cdr virtuals)))
12525 (gnus-message 5 "Checking new news...done")))
12527 ;; Create a hash table out of the newsrc alist. The `car's of the
12528 ;; alist elements are used as keys.
12529 (defun gnus-make-hashtable-from-newsrc-alist ()
12530 (let ((alist gnus-newsrc-alist)
12531 (ohashtb gnus-newsrc-hashtb)
12533 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12535 (setq prev (setq gnus-newsrc-alist
12536 (if (equal (car (car gnus-newsrc-alist))
12539 (cons (list "dummy.group" 0 nil) alist)))))
12541 (gnus-sethash (car (car alist))
12542 (cons (and ohashtb (car (gnus-gethash
12543 (car (car alist)) ohashtb)))
12544 prev) gnus-newsrc-hashtb)
12546 alist (cdr alist)))))
12548 (defun gnus-make-hashtable-from-killed ()
12549 "Create a hash table from the killed and zombie lists."
12550 (let ((lists '(gnus-killed-list gnus-zombie-list))
12552 (setq gnus-killed-hashtb
12553 (gnus-make-hashtable
12554 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12556 (setq list (symbol-value (car lists)))
12557 (setq lists (cdr lists))
12559 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12560 (setq list (cdr list))))))
12562 (defun gnus-get-unread-articles-in-group (info active)
12563 (let* ((range (nth 2 info))
12565 (marked (nth 3 info)))
12566 ;; If a cache is present, we may have to alter the active info.
12567 (and gnus-use-cache
12568 (gnus-cache-possibly-alter-active (car info) active))
12569 ;; Modify the list of read articles according to what articles
12570 ;; are available; then tally the unread articles and add the
12571 ;; number to the group hash table entry.
12573 ((zerop (cdr active))
12576 (setq num (- (1+ (cdr active)) (car active))))
12577 ((not (listp (cdr range)))
12578 ;; Fix a single (num . num) range according to the
12579 ;; active hash table.
12580 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12581 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12582 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12583 ;; Compute number of unread articles.
12584 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
12586 ;; The read list is a list of ranges. Fix them according to
12587 ;; the active hash table.
12588 ;; First peel off any elements that are below the lower
12590 (while (and (cdr range)
12592 (or (and (atom (car (cdr range))) (car (cdr range)))
12593 (car (car (cdr range))))))
12594 (if (numberp (car range))
12597 (or (and (numberp (car (cdr range)))
12599 (cdr (car (cdr range))))))
12600 (setcdr (car range)
12601 (or (and (numberp (nth 1 range)) (nth 1 range))
12602 (cdr (car (cdr range))))))
12603 (setcdr range (cdr (cdr range))))
12604 ;; Adjust the first element to be the same as the lower limit.
12605 (if (and (not (atom (car range)))
12606 (< (cdr (car range)) (car active)))
12607 (setcdr (car range) (1- (car active))))
12608 ;; Then we want to peel off any elements that are higher
12609 ;; than the upper active limit.
12610 (let ((srange range))
12611 ;; Go past all legal elements.
12612 (while (and (cdr srange)
12613 (<= (or (and (atom (car (cdr srange)))
12614 (car (cdr srange)))
12615 (car (car (cdr srange)))) (cdr active)))
12616 (setq srange (cdr srange)))
12618 ;; Nuke all remaining illegal elements.
12619 (setcdr srange nil))
12621 ;; Adjust the final element.
12622 (if (and (not (atom (car srange)))
12623 (> (cdr (car srange)) (cdr active)))
12624 (setcdr (car srange) (cdr active))))
12625 ;; Compute the number of unread articles.
12627 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12628 (cdr (car range))))
12629 (or (and (atom (car range)) (car range))
12630 (car (car range))))))
12631 (setq range (cdr range)))
12632 (setq num (max 0 (- (cdr active) num)))))
12635 (and (assq 'tick marked)
12636 (inline (gnus-remove-illegal-marked-articles
12637 (assq 'tick marked) (nth 2 info))))
12638 (and (assq 'dormant marked)
12639 (inline (gnus-remove-illegal-marked-articles
12640 (assq 'dormant marked) (nth 2 info))))
12642 (gnus-gethash (car info) gnus-newsrc-hashtb)
12643 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12644 (length (cdr (assq 'dormant marked)))))))))
12647 (defun gnus-remove-illegal-marked-articles (marked ranges)
12648 (let ((m (cdr marked)))
12649 ;; Make sure that all ticked articles are a subset of the unread
12652 (if (gnus-member-of-range (car m) ranges)
12653 (setcdr marked (cdr m))
12655 (setq m (cdr m)))))
12657 (defun gnus-activate-group (group)
12658 ;; Check whether a group has been activated or not.
12659 (let ((method (gnus-find-method-for-group group))
12661 (and (gnus-check-server method)
12662 ;; We escape all bugs and quit here to make it possible to
12663 ;; continue if a group is so out-there that it reports bugs
12666 (gnus-request-group group)
12670 (set-buffer nntp-server-buffer)
12671 (goto-char (point-min))
12672 ;; Parse the result we got from `gnus-request-group'.
12673 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12675 (goto-char (match-beginning 1))
12677 group (setq active (cons (read (current-buffer))
12678 (read (current-buffer))))
12679 gnus-active-hashtb))
12680 ;; Return the new active info.
12683 (defun gnus-update-read-articles
12684 (group unread unselected ticked &optional domarks replied expirable killed
12685 dormant bookmark score)
12686 "Update the list of read and ticked articles in GROUP using the
12687 UNREAD and TICKED lists.
12688 Note: UNSELECTED has to be sorted over `<'.
12689 Returns whether the updating was successful."
12690 (let* ((active (or gnus-newsgroup-active
12691 (gnus-gethash group gnus-active-hashtb)))
12692 (entry (gnus-gethash group gnus-newsrc-hashtb))
12693 (info (nth 2 entry))
12694 (marked (nth 3 info))
12696 (unread (sort (copy-sequence unread) (function <)))
12698 (if (or (not info) (not active))
12699 ;; There is no info on this group if it was, in fact,
12700 ;; killed. Gnus stores no information on killed groups, so
12701 ;; there's nothing to be done.
12702 ;; One could store the information somewhere temporarily,
12703 ;; perhaps... Hmmm...
12705 ;; Remove any negative articles numbers.
12706 (while (and unread (< (car unread) 0))
12707 (setq unread (cdr unread)))
12708 ;; Remove any expired article numbers
12709 (while (and unread (< (car unread) (car active)))
12710 (setq unread (cdr unread)))
12711 (while (and ticked (< (car ticked) (car active)))
12712 (setq ticked (cdr ticked)))
12713 (while (and dormant (< (car dormant) (car active)))
12714 (setq dormant (cdr dormant)))
12715 (setq unread (sort (append unselected unread) '<))
12716 ;; Compute the ranges of read articles by looking at the list of
12717 ;; unread articles.
12719 (if (/= (car unread) prev)
12720 (setq read (cons (if (= prev (1- (car unread))) prev
12721 (cons prev (1- (car unread)))) read)))
12722 (setq prev (1+ (car unread)))
12723 (setq unread (cdr unread)))
12724 (if (<= prev (cdr active))
12725 (setq read (cons (cons prev (cdr active)) read)))
12726 ;; Enter this list into the group info.
12727 (setcar (cdr (cdr info))
12728 (if (> (length read) 1) (nreverse read) read))
12729 ;; Enter the list of ticked articles.
12730 (gnus-set-marked-articles
12732 (if domarks replied (cdr (assq 'reply marked)))
12733 (if domarks expirable (cdr (assq 'expire marked)))
12734 (if domarks killed (cdr (assq 'killed marked)))
12735 (if domarks dormant (cdr (assq 'dormant marked)))
12736 (if domarks bookmark (cdr (assq 'bookmark marked)))
12737 (if domarks score (cdr (assq 'score marked))))
12738 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12739 (gnus-get-unread-articles-in-group
12740 info (gnus-gethash group gnus-active-hashtb))
12743 (defun gnus-make-articles-unread (group articles)
12744 "Mark ARTICLES in GROUP as unread."
12745 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12746 (gnus-gethash (gnus-group-real-name group)
12747 gnus-newsrc-hashtb))))
12748 (ranges (nth 2 info))
12751 (and (gnus-member-of-range (car articles) ranges)
12752 (setq news (cons (car articles) news)))
12753 (setq articles (cdr articles)))
12756 (setcar (nthcdr 2 info)
12757 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12758 (gnus-group-update-group group t))))
12760 ;; Enter all dead groups into the hashtb.
12761 (defun gnus-update-active-hashtb-from-killed ()
12762 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
12763 (lists (list gnus-killed-list gnus-zombie-list))
12766 (setq killed (car lists))
12768 (gnus-sethash (car killed) nil hashtb)
12769 (setq killed (cdr killed)))
12770 (setq lists (cdr lists)))))
12772 ;; Get the active file(s) from the backend(s).
12773 (defun gnus-read-active-file ()
12774 (gnus-group-set-mode-line)
12775 (let ((methods (if (gnus-check-server gnus-select-method)
12776 ;; The native server is available.
12777 (cons gnus-select-method gnus-secondary-select-methods)
12778 ;; The native server is down, so we just do the
12780 gnus-secondary-select-methods))
12782 (setq gnus-have-read-active-file nil)
12784 (set-buffer nntp-server-buffer)
12786 (let* ((method (gnus-server-get-method nil (car methods)))
12787 (where (nth 1 method))
12788 (mesg (format "Reading active file%s via %s..."
12789 (if (and where (not (zerop (length where))))
12790 (concat " from " where) "")
12792 (gnus-message 5 mesg)
12793 (if (not (gnus-check-server method))
12796 ((and (eq gnus-read-active-file 'some)
12797 (gnus-check-backend-function 'retrieve-groups (car method)))
12798 (let ((newsrc (cdr gnus-newsrc-alist))
12799 (gmethod (gnus-server-get-method nil method))
12802 (and (gnus-server-equal
12803 (gnus-find-method-for-group
12804 (car (car newsrc)) (car newsrc))
12806 (setq groups (cons (gnus-group-real-name
12807 (car (car newsrc))) groups)))
12808 (setq newsrc (cdr newsrc)))
12809 (gnus-check-server method)
12810 (setq list-type (gnus-retrieve-groups groups method))
12814 1 "Cannot read partial active file from %s server."
12818 ((eq list-type 'active)
12819 (gnus-active-to-gnus-format method gnus-active-hashtb))
12821 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
12823 (if (not (gnus-request-list method))
12825 (gnus-message 1 "Cannot read active file from %s server."
12828 (gnus-active-to-gnus-format method)
12829 ;; We mark this active file as read.
12830 (setq gnus-have-read-active-file
12831 (cons method gnus-have-read-active-file))
12832 (gnus-message 5 "%sdone" mesg))))))
12833 (setq methods (cdr methods))))))
12835 ;; Read an active file and place the results in `gnus-active-hashtb'.
12836 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12837 (let ((cur (current-buffer))
12839 (if (and gnus-active-hashtb
12840 (not (equal method gnus-select-method)))
12842 (setq gnus-active-hashtb
12843 (if (equal method gnus-select-method)
12844 (gnus-make-hashtable
12845 (count-lines (point-min) (point-max)))
12846 (gnus-make-hashtable 4096))))))
12847 (flag-hashtb (gnus-make-hashtable 60)))
12848 ;; Delete unnecessary lines.
12849 (goto-char (point-min))
12850 (while (search-forward "\nto." nil t)
12851 (delete-region (1+ (match-beginning 0))
12852 (progn (forward-line 1) (point))))
12853 (or (string= gnus-ignored-newsgroups "")
12855 (goto-char (point-min))
12856 (delete-matching-lines gnus-ignored-newsgroups)))
12857 ;; Make the group names readable as a lisp expression even if they
12858 ;; contain special characters.
12859 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
12860 (goto-char (point-max))
12861 (while (re-search-backward "[][';?()#]" nil t)
12863 ;; If these are groups from a foreign select method, we insert the
12864 ;; group prefix in front of the group names.
12865 (and method (not (gnus-server-equal
12866 (gnus-server-get-method nil method)
12867 (gnus-server-get-method nil gnus-select-method)))
12868 (let ((prefix (gnus-group-prefixed-name "" method)))
12869 (goto-char (point-min))
12870 (while (and (not (eobp))
12871 (progn (insert prefix)
12872 (zerop (forward-line 1)))))))
12873 ;; Store the active file in a hash table.
12874 (goto-char (point-min))
12875 (if (string-match "%[oO]" gnus-group-line-format)
12876 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12877 ;; If we want information on moderated groups, we use this
12879 (let* ((mod-hashtb (make-vector 7 0))
12880 (m (intern "m" mod-hashtb))
12882 (while (not (eobp))
12883 (condition-case nil
12885 (narrow-to-region (point) (gnus-point-at-eol))
12886 (setq group (let ((obarray hashtb)) (read cur)))
12887 (if (and (numberp (setq max (read cur)))
12888 (numberp (setq min (read cur)))
12890 (skip-chars-forward " \t")
12892 (or (= (following-char) ?=)
12893 (= (following-char) ?x)
12894 (= (following-char) ?j)))))
12895 (set group (cons min max))
12897 ;; Enter moderated groups into a list.
12898 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12899 (setq gnus-moderated-list
12900 (cons (symbol-name group) gnus-moderated-list))))
12907 ;; And if we do not care about moderation, we use this loop,
12908 ;; which is faster.
12909 (let (group max min)
12910 (while (not (eobp))
12913 (narrow-to-region (point) (gnus-point-at-eol))
12914 ;; group gets set to a symbol interned in the hash table
12915 ;; (what a hack!!) - jwz
12916 (setq group (let ((obarray hashtb)) (read cur)))
12917 (if (and (numberp (setq max (read cur)))
12918 (numberp (setq min (read cur)))
12920 (skip-chars-forward " \t")
12922 (or (= (following-char) ?=)
12923 (= (following-char) ?x)
12924 (= (following-char) ?j)))))
12925 (set group (cons min max))
12933 (gnus-message 3 "Warning - illegal active: %s"
12935 (gnus-point-at-bol) (gnus-point-at-eol)))))))
12937 (forward-line 1))))))
12939 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12940 ;; Parse a "groups" active file.
12941 (let ((cur (current-buffer))
12943 (if (and method gnus-active-hashtb)
12945 (setq gnus-active-hashtb
12946 (gnus-make-hashtable
12947 (count-lines (point-min) (point-max)))))))
12948 (prefix (and method
12949 (not (gnus-server-equal
12950 (gnus-server-get-method nil method)
12951 (gnus-server-get-method nil gnus-select-method)))
12952 (gnus-group-prefixed-name "" method))))
12954 (goto-char (point-min))
12955 ;; We split this into to separate loops, one with the prefix
12956 ;; and one without to speed the reading up somewhat.
12958 (let (min max opoint group)
12959 (while (not (eobp))
12962 (read cur) (read cur)
12963 (setq min (read cur)
12966 (skip-chars-forward " \t")
12969 (set (let ((obarray hashtb)) (read cur))
12971 (error (and group (symbolp group) (set group nil))))
12973 (let (min max group)
12974 (while (not (eobp))
12976 (if (= (following-char) ?2)
12978 (read cur) (read cur)
12979 (setq min (read cur)
12981 (set (setq group (let ((obarray hashtb)) (read cur)))
12983 (error (and group (symbolp group) (set group nil))))
12984 (forward-line 1))))))
12986 (defun gnus-read-newsrc-file (&optional force)
12987 "Read startup file.
12988 If FORCE is non-nil, the .newsrc file is read."
12989 ;; Reset variables that might be defined in the .newsrc.eld file.
12990 (let ((variables gnus-variable-list))
12992 (set (car variables) nil)
12993 (setq variables (cdr variables))))
12994 (let* ((newsrc-file gnus-current-startup-file)
12995 (quick-file (concat newsrc-file ".el")))
12997 ;; We always load the .newsrc.eld file. If always contains
12998 ;; much information that can not be gotten from the .newsrc
12999 ;; file (ticked articles, killed groups, foreign methods, etc.)
13000 (gnus-read-newsrc-el-file quick-file)
13003 (and (file-newer-than-file-p newsrc-file quick-file)
13004 (file-newer-than-file-p newsrc-file
13005 (concat quick-file "d")))
13006 (not gnus-newsrc-alist))
13007 ;; We read the .newsrc file. Note that if there if a
13008 ;; .newsrc.eld file exists, it has already been read, and
13009 ;; the `gnus-newsrc-hashtb' has been created. While reading
13010 ;; the .newsrc file, Gnus will only use the information it
13011 ;; can find there for changing the data already read -
13012 ;; ie. reading the .newsrc file will not trash the data
13013 ;; already read (except for read articles).
13015 (gnus-message 5 "Reading %s..." newsrc-file)
13016 (set-buffer (find-file-noselect newsrc-file))
13017 (buffer-disable-undo (current-buffer))
13018 (gnus-newsrc-to-gnus-format)
13019 (kill-buffer (current-buffer))
13020 (gnus-message 5 "Reading %s...done" newsrc-file))))))
13022 (defun gnus-read-newsrc-el-file (file)
13023 (let ((ding-file (concat file "d")))
13024 ;; We always, always read the .eld file.
13025 (gnus-message 5 "Reading %s..." ding-file)
13026 (let (gnus-newsrc-assoc)
13027 (condition-case nil
13028 (load ding-file t t t)
13030 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
13031 (let ((inhibit-quit t))
13032 (gnus-uncompress-newsrc-alist))
13033 (gnus-make-hashtable-from-newsrc-alist)
13034 (if (not (file-newer-than-file-p file ding-file))
13036 ;; Old format quick file
13037 (gnus-message 5 "Reading %s..." file)
13038 ;; The .el file is newer than the .eld file, so we read that one
13040 (gnus-read-old-newsrc-el-file file))))
13042 ;; Parse the old-style quick startup file
13043 (defun gnus-read-old-newsrc-el-file (file)
13044 (let (newsrc killed marked group m)
13046 (let ((gnus-killed-assoc nil)
13047 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
13049 (condition-case nil
13052 (setq newsrc gnus-newsrc-assoc
13053 killed gnus-killed-assoc
13054 marked gnus-marked-assoc)))
13055 (setq gnus-newsrc-alist nil)
13057 (setq group (car newsrc))
13058 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13061 (setcar (nthcdr 2 info) (cdr (cdr group)))
13063 (if (nth 1 group) gnus-level-default-subscribed
13064 gnus-level-default-unsubscribed))
13065 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
13066 (setq gnus-newsrc-alist
13070 (if (nth 1 group) gnus-level-default-subscribed
13071 gnus-level-default-unsubscribed)
13072 (cdr (cdr group))))
13073 gnus-newsrc-alist)))
13074 (if (setq m (assoc (car group) marked))
13075 (setcdr (cdr (cdr info))
13076 (cons (list (cons 'tick (cdr m))) nil))))
13077 (setq newsrc (cdr newsrc)))
13078 (setq newsrc killed)
13080 (setcar newsrc (car (car newsrc)))
13081 (setq newsrc (cdr newsrc)))
13082 (setq gnus-killed-list killed))
13083 ;; The .el file version of this variable does not begin with
13084 ;; "options", while the .eld version does, so we just add it if it
13087 gnus-newsrc-options
13089 (and (not (string-match "^ *options" gnus-newsrc-options))
13090 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
13091 (and (not (string-match "\n$" gnus-newsrc-options))
13092 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
13093 ;; Finally, if we read some options lines, we parse them.
13094 (or (string= gnus-newsrc-options "")
13095 (gnus-newsrc-parse-options gnus-newsrc-options))))
13097 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
13098 (gnus-make-hashtable-from-newsrc-alist)))
13100 (defun gnus-make-newsrc-file (file)
13101 "Make server dependent file name by catenating FILE and server host name."
13102 (let* ((file (expand-file-name file nil))
13103 (real-file (concat file "-" (nth 1 gnus-select-method))))
13104 (if (or (file-exists-p real-file)
13105 (file-exists-p (concat real-file ".el"))
13106 (file-exists-p (concat real-file ".eld")))
13109 (defun gnus-uncompress-newsrc-alist ()
13110 ;; Uncompress all lists of marked articles in the newsrc assoc.
13111 (let ((newsrc gnus-newsrc-alist)
13114 (if (not (setq marked (nth 3 (car newsrc))))
13117 (or (eq 'score (car (car marked)))
13118 (eq 'bookmark (car (car marked)))
13119 (eq 'killed (car (car marked)))
13120 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13121 (setq marked (cdr marked))))
13122 (setq newsrc (cdr newsrc)))))
13124 (defun gnus-compress-newsrc-alist ()
13125 ;; Compress all lists of marked articles in the newsrc assoc.
13126 (let ((newsrc gnus-newsrc-alist)
13129 (if (not (setq marked (nth 3 (car newsrc))))
13132 (or (eq 'score (car (car marked)))
13133 (eq 'bookmark (car (car marked)))
13134 (eq 'killed (car (car marked)))
13135 (setcdr (car marked)
13137 (gnus-compress-sequence
13138 (sort (cdr (car marked)) '<) t)
13139 (error (cdr (car marked))))))
13140 (setq marked (cdr marked))))
13141 (setq newsrc (cdr newsrc)))))
13143 (defun gnus-newsrc-to-gnus-format ()
13144 (setq gnus-newsrc-options "")
13145 (setq gnus-newsrc-options-n nil)
13147 (or gnus-active-hashtb
13148 (setq gnus-active-hashtb (make-vector 4095 0)))
13149 (let ((buf (current-buffer))
13150 (already-read (> (length gnus-newsrc-alist) 1))
13151 group subscribed options-symbol newsrc Options-symbol
13153 (goto-char (point-min))
13154 ;; We intern the symbol `options' in the active hashtb so that we
13155 ;; can `eq' against it later.
13156 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
13157 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
13159 (while (not (eobp))
13160 ;; We first read the first word on the line by narrowing and
13161 ;; then reading into `gnus-active-hashtb'. Most groups will
13162 ;; already exist in that hashtb, so this will save some string
13166 (progn (skip-chars-forward "^ \t!:\n") (point)))
13167 (goto-char (point-min))
13169 (and (/= (point-min) (point-max))
13170 (let ((obarray gnus-active-hashtb)) (read buf))))
13172 ;; Now, the symbol we have read is either `options' or a group
13173 ;; name. If it is an options line, we just add it to a string.
13175 ((or (eq symbol options-symbol)
13176 (eq symbol Options-symbol))
13177 (setq gnus-newsrc-options
13178 ;; This concating is quite inefficient, but since our
13179 ;; thorough studies show that approx 99.37% of all
13180 ;; .newsrc files only contain a single options line, we
13181 ;; don't give a damn, frankly, my dear.
13182 (concat gnus-newsrc-options
13184 (gnus-point-at-bol)
13185 ;; Options may continue on the next line.
13186 (or (and (re-search-forward "^[^ \t]" nil 'move)
13187 (progn (beginning-of-line) (point)))
13191 (or (boundp symbol) (set symbol nil))
13192 ;; It was a group name.
13193 (setq subscribed (= (following-char) ?:)
13194 group (symbol-name symbol)
13197 ;; If the line ends here, this is clearly a buggy line, so
13198 ;; we put point a the beginning of line and let the cond
13199 ;; below do the error handling.
13200 (beginning-of-line)
13201 ;; We skip to the beginning of the ranges.
13202 (skip-chars-forward "!: \t"))
13203 ;; We are now at the beginning of the list of read articles.
13204 ;; We read them range by range.
13207 ((looking-at "[0-9]+")
13208 ;; We narrow and read a number instead of buffer-substring/
13209 ;; string-to-int because it's faster. narrow/widen is
13210 ;; faster than save-restriction/narrow, and save-restriction
13211 ;; produces a garbage object.
13213 (narrow-to-region (match-beginning 0) (match-end 0))
13216 ;; If the next character is a dash, then this is a range.
13217 (if (= (following-char) ?-)
13219 ;; We read the upper bound of the range.
13221 (if (not (looking-at "[0-9]+"))
13222 ;; This is a buggy line, by we pretend that
13223 ;; it's kinda OK. Perhaps the user should be
13225 (setq reads (cons num1 reads))
13230 (narrow-to-region (match-beginning 0)
13235 ;; It was just a simple number, so we add it to the
13237 (setq reads (cons num1 reads)))
13238 ;; If the next char in ?\n, then we have reached the end
13239 ;; of the line and return nil.
13240 (/= (following-char) ?\n))
13241 ((= (following-char) ?\n)
13242 ;; End of line, so we end.
13245 ;; Not numbers and not eol, so this might be a buggy
13248 ;; If it was eob instead of ?\n, we allow it.
13250 ;; The line was buggy.
13252 (gnus-message 3 "Mangled line: %s"
13253 (buffer-substring (gnus-point-at-bol)
13254 (gnus-point-at-eol)))
13258 ;; Skip past ", ". Spaces are illegal in these ranges, but
13259 ;; we allow them, because it's a common mistake to put a
13260 ;; space after the comma.
13261 (skip-chars-forward ", "))
13263 ;; We have already read .newsrc.eld, so we gently update the
13264 ;; data in the hash table with the information we have just
13268 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
13271 ;; There is an entry for this file in the alist.
13273 (setcar (nthcdr 2 info) (nreverse reads))
13274 ;; We update the level very gently. In fact, we
13275 ;; only change it if there's been a status change
13276 ;; from subscribed to unsubscribed, or vice versa.
13277 (setq level (nth 1 info))
13278 (cond ((and (<= level gnus-level-subscribed)
13280 (setq level (if reads
13281 gnus-level-default-unsubscribed
13282 (1+ gnus-level-default-unsubscribed))))
13283 ((and (> level gnus-level-subscribed) subscribed)
13284 (setq level gnus-level-default-subscribed)))
13285 (setcar (cdr info) level))
13286 ;; This is a new group.
13287 (setq info (list group
13289 gnus-level-default-subscribed
13291 (1+ gnus-level-subscribed)
13292 gnus-level-default-unsubscribed))
13293 (nreverse reads))))
13294 (setq newsrc (cons info newsrc))))))
13297 (setq newsrc (nreverse newsrc))
13299 (if (not already-read)
13301 ;; We now have two newsrc lists - `newsrc', which is what we
13302 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13303 ;; what we've read from .newsrc.eld. We have to merge these
13304 ;; lists. We do this by "attaching" any (foreign) groups in the
13305 ;; gnus-newsrc-alist to the (native) group that precedes them.
13306 (let ((rc (cdr gnus-newsrc-alist))
13307 (prev gnus-newsrc-alist)
13310 (or (null (nth 4 (car rc))) ; It's a native group.
13311 (assoc (car (car rc)) newsrc) ; It's already in the alist.
13312 (if (setq entry (assoc (car (car prev)) newsrc))
13313 (setcdr (setq mentry (memq entry newsrc))
13314 (cons (car rc) (cdr mentry)))
13315 (setq newsrc (cons (car rc) newsrc))))
13319 (setq gnus-newsrc-alist newsrc)
13320 ;; We make the newsrc hashtb.
13321 (gnus-make-hashtable-from-newsrc-alist)
13323 ;; Finally, if we read some options lines, we parse them.
13324 (or (string= gnus-newsrc-options "")
13325 (gnus-newsrc-parse-options gnus-newsrc-options))))
13327 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13328 ;; The return value will be a list on the form
13329 ;; ((regexp1 . ignore)
13330 ;; (regexp2 . subscribe)...)
13331 ;; When handling new newsgroups, groups that match a `ignore' regexp
13332 ;; will be ignored, and groups that match a `subscribe' regexp will be
13333 ;; subscribed. A line like
13334 ;; options -n !all rec.all
13335 ;; will lead to a list that looks like
13336 ;; (("^rec\\..+" . subscribe)
13337 ;; ("^.+" . ignore))
13338 ;; So all "rec.*" groups will be subscribed, while all the other
13339 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13340 ;; different from "options -n rec.all !all".
13341 (defun gnus-newsrc-parse-options (options)
13344 (gnus-set-work-buffer)
13345 (insert (regexp-quote options))
13346 ;; First we treat all continuation lines.
13347 (goto-char (point-min))
13348 (while (re-search-forward "\n[ \t]+" nil t)
13349 (replace-match " " t t))
13350 ;; Then we transform all "all"s into ".+"s.
13351 (goto-char (point-min))
13352 (while (re-search-forward "\\ball\\b" nil t)
13353 (replace-match ".+" t t))
13354 (goto-char (point-min))
13355 ;; We remove all other options than the "-n" ones.
13356 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
13357 (replace-match " ")
13359 (goto-char (point-min))
13361 ;; We are only interested in "options -n" lines - we
13362 ;; ignore the other option lines.
13363 (while (re-search-forward "[ \t]-n" nil t)
13365 (or (save-excursion
13366 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
13368 (gnus-point-at-eol)))
13369 ;; Search for all "words"...
13370 (while (re-search-forward "[^ \t,\n]+" eol t)
13371 (if (= (char-after (match-beginning 0)) ?!)
13372 ;; If the word begins with a bang (!), this is a "not"
13373 ;; spec. We put this spec (minus the bang) and the
13374 ;; symbol `ignore' into the list.
13375 (setq out (cons (cons (concat
13376 "^" (buffer-substring
13377 (1+ (match-beginning 0))
13380 ;; There was no bang, so this is a "yes" spec.
13381 (setq out (cons (cons (concat
13382 "^" (buffer-substring (match-beginning 0)
13384 'subscribe) out)))))
13386 (setq gnus-newsrc-options-n out))))
13389 (defun gnus-save-newsrc-file ()
13390 "Save .newsrc file."
13391 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13392 ;; from the variable gnus-newsrc-alist.
13393 (and (or gnus-newsrc-alist gnus-killed-list)
13394 gnus-current-startup-file
13396 (run-hooks 'gnus-save-newsrc-hook)
13398 (if (and gnus-use-dribble-file
13399 (or (not gnus-dribble-buffer)
13400 (not (buffer-name gnus-dribble-buffer))
13401 (zerop (save-excursion
13402 (set-buffer gnus-dribble-buffer)
13404 (gnus-message 4 "(No changes need to be saved)")
13405 (if gnus-save-newsrc-file
13407 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
13408 ;; Make backup file of master newsrc.
13409 (gnus-gnus-to-newsrc-format)
13410 (gnus-message 5 "Saving %s...done"
13411 gnus-current-startup-file)))
13412 ;; Quickly loadable .newsrc.
13413 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13414 (setq buffer-file-name (concat gnus-current-startup-file ".eld"))
13415 (gnus-add-current-to-buffer-list)
13416 (buffer-disable-undo (current-buffer))
13418 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
13419 (gnus-gnus-to-quick-newsrc-format)
13421 (kill-buffer (current-buffer))
13422 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
13423 (gnus-dribble-delete-file))))))
13425 (defun gnus-gnus-to-quick-newsrc-format ()
13426 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13427 (insert ";; Gnus startup file.\n")
13428 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13429 (insert ";; to read .newsrc.\n")
13430 (insert "(setq gnus-newsrc-file-version "
13431 (prin1-to-string gnus-version) ")\n")
13432 (let ((variables gnus-variable-list)
13434 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
13436 ;; insert lisp expressions.
13437 (gnus-compress-newsrc-alist)
13439 (setq variable (car variables))
13440 (and (boundp variable)
13441 (symbol-value variable)
13442 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13443 (insert "(setq " (symbol-name variable) " '"
13444 (prin1-to-string (symbol-value variable))
13446 (setq variables (cdr variables)))
13447 (gnus-uncompress-newsrc-alist)))
13450 (defun gnus-gnus-to-newsrc-format ()
13451 ;; Generate and save the .newsrc file.
13452 (let ((newsrc (cdr gnus-newsrc-alist))
13455 (set-buffer (create-file-buffer gnus-current-startup-file))
13456 (setq buffer-file-name gnus-current-startup-file)
13457 (buffer-disable-undo (current-buffer))
13460 (if gnus-newsrc-options (insert gnus-newsrc-options))
13461 ;; Write subscribed and unsubscribed.
13463 (setq info (car newsrc))
13464 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13466 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13468 (if (setq ranges (nth 2 info))
13471 (if (not (listp (cdr ranges)))
13472 (if (= (car ranges) (cdr ranges))
13473 (insert (int-to-string (car ranges)))
13474 (insert (int-to-string (car ranges)) "-"
13475 (int-to-string (cdr ranges))))
13477 (setq range (car ranges)
13478 ranges (cdr ranges))
13479 (if (or (atom range) (= (car range) (cdr range)))
13480 (insert (int-to-string
13481 (or (and (atom range) range)
13483 (insert (int-to-string (car range)) "-"
13484 (int-to-string (cdr range))))
13485 (if ranges (insert ","))))))
13487 (setq newsrc (cdr newsrc)))
13488 ;; It has been reported that sometime the modtime on the .newsrc
13489 ;; file seems to be off. We really do want to overwrite it, so
13490 ;; we clear the modtime here before saving. It's a bit odd,
13492 ;; sometimes the modtime clear isn't sufficient. most brute force:
13493 ;; delete the silly thing entirely first. but this fails to provide
13494 ;; such niceties as .newsrc~ creation.
13495 (if gnus-modtime-botch
13496 (delete-file gnus-startup-file)
13497 (clear-visited-file-modtime))
13499 (kill-buffer (current-buffer)))))
13501 (defun gnus-read-all-descriptions-files ()
13502 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13504 (gnus-read-descriptions-file (car methods))
13505 (setq methods (cdr methods)))
13508 (defun gnus-read-descriptions-file (&optional method)
13509 (let ((method (or method gnus-select-method)))
13510 ;; We create the hashtable whether we manage to read the desc file
13511 ;; to avoid trying to re-read after a failed read.
13512 (or gnus-description-hashtb
13513 (setq gnus-description-hashtb
13514 (gnus-make-hashtable (length gnus-active-hashtb))))
13515 ;; Mark this method's desc file as read.
13516 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
13517 gnus-description-hashtb)
13519 (gnus-message 5 "Reading descriptions file via %s..." (car method))
13521 ((not (gnus-check-server method))
13522 (gnus-message 1 "Couldn't open server")
13524 ((not (gnus-request-list-newsgroups method))
13525 (gnus-message 1 "Couldn't read newsgroups descriptions")
13531 (set-buffer nntp-server-buffer)
13532 (goto-char (point-min))
13533 (if (or (search-forward "\n.\n" nil t)
13534 (goto-char (point-max)))
13536 (beginning-of-line)
13537 (narrow-to-region (point-min) (point))))
13538 (goto-char (point-min))
13539 (while (not (eobp))
13540 ;; If we get an error, we set group to 0, which is not a
13544 (let ((obarray gnus-description-hashtb))
13545 ;; Group is set to a symbol interned in this
13547 (read nntp-server-buffer))
13549 (skip-chars-forward " \t")
13550 ;; ... which leads to this line being effectively ignored.
13551 (and (symbolp group)
13552 (set group (buffer-substring
13553 (point) (progn (end-of-line) (point)))))
13554 (forward-line 1))))
13555 (gnus-message 5 "Reading descriptions file...done")
13558 (defun gnus-group-get-description (group)
13559 ;; Get the description of a group by sending XGTITLE to the server.
13560 (and (gnus-request-group-description group)
13562 (set-buffer nntp-server-buffer)
13563 (goto-char (point-min))
13564 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13565 (buffer-substring (match-beginning 1) (match-end 1))))))
13571 (defvar gnus-server-mode-hook nil
13572 "Hook run in `gnus-server-mode' buffers.")
13574 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13575 "Format of server lines.
13576 It works along the same lines as a normal formatting string,
13577 with some simple extensions.")
13579 (defvar gnus-server-mode-line-format "Gnus List of servers"
13580 "The format specification for the server mode line.")
13582 (defconst gnus-server-line-format-alist
13583 (list (list ?h 'how ?s)
13585 (list ?w 'where ?s)
13588 (defconst gnus-server-mode-line-format-alist
13589 (list (list ?S 'news-server ?s)
13590 (list ?M 'news-method ?s)
13591 (list ?u 'user-defined ?s)))
13593 (defvar gnus-server-line-format-spec nil)
13594 (defvar gnus-server-mode-line-format-spec nil)
13595 (defvar gnus-server-killed-servers nil)
13597 (defvar gnus-server-mode-map nil)
13598 (put 'gnus-server-mode 'mode-class 'special)
13600 (if gnus-server-mode-map
13602 (setq gnus-server-mode-map (make-sparse-keymap))
13603 (suppress-keymap gnus-server-mode-map)
13604 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13605 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
13606 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
13607 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13608 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13609 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13610 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13611 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13612 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13613 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13615 (defun gnus-server-mode ()
13616 "Major mode for listing and editing servers.
13618 All normal editing commands are switched off.
13619 \\<gnus-server-mode-map>
13621 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13623 The following commands are available:
13625 \\{gnus-server-mode-map}"
13627 (if gnus-visual (gnus-server-make-menu-bar))
13628 (kill-all-local-variables)
13629 (gnus-simplify-mode-line)
13630 (setq major-mode 'gnus-server-mode)
13631 (setq mode-name "Server")
13632 ; (gnus-group-set-mode-line)
13633 (setq mode-line-process nil)
13634 (use-local-map gnus-server-mode-map)
13635 (buffer-disable-undo (current-buffer))
13636 (setq truncate-lines t)
13637 (setq buffer-read-only t)
13638 (run-hooks 'gnus-server-mode-hook))
13640 (defun gnus-server-insert-server-line (sformat name method)
13641 (let* ((sformat (or sformat gnus-server-line-format-spec))
13643 (where (nth 1 method))
13645 (beginning-of-line)
13647 ;; Insert the text.
13648 (insert (eval sformat))
13649 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
13651 (defun gnus-server-setup-buffer ()
13652 (if (get-buffer gnus-server-buffer)
13655 (set-buffer (get-buffer-create gnus-server-buffer))
13657 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
13659 (defun gnus-server-prepare ()
13660 (setq gnus-server-mode-line-format-spec
13661 (gnus-parse-format gnus-server-mode-line-format
13662 gnus-server-mode-line-format-alist))
13663 (setq gnus-server-line-format-spec
13664 (gnus-parse-format gnus-server-line-format
13665 gnus-server-line-format-alist))
13666 (let ((alist gnus-server-alist)
13667 (buffer-read-only nil))
13670 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13671 (setq alist (cdr alist))))
13672 (goto-char (point-min))
13673 (gnus-server-position-cursor))
13675 (defun gnus-server-server-name ()
13676 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
13677 (and server (symbol-name server))))
13679 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13681 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13683 (defun gnus-server-update-server (server)
13685 (set-buffer gnus-server-buffer)
13686 (let ((buffer-read-only nil)
13687 (info (cdr (assoc server gnus-server-alist))))
13688 (gnus-dribble-enter
13689 (concat "(gnus-server-set-info \"" server "\" '"
13690 (prin1-to-string info) ")"))
13691 ;; Buffer may be narrowed.
13694 (if (gnus-server-goto-server server)
13695 (delete-region (progn (beginning-of-line) (point))
13696 (progn (forward-line 1) (point))))
13697 (let ((entry (assoc server gnus-server-alist)))
13698 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13699 (gnus-server-position-cursor))))))
13701 (defun gnus-server-set-info (server info)
13702 ;; Enter a select method into the virtual server alist.
13703 (gnus-dribble-enter
13704 (concat "(gnus-server-set-info \"" server "\" '"
13705 (prin1-to-string info) ")"))
13706 (let* ((server (nth 1 info))
13707 (entry (assoc server gnus-server-alist)))
13708 (if entry (setcdr entry info)
13709 (setq gnus-server-alist
13710 (nconc gnus-server-alist (list (cons server info)))))))
13712 (defun gnus-server-to-method (server)
13713 ;; Map virtual server names to select methods.
13714 (or (and (equal server "native") gnus-select-method)
13715 (cdr (assoc server gnus-server-alist))))
13717 (defun gnus-server-extend-method (group method)
13718 ;; This function "extends" a virtual server. If the server is
13719 ;; "hello", and the select method is ("hello" (my-var "something"))
13720 ;; in the group "alt.alt", this will result in a new virtual server
13721 ;; called "helly+alt.alt".
13723 (gnus-copy-sequence
13724 (if (equal (car method) "native") gnus-select-method
13725 (cdr (assoc (car method) gnus-server-alist))))))
13726 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13727 (nconc entry (cdr method))))
13729 (defun gnus-server-get-method (group method)
13730 ;; Input either a server name, and extended server name, or a
13731 ;; select method, and return a select method.
13732 (cond ((stringp method)
13733 (gnus-server-to-method method))
13734 ((and (stringp (car method)) group)
13735 (gnus-server-extend-method group method))
13737 (gnus-server-add-address method))))
13739 (defun gnus-server-add-address (method)
13740 (let ((method-name (symbol-name (car method))))
13741 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13742 (not (assq (intern (concat method-name "-address")) method)))
13743 (append method (list (list (intern (concat method-name "-address"))
13747 (defun gnus-server-equal (s1 s2)
13749 (and (= (length s1) (length s2))
13751 (while (and s1 (member (car s1) s2))
13752 (setq s1 (cdr s1)))
13755 ;;; Interactive server functions.
13757 (defun gnus-server-kill-server (server)
13758 "Kill the server on the current line."
13759 (interactive (list (gnus-server-server-name)))
13760 (or (gnus-server-goto-server server)
13761 (if server (error "No such server: %s" server)
13762 (error "No server on the current line")))
13763 (gnus-dribble-enter "")
13764 (let ((buffer-read-only nil))
13765 (delete-region (progn (beginning-of-line) (point))
13766 (progn (forward-line 1) (point))))
13767 (setq gnus-server-killed-servers
13768 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13769 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13770 gnus-server-alist))
13771 (gnus-server-position-cursor))
13773 (defun gnus-server-yank-server ()
13774 "Yank the previously killed server."
13776 (or gnus-server-killed-servers
13777 (error "No killed servers to be yanked"))
13778 (let ((alist gnus-server-alist)
13779 (server (gnus-server-server-name))
13780 (killed (car gnus-server-killed-servers)))
13782 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13783 (if (string= server (car (car gnus-server-alist)))
13784 (setq gnus-server-alist (cons killed gnus-server-alist))
13785 (while (and (cdr alist)
13786 (not (string= server (car (car (cdr alist))))))
13787 (setq alist (cdr alist)))
13788 (setcdr alist (cons killed (cdr alist)))))
13789 (gnus-server-update-server (car killed))
13790 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13791 (gnus-server-position-cursor)))
13793 (defun gnus-server-exit ()
13794 "Return to the group buffer."
13796 (kill-buffer (current-buffer))
13797 (switch-to-buffer gnus-group-buffer))
13799 (defun gnus-server-list-servers ()
13800 "List all available servers."
13802 (let ((cur (gnus-server-server-name)))
13803 (gnus-server-prepare)
13804 (if cur (gnus-server-goto-server cur)
13805 (goto-char (point-max))
13807 (gnus-server-position-cursor)))
13809 (defun gnus-server-copy-server (from to)
13812 (or (gnus-server-server-name)
13813 (error "No server on the current line"))
13814 (read-string "Copy to: ")))
13815 (or from (error "No server on current line"))
13816 (or (and to (not (string= to ""))) (error "No name to copy to"))
13817 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13818 (or (assoc from gnus-server-alist)
13819 (error "%s: no such server" from))
13820 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13821 (setcar to-entry to)
13822 (setcar (nthcdr 2 to-entry) to)
13823 (setq gnus-server-killed-servers
13824 (cons to-entry gnus-server-killed-servers))
13825 (gnus-server-yank-server)))
13827 (defun gnus-server-add-server (how where)
13829 (list (intern (completing-read "Server method: "
13830 gnus-valid-select-methods nil t))
13831 (read-string "Server name: ")))
13832 (setq gnus-server-killed-servers
13833 (cons (list where how where) gnus-server-killed-servers))
13834 (gnus-server-yank-server))
13836 (defun gnus-server-goto-server (server)
13837 "Jump to a server line."
13839 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13840 (let ((to (text-property-any (point-min) (point-max)
13841 'gnus-server (intern server))))
13845 (gnus-server-position-cursor)))))
13847 (defun gnus-server-edit-server (server)
13848 "Edit the server on the current line."
13849 (interactive (list (gnus-server-server-name)))
13851 (error "No server on current line"))
13852 (let ((winconf (current-window-configuration)))
13853 (get-buffer-create gnus-server-edit-buffer)
13854 (gnus-configure-windows 'edit-server)
13855 (gnus-add-current-to-buffer-list)
13857 (make-local-variable 'gnus-prev-winconf)
13858 (setq gnus-prev-winconf winconf)
13859 (use-local-map (copy-keymap (current-local-map)))
13860 (let ((done-func '(lambda ()
13861 "Exit editing mode and update the information."
13863 (gnus-server-edit-server-done 'group))))
13864 (setcar (cdr (nth 4 done-func)) server)
13865 (local-set-key "\C-c\C-c" done-func))
13867 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13868 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13870 (defun gnus-server-edit-server-done (server)
13872 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13873 (goto-char (point-min))
13874 (let ((form (read (current-buffer)))
13875 (winconf gnus-prev-winconf))
13876 (gnus-server-set-info server form)
13877 (kill-buffer (current-buffer))
13878 (and winconf (set-window-configuration winconf))
13879 (set-buffer gnus-server-buffer)
13880 (gnus-server-update-server (gnus-server-server-name))
13881 (gnus-server-list-servers)
13882 (gnus-server-position-cursor)))
13884 (defun gnus-server-read-server (server)
13886 (interactive (list (gnus-server-server-name)))
13887 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13889 (defun gnus-mouse-pick-server (e)
13891 (mouse-set-point e)
13892 (gnus-server-read-server (gnus-server-server-name)))
13895 ;;; entry points into gnus-score.el
13898 ;;; Finding score files.
13900 (defvar gnus-global-score-files nil
13901 "*List of global score files and directories.
13902 Set this variable if you want to use people's score files. One entry
13903 for each score file or each score file directory. Gnus will decide
13904 by itself what score files are applicable to which group.
13906 Say you want to use the single score file
13907 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13908 score files in the \"/ftp.some-where:/pub/score\" directory.
13910 (setq gnus-global-score-files
13911 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13912 \"/ftp.some-where:/pub/score\"))")
13914 (defun gnus-score-score-files (group)
13915 "Return a list of all possible score files."
13916 ;; Search and set any global score files.
13917 (and gnus-global-score-files
13918 (or gnus-internal-global-score-files
13919 (gnus-score-search-global-directories gnus-global-score-files)))
13920 ;; Fix the kill-file dir variable.
13921 (setq gnus-kill-files-directory
13922 (file-name-as-directory
13923 (or gnus-kill-files-directory "~/News/")))
13924 ;; If we can't read it, there are no score files.
13925 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13926 (setq gnus-score-file-list nil)
13927 (if (gnus-use-long-file-name 'not-score)
13928 ;; We want long file names.
13929 (if (or (not gnus-score-file-list)
13930 (not (car gnus-score-file-list))
13931 (gnus-file-newer-than gnus-kill-files-directory
13932 (car gnus-score-file-list)))
13933 (setq gnus-score-file-list
13934 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13937 gnus-kill-files-directory t
13938 (gnus-score-file-regexp))))))
13939 ;; We do not use long file names, so we have to do some
13940 ;; directory traversing.
13941 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13942 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13945 (setq dir (expand-file-name
13946 (concat gnus-kill-files-directory
13947 (gnus-replace-chars-in-string group ?. ?/))))
13948 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13949 (setq suffix (car suffixes)
13950 suffixes (cdr suffixes))
13951 (if (file-exists-p (concat dir "/" suffix))
13952 (setq files (cons (concat dir "/" suffix) files)))
13953 (while (>= (1+ (length dir)) mdir)
13954 (and (file-exists-p (concat dir "/all/" suffix))
13955 (setq files (cons (concat dir "/all/" suffix) files)))
13956 (string-match "/[^/]*$" dir)
13957 (setq dir (substring dir 0 (match-beginning 0)))))
13958 (setq gnus-score-file-list
13959 (cons nil (nreverse files)))))
13960 (cdr gnus-score-file-list)))
13962 (defun gnus-score-file-regexp ()
13963 (concat "\\(" gnus-score-file-suffix
13964 "\\|" gnus-adaptive-file-suffix "\\)$"))
13966 (defun gnus-score-find-bnews (group)
13967 "Return a list of score files for GROUP.
13968 The score files are those files in the ~/News directory which matches
13969 GROUP using BNews sys file syntax."
13970 (let* ((sfiles (append (gnus-score-score-files group)
13971 gnus-internal-global-score-files))
13972 (kill-dir (file-name-as-directory
13973 (expand-file-name gnus-kill-files-directory)))
13974 (klen (length kill-dir))
13975 ofiles not-match regexp)
13977 (set-buffer (get-buffer-create "*gnus score files*"))
13978 (buffer-disable-undo (current-buffer))
13979 ;; Go through all score file names and create regexp with them
13983 (insert (car sfiles))
13984 (goto-char (point-min))
13985 ;; First remove the suffix itself.
13986 (re-search-forward (concat "." (gnus-score-file-regexp)))
13987 (replace-match "" t t)
13988 (goto-char (point-min))
13989 (if (looking-at (regexp-quote kill-dir))
13990 ;; If the file name was just "SCORE", `klen' is one character
13992 (delete-char (min (1- (point-max)) klen))
13993 (goto-char (point-max))
13994 (search-backward "/")
13995 (delete-region (1+ (point)) (point-min)))
13996 ;; If short file names were used, we have to translate slashes.
13997 (goto-char (point-min))
13998 (while (re-search-forward "[/:]" nil t)
13999 (replace-match "." t t))
14000 ;; Kludge to get rid of "nntp+" problems.
14001 (goto-char (point-min))
14002 (and (looking-at "nn[a-z]+\\+")
14004 (search-forward "+")
14007 ;; Translate ".all" to "[./].*";
14008 (while (search-forward ".all" nil t)
14009 (replace-match "[./:].*" t t))
14010 (goto-char (point-min))
14011 ;; Translate "all" to ".*".
14012 (while (search-forward "all" nil t)
14013 (replace-match ".*" t t))
14014 (goto-char (point-min))
14015 ;; Deal with "not."s.
14016 (if (looking-at "not.")
14019 (setq regexp (buffer-substring 5 (point-max))))
14020 (setq regexp (buffer-substring 1 (point-max)))
14021 (setq not-match nil))
14022 ;; Finally - if this resulting regexp matches the group name,
14023 ;; we add this score file to the list of score files
14024 ;; applicable to this group.
14025 (if (or (and not-match
14026 (not (string-match regexp group)))
14027 (and (not not-match)
14028 (string-match regexp group)))
14029 (setq ofiles (cons (car sfiles) ofiles)))
14030 (setq sfiles (cdr sfiles)))
14031 (kill-buffer (current-buffer))
14032 ;; Slight kludge here - the last score file returned should be
14033 ;; the local score file, whether it exists or not. This is so
14034 ;; that any score commands the user enters will go to the right
14035 ;; file, and not end up in some global score file.
14038 (if (gnus-use-long-file-name 'not-score)
14039 (concat gnus-kill-files-directory group "."
14040 gnus-score-file-suffix)
14041 (concat gnus-kill-files-directory
14042 (gnus-replace-chars-in-string group ?. ?/ ?: ?/)
14043 "/" gnus-score-file-suffix)))))
14044 ;; The local score file might already be there, but it's
14045 ;; supposed to be the very last file, so we delete it from the
14046 ;; list if it's already there, and add it to the head of the
14048 (setq ofiles (cons localscore (delete localscore ofiles))))
14049 (nreverse ofiles))))
14051 (defun gnus-score-find-single (group)
14052 "Return list containing the score file for GROUP."
14053 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
14054 (gnus-score-file-name group)))
14056 (defun gnus-score-find-hierarchical (group)
14057 "Return list of score files for GROUP.
14058 This includes the score file for the group and all its parents."
14059 (let ((all (copy-sequence '(nil)))
14061 (while (string-match "\\." group (1+ start))
14062 (setq start (match-beginning 0))
14063 (setq all (cons (substring group 0 start) all)))
14064 (setq all (cons group all))
14066 (mapcar (lambda (newsgroup)
14067 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
14068 (setq all (nreverse all)))
14069 (mapcar 'gnus-score-file-name all))))
14071 (defvar gnus-score-file-alist-cache nil)
14073 (defun gnus-score-find-alist (group)
14074 "Return list of score files for GROUP.
14075 The list is determined from the variable gnus-score-file-alist."
14076 (let ((alist gnus-score-file-multiple-match-alist)
14078 ;; if this group has been seen before, return the cached entry
14079 (if (setq score-files (assoc group gnus-score-file-alist-cache))
14080 (cdr score-files) ;ensures caching groups with no matches
14081 ;; handle the multiple match alist
14083 (and (string-match (car (car alist)) group)
14085 (nconc score-files (copy-sequence (cdr (car alist))))))
14086 (setq alist (cdr alist)))
14087 (setq alist gnus-score-file-single-match-alist)
14088 ;; handle the single match alist
14090 (and (string-match (car (car alist)) group)
14091 ;; progn used just in case ("regexp") has no files
14092 ;; and score-files is still nil. -sj
14093 ;; this can be construed as a "stop searching here" feature :>
14094 ;; and used to simplify regexps in the single-alist
14097 (nconc score-files (copy-sequence (cdr (car alist)))))
14099 (setq alist (cdr alist)))
14100 ;; cache the score files
14101 (setq gnus-score-file-alist-cache
14102 (cons (cons group score-files) gnus-score-file-alist-cache))
14106 (defun gnus-possibly-score-headers (&optional trace)
14107 (let ((func gnus-score-find-score-files-function)
14109 (and func (not (listp func))
14110 (setq func (list func)))
14111 ;; Go through all the functions for finding score files (or actual
14112 ;; scores) and add them to a list.
14113 (setq score-files (gnus-score-find-alist gnus-newsgroup-name))
14115 (and (symbolp (car func))
14116 (fboundp (car func))
14118 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
14119 (setq func (cdr func)))
14120 (if score-files (gnus-score-headers score-files trace))))
14122 (defun gnus-score-file-name (newsgroup &optional suffix)
14123 "Return the name of a score file for NEWSGROUP."
14124 (let ((suffix (or suffix gnus-score-file-suffix)))
14126 ((or (null newsgroup)
14127 (string-equal newsgroup ""))
14128 ;; The global score file is placed at top of the directory.
14130 suffix (or gnus-kill-files-directory "~/News")))
14131 ((gnus-use-long-file-name 'not-score)
14132 ;; Append ".SCORE" to newsgroup name.
14133 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14135 (or gnus-kill-files-directory "~/News")))
14137 ;; Place "SCORE" under the hierarchical directory.
14138 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14140 (or gnus-kill-files-directory "~/News"))))))
14142 (defun gnus-score-search-global-directories (files)
14143 "Scan all global score directories for score files."
14144 ;; Set the variable `gnus-internal-global-score-files' to all
14145 ;; available global score files.
14146 (interactive (list gnus-global-score-files))
14149 (if (string-match "/$" (car files))
14150 (setq out (nconc (directory-files
14152 (concat (gnus-score-file-regexp) "$"))))
14153 (setq out (cons (car files) out)))
14154 (setq files (cdr files)))
14155 (setq gnus-internal-global-score-files out)))
14157 ;; Allow redefinition of Gnus functions.
14159 (gnus-ems-redefine)
14163 ;;; gnus.el ends here