1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;; Although (ding) Gnus looks suspiciously like GNUS, it isn't quite
27 ;; the same beast. Most internal structures have been changed. If you
28 ;; have written packages that depend on any of the hash tables,
29 ;; `gnus-newsrc-alist', `gnus-killed-assoc', marked lists, the .newsrc
30 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
31 ;; dependence on the buffers having a certain format, your code will
40 ;; Site dependent variables. These variables should be defined in
43 (defvar gnus-default-nntp-server nil
44 "Specify a default NNTP server.
45 This variable should be defined in paths.el, and should never be set
47 If you want to change servers, you should use `gnus-select-method'.
48 See the documentation to that variable.")
50 (defconst gnus-backup-default-subscribed-newsgroups
51 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
52 "Default default new newsgroups the first time Gnus is run.
53 Should be set in paths.el, and shouldn't be touched by the user.")
55 (defvar gnus-local-domain nil
56 "Local domain name without a host name.
57 The DOMAINNAME environment variable is used instead if it is defined.
58 If the `system-name' function returns the full Internet name, there is
59 no need to set this variable.")
61 (defvar gnus-local-organization nil
62 "String with a description of what organization (if any) the user belongs to.
63 The ORGANIZATION environment variable is used instead if it is defined.
64 If this variable contains a function, this function will be called
65 with the current newsgroup name as the argument. The function should
68 In any case, if the string (either in the variable, in the environment
69 variable, or returned by the function) is a file name, the contents of
70 this file will be used as the organization.")
72 (defvar gnus-use-generic-from nil
73 "If nil, the full host name will be the system name prepended to the domain name.
74 If this is a string, the full host name will be this string.
75 If this is non-nil, non-string, the domain name will be used as the
78 (defvar gnus-use-generic-path nil
79 "If nil, use the NNTP server name in the Path header.
80 If stringp, use this; if non-nil, use no host name (user name only).")
83 ;; Customization variables
85 (defvar gnus-select-method
86 (list 'nntp (or (getenv "NNTPSERVER")
87 (if (and gnus-default-nntp-server
88 (not (string= gnus-default-nntp-server "")))
89 gnus-default-nntp-server)
91 "*Default method for selecting a newsgroup.
92 This variable should be a list, where the first element is how the
93 news is to be fetched, the second is the address.
95 For instance, if you want to get your news via NNTP from
96 \"flab.flab.edu\", you could say:
98 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
100 If you want to use your local spool, say:
102 (setq gnus-select-method (list 'nnspool (system-name)))
104 If you use this variable, you must set `gnus-nntp-server' to nil.
106 There is a lot more to know about select methods and virtual servers -
107 see the manual for details.")
109 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
110 (defvar gnus-post-method nil
111 "*Preferred method for posting USENET news.
112 If this variable is nil, Gnus will use the current method to decide
113 which method to use when posting. If it is non-nil, it will override
114 the current method. This method will not be used in mail groups and
115 the like, only in \"real\" newsgroups.
117 The value must be a valid method as discussed in the documentation of
118 `gnus-select-method'.")
120 (defvar gnus-refer-article-method nil
121 "*Preferred method for fetching an article by Message-ID.
122 If you are reading news from the local spool (with nnspool), fetching
123 articles by Message-ID is painfully slow. By setting this method to an
124 nntp method, you might get acceptable results.
126 The value of this variable must be a valid select method as discussed
127 in the documentation of `gnus-select-method'")
129 (defvar gnus-secondary-select-methods nil
130 "*A list of secondary methods that will be used for reading news.
131 This is a list where each element is a complete select method (see
132 `gnus-select-method').
134 If, for instance, you want to read your mail with the nnml backend,
135 you could set this variable:
137 (setq gnus-secondary-select-methods '((nnml \"\"))")
139 (defvar gnus-secondary-servers nil
140 "*List of NNTP servers that the user can choose between interactively.
141 To make Gnus query you for a server, you have to give `gnus' a
142 non-numeric prefix - `C-u M-x gnus', in short.")
144 (defvar gnus-nntp-server nil
145 "*The name of the host running the NNTP server.
146 This variable is semi-obsolete. Use the `gnus-select-method'
149 (defvar gnus-nntp-service "nntp"
150 "*NNTP service name (\"nntp\" or 119).
151 This is an obsolete variable, which is scarcely used. If you use an
152 nntp server for your newsgroup and want to change the port number
153 used to 899, you would say something along these lines:
155 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
157 (defvar gnus-startup-file "~/.newsrc"
158 "*Your `.newsrc' file.
159 `.newsrc-SERVER' will be used instead if that exists.")
161 (defvar gnus-init-file "~/.gnus"
162 "*Your Gnus elisp startup file.
163 If a file with the .el or .elc suffixes exist, it will be read
166 (defvar gnus-group-faq-directory
167 "/anonymous@rtfm.mit.edu:/pub/usenet-by-group/"
168 "*Directory where the group FAQs are stored.
169 This will most commonly be on a remote machine, and the file will be
170 fetched by ange-ftp.")
172 (defvar gnus-group-archive-directory
173 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
174 "*The address of the (ding) archives.")
176 (defvar gnus-default-subscribed-newsgroups nil
177 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
178 It should be a list of strings.
179 If it is `t', Gnus will not do anything special the first time it is
180 started; it'll just use the normal newsgroups subscription methods.")
182 (defvar gnus-use-cross-reference t
183 "*Non-nil means that cross referenced articles will be marked as read.
184 If nil, ignore cross references. If t, mark articles as read in
185 subscribed newsgroups. If neither t nor nil, mark as read in all
188 (defvar gnus-use-dribble-file t
189 "*Non-nil means that Gnus will use a dribble file to store user updates.
190 If Emacs should crash without saving the .newsrc files, complete
191 information can be restored from the dribble file.")
193 (defvar gnus-asynchronous nil
194 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
196 (defvar gnus-asynchronous-article-function nil
197 "*Function for picking articles to pre-fetch, possibly.")
199 (defvar gnus-score-file-single-match-alist nil
200 "*Alist mapping regexps to lists of score files.
201 Each element of this alist should be of the form
202 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
204 If the name of a group is matched by REGEXP, the corresponding scorefiles
205 will be used for that group.
206 The first match found is used, subsequent matching entries are ignored (to
207 use multiple matches, see gnus-score-file-multiple-match-alist).
209 These score files are loaded in addition to any files returned by
210 gnus-score-find-score-files-function (which see).")
212 (defvar gnus-score-file-multiple-match-alist nil
213 "*Alist mapping regexps to lists of score files.
214 Each element of this alist should be of the form
215 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
217 If the name of a group is matched by REGEXP, the corresponding scorefiles
218 will be used for that group.
219 If multiple REGEXPs match a group, the score files corresponding to each
220 match will be used (for only one match to be used, see
221 gnus-score-file-single-match-alist).
223 These score files are loaded in addition to any files returned by
224 gnus-score-find-score-files-function (which see).")
227 (defvar gnus-score-file-suffix "SCORE"
228 "*Suffix of the score files.")
230 (defvar gnus-adaptive-file-suffix "ADAPT"
231 "*Suffix of the adaptive score files.")
233 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
234 "*Function used to find score files.
235 The function will be called with the group name as the argument, and
236 should return a list of score files to apply to that group. The score
237 files do not actually have to exist.
239 Predefined values are:
241 gnus-score-find-single: Only apply the group's own score file.
242 gnus-score-find-hierarchical: Also apply score files from parent groups.
243 gnus-score-find-bnews: Apply score files whose names matches.
245 See the documentation to these functions for more information.
247 This variable can also be a list of functions to be called. Each
248 function should either return a list of score files, or a list of
251 (defvar gnus-score-interactive-default-score 1000
252 "*Scoring commands will raise/lower the score with this number as the default.")
254 (defvar gnus-large-newsgroup 200
255 "*The number of articles which indicates a large newsgroup.
256 If the number of articles in a newsgroup is greater than this value,
257 confirmation is required for selecting the newsgroup.")
259 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
260 (defvar gnus-no-groups-message "No news is horrible news"
261 "*Message displayed by Gnus when no groups are available.")
263 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
264 "*Non-nil means that the default name of a file to save articles in is the group name.
265 If it's nil, the directory form of the group name is used instead.
267 If this variable is a list, and the list contains the element
268 `not-score', long file names will not be used for score files; if it
269 contains the element `not-save', long file names will not be used for
270 saving; and if it contains the element `not-kill', long file names
271 will not be used for kill files.")
273 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
274 "*Name of the directory articles will be saved in (default \"~/News\").
275 Initialized from the SAVEDIR environment variable.")
277 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
278 "*Name of the directory where kill files will be stored (default \"~/News\").
279 Initialized from the SAVEDIR environment variable.")
281 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
282 "*A function to save articles in your favorite format.
283 The function must be interactively callable (in other words, it must
284 be an Emacs command).
286 Gnus provides the following functions:
288 * gnus-summary-save-in-rmail (Rmail format)
289 * gnus-summary-save-in-mail (Unix mail format)
290 * gnus-summary-save-in-folder (MH folder)
291 * gnus-summary-save-in-file (article format).
292 * gnus-summary-save-in-vm (use VM's folder format).")
294 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
295 "*A function generating a file name to save articles in Rmail format.
296 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
298 (defvar gnus-mail-save-name (function gnus-plain-save-name)
299 "*A function generating a file name to save articles in Unix mail format.
300 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
302 (defvar gnus-folder-save-name (function gnus-folder-save-name)
303 "*A function generating a file name to save articles in MH folder.
304 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
306 (defvar gnus-file-save-name (function gnus-numeric-save-name)
307 "*A function generating a file name to save articles in article format.
308 The function is called with NEWSGROUP, HEADERS, and optional
311 (defvar gnus-split-methods nil
312 "*Variable used to suggest where articles are to be saved.
313 The syntax of this variable is the same as `nnmail-split-methods'.
315 For instance, if you would like to save articles related to Gnus in
316 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
317 you could set this variable to something like:
319 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
320 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
322 (defvar gnus-save-score nil
323 "*If non-nil, save group scoring info.")
325 (defvar gnus-use-adaptive-scoring nil
326 "*If non-nil, use some adaptive scoring scheme.")
328 (defvar gnus-use-cache nil
329 "*If non-nil, Gnus will cache (some) articles locally.")
331 (defvar gnus-use-scoring t
332 "*If non-nil, enable scoring.")
334 (defvar gnus-fetch-old-headers nil
335 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
336 If an unread article in the group refers to an older, already read (or
337 just marked as read) article, the old article will not normally be
338 displayed in the Summary buffer. If this variable is non-nil, Gnus
339 will attempt to grab the headers to the old articles, and thereby
340 build complete threads. If it has the value `some', only enough
341 headers to connect otherwise loose threads will be displayed.
343 The server has to support XOVER for any of this to work.")
345 (defvar gnus-visual t
346 "*If non-nil, will do various highlighting.
347 If nil, no mouse highlights (or any other highlights) will be
348 performed. This might speed up Gnus some when generating large group
349 and summary buffers.")
351 (defvar gnus-novice-user t
352 "*Non-nil means that you are a usenet novice.
353 If non-nil, verbose messages may be displayed and confirmations may be
356 (defvar gnus-expert-user nil
357 "*Non-nil means that you will never be asked for confirmation about anything.
358 And that means *anything*.")
360 (defvar gnus-verbose 7
361 "*Integer that says how verbose Gnus should be.
362 The higher the number, the more messages Gnus will flash to say what
363 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
364 display most important messages; and at ten, Gnus will keep on
365 jabbering all the time.")
367 (defvar gnus-keep-same-level nil
368 "*Non-nil means that the next newsgroup after the current will be on the same level.
369 When you type, for instance, `n' after reading the last article in the
370 current newsgroup, you will go to the next newsgroup. If this variable
371 is nil, the next newsgroup will be the next from the group
373 If this variable is non-nil, Gnus will either put you in the
374 next newsgroup with the same level, or, if no such newsgroup is
375 available, the next newsgroup with the lowest possible level higher
376 than the current level.
377 If this variable is `best', Gnus will make the next newsgroup the one
378 with the best level.")
380 (defvar gnus-summary-make-false-root 'adopt
381 "*nil means that Gnus won't gather loose threads.
382 If the root of a thread has expired or been read in a previous
383 session, the information necessary to build a complete thread has been
384 lost. Instead of having many small sub-threads from this original thread
385 scattered all over the summary buffer, Gnus can gather them.
387 If non-nil, Gnus will try to gather all loose sub-threads from an
388 original thread into one large thread.
390 If this variable is non-nil, it should be one of `none', `adopt',
393 If this variable is `none', Gnus will not make a false root, but just
394 present the sub-threads after another.
395 If this variable is `dummy', Gnus will create a dummy root that will
396 have all the sub-threads as children.
397 If this variable is `adopt', Gnus will make one of the \"children\"
398 the parent and mark all the step-children as such.
399 If this variable is `empty', the \"children\" are printed with empty
400 subject fields. (Or rather, they will be printed with a string
401 given by the `gnus-summary-same-subject' variable.)")
403 (defvar gnus-summary-gather-subject-limit nil
404 "*Maximum length of subject comparisons when gathering loose threads.
405 Use nil to compare full subjects. Setting this variable to a low
406 number will help gather threads that have been corrupted by
407 newsreaders chopping off subject lines, but it might also mean that
408 unrelated articles that have subject that happen to begin with the
409 same few characters will be incorrectly gathered.
411 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
412 comparing subjects.")
414 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
415 (defvar gnus-summary-same-subject ""
416 "*String indicating that the current article has the same subject as the previous.
417 This variable will only be used if the value of
418 `gnus-summary-make-false-root' is `empty'.")
420 (defvar gnus-summary-goto-unread t
421 "*If non-nil, marking commands will go to the next unread article.")
423 (defvar gnus-group-goto-unread t
424 "*If non-nil, movement commands will go to the next unread and subscribed group.")
426 (defvar gnus-check-new-newsgroups t
427 "*Non-nil means that Gnus will add new newsgroups at startup.
428 If this variable is `ask-server', Gnus will ask the server for new
429 groups since the last time it checked. This means that the killed list
430 is no longer necessary, so you could set `gnus-save-killed-list' to
433 A variant is to have this variable be a list of select methods. Gnus
434 will then use the `ask-server' method on all these select methods to
435 query for new groups from all those servers.
438 (setq gnus-check-new-newsgroups
439 '((nntp \"some.server\") (nntp \"other.server\")))
441 If this variable is nil, then you have to tell Gnus explicitly to
442 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
444 (defvar gnus-check-bogus-newsgroups nil
445 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
446 If this variable is nil, then you have to tell Gnus explicitly to
447 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
449 (defvar gnus-read-active-file t
450 "*Non-nil means that Gnus will read the entire active file at startup.
451 If this variable is nil, Gnus will only know about the groups in your
454 If this variable is `some', Gnus will try to only read the relevant
455 parts of the active file from the server. Not all servers support
456 this, and it might be quite slow with other servers, but this should
457 generally be faster than both the t and nil value.
459 If you set this variable to nil or `some', you probably still want to
460 be told about new newsgroups that arrive. To do that, set
461 `gnus-check-new-newsgroups' to `ask-server'. This may not work
462 properly with all servers.")
464 (defvar gnus-level-subscribed 5
465 "*Groups with levels less than or equal to this variable are subscribed.")
467 (defvar gnus-level-unsubscribed 7
468 "*Groups with levels less than or equal to this variable are unsubscribed.
469 Groups with levels less than `gnus-level-subscribed', which should be
470 less than this variable, are subscribed.")
472 (defvar gnus-level-zombie 8
473 "*Groups with this level are zombie groups.")
475 (defvar gnus-level-killed 9
476 "*Groups with this level are killed.")
478 (defvar gnus-level-default-subscribed 3
479 "*New subscribed groups will be subscribed at this level.")
481 (defvar gnus-level-default-unsubscribed 6
482 "*New unsubscribed groups will be unsubscribed at this level.")
484 (defvar gnus-activate-foreign-newsgroups 4
485 "*If nil, Gnus will not check foreign newsgroups at startup.
486 If it is non-nil, it should be a number between one and nine. Foreign
487 newsgroups that have a level lower or equal to this number will be
488 activated on startup. For instance, if you want to active all
489 subscribed newsgroups, but not the rest, you'd set this variable to
490 `gnus-level-subscribed'.
492 If you subscribe to lots of newsgroups from different servers, startup
493 might take a while. By setting this variable to nil, you'll save time,
494 but you won't be told how many unread articles there are in the
497 (defvar gnus-save-newsrc-file t
498 "*Non-nil means that Gnus will save the `.newsrc' file.
499 Gnus always saves its own startup file, which is called
500 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
501 be readily understood by other newsreaders. If you don't plan on
502 using other newsreaders, set this variable to nil to save some time on
505 (defvar gnus-save-killed-list t
506 "*If non-nil, save the list of killed groups to the startup file.
507 This will save both time (when starting and quitting) and space (both
508 memory and disk), but it will also mean that Gnus has no record of
509 which groups are new and which are old, so the automatic new
510 newsgroups subscription methods become meaningless. You should always
511 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
514 (defvar gnus-interactive-catchup t
515 "*If non-nil, require your confirmation when catching up a group.")
517 (defvar gnus-interactive-post t
518 "*If non-nil, group name will be asked for when posting.")
520 (defvar gnus-interactive-exit t
521 "*If non-nil, require your confirmation when exiting Gnus.")
523 (defvar gnus-kill-killed nil
524 "*If non-nil, Gnus will apply kill files to already killed articles.
525 If it is nil, Gnus will never apply kill files to articles that have
526 already been through the scoring process, which might very well save lots
529 (defvar gnus-extract-address-components 'gnus-extract-address-components
530 "*Function for extracting address components from a From header.
531 Two pre-defined function exist: `gnus-extract-address-components',
532 which is the default, quite fast, and too simplistic solution, and
533 `mail-extract-address-components', which works much better, but is
536 (defvar gnus-summary-default-score 0
537 "*Default article score level.
538 If this variable is nil, scoring will be disabled.")
540 (defvar gnus-summary-zcore-fuzz 0
541 "*Fuzziness factor for the zcore in the summary buffer.
542 Articles with scores closer than this to `gnus-summary-default-score'
543 will not be marked.")
545 (defvar gnus-simplify-subject-fuzzy-regexp nil
546 "*Regular expression that will be removed from subject strings if
547 fuzzy subject simplification is selected.")
549 (defvar gnus-group-default-list-level gnus-level-subscribed
550 "*Default listing level.
551 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
553 (defvar gnus-group-use-permanent-levels nil
554 "*If non-nil, once you set a level, Gnus will use this level.")
556 (defvar gnus-show-mime nil
557 "*If non-nil, do mime processing of articles.
558 The articles will simply be fed to the function given by
559 `gnus-show-mime-method'.")
561 (defvar gnus-strict-mime t
562 "*If nil, decode MIME header even if there is not Mime-Version field.")
564 (defvar gnus-show-mime-method (function metamail-buffer)
565 "*Function to process a MIME message.
566 The function is called from the article buffer.")
568 (defvar gnus-show-threads t
569 "*If non-nil, display threads in summary mode.")
571 (defvar gnus-thread-hide-subtree nil
572 "*If non-nil, hide all threads initially.
573 If threads are hidden, you have to run the command
574 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
575 to expose hidden threads.")
577 (defvar gnus-thread-hide-killed t
578 "*If non-nil, hide killed threads automatically.")
580 (defvar gnus-thread-ignore-subject nil
581 "*If non-nil, ignore subjects and do all threading based on the Reference header.
582 If nil, which is the default, articles that have different subjects
583 from their parents will start separate threads.")
585 (defvar gnus-thread-indent-level 4
586 "*Number that says how much each sub-thread should be indented.")
588 (defvar gnus-ignored-newsgroups
589 (purecopy (mapconcat 'identity
590 '("^to\\." ; not "real" groups
591 "^[0-9. \t]+ " ; all digits in name
592 "[][\"#'()]" ; bogus characters
595 "*A regexp to match uninteresting newsgroups in the active file.
596 Any lines in the active file matching this regular expression are
597 removed from the newsgroup list before anything else is done to it,
598 thus making them effectively non-existent.")
600 (defvar gnus-ignored-headers
601 "^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:"
602 "*All headers that match this regexp will be hidden.
603 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
605 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
606 "*All headers that do not match this regexp will be hidden.
607 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
609 (defvar gnus-sorted-header-list
610 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
611 "^Cc:" "^Date:" "^Organization:")
612 "*This variable is a list of regular expressions.
613 If it is non-nil, headers that match the regular expressions will
614 be placed first in the article buffer in the sequence specified by
617 (defvar gnus-show-all-headers nil
618 "*If non-nil, don't hide any headers.")
620 (defvar gnus-save-all-headers t
621 "*If non-nil, don't remove any headers before saving.")
623 (defvar gnus-inhibit-startup-message nil
624 "*If non-nil, the startup message will not be displayed.")
626 (defvar gnus-signature-separator "^-- *$"
627 "Regexp matching signature separator.")
629 (defvar gnus-auto-extend-newsgroup t
630 "*If non-nil, extend newsgroup forward and backward when requested.")
632 (defvar gnus-auto-select-first t
633 "*If non-nil, select the first unread article when entering a group.
634 If you want to prevent automatic selection of the first unread article
635 in some newsgroups, set the variable to nil in
636 `gnus-select-group-hook'.")
638 (defvar gnus-auto-select-next t
639 "*If non-nil, offer to go to the next group from the end of the previous.
640 If the value is t and the next newsgroup is empty, Gnus will exit
641 summary mode and go back to group mode. If the value is neither nil
642 nor t, Gnus will select the following unread newsgroup. In
643 particular, if the value is the symbol `quietly', the next unread
644 newsgroup will be selected without any confirmations.")
646 (defvar gnus-auto-select-same nil
647 "*If non-nil, select the next article with the same subject.")
649 (defvar gnus-summary-check-current nil
650 "*If non-nil, consider the current article when moving.
651 The \"unread\" movement commands will stay on the same line if the
652 current article is unread.")
654 (defvar gnus-auto-center-summary t
655 "*If non-nil, always center the current summary buffer.")
657 (defvar gnus-break-pages t
658 "*If non-nil, do page breaking on articles.
659 The page delimiter is specified by the `gnus-page-delimiter'
662 (defvar gnus-page-delimiter "^\^L"
663 "*Regexp describing what to use as article page delimiters.
664 The default value is \"^\^L\", which is a form linefeed at the
665 beginning of a line.")
667 (defvar gnus-use-full-window t
668 "*If non-nil, use the entire Emacs screen.")
670 (defvar gnus-window-configuration nil
671 "Obsolete variable. See `gnus-buffer-configuration'.")
673 (defvar gnus-buffer-configuration
674 '((group ([group 1.0 point]
675 (if gnus-carpal [group-carpal 4])))
676 (summary ([summary 1.0 point]
677 (if gnus-carpal [summary-carpal 4])))
678 (article ([summary 0.25 point]
679 (if gnus-carpal [summary-carpal 4])
681 (server ([server 1.0 point]
682 (if gnus-carpal [server-carpal 2])))
683 (browse ([browse 1.0 point]
684 (if gnus-carpal [browse-carpal 2])))
685 (group-mail ([mail 1.0 point]))
686 (summary-mail ([mail 1.0 point]))
687 (summary-reply ([article 0.5]
689 (info ([nil 1.0 point]))
690 (summary-faq ([summary 0.25]
692 (edit-group ([group 0.5]
693 [edit-group 1.0 point]))
694 (edit-server ([server 0.5]
695 [edit-server 1.0 point]))
696 (edit-score ([summary 0.25]
697 [edit-score 1.0 point]))
698 (post ([post 1.0 point]))
699 (reply ([article 0.5]
701 (mail-forward ([mail 1.0 point]))
702 (post-forward ([post 1.0 point]))
703 (reply-yank ([mail 1.0 point]))
704 (followup ([article 0.5]
706 (followup-yank ([post 1.0 point])))
707 "Window configuration for all possible Gnus buffers.
708 This variable is a list of lists. Each of these lists has a NAME and
709 a RULE. The NAMEs are commonsense names like `group', which names a
710 rule used when displaying the group buffer; `summary', which names a
711 rule for what happens when you enter a group and do not display an
712 article buffer; and so on. See the value of this variable for a
713 complete list of NAMEs.
715 Each RULE is a list of vectors. The first element in this vector is
716 the name of the buffer to be displayed; the second element is the
717 percentage of the screen this buffer is to occupy (a number in the
718 0.0-0.99 range); the optional third element is `point', which should
719 be present to denote which buffer point is to go to after making this
720 buffer configuration.")
722 (defvar gnus-window-to-buffer
723 '((group . gnus-group-buffer)
724 (summary . gnus-summary-buffer)
725 (article . gnus-article-buffer)
726 (server . gnus-server-buffer)
727 (browse . "*Gnus Browse Server*")
728 (edit-group . gnus-group-edit-buffer)
729 (edit-server . gnus-server-edit-buffer)
730 (group-carpal . gnus-carpal-group-buffer)
731 (summary-carpal . gnus-carpal-summary-buffer)
732 (server-carpal . gnus-carpal-server-buffer)
733 (browse-carpal . gnus-carpal-browse-buffer)
734 (edit-score . gnus-score-edit-buffer)
735 (mail . gnus-mail-buffer)
736 (post . gnus-post-news-buffer)
737 (faq . gnus-faq-buffer))
738 "Mapping from short symbols to buffer names or buffer variables.")
740 (defvar gnus-carpal nil
741 "*If non-nil, display clickable icons.")
743 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
744 "*Function called with a group name when new group is detected.
745 A few pre-made functions are supplied: `gnus-subscribe-randomly'
746 inserts new groups at the beginning of the list of groups;
747 `gnus-subscribe-alphabetically' inserts new groups in strict
748 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
749 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
752 ;; Suggested by a bug report by Hallvard B Furuseth.
753 ;; <h.b.furuseth@usit.uio.no>.
754 (defvar gnus-subscribe-options-newsgroup-method
755 (function gnus-subscribe-alphabetically)
756 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
757 If, for instance, you want to subscribe to all newsgroups in the
758 \"no\" and \"alt\" hierarchies, you'd put the following in your
761 options -n no.all alt.all
763 Gnus will the subscribe all new newsgroups in these hierarchies with
764 the subscription method in this variable.")
766 (defvar gnus-subscribe-hierarchical-interactive nil
767 "*If non-nil, Gnus will offer to subscribe hierarchically.
768 When a new hierarchy appears, Gnus will ask the user:
770 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
772 If the user pressed `d', Gnus will descend the hierarchy, `y' will
773 subscribe to all newsgroups in the hierarchy and `s' will skip this
774 hierarchy in its entirety.")
776 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
777 "*Function used for sorting the group buffer.
778 This function will be called with group info entries as the arguments
779 for the groups to be sorted. Pre-made functions include
780 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread' and
781 `gnus-group-sort-by-level'")
783 ;; Mark variables suggested by Thomas Michanek
784 ;; <Thomas.Michanek@telelogic.se>.
785 (defvar gnus-unread-mark ?
786 "*Mark used for unread articles.")
787 (defvar gnus-ticked-mark ?!
788 "*Mark used for ticked articles.")
789 (defvar gnus-dormant-mark ??
790 "*Mark used for dormant articles.")
791 (defvar gnus-del-mark ?r
792 "*Mark used for del'd articles.")
793 (defvar gnus-read-mark ?R
794 "*Mark used for read articles.")
795 (defvar gnus-expirable-mark ?E
796 "*Mark used for expirable articles.")
797 (defvar gnus-killed-mark ?K
798 "*Mark used for killed articles.")
799 (defvar gnus-kill-file-mark ?X
800 "*Mark used for articles killed by kill files.")
801 (defvar gnus-low-score-mark ?Y
802 "*Mark used for articles with a low score.")
803 (defvar gnus-catchup-mark ?C
804 "*Mark used for articles that are caught up.")
805 (defvar gnus-replied-mark ?A
806 "*Mark used for articles that have been replied to.")
807 (defvar gnus-process-mark ?#
809 (defvar gnus-ancient-mark ?O
810 "*Mark used for ancient articles.")
811 (defvar gnus-canceled-mark ?G
812 "*Mark used for canceled articles.")
813 (defvar gnus-score-over-mark ?+
814 "*Score mark used for articles with high scores.")
815 (defvar gnus-score-below-mark ?-
816 "*Score mark used for articles with low scores.")
817 (defvar gnus-empty-thread-mark ?
818 "*There is no thread under the article.")
819 (defvar gnus-not-empty-thread-mark ?=
820 "*There is a thread under the article.")
821 (defvar gnus-dummy-mark ?Z
822 "*This is a dummy article.")
824 (defvar gnus-view-pseudo-asynchronously nil
825 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
827 (defvar gnus-view-pseudos nil
828 "*If `automatic', pseudo-articles will be viewed automatically.
829 If `not-confirm', pseudos will be viewed automatically, and the user
830 will not be asked to confirm the command.")
832 (defvar gnus-view-pseudos-separately t
833 "*If non-nil, one pseudo-article will be created for each file to be viewed.
834 If nil, all files that use the same viewing command will be given as a
835 list of parameters to that command.")
837 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
838 "*Format of group lines.
839 It works along the same lines as a normal formatting string,
840 with some simple extensions.
842 %M Only marked articles (character, \"*\" or \" \")
843 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
844 %L Level of subscribedness (integer)
845 %N Number of unread articles (integer)
846 %I Number of dormant articles (integer)
847 %i Number of ticked and dormant (integer)
848 %T Number of ticked articles (integer)
849 %R Number of read articles (integer)
850 %t Total number of articles (integer)
851 %y Number of unread, unticked articles (integer)
852 %G Group name (string)
853 %g Qualified group name (string)
854 %D Group description (string)
855 %s Select method (string)
856 %o Moderated group (char, \"m\")
857 %p Process mark (char)
858 %O Moderated group (string, \"(m)\" or \"\")
859 %n Select from where (string)
860 %z A string that look like `<%s:%n>' if a foreign select method is used
861 %u User defined specifier. The next character in the format string should
862 be a letter. Gnus will call the function gnus-user-format-function-X,
863 where X is the letter following %u. The function will be passed the
864 current header as argument. The function should return a string, which
865 will be inserted into the buffer just like information from any other
868 Text between %( and %) will be highlighted with `gnus-mouse-face' when
869 the mouse point move inside the area. There can only be one such area.
871 Note that this format specification is not always respected. For
872 reasons of efficiency, when listing killed groups, this specification
873 is ignored altogether. If the spec is changed considerably, your
874 output may end up looking strange when listing both alive and killed
877 If you use %o or %O, reading the active file will be slower and quite
878 a bit of extra memory will be used. %D will also worsen performance.
879 Also note that if you change the format specification to include any
880 of these specs, you must probably re-start Gnus to see them go into
883 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
884 "*The format specification of the lines in the summary buffer.
886 It works along the same lines as a normal formatting string,
887 with some simple extensions.
889 %N Article number, left padded with spaces (string)
891 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
892 %n Name of the poster (string)
893 %a Extracted name of the poster (string)
894 %A Extracted address of the poster (string)
895 %F Contents of the From: header (string)
896 %x Contents of the Xref: header (string)
897 %D Date of the article (string)
898 %d Date of the article (string) in DD-MMM format
899 %M Message-id of the article (string)
900 %r References of the article (string)
901 %c Number of characters in the article (integer)
902 %L Number of lines in the article (integer)
903 %I Indentation based on thread level (a string of spaces)
904 %T A string with two possible values: 80 spaces if the article
905 is on thread level two or larger and 0 spaces on level one
906 %R \"R\" if this article has been replied to, \" \" otherwise (character)
907 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
908 %[ Opening bracket (character, \"[\" or \"<\")
909 %] Closing bracket (character, \"]\" or \">\")
910 %> Spaces of length thread-level (string)
911 %< Spaces of length (- 20 thread-level) (string)
912 %i Article score (number)
913 %z Article zcore (character)
914 %t Number of articles under the current thread (number).
915 %e Whether the thread is empty or not (character).
916 %u User defined specifier. The next character in the format string should
917 be a letter. Gnus will call the function gnus-user-format-function-X,
918 where X is the letter following %u. The function will be passed the
919 current header as argument. The function should return a string, which
920 will be inserted into the summary just like information from any other
923 Text between %( and %) will be highlighted with `gnus-mouse-face'
924 when the mouse point is placed inside the area. There can only be one
927 The %U (status), %R (replied) and %z (zcore) specs have to be handled
928 with care. For reasons of efficiency, Gnus will compute what column
929 these characters will end up in, and \"hard-code\" that. This means that
930 it is illegal to have these specs after a variable-length spec. Well,
931 you might not be arrested, but your summary buffer will look strange,
934 The smart choice is to have these specs as for to the left as
937 This restriction may disappear in later versions of Gnus.")
939 (defvar gnus-summary-dummy-line-format "* : : %S\n"
940 "*The format specification for the dummy roots in the summary buffer.
941 It works along the same lines as a normal formatting string,
942 with some simple extensions.
946 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
947 "*The format specification for the summary mode line.")
949 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
950 "*The format specification for the article mode line.")
952 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
953 "*The format specification for the group mode line.")
955 (defvar gnus-valid-select-methods
956 '(("nntp" post address prompt-address)
958 ("nnvirtual" none virtual prompt-address)
959 ("nnmbox" mail respool)
960 ("nnml" mail respool)
961 ("nnmh" mail respool)
962 ("nndir" none prompt-address address)
963 ("nneething" none prompt-address)
965 ("nndoc" none prompt-address)
966 ("nnbabyl" mail respool)
967 ("nnkiboze" post virtual)
969 ("nnfolder" mail respool))
970 "An alist of valid select methods.
971 The first element of each list lists should be a string with the name
972 of the select method. The other elements may be be the category of
973 this method (ie. `post', `mail', `none' or whatever) or other
974 properties that this method has (like being respoolable).
975 If you implement a new select method, all you should have to change is
976 this variable. I think.")
978 (defvar gnus-updated-mode-lines '(group article summary)
979 "*List of buffers that should update their mode lines.
980 The list may contain the symbols `group', `article' and `summary'. If
981 the corresponding symbol is present, Gnus will keep that mode line
982 updated with information that may be pertinent.
983 If this variable is nil, screen refresh may be quicker.")
985 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
986 (defvar gnus-mode-non-string-length 21
987 "*Max length of mode-line non-string contents.
988 If this is nil, Gnus will take space as is needed, leaving the rest
989 of the modeline intact.")
991 (defvar gnus-mouse-face 'highlight
992 "*Face used for mouse highlighting in Gnus.
993 No mouse highlights will be done if `gnus-visual' is nil.")
995 (defvar gnus-summary-mark-below nil
996 "*Mark all articles with a score below this variable as read.
997 This variable is local to each summary buffer and usually set by the
1000 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1001 "*List of functions used for sorting threads in the summary buffer.
1002 By default, threads are sorted by article number.
1004 Each function takes two threads and return non-nil if the first thread
1005 should be sorted before the other. If you use more than one function,
1006 the primary sort function should be the last.
1008 Ready-mady functions include `gnus-thread-sort-by-number',
1009 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1010 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1011 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1013 (defvar gnus-thread-score-function '+
1014 "*Function used for calculating the total score of a thread.
1016 The function is called with the scores of the article and each
1017 subthread and should then return the score of the thread.
1019 Some functions you can use are `+', `max', or `min'.")
1021 (defvar gnus-options-subscribe nil
1022 "*All new groups matching this regexp will be subscribed unconditionally.
1023 Note that this variable deals only with new newsgroups. This variable
1024 does not affect old newsgroups.")
1026 (defvar gnus-options-not-subscribe nil
1027 "*All new groups matching this regexp will be ignored.
1028 Note that this variable deals only with new newsgroups. This variable
1029 does not affect old (already subscribed) newsgroups.")
1031 (defvar gnus-auto-expirable-newsgroups nil
1032 "*Groups in which to automatically mark read articles as expirable.
1033 If non-nil, this should be a regexp that should match all groups in
1034 which to perform auto-expiry. This only makes sense for mail groups.")
1036 (defvar gnus-hidden-properties '(invisible t intangible t)
1037 "Property list to use for hiding text.")
1041 (defvar gnus-group-mode-hook nil
1042 "*A hook for Gnus group mode.")
1044 (defvar gnus-summary-mode-hook nil
1045 "*A hook for Gnus summary mode.
1046 This hook is run before any variables are set in the summary buffer.")
1048 (defvar gnus-article-mode-hook nil
1049 "*A hook for Gnus article mode.")
1051 (defun gnus-summary-prepare-exit-hook nil
1052 "*A hook called when preparing to exit from the summary buffer.
1053 It calls `gnus-summary-expire-articles' by default.")
1054 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1056 (defun gnus-summary-exit-hook nil
1057 "*A hook called on exit from the summary buffer.")
1059 (defvar gnus-open-server-hook nil
1060 "*A hook called just before opening connection to the news server.")
1062 (defvar gnus-startup-hook nil
1063 "*A hook called at startup.
1064 This hook is called after Gnus is connected to the NNTP server.")
1066 (defvar gnus-get-new-news-hook nil
1067 "*A hook run just before Gnus checks for new news.")
1069 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1070 "*A function that is called to generate the group buffer.
1071 The function is called with three arguments: The first is a number;
1072 all group with a level less or equal to that number should be listed,
1073 if the second is non-nil, empty groups should also be displayed. If
1074 the third is non-nil, it is a number. No groups with a level lower
1075 than this number should be displayed.
1077 The only current function implemented is `gnus-group-prepare-flat'.")
1079 (defvar gnus-group-prepare-hook nil
1080 "*A hook called after the group buffer has been generated.
1081 If you want to modify the group buffer, you can use this hook.")
1083 (defvar gnus-summary-prepare-hook nil
1084 "*A hook called after the summary buffer has been generated.
1085 If you want to modify the summary buffer, you can use this hook.")
1087 (defvar gnus-article-prepare-hook nil
1088 "*A hook called after an article has been prepared in the article buffer.
1089 If you want to run a special decoding program like nkf, use this hook.")
1091 (defvar gnus-article-display-hook nil
1092 "*A hook called after the article is displayed in the article buffer.
1093 The hook is designed to change the contents of the article
1094 buffer. Typical functions that this hook may contain are
1095 `gnus-article-hide-headers' (hide selected headers),
1096 `gnus-article-maybe-highlight' (perform fancy article highlighting),
1097 `gnus-article-hide-signature' (hide signature) and
1098 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1099 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1100 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1101 (add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1103 (defvar gnus-article-x-face-command
1104 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1105 "String or function to be executed to display an X-Face header.
1106 If it is a string, the command will be executed in a sub-shell
1107 asynchronously. The compressed face will be piped to this command.")
1109 (defvar gnus-article-x-face-too-ugly nil
1110 "Regexp matching posters whose face shouldn't be shown automatically.")
1112 (defvar gnus-select-group-hook nil
1113 "*A hook called when a newsgroup is selected.
1115 If you'd like to simplify subjects like the
1116 `gnus-summary-next-same-subject' command does, you can use the
1119 (setq gnus-select-group-hook
1122 (mapcar (lambda (header)
1125 (gnus-simplify-subject
1126 (header-subject header) 're-only)))
1127 gnus-newsgroup-headers))))")
1129 (defvar gnus-select-article-hook
1130 '(gnus-summary-show-thread)
1131 "*A hook called when an article is selected.
1132 The default hook shows conversation thread subtrees of the selected
1133 article automatically using `gnus-summary-show-thread'.")
1135 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1136 "*A hook called to apply kill files to a group.
1137 This hook is intended to apply a kill file to the selected newsgroup.
1138 The function `gnus-apply-kill-file' is called by default.
1140 Since a general kill file is too heavy to use only for a few
1141 newsgroups, I recommend you to use a lighter hook function. For
1142 example, if you'd like to apply a kill file to articles which contains
1143 a string `rmgroup' in subject in newsgroup `control', you can use the
1146 \(setq gnus-apply-kill-hook
1149 (cond ((string-match \"control\" gnus-newsgroup-name)
1150 (gnus-kill \"Subject\" \"rmgroup\")
1151 (gnus-expunge \"X\"))))))")
1153 (defvar gnus-visual-mark-article-hook
1154 (list 'gnus-highlight-selected-summary)
1155 "*Hook run after selecting an article in the summary buffer.
1156 It is meant to be used for highlighting the article in some way. It
1157 is not run if `gnus-visual' is nil.")
1159 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1160 "*A hook called after preparing body, but before preparing header headers.
1161 The default hook (`gnus-inews-insert-signature') inserts a signature
1162 file specified by the variable `gnus-signature-file'.")
1164 (defvar gnus-exit-group-hook nil
1165 "*A hook called when exiting (not quitting) summary mode.")
1167 (defvar gnus-suspend-gnus-hook nil
1168 "*A hook called when suspending (not exiting) Gnus.")
1170 (defvar gnus-exit-gnus-hook nil
1171 "*A hook called when exiting Gnus.")
1173 (defvar gnus-save-newsrc-hook nil
1174 "*A hook called when saving the newsrc file.")
1176 (defvar gnus-summary-update-hook
1177 (list 'gnus-summary-highlight-line)
1178 "*A hook called when a summary line is changed.
1179 The hook will not be called if `gnus-visual' is nil.
1181 The default function `gnus-summary-highlight-line' will
1182 highlight the line according to the `gnus-summary-highlight'
1185 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1186 "*A hook called when an article is selected for the first time.
1187 The hook is intended to mark an article as read (or unread)
1188 automatically when it is selected.")
1190 ;; Remove any hilit infestation.
1191 (add-hook 'gnus-startup-hook
1193 (remove-hook 'gnus-summary-prepare-hook
1194 'hilit-rehighlight-buffer-quietly)
1195 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1196 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1197 (remove-hook 'gnus-article-prepare-hook
1198 'hilit-rehighlight-buffer-quietly)))
1202 ;; Internal variables
1204 ;; Avoid highlighting in kill files.
1205 (defvar gnus-summary-inhibit-highlight nil)
1206 (defvar gnus-newsgroup-selected-overlay nil)
1208 (defvar gnus-article-mode-map nil)
1209 (defvar gnus-dribble-buffer nil)
1210 (defvar gnus-headers-retrieved-by nil)
1211 (defvar gnus-article-reply nil)
1212 (defvar gnus-override-method nil)
1213 (defvar gnus-article-check-size nil)
1215 (defvar gnus-current-score-file nil)
1216 (defvar gnus-internal-global-score-files nil)
1217 (defvar gnus-score-file-list nil)
1220 (defvar gnus-current-move-group nil)
1222 (defvar gnus-newsgroup-dependencies nil)
1223 (defvar gnus-newsgroup-threads nil)
1224 (defvar gnus-newsgroup-async nil)
1225 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1227 (defvar gnus-newsgroup-adaptive nil)
1229 (defvar gnus-summary-display-table nil)
1231 (defconst gnus-group-line-format-alist
1232 (list (list ?M 'marked ?c)
1233 (list ?S 'subscribed ?c)
1235 (list ?N 'number ?s)
1236 (list ?I 'number-of-dormant ?d)
1237 (list ?T 'number-of-ticked ?d)
1238 (list ?R 'number-of-read ?s)
1239 (list ?t 'number-total ?d)
1240 (list ?y 'number-of-unread-unticked ?s)
1241 (list ?i 'number-of-ticked-and-dormant ?d)
1243 (list ?G 'qualified-group ?s)
1244 (list ?D 'newsgroup-description ?s)
1245 (list ?o 'moderated ?c)
1246 (list ?O 'moderated-string ?s)
1247 (list ?p 'process-marked ?c)
1248 (list ?s 'news-server ?s)
1249 (list ?n 'news-method ?s)
1250 (list ?z 'news-method-string ?s)
1251 (list ?u 'user-defined ?s)))
1253 (defconst gnus-summary-line-format-alist
1254 (list (list ?N 'number ?d)
1255 (list ?S 'subject ?s)
1256 (list ?s 'subject-or-nil ?s)
1258 (list ?A '(car (cdr (funcall gnus-extract-address-components from)))
1260 (list ?a '(or (car (funcall gnus-extract-address-components from))
1263 (list ?x (macroexpand '(header-xref header)) ?s)
1264 (list ?D (macroexpand '(header-date header)) ?s)
1265 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1266 (list ?M (macroexpand '(header-id header)) ?s)
1267 (list ?r (macroexpand '(header-references header)) ?s)
1268 (list ?c '(or (header-chars header) 0) ?d)
1270 (list ?I 'indentation ?s)
1271 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1272 (list ?R 'replied ?c)
1273 (list ?\[ 'opening-bracket ?c)
1274 (list ?\] 'closing-bracket ?c)
1275 (list ?\> '(make-string level ? ) ?s)
1276 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1278 (list ?z 'score-char ?c)
1279 (list ?U 'unread ?c)
1280 (list ?t '(gnus-summary-number-of-articles-in-thread
1281 (and (boundp 'thread) (car thread)))
1283 (list ?e '(gnus-summary-number-of-articles-in-thread
1284 (and (boundp 'thread) (car thread)) t)
1286 (list ?u 'user-defined ?s))
1287 "An alist of format specifications that can appear in summary lines,
1288 and what variables they correspond with, along with the type of the
1289 variable (string, integer, character, etc).")
1291 (defconst gnus-summary-dummy-line-format-alist
1292 (list (list ?S 'subject ?s)
1293 (list ?N 'number ?d)
1294 (list ?u 'user-defined ?s)))
1296 (defconst gnus-summary-mode-line-format-alist
1297 (list (list ?G 'group-name ?s)
1298 (list ?g '(gnus-short-group-name group-name) ?s)
1299 (list ?A 'article-number ?d)
1300 (list ?Z 'unread-and-unselected ?s)
1301 (list ?V 'gnus-version ?s)
1302 (list ?U 'unread ?d)
1303 (list ?S 'subject ?s)
1304 (list ?e 'unselected ?d)
1305 (list ?u 'user-defined ?s)
1306 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1308 (defconst gnus-group-mode-line-format-alist
1309 (list (list ?S 'news-server ?s)
1310 (list ?M 'news-method ?s)
1311 (list ?u 'user-defined ?s)))
1313 (defvar gnus-have-read-active-file nil)
1315 (defconst gnus-maintainer
1316 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1317 "The mail address of the Gnus maintainers.")
1319 (defconst gnus-version "(ding) Gnus v0.99.15"
1320 "Version number for this version of Gnus.")
1322 (defvar gnus-info-nodes
1323 '((gnus-group-mode "(gnus)The Group Buffer")
1324 (gnus-summary-mode "(gnus)The Summary Buffer")
1325 (gnus-article-mode "(gnus)The Article Buffer"))
1326 "Assoc list of major modes and related Info nodes.")
1328 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1329 "The location of the (ding) Gnus documentation group.")
1331 (defvar gnus-group-buffer "*Group*")
1332 (defvar gnus-summary-buffer "*Summary*")
1333 (defvar gnus-article-buffer "*Article*")
1334 (defvar gnus-server-buffer "*Server*")
1336 (defvar gnus-work-buffer " *gnus work*")
1338 (defvar gnus-buffer-list nil
1339 "Gnus buffers that should be killed on exit.")
1341 (defvar gnus-server-alist nil
1342 "List of available servers.")
1344 (defvar gnus-variable-list
1345 '(gnus-newsrc-options gnus-newsrc-options-n
1346 gnus-newsrc-last-checked-date
1347 gnus-newsrc-alist gnus-server-alist
1348 gnus-killed-list gnus-zombie-list)
1349 "Gnus variables saved in the quick startup file.")
1351 (defvar gnus-overload-functions
1352 '((news-inews gnus-inews-news "rnewspost"))
1353 "Functions overloaded by gnus.
1354 It is a list of `(original overload &optional file)'.")
1356 (defvar gnus-newsrc-options nil
1357 "Options line in the .newsrc file.")
1359 (defvar gnus-newsrc-options-n nil
1360 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1362 (defvar gnus-newsrc-last-checked-date nil
1363 "Date Gnus last asked server for new newsgroups.")
1365 (defvar gnus-newsrc-alist nil
1366 "Assoc list of read articles.
1367 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1369 (defvar gnus-newsrc-hashtb nil
1370 "Hashtable of gnus-newsrc-alist.")
1372 (defvar gnus-killed-list nil
1373 "List of killed newsgroups.")
1375 (defvar gnus-killed-hashtb nil
1376 "Hash table equivalent of gnus-killed-list.")
1378 (defvar gnus-zombie-list nil
1379 "List of almost dead newsgroups.")
1381 (defvar gnus-description-hashtb nil
1382 "Descriptions of newsgroups.")
1384 (defvar gnus-list-of-killed-groups nil
1385 "List of newsgroups that have recently been killed by the user.")
1387 (defvar gnus-active-hashtb nil
1388 "Hashtable of active articles.")
1390 (defvar gnus-moderated-list nil
1391 "List of moderated newsgroups.")
1393 (defvar gnus-group-marked nil)
1395 (defvar gnus-current-startup-file nil
1396 "Startup file for the current host.")
1398 (defvar gnus-last-search-regexp nil
1399 "Default regexp for article search command.")
1401 (defvar gnus-last-shell-command nil
1402 "Default shell command on article.")
1404 (defvar gnus-current-select-method nil
1405 "The current method for selecting a newsgroup.")
1407 (defvar gnus-group-list-mode nil)
1409 (defvar gnus-article-internal-prepare-hook nil)
1411 (defvar gnus-newsgroup-name nil)
1412 (defvar gnus-newsgroup-begin nil)
1413 (defvar gnus-newsgroup-end nil)
1414 (defvar gnus-newsgroup-last-rmail nil)
1415 (defvar gnus-newsgroup-last-mail nil)
1416 (defvar gnus-newsgroup-last-folder nil)
1417 (defvar gnus-newsgroup-last-file nil)
1418 (defvar gnus-newsgroup-auto-expire nil)
1419 (defvar gnus-newsgroup-active nil)
1421 (defvar gnus-newsgroup-unreads nil
1422 "List of unread articles in the current newsgroup.")
1424 (defvar gnus-newsgroup-unselected nil
1425 "List of unselected unread articles in the current newsgroup.")
1427 (defvar gnus-newsgroup-reads nil
1428 "Alist of read articles and article marks in the current newsgroup.")
1430 (defvar gnus-newsgroup-marked nil
1431 "List of ticked articles in the current newsgroup (a subset of unread art).")
1433 (defvar gnus-newsgroup-killed nil
1434 "List of ranges of articles that have been through the scoring process.")
1436 (defvar gnus-newsgroup-kill-headers nil)
1438 (defvar gnus-newsgroup-replied nil
1439 "List of articles that have been replied to in the current newsgroup.")
1441 (defvar gnus-newsgroup-expirable nil
1442 "List of articles in the current newsgroup that can be expired.")
1444 (defvar gnus-newsgroup-processable nil
1445 "List of articles in the current newsgroup that can be processed.")
1447 (defvar gnus-newsgroup-bookmarks nil
1448 "List of articles in the current newsgroup that have bookmarks.")
1450 (defvar gnus-newsgroup-dormant nil
1451 "List of dormant articles in the current newsgroup.")
1453 (defvar gnus-newsgroup-scored nil
1454 "List of scored articles in the current newsgroup.")
1456 (defvar gnus-newsgroup-headers nil
1457 "List of article headers in the current newsgroup.")
1458 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1460 (defvar gnus-newsgroup-ancient nil
1461 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1463 (defvar gnus-current-article nil)
1464 (defvar gnus-article-current nil)
1465 (defvar gnus-current-headers nil)
1466 (defvar gnus-have-all-headers nil)
1467 (defvar gnus-last-article nil)
1468 (defvar gnus-newsgroup-history nil)
1469 (defvar gnus-current-kill-article nil)
1471 ;; Save window configuration.
1472 (defvar gnus-prev-winconf nil)
1475 (defvar gnus-summary-line-format-spec nil)
1476 (defvar gnus-summary-dummy-line-format-spec nil)
1477 (defvar gnus-group-line-format-spec nil)
1478 (defvar gnus-summary-mode-line-format-spec nil)
1479 (defvar gnus-article-mode-line-format-spec nil)
1480 (defvar gnus-group-mode-line-format-spec nil)
1481 (defvar gnus-summary-mark-positions nil)
1482 (defvar gnus-group-mark-positions nil)
1484 (defvar gnus-summary-expunge-below nil)
1485 (defvar gnus-reffed-article-number nil)
1487 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1488 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1490 (defvar gnus-cache-removeable-articles nil)
1492 (defconst gnus-summary-local-variables
1493 '(gnus-newsgroup-name
1494 gnus-newsgroup-begin gnus-newsgroup-end
1495 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1496 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1497 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1498 gnus-newsgroup-unselected gnus-newsgroup-marked
1499 gnus-newsgroup-reads
1500 gnus-newsgroup-replied gnus-newsgroup-expirable
1501 gnus-newsgroup-processable gnus-newsgroup-killed
1502 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1503 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1504 gnus-current-article gnus-current-headers gnus-have-all-headers
1505 gnus-last-article gnus-article-internal-prepare-hook
1506 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1507 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1508 gnus-newsgroup-threads gnus-newsgroup-async
1509 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1510 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1511 gnus-newsgroup-history gnus-newsgroup-ancient
1512 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1513 gnus-cache-removeable-articles)
1514 "Variables that are buffer-local to the summary buffers.")
1516 (defconst gnus-bug-message
1517 "Sending a bug report to the Gnus Towers.
1518 ========================================
1520 The buffer below is a mail buffer. When you press `C-c C-c', it will
1521 be sent to the Gnus Bug Exterminators.
1523 At the bottom of the buffer you'll see lots of variable settings.
1524 Please do not delete those. They will tell the Bug People what your
1525 environment is, so that it will be easier to locate the bugs.
1527 If you have found a bug that makes Emacs go \"beep\", set
1528 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1529 and include the backtrace in your bug report.
1531 Please describe the bug in annoying, painstaking detail.
1533 Thank you for your help in stamping out bugs.
1536 ;;; End of variables.
1538 ;; Define some autoload functions Gnus might use.
1542 (autoload 'metamail-buffer "metamail")
1543 (autoload 'Info-goto-node "info")
1544 (autoload 'hexl-hex-string-to-integer "hexl")
1546 (autoload 'pp-to-string "pp")
1547 (autoload 'pp-eval-expression "pp")
1548 (autoload 'mail-extract-address-components "mail-extr")
1550 (autoload 'nnmail-split-fancy "nnmail")
1551 (autoload 'nnvirtual-catchup-group "nnvirtual")
1554 (autoload 'timezone-make-date-arpa-standard "timezone")
1555 (autoload 'timezone-fix-time "timezone")
1556 (autoload 'timezone-make-sortable-date "timezone")
1557 (autoload 'timezone-make-time-string "timezone")
1560 (autoload 'mail-position-on-field "sendmail")
1561 (autoload 'mail-setup "sendmail")
1562 (autoload 'rmail-output "rmailout")
1563 (autoload 'news-mail-other-window "rnewspost")
1564 (autoload 'news-reply-yank-original "rnewspost")
1565 (autoload 'news-caesar-buffer-body "rnewspost")
1566 (autoload 'rmail-insert-rmail-file-header "rmail")
1567 (autoload 'rmail-count-new-messages "rmail")
1568 (autoload 'rmail-show-message "rmail")
1571 (autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1572 (autoload 'gnus-brew-soup "gnus-soup" nil t)
1573 (autoload 'gnus-soup-add-article "gnus-soup" nil t)
1574 (autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1575 (autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1576 (autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1577 (autoload 'nnsoup-pack-replies "nnsoup" nil t)
1580 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1581 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1582 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1583 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1584 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1585 (autoload 'gnus-Folder-save-name "gnus-mh")
1586 (autoload 'gnus-folder-save-name "gnus-mh")
1589 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1590 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1591 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1592 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1593 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1594 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1595 (autoload 'gnus-summary-highlight-line "gnus-vis")
1596 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1599 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1600 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1601 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1602 (autoload 'gnus-article-highlight-some "gnus-vis" nil t)
1603 (autoload 'gnus-article-hide "gnus-vis" nil t)
1604 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1605 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1606 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1607 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1608 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1609 (autoload 'gnus-article-add-button "gnus-vis")
1612 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1613 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1614 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1617 (autoload 'gnus-kill "gnus-kill")
1618 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1619 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1620 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1621 (autoload 'gnus-execute "gnus-kill")
1622 (autoload 'gnus-expunge "gnus-kill")
1625 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1626 (autoload 'gnus-cache-save-buffers "gnus-cache")
1627 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1628 (autoload 'gnus-cache-request-article "gnus-cache")
1629 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1630 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1631 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1632 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1635 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1636 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1637 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1638 (autoload 'gnus-score-save "gnus-score")
1639 (autoload 'gnus-score-headers "gnus-score")
1640 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1641 (autoload 'gnus-score-adaptive "gnus-score")
1642 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1643 (autoload 'gnus-score-find-trace "gnus-score")
1646 (autoload 'gnus-score-customize "gnus-edit" nil t)
1649 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1650 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1651 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1652 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1653 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1654 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1655 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1656 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1657 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1658 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1659 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1660 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1661 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1662 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1663 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1664 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1665 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1666 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1667 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1668 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1669 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1670 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1673 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1674 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1675 (autoload 'gnus-group-mail "gnus-msg" nil t)
1676 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1677 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1678 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1679 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1680 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1681 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1682 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1683 (autoload 'gnus-post-news "gnus-msg" nil t)
1684 (autoload 'gnus-inews-news "gnus-msg" nil t)
1685 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1686 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1687 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1688 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1689 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1690 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1691 (autoload 'gnus-mail-yank-original "gnus-msg")
1692 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1693 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1694 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1695 (autoload 'gnus-article-mail-with-original "gnus-msg")
1696 (autoload 'gnus-article-mail "gnus-msg")
1697 (autoload 'gnus-bug "gnus-msg" nil t)
1700 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1701 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1702 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1703 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1704 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1705 (autoload 'gnus-yank-article "gnus-vm" nil t)
1711 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1712 ;; If you want the cursor to go somewhere else, set these two
1713 ;; functions in some startup hook to whatever you want.
1714 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1715 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1717 ;;; Various macros and substs.
1719 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1720 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1721 (` (let ((GnusStartBufferWindow (selected-window)))
1724 (pop-to-buffer (, buffer))
1726 (select-window GnusStartBufferWindow)))))
1728 (defmacro gnus-gethash (string hashtable)
1729 "Get hash value of STRING in HASHTABLE."
1730 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1731 ;;(` (abbrev-expansion (, string) (, hashtable)))
1732 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1734 (defmacro gnus-sethash (string value hashtable)
1735 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1736 ;; We cannot use define-abbrev since it only accepts string as value.
1737 ;; (set (intern string hashtable) value))
1738 (` (set (intern (, string) (, hashtable)) (, value))))
1740 (defsubst gnus-buffer-substring (beg end)
1741 (buffer-substring (match-beginning beg) (match-end end)))
1743 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1744 ;; function `substring' might cut on a middle of multi-octet
1746 (defun gnus-truncate-string (str width)
1747 (substring str 0 width))
1749 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1750 ;; to limit the length of a string. This function is necessary since
1751 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1752 (defsubst gnus-limit-string (str width)
1753 (if (> (length str) width)
1754 (substring str 0 width)
1757 (defsubst gnus-simplify-subject-re (subject)
1758 "Remove \"Re:\" from subject lines."
1759 (let ((case-fold-search t))
1760 (if (string-match "^re: *" subject)
1761 (substring subject (match-end 0))
1764 (defsubst gnus-goto-char (point)
1765 (and point (goto-char point)))
1767 (defmacro gnus-buffer-exists-p (buffer)
1769 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1772 (defmacro gnus-kill-buffer (buffer)
1773 (` (if (gnus-buffer-exists-p (, buffer))
1774 (kill-buffer (, buffer)))))
1776 (defsubst gnus-point-at-bol ()
1777 "Return point at the beginning of line."
1784 (defsubst gnus-point-at-eol ()
1785 "Return point at the beginning of line."
1792 ;; Delete the current line (and the next N lines.);
1793 (defmacro gnus-delete-line (&optional n)
1794 (` (delete-region (progn (beginning-of-line) (point))
1795 (progn (forward-line (, (or n 1))) (point)))))
1797 ;;; Load the compatability functions.
1803 ;;; Gnus Utility Functions
1806 (defun gnus-extract-address-components (from)
1808 ;; First find the address - the thing with the @ in it. This may
1809 ;; not be accurate in mail addresses, but does the trick most of
1810 ;; the time in news messages.
1811 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1812 (setq address (substring from (match-beginning 0) (match-end 0))))
1813 ;; Then we check whether the "name <address>" format is used.
1815 (string-match (concat "<" (regexp-quote address) ">") from)
1816 (and (setq name (substring from 0 (1- (match-beginning 0))))
1817 ;; Strip any quotes from the name.
1818 (string-match "\".*\"" name)
1819 (setq name (substring name 1 (1- (match-end 0))))))
1820 ;; If not, then "address (name)" is used.
1822 (and (string-match "(.+)" from)
1823 (setq name (substring from (1+ (match-beginning 0))
1824 (1- (match-end 0)))))
1825 (and (string-match "()" from)
1826 (setq name address))
1827 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1828 ;; XOVER might not support folded From headers.
1829 (and (string-match "(.*" from)
1830 (setq name (substring from (1+ (match-beginning 0))
1832 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1833 (list (or name from) (or address from))))
1835 (defun gnus-fetch-field (field)
1836 "Return the value of the header FIELD of current article."
1839 (let ((case-fold-search t))
1840 (gnus-narrow-to-headers)
1841 (mail-fetch-field field)))))
1843 (defun gnus-goto-colon ()
1845 (search-forward ":" (gnus-point-at-eol) t))
1847 (defun gnus-narrow-to-headers ()
1851 (goto-char (point-min))
1852 (if (search-forward "\n\n" nil t)
1856 (defvar gnus-old-specs nil)
1858 (defun gnus-update-format-specifications ()
1859 (gnus-make-thread-indent-array)
1861 (let ((formats '(summary summary-dummy group
1862 summary-mode group-mode article-mode))
1863 old-format new-format)
1865 (setq new-format (symbol-value
1866 (intern (format "gnus-%s-line-format" (car formats)))))
1867 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs)))
1868 (equal old-format new-format))
1869 (set (intern (format "gnus-%s-line-format-spec" (car formats)))
1873 (intern (format "gnus-%s-line-format-alist"
1874 (if (eq (car formats) 'article-mode)
1875 'summary-mode (car formats))))))))
1876 (setq gnus-old-specs (cons (cons (car formats) new-format)
1877 (delq (car formats) gnus-old-specs)))
1878 (setq formats (cdr formats))))
1880 (gnus-update-group-mark-positions)
1881 (gnus-update-summary-mark-positions)
1883 (if (and (string-match "%D" gnus-group-line-format)
1884 (not gnus-description-hashtb)
1885 gnus-read-active-file)
1886 (gnus-read-all-descriptions-files)))
1888 (defun gnus-update-summary-mark-positions ()
1890 (let ((gnus-replied-mark 129)
1891 (gnus-score-below-mark 130)
1892 (gnus-score-over-mark 130)
1895 (gnus-set-work-buffer)
1896 (gnus-summary-insert-line
1897 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1898 (goto-char (point-min))
1899 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1901 (goto-char (point-min))
1902 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1903 (- (point) 2))) pos))
1904 (goto-char (point-min))
1905 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1906 (- (point) 2))) pos))
1907 (setq gnus-summary-mark-positions pos))))
1909 (defun gnus-update-group-mark-positions ()
1911 (let ((gnus-process-mark 128)
1912 (gnus-group-marked '("dummy.group")))
1913 (gnus-set-work-buffer)
1914 (gnus-group-insert-group-line nil "dummy.group" 0 nil 0 nil)
1915 (goto-char (point-min))
1916 (setq gnus-group-mark-positions
1917 (list (cons 'process (and (search-forward "\200" nil t)
1918 (- (point) 2))))))))
1920 (defun gnus-mouse-face-function (form)
1921 (` (let ((string (, form)))
1922 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1925 (defun gnus-max-width-function (el max-width)
1926 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
1927 (` (let* ((val (eval (, el)))
1928 (valstr (if (numberp val)
1929 (int-to-string val) val)))
1930 (if (> (length valstr) (, max-width))
1931 (substring valstr 0 (, max-width))
1934 (defun gnus-parse-format (format spec-alist)
1935 ;; This function parses the FORMAT string with the help of the
1936 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1937 ;; string. If the FORMAT string contains the specifiers %( and %)
1938 ;; the text between them will have the mouse-face text property.
1939 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1940 (if (and gnus-visual gnus-mouse-face)
1941 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1942 (button (substring format (match-beginning 2) (match-end 2)))
1943 (post (substring format (match-beginning 3) (match-end 3))))
1945 (gnus-parse-simple-format pre spec-alist)
1946 (gnus-mouse-face-function
1947 (gnus-parse-simple-format button spec-alist))
1948 (gnus-parse-simple-format post spec-alist)))
1949 (gnus-parse-simple-format
1950 (concat (substring format (match-beginning 1) (match-end 1))
1951 (substring format (match-beginning 2) (match-end 2))
1952 (substring format (match-beginning 3) (match-end 3)))
1954 (gnus-parse-simple-format format spec-alist)))
1956 (defun gnus-parse-simple-format (format spec-alist)
1957 ;; This function parses the FORMAT string with the help of the
1958 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1959 ;; string. The list will consist of the symbol `format', a format
1960 ;; specification string, and a list of forms depending on the
1963 spec flist fstring newspec elem beg)
1965 (gnus-set-work-buffer)
1967 (goto-char (point-min))
1968 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1969 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1971 ;; First check if there are any specs that look anything like
1972 ;; "%12,12A", ie. with a "max width specification". These have
1973 ;; to be treated specially.
1974 (if (setq beg (match-beginning 1))
1977 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1979 (setq beg (match-beginning 2)))
1980 ;; Find the specification from `spec-alist'.
1981 (if (not (setq elem (cdr (assq spec spec-alist))))
1982 (setq elem '("*" ?s)))
1983 ;; Treat user defined format specifiers specially
1984 (and (eq (car elem) 'user-defined)
1987 (list (intern (concat "gnus-user-format-function-"
1993 (delete-region (match-beginning 3) (match-end 3)))
1994 (if (not (zerop max-width))
1995 (let ((el (car elem)))
1996 (cond ((= (car (cdr elem)) ?c)
1997 (setq el (list 'char-to-string el)))
1998 ((= (car (cdr elem)) ?d)
1999 (numberp el) (setq el (list 'int-to-string el))))
2000 (setq flist (cons (gnus-max-width-function el max-width)
2003 (setq flist (cons (car elem) flist))
2004 (setq newspec (car (cdr elem))))
2005 ;; Remove the old specification (and possibly a ",12" string).
2006 (delete-region beg (match-end 2))
2007 ;; Insert the new specification.
2010 (setq fstring (buffer-substring 1 (point-max))))
2011 (cons 'format (cons fstring (nreverse flist)))))
2013 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2014 (defun gnus-read-init-file ()
2016 (or (and (file-exists-p gnus-init-file)
2017 ;; Don't try to load a directory.
2018 (not (file-directory-p gnus-init-file)))
2019 (file-exists-p (concat gnus-init-file ".el"))
2020 (file-exists-p (concat gnus-init-file ".elc")))
2021 (load gnus-init-file nil t)))
2023 (defun gnus-set-work-buffer ()
2024 (if (get-buffer gnus-work-buffer)
2026 (set-buffer gnus-work-buffer)
2028 (set-buffer (get-buffer-create gnus-work-buffer))
2029 (kill-all-local-variables)
2030 (buffer-disable-undo (current-buffer))
2031 (gnus-add-current-to-buffer-list)))
2033 ;; Article file names when saving.
2035 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2036 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2037 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2038 Otherwise, it is like ~/News/news/group/num."
2041 (concat (if (gnus-use-long-file-name 'not-save)
2042 (gnus-capitalize-newsgroup newsgroup)
2043 (gnus-newsgroup-directory-form newsgroup))
2044 "/" (int-to-string (header-number headers)))
2045 (or gnus-article-save-directory "~/News"))))
2047 (string-equal (file-name-directory default)
2048 (file-name-directory last-file))
2049 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2051 (or last-file default))))
2053 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2054 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2055 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
2056 Otherwise, it is like ~/News/news/group/num."
2059 (concat (if (gnus-use-long-file-name 'not-save)
2061 (gnus-newsgroup-directory-form newsgroup))
2062 "/" (int-to-string (header-number headers)))
2063 (or gnus-article-save-directory "~/News"))))
2065 (string-equal (file-name-directory default)
2066 (file-name-directory last-file))
2067 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2069 (or last-file default))))
2071 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2072 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2073 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
2074 Otherwise, it is like ~/News/news/group/news."
2077 (if (gnus-use-long-file-name 'not-save)
2078 (gnus-capitalize-newsgroup newsgroup)
2079 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2080 (or gnus-article-save-directory "~/News"))))
2082 (defun gnus-plain-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.
2085 Otherwise, it is like ~/News/news/group/news."
2088 (if (gnus-use-long-file-name 'not-save)
2090 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2091 (or gnus-article-save-directory "~/News"))))
2093 ;; For subscribing new newsgroup
2095 (defun gnus-subscribe-hierarchical-interactive (groups)
2096 (let ((groups (sort groups 'string<))
2097 prefixes prefix start ans group starts)
2099 (setq prefixes (list "^"))
2100 (while (and groups prefixes)
2101 (while (not (string-match (car prefixes) (car groups)))
2102 (setq prefixes (cdr prefixes)))
2103 (setq prefix (car prefixes))
2104 (setq start (1- (length prefix)))
2105 (if (and (string-match "[^\\.]\\." (car groups) start)
2108 (concat "^" (substring (car groups) 0 (match-end 0))))
2109 (string-match prefix (car (cdr groups))))
2111 (setq prefixes (cons prefix prefixes))
2112 (message "Descend hierarchy %s? ([y]nsq): "
2113 (substring prefix 1 (1- (length prefix))))
2114 (setq ans (read-char))
2117 (string-match prefix
2118 (setq group (car groups))))
2119 (setq gnus-killed-list
2120 (cons group gnus-killed-list))
2121 (gnus-sethash group group gnus-killed-hashtb)
2122 (setq groups (cdr groups)))
2123 (setq starts (cdr starts)))
2126 (string-match prefix
2127 (setq group (car groups))))
2128 (gnus-sethash group group gnus-killed-hashtb)
2129 (gnus-subscribe-alphabetically (car groups))
2130 (setq groups (cdr groups)))
2131 (setq starts (cdr starts)))
2134 (setq group (car groups))
2135 (setq gnus-killed-list (cons group gnus-killed-list))
2136 (gnus-sethash group group gnus-killed-hashtb)
2137 (setq groups (cdr groups))))
2139 (message "Subscribe %s? ([n]yq)" (car groups))
2140 (setq ans (read-char))
2141 (setq group (car groups))
2143 (gnus-subscribe-alphabetically (car groups))
2144 (gnus-sethash group group gnus-killed-hashtb))
2147 (setq group (car groups))
2148 (setq gnus-killed-list (cons group gnus-killed-list))
2149 (gnus-sethash group group gnus-killed-hashtb)
2150 (setq groups (cdr groups))))
2152 (setq gnus-killed-list (cons group gnus-killed-list))
2153 (gnus-sethash group group gnus-killed-hashtb)))
2154 (setq groups (cdr groups)))))))
2156 (defun gnus-subscribe-randomly (newsgroup)
2157 "Subscribe new NEWSGROUP by making it the first newsgroup."
2158 (gnus-subscribe-newsgroup newsgroup))
2160 (defun gnus-subscribe-alphabetically (newgroup)
2161 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2162 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2163 (let ((groups (cdr gnus-newsrc-alist))
2165 (while (and (not before) groups)
2166 (if (string< newgroup (car (car groups)))
2167 (setq before (car (car groups)))
2168 (setq groups (cdr groups))))
2169 (gnus-subscribe-newsgroup newgroup before)))
2171 (defun gnus-subscribe-hierarchically (newgroup)
2172 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2173 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2175 (set-buffer (find-file-noselect gnus-current-startup-file))
2176 (let ((groupkey newgroup)
2178 (while (and (not before) groupkey)
2179 (goto-char (point-min))
2181 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2182 (while (and (re-search-forward groupkey-re nil t)
2184 (setq before (buffer-substring
2185 (match-beginning 1) (match-end 1)))
2186 (string< before newgroup)))))
2187 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2189 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2190 (substring groupkey (match-beginning 1) (match-end 1)))))
2191 (gnus-subscribe-newsgroup newgroup before))))
2193 (defun gnus-subscribe-interactively (newsgroup)
2194 "Subscribe new NEWSGROUP interactively.
2195 It is inserted in hierarchical newsgroup order if subscribed. If not,
2197 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2198 (gnus-subscribe-hierarchically newsgroup)
2199 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2201 (defun gnus-subscribe-zombies (newsgroup)
2202 "Make new NEWSGROUP a zombie group."
2203 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2205 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2206 "Subscribe new NEWSGROUP.
2207 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2208 the first newsgroup."
2209 ;; We subscribe the group by changing its level to `subscribed'.
2210 (gnus-group-change-level
2211 newsgroup gnus-level-default-subscribed
2212 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2213 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2217 (defun gnus-newsgroup-directory-form (newsgroup)
2218 "Make hierarchical directory name from NEWSGROUP name."
2219 (let ((newsgroup (gnus-newsgroup-saveable-name newsgroup))
2220 (len (length newsgroup))
2222 ;; If this is a foreign group, we don't want to translate the
2224 (if (setq idx (string-match ":" newsgroup))
2225 (aset newsgroup idx ?/)
2227 ;; Replace all occurrences of `.' with `/'.
2229 (if (= (aref newsgroup idx) ?.)
2230 (aset newsgroup idx ?/))
2231 (setq idx (1+ idx)))
2234 (defun gnus-newsgroup-saveable-name (group)
2235 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2237 (gnus-replace-chars-in-string group ?/ ?.))
2239 (defun gnus-make-directory (dir)
2240 "Make DIRECTORY recursively."
2241 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2242 ;; of the many mysteries of the universe.
2243 (let* ((dir (expand-file-name dir default-directory))
2245 (if (string-match "/$" dir)
2246 (setq dir (substring dir 0 (match-beginning 0))))
2247 ;; First go down the path until we find a directory that exists.
2248 (while (not (file-exists-p dir))
2249 (setq dirs (cons dir dirs))
2250 (string-match "/[^/]+$" dir)
2251 (setq dir (substring dir 0 (match-beginning 0))))
2252 ;; Then create all the subdirs.
2253 (while (and dirs (not err))
2255 (make-directory (car dirs))
2256 (error (setq err t)))
2257 (setq dirs (cdr dirs)))
2258 ;; We return whether we were successful or not.
2261 (defun gnus-capitalize-newsgroup (newsgroup)
2262 "Capitalize NEWSGROUP name."
2263 (and (not (zerop (length newsgroup)))
2264 (concat (char-to-string (upcase (aref newsgroup 0)))
2265 (substring newsgroup 1))))
2269 (defun gnus-simplify-subject (subject &optional re-only)
2270 "Remove `Re:' and words in parentheses.
2271 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2272 (let ((case-fold-search t)) ;Ignore case.
2273 ;; Remove `Re:' and `Re^N:'.
2274 (if (string-match "^re:[ \t]*" subject)
2275 (setq subject (substring subject (match-end 0))))
2276 ;; Remove words in parentheses from end.
2278 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2279 (setq subject (substring subject 0 (match-beginning 0)))))
2280 ;; Return subject string.
2283 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2285 (defun gnus-simplify-subject-fuzzy (subject)
2286 (let ((case-fold-search t))
2288 (gnus-set-work-buffer)
2290 (inline (gnus-simplify-buffer-fuzzy))
2293 (defun gnus-simplify-buffer-fuzzy ()
2294 (goto-char (point-min))
2295 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2296 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2298 (replace-match "" t t))
2299 (goto-char (point-min))
2300 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2301 (replace-match "" t t))
2302 (goto-char (point-min))
2303 (while (re-search-forward "[ \t]+" nil t)
2304 (replace-match " " t t))
2305 (goto-char (point-min))
2306 (while (re-search-forward "[ \t]+$" nil t)
2307 (replace-match "" t t))
2308 (goto-char (point-min))
2309 (while (re-search-forward "^[ \t]+" nil t)
2310 (replace-match "" t t))
2311 (if gnus-simplify-subject-fuzzy-regexp
2312 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2313 (replace-match "" t t))))
2315 ;; Add the current buffer to the list of buffers to be killed on exit.
2316 (defun gnus-add-current-to-buffer-list ()
2317 (or (memq (current-buffer) gnus-buffer-list)
2318 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2320 (defun gnus-string> (s1 s2)
2321 (not (or (string< s1 s2)
2324 ;; Functions accessing headers.
2325 ;; Functions are more convenient than macros in some cases.
2327 (defun gnus-header-number (header)
2328 (header-number header))
2330 (defun gnus-header-subject (header)
2331 (header-subject header))
2333 (defun gnus-header-from (header)
2334 (header-from header))
2336 (defun gnus-header-xref (header)
2337 (header-xref header))
2339 (defun gnus-header-lines (header)
2340 (header-lines header))
2342 (defun gnus-header-date (header)
2343 (header-date header))
2345 (defun gnus-header-id (header)
2348 (defun gnus-header-references (header)
2349 (header-references header))
2351 ;;; General various misc type functions.
2353 (defun gnus-clear-system ()
2354 "Clear all variables and buffers."
2355 ;; Clear Gnus variables.
2356 (let ((variables gnus-variable-list))
2358 (set (car variables) nil)
2359 (setq variables (cdr variables))))
2360 ;; Clear other internal variables.
2361 (setq gnus-list-of-killed-groups nil
2362 gnus-have-read-active-file nil
2363 gnus-newsrc-alist nil
2364 gnus-newsrc-hashtb nil
2365 gnus-killed-list nil
2366 gnus-zombie-list nil
2367 gnus-killed-hashtb nil
2368 gnus-active-hashtb nil
2369 gnus-moderated-list nil
2370 gnus-description-hashtb nil
2371 gnus-newsgroup-headers nil
2372 gnus-newsgroup-headers-hashtb-by-number nil
2373 gnus-newsgroup-name nil
2374 gnus-server-alist nil
2375 gnus-current-select-method nil)
2376 ;; Reset any score variables.
2377 (and (boundp 'gnus-score-cache)
2378 (set 'gnus-score-cache nil))
2379 (and (boundp 'gnus-internal-global-score-files)
2380 (set 'gnus-internal-global-score-files nil))
2381 ;; Kill the startup file.
2382 (and gnus-current-startup-file
2383 (get-file-buffer gnus-current-startup-file)
2384 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2385 ;; Save any cache buffers.
2386 (and gnus-use-cache (gnus-cache-save-buffers))
2387 ;; Clear the dribble buffer.
2388 (gnus-dribble-clear)
2389 ;; Kill global KILL file buffer.
2390 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2391 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2392 (gnus-kill-buffer nntp-server-buffer)
2393 ;; Kill Gnus buffers.
2394 (while gnus-buffer-list
2395 (gnus-kill-buffer (car gnus-buffer-list))
2396 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2398 (defun gnus-windows-old-to-new (setting)
2399 (if (symbolp setting)
2401 (cond ((eq setting 'SelectArticle)
2403 ((eq setting 'SelectSubject)
2405 ((eq setting 'SelectNewsgroup)
2408 (if (or (listp setting)
2409 (not (and gnus-window-configuration
2410 (memq setting '(group summary article)))))
2412 (let* ((setting (if (eq setting 'group)
2413 (if (assq 'newsgroup gnus-window-configuration)
2415 'newsgroups) setting))
2416 (elem (car (cdr (assq setting gnus-window-configuration))))
2417 (total (apply '+ elem))
2418 (types '(group summary article))
2419 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2424 (or (zerop (nth i elem))
2426 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2427 (setq out (cons (if (eq pbuf (nth i types))
2428 (vector (nth i types) perc 'point)
2429 (vector (nth i types) perc))
2432 (list (nreverse out)))))
2434 (defun gnus-add-configuration (conf)
2435 (setq gnus-buffer-configuration
2436 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2437 gnus-buffer-configuration))))
2439 (defun gnus-configure-windows (setting &optional force)
2440 (setq setting (gnus-windows-old-to-new setting))
2441 (let ((r (if (symbolp setting)
2442 (cdr (assq setting gnus-buffer-configuration))
2444 (in-buf (current-buffer))
2445 rule val w height hor ohor heights sub jump-buffer
2446 rel total to-buf all-visible)
2447 (or r (error "No such setting: %s" setting))
2449 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r)))
2450 ;; All the windows mentioned are already visibe, so we just
2451 ;; put point in the assigned buffer, and do not touch the
2453 (select-window (get-buffer-window all-visible))
2455 ;; Either remove all windows or just remove all Gnus windows.
2456 (if gnus-use-full-window
2457 (delete-other-windows)
2458 (gnus-remove-some-windows)
2459 (switch-to-buffer nntp-server-buffer))
2465 ;; We have to do the (possible) horizontal splitting before the
2467 (if (and (listp (car hor))
2468 (eq (car (car hor)) 'horizontal))
2472 (if (integerp (nth 1 (car hor)))
2474 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2476 (setq hor (cdr hor))))
2478 ;; Go through the rules and eval the elements that are to be
2481 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2483 ;; Expand short buffer name.
2484 (setq w (aref val 0))
2485 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2487 (setq val (apply 'vector (mapcar 'identity val)))
2489 (setq ohor (cons val ohor))))
2490 (setq hor (cdr hor)))
2491 (setq rule (cons (nreverse ohor) rule))
2493 (setq rule (nreverse rule))
2495 ;; We tally the window sizes.
2496 (setq total (window-height))
2498 (setq hor (car rule))
2499 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2500 (setq hor (cdr hor)))
2503 (setq rel (aref (car hor) 1)
2505 (cond ((and (floatp rel) (= 1.0 rel))
2510 (max (floor (* total rel)) 4)))
2512 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2514 (setq heights (nreverse heights)
2517 ;; We then go through these heighs and create windows for them.
2519 (setq height (car heights)
2520 heights (cdr heights))
2522 (setq height (- total sub)))
2524 (split-window nil height))
2525 (setq to-buf (aref (car hor) 0))
2530 (symbol-value (aref (car hor) 0)))
2532 (aref (car hor) 0))))
2533 (and (> (length (car hor)) 2)
2534 (eq (aref (car hor) 2) 'point)
2535 (setq jump-buffer (current-buffer)))
2537 (setq hor (cdr hor)))
2539 (setq rule (cdr rule)))
2541 ;; Finally, we pop to the buffer that's supposed to have point.
2542 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2544 (select-window (get-buffer-window jump-buffer))
2545 (set-buffer jump-buffer))))
2547 (defun gnus-all-windows-visible-p (rule)
2548 (let (invisible hor jump-buffer val buffer)
2549 ;; Go through the rules and eval the elements that are to be
2551 (while (and rule (not invisible))
2552 (setq hor (car rule)
2554 (while (and hor (not invisible))
2555 (if (setq val (if (vectorp (car hor))
2557 (if (not (eq (car (car hor)) 'horizontal))
2560 ;; Expand short buffer name.
2561 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer))
2563 (setq buffer (if (symbolp buffer) (symbol-value buffer)
2565 (and (> (length val) 2) (eq 'point (aref val 2))
2566 (setq jump-buffer buffer))
2567 (setq invisible (not (and buffer (get-buffer-window buffer))))))
2568 (setq hor (cdr hor))))
2569 (and (not invisible) jump-buffer)))
2571 (defun gnus-window-left-corner (&optional window)
2572 (nth 1 (window-edges window)))
2574 (defun gnus-remove-some-windows ()
2575 (let ((buffers gnus-window-to-buffer)
2576 (lowest (frame-height))
2577 buf bufs lowest-buf)
2579 ;; Remove windows on all known Gnus buffers.
2581 (setq buf (cdr (car buffers)))
2583 (setq buf (and (boundp buf) (symbol-value buf))))
2585 (get-buffer-window buf)
2587 (setq bufs (cons buf bufs))
2589 (if (< (gnus-window-left-corner) lowest)
2591 (setq lowest (gnus-window-left-corner))
2592 (setq lowest-buf buf)))))
2593 (setq buffers (cdr buffers)))
2594 ;; Remove windows on *all* summary buffers.
2598 (let ((buf (window-buffer win)))
2599 (if (string-match "^\\*Summary" (buffer-name buf))
2601 (setq bufs (cons buf bufs))
2603 (if (< (gnus-window-left-corner) lowest)
2605 (setq lowest-buf buf)
2606 (setq lowest (gnus-window-left-corner))))))))))
2609 (pop-to-buffer lowest-buf)
2610 (switch-to-buffer nntp-server-buffer)))
2612 (and (not (eq (car bufs) lowest-buf))
2613 (delete-windows-on (car bufs)))
2614 (setq bufs (cdr bufs))))))
2616 (defun gnus-version ()
2617 "Version numbers of this version of Gnus."
2619 (let ((methods gnus-valid-select-methods)
2622 ;; Go through all the legal select methods and add their version
2623 ;; numbers to the total version string. Only the backends that are
2624 ;; currently in use will have their message numbers taken into
2627 (setq meth (intern (concat (car (car methods)) "-version")))
2629 (stringp (symbol-value meth))
2630 (setq mess (concat mess "; " (symbol-value meth))))
2631 (setq methods (cdr methods)))
2632 (gnus-message 2 mess)))
2634 (defun gnus-info-find-node ()
2635 "Find Info documentation of Gnus."
2637 ;; Enlarge info window if needed.
2638 (let ((mode major-mode))
2639 (gnus-configure-windows 'info)
2640 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2642 (defun gnus-overload-functions (&optional overloads)
2643 "Overload functions specified by optional argument OVERLOADS.
2644 If nothing is specified, use the variable gnus-overload-functions."
2646 (overloads (or overloads gnus-overload-functions)))
2648 (setq defs (car overloads))
2649 (setq overloads (cdr overloads))
2650 ;; Load file before overloading function if necessary. Make
2651 ;; sure we cannot use `require' always.
2652 (and (not (fboundp (car defs)))
2653 (car (cdr (cdr defs)))
2654 (load (car (cdr (cdr defs))) nil 'nomessage))
2655 (fset (car defs) (car (cdr defs))))))
2657 (defun gnus-replace-chars-in-string (string from to)
2658 "Replace characters in STRING from FROM to TO."
2659 (let ((string (substring string 0)) ;Copy string.
2660 (len (length string))
2662 ;; Replace all occurrences of FROM with TO.
2664 (if (= (aref string idx) from)
2665 (aset string idx to))
2666 (setq idx (1+ idx)))
2669 (defun gnus-days-between (date1 date2)
2670 ;; Return the number of days between date1 and date2.
2671 (- (gnus-day-number date1) (gnus-day-number date2)))
2673 (defun gnus-day-number (date)
2674 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2675 (timezone-parse-date date))))
2676 (timezone-absolute-from-gregorian
2677 (nth 1 dat) (nth 2 dat) (car dat))))
2679 ;; Returns a floating point number that says how many seconds have
2680 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2681 (defun gnus-seconds-since-epoch (date)
2682 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2683 (timezone-parse-date date)))
2684 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2685 (timezone-parse-time
2686 (aref (timezone-parse-date date) 3))))
2687 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2688 (timezone-parse-date "Jan 1 12:00:00 1970")))
2689 (tday (- (timezone-absolute-from-gregorian
2690 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2691 (timezone-absolute-from-gregorian
2692 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2694 (* (nth 1 ttime) 60)
2695 (* 1.0 (nth 0 ttime) 60 60)
2696 (* 1.0 tday 60 60 24))))
2698 (defun gnus-file-newer-than (file date)
2699 (let ((fdate (nth 5 (file-attributes file))))
2700 (or (> (car fdate) (car date))
2701 (and (= (car fdate) (car date))
2702 (> (nth 1 fdate) (nth 1 date))))))
2704 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2706 (defun gnus-y-or-n-p (prompt)
2711 (defun gnus-yes-or-no-p (prompt)
2713 (yes-or-no-p prompt)
2716 ;; Check whether to use long file names.
2717 (defun gnus-use-long-file-name (symbol)
2718 ;; The variable has to be set...
2719 (and gnus-use-long-file-name
2720 ;; If it isn't a list, then we return t.
2721 (or (not (listp gnus-use-long-file-name))
2722 ;; If it is a list, and the list contains `symbol', we
2724 (not (memq symbol gnus-use-long-file-name)))))
2726 ;; I suspect there's a better way, but I haven't taken the time to do
2727 ;; it yet. -erik selberg@cs.washington.edu
2728 (defun gnus-dd-mmm (messy-date)
2729 "Return a string like DD-MMM from a big messy string"
2730 (let ((datevec (timezone-parse-date messy-date)))
2732 (or (aref datevec 2) "??")
2735 (nth (1- (string-to-number (aref datevec 1)))
2736 timezone-months-assoc))
2739 ;; Make a hash table (default and minimum size is 255).
2740 ;; Optional argument HASHSIZE specifies the table size.
2741 (defun gnus-make-hashtable (&optional hashsize)
2742 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2744 ;; Make a number that is suitable for hashing; bigger than MIN and one
2746 (defun gnus-create-hash-size (min)
2752 ;; Show message if message has a lower level than `gnus-verbose'.
2753 ;; Guide-line for numbers:
2754 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2755 ;; for things that take a long time, 7 - not very important messages
2756 ;; on stuff, 9 - messages inside loops.
2757 (defun gnus-message (level &rest args)
2758 (if (<= level gnus-verbose)
2759 (apply 'message args)
2760 ;; We have to do this format thingie here even if the result isn't
2761 ;; shown - the return value has to be the same as the return value
2763 (apply 'format args)))
2765 ;; Generate a unique new group name.
2766 (defun gnus-generate-new-group-name (leaf)
2769 (while (gnus-gethash name gnus-newsrc-hashtb)
2770 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2773 (defun gnus-find-file-noselect (file &optional force)
2774 "Does vaguely the same as find-file-noselect. No hooks are run."
2776 (if (setq buf (get-file-buffer file))
2778 (setq buf (create-file-buffer file))
2785 (and (file-readable-p file)
2786 (insert-file-contents file))
2787 (set-visited-file-name file)
2788 (set-buffer-modified-p nil)
2789 (current-buffer)))))
2791 ;;; List and range functions
2793 (defun gnus-last-element (list)
2794 "Return last element of LIST."
2796 (setq list (cdr list)))
2799 (defun gnus-copy-sequence (list)
2800 "Do a complete, total copy of a list."
2801 (if (and (consp list) (not (consp (cdr list))))
2802 (cons (car list) (cdr list))
2803 (mapcar (lambda (elem) (if (consp elem)
2804 (if (consp (cdr elem))
2805 (gnus-copy-sequence elem)
2806 (cons (car elem) (cdr elem)))
2810 (defun gnus-set-difference (list1 list2)
2811 "Return a list of elements of LIST1 that do not appear in LIST2."
2812 (let ((list1 (copy-sequence list1)))
2814 (setq list1 (delq (car list2) list1))
2815 (setq list2 (cdr list2)))
2818 (defun gnus-sorted-complement (list1 list2)
2819 "Return a list of elements of LIST1 that do not appear in LIST2.
2820 Both lists have to be sorted over <."
2822 (if (or (null list1) (null list2))
2824 (while (and list1 list2)
2825 (cond ((= (car list1) (car list2))
2826 (setq list1 (cdr list1)
2828 ((< (car list1) (car list2))
2829 (setq out (cons (car list1) out))
2830 (setq list1 (cdr list1)))
2832 (setq out (cons (car list2) out))
2833 (setq list2 (cdr list2)))))
2834 (nconc (nreverse out) (or list1 list2)))))
2836 (defun gnus-intersection (list1 list2)
2839 (if (memq (car list2) list1)
2840 (setq result (cons (car list2) result)))
2841 (setq list2 (cdr list2)))
2844 (defun gnus-sorted-intersection (list1 list2)
2845 ;; LIST1 and LIST2 have to be sorted over <.
2847 (while (and list1 list2)
2848 (cond ((= (car list1) (car list2))
2849 (setq out (cons (car list1) out)
2852 ((< (car list1) (car list2))
2853 (setq list1 (cdr list1)))
2855 (setq list2 (cdr list2)))))
2858 (defun gnus-set-sorted-intersection (list1 list2)
2859 ;; LIST1 and LIST2 have to be sorted over <.
2860 ;; This function modifies LIST1.
2861 (let* ((top (cons nil list1))
2863 (while (and list1 list2)
2864 (cond ((= (car list1) (car list2))
2868 ((< (car list1) (car list2))
2869 (setcdr prev (cdr list1))
2870 (setq list1 (cdr list1)))
2872 (setq list2 (cdr list2)))))
2876 (defun gnus-compress-sequence (numbers &optional always-list)
2877 "Convert list of numbers to a list of ranges or a single range.
2878 If ALWAYS-LIST is non-nil, this function will always release a list of
2880 (let* ((first (car numbers))
2881 (last (car numbers))
2885 (if (not (listp (cdr numbers)))
2888 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2889 ((= (1+ last) (car numbers)) ;Still in sequence
2890 (setq last (car numbers)))
2891 (t ;End of one sequence
2893 (cons (if (= first last) first
2894 (cons first last)) result))
2895 (setq first (car numbers))
2896 (setq last (car numbers))))
2897 (setq numbers (cdr numbers)))
2898 (if (and (not always-list) (null result))
2899 (if (= first last) (list first) (cons first last))
2900 (nreverse (cons (if (= first last) first (cons first last))
2903 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2904 (defun gnus-uncompress-range (ranges)
2905 "Expand a list of ranges into a list of numbers.
2906 RANGES is either a single range on the form `(num . num)' or a list of
2908 (let (first last result)
2912 ((not (listp (cdr ranges)))
2913 (setq first (car ranges))
2914 (setq last (cdr ranges))
2915 (while (<= first last)
2916 (setq result (cons first result))
2917 (setq first (1+ first)))
2921 (if (atom (car ranges))
2922 (if (numberp (car ranges))
2923 (setq result (cons (car ranges) result)))
2924 (setq first (car (car ranges)))
2925 (setq last (cdr (car ranges)))
2926 (while (<= first last)
2927 (setq result (cons first result))
2928 (setq first (1+ first))))
2929 (setq ranges (cdr ranges)))
2930 (nreverse result)))))
2932 (defun gnus-add-to-range (ranges list)
2933 "Return a list of ranges that has all articles from both RANGES and LIST.
2934 Note: LIST has to be sorted over `<'."
2936 (gnus-compress-sequence list t)
2937 (setq list (copy-sequence list))
2938 (or (listp (cdr ranges))
2939 (setq ranges (list ranges)))
2941 ilist lowest highest temp)
2942 (while (and ranges list)
2944 (setq lowest (or (and (atom (car ranges)) (car ranges))
2945 (car (car ranges))))
2946 (while (and list (cdr list) (< (car (cdr list)) lowest))
2947 (setq list (cdr list)))
2948 (if (< (car ilist) lowest)
2951 (setq list (cdr list))
2953 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2954 (setq highest (or (and (atom (car ranges)) (car ranges))
2955 (cdr (car ranges))))
2956 (while (and list (<= (car list) highest))
2957 (setq list (cdr list)))
2958 (setq ranges (cdr ranges)))
2960 (setq out (nconc (gnus-compress-sequence list t) out)))
2961 (setq out (sort out (lambda (r1 r2)
2962 (< (or (and (atom r1) r1) (car r1))
2963 (or (and (atom r2) r2) (car r2))))))
2966 (if (atom (car ranges))
2968 (if (atom (car (cdr ranges)))
2969 (if (= (1+ (car ranges)) (car (cdr ranges)))
2971 (setcar ranges (cons (car ranges)
2972 (car (cdr ranges))))
2973 (setcdr ranges (cdr (cdr ranges)))))
2974 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2976 (setcar (car (cdr ranges)) (car ranges))
2977 (setcar ranges (car (cdr ranges)))
2978 (setcdr ranges (cdr (cdr ranges)))))))
2980 (if (atom (car (cdr ranges)))
2981 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2983 (setcdr (car ranges) (car (cdr ranges)))
2984 (setcdr ranges (cdr (cdr ranges)))))
2985 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2987 (setcdr (car ranges) (cdr (car (cdr ranges))))
2988 (setcdr ranges (cdr (cdr ranges))))))))
2989 (setq ranges (cdr ranges)))
2992 (defun gnus-remove-from-range (ranges list)
2993 "Return a list of ranges that has all articles from LIST removed from RANGES.
2994 Note: LIST has to be sorted over `<'."
2995 ;; !!! This function shouldn't look like this, but I've got a headache.
2996 (gnus-compress-sequence
2997 (gnus-sorted-complement
2998 (gnus-uncompress-range ranges) list)))
3000 (defun gnus-member-of-range (number ranges)
3001 (if (not (listp (cdr ranges)))
3002 (and (>= number (car ranges))
3003 (<= number (cdr ranges)))
3006 (if (numberp (car ranges))
3007 (>= number (car ranges))
3008 (>= number (car (car ranges))))
3010 (if (if (numberp (car ranges))
3011 (= number (car ranges))
3012 (and (>= number (car (car ranges)))
3013 (<= number (cdr (car ranges)))))
3014 (setq not-stop nil))
3015 (setq ranges (cdr ranges)))
3023 (defvar gnus-group-mode-map nil)
3024 (defvar gnus-group-group-map nil)
3025 (defvar gnus-group-mark-map nil)
3026 (defvar gnus-group-list-map nil)
3027 (defvar gnus-group-sub-map nil)
3028 (put 'gnus-group-mode 'mode-class 'special)
3030 (if gnus-group-mode-map
3032 (setq gnus-group-mode-map (make-keymap))
3033 (suppress-keymap gnus-group-mode-map)
3034 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
3035 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
3036 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
3037 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
3038 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
3039 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
3040 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
3041 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
3042 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
3043 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
3044 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
3045 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
3046 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
3047 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3048 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3049 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3050 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3051 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3052 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3053 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3054 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3055 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3056 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3057 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3058 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3059 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3060 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3061 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3062 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3063 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3064 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
3065 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3066 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3067 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3068 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3069 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3070 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3071 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3072 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3073 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3074 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3075 (define-key gnus-group-mode-map "V" 'gnus-version)
3076 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3077 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3078 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3079 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3080 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3081 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3082 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3083 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3084 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3085 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3086 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3087 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3088 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3089 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3090 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3092 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3093 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3094 (define-prefix-command 'gnus-group-mark-map)
3095 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3096 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3097 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3098 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3100 (define-prefix-command 'gnus-group-group-map)
3101 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3102 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3103 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3104 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3105 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3106 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3107 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3108 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3109 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3110 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3111 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3112 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3113 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3114 (define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3115 (define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3116 (define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3117 (define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3118 (define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3120 (define-prefix-command 'gnus-group-list-map)
3121 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3122 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3123 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3124 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3125 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3126 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3127 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3128 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3129 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3131 (define-prefix-command 'gnus-group-sub-map)
3132 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3133 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3134 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3135 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3136 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3137 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3138 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3139 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3141 (defun gnus-group-mode ()
3142 "Major mode for reading news.
3144 All normal editing commands are switched off.
3145 \\<gnus-group-mode-map>
3146 The group buffer lists (some of) the groups available. For instance,
3147 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3148 lists all zombie groups.
3150 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3151 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3153 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3155 The following commands are available:
3157 \\{gnus-group-mode-map}"
3159 (if gnus-visual (gnus-group-make-menu-bar))
3160 (kill-all-local-variables)
3161 (setq mode-line-modified "-- ")
3162 (make-local-variable 'mode-line-format)
3163 (setq mode-line-format (copy-sequence mode-line-format))
3164 (and (equal (nth 3 mode-line-format) " ")
3165 (setcar (nthcdr 3 mode-line-format) ""))
3166 (setq major-mode 'gnus-group-mode)
3167 (setq mode-name "Group")
3168 (gnus-group-set-mode-line)
3169 (setq mode-line-process nil)
3170 (use-local-map gnus-group-mode-map)
3171 (buffer-disable-undo (current-buffer))
3172 (setq truncate-lines t)
3173 (setq buffer-read-only t)
3174 (run-hooks 'gnus-group-mode-hook))
3176 (defun gnus-mouse-pick-group (e)
3179 (gnus-group-read-group nil))
3181 ;; Look at LEVEL and find out what the level is really supposed to be.
3182 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
3183 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
3184 (defun gnus-group-default-level (&optional level number-or-nil)
3186 (gnus-group-use-permanent-levels
3187 (setq gnus-group-default-list-level
3188 (or level gnus-group-default-list-level))
3189 (or gnus-group-default-list-level gnus-level-subscribed))
3193 (or level gnus-group-default-list-level gnus-level-subscribed))))
3197 (defun gnus-no-server (&optional arg)
3199 If ARG is a positive number, Gnus will use that as the
3200 startup level. If ARG is nil, Gnus will be started at level 2.
3201 If ARG is non-nil and not a positive number, Gnus will
3202 prompt the user for the name of an NNTP server to use.
3203 As opposed to `gnus', this command will not connect to the local server."
3205 (setq gnus-group-use-permanent-levels t)
3206 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3208 (defalias '\(ding\) 'gnus)
3211 (defun gnus (&optional arg dont-connect)
3213 If ARG is non-nil and a positive number, Gnus will use that as the
3214 startup level. If ARG is non-nil and not a positive number, Gnus will
3215 prompt the user for the name of an NNTP server to use."
3217 (if (get-buffer gnus-group-buffer)
3219 (switch-to-buffer gnus-group-buffer)
3220 (gnus-group-get-new-news))
3222 (nnheader-init-server-buffer)
3223 (gnus-read-init-file)
3225 (let ((level (and arg (numberp arg) (> arg 0) arg))
3229 (gnus-group-setup-buffer)
3232 (gnus-start-news-server (and arg (not level))))))
3233 (if (and (not dont-connect)
3236 (run-hooks 'gnus-startup-hook)
3237 ;; NNTP server is successfully open.
3239 ;; Find the current startup file name.
3240 (setq gnus-current-startup-file
3241 (gnus-make-newsrc-file gnus-startup-file))
3243 ;; Read the dribble file.
3244 (and gnus-use-dribble-file (gnus-dribble-read-file))
3246 (gnus-summary-make-display-table)
3247 (let ((buffer-read-only nil))
3249 (if (not gnus-inhibit-startup-message)
3251 (gnus-group-startup-message)
3253 (gnus-setup-news nil level)
3254 (gnus-group-list-groups level)
3255 (gnus-configure-windows 'group))))))
3257 (defun gnus-unload ()
3258 "Unload all Gnus features."
3260 (let ((history load-history)
3263 (and (string-match "^gnus" (car (car history)))
3264 (setq feature (cdr (assq 'provide (car history))))
3265 (unload-feature feature 'force))
3266 (setq history (cdr history)))))
3270 (defun gnus-group-startup-message (&optional x y)
3271 "Insert startup message in current buffer."
3272 ;; Insert the message.
3277 _ ___ __ ___ __ _ ___
3295 Gnus * A newsreader for Emacsen
3296 A Praxis release * larsi@ifi.uio.no
3299 ;; And then hack it.
3300 ;; 18 is the longest line.
3301 (indent-rigidly (point-min) (point-max)
3302 (/ (max (- (window-width) (or x 46)) 0) 2))
3303 (goto-char (point-min))
3304 (let* ((pheight (count-lines (point-min) (point-max)))
3305 (wheight (window-height))
3306 (rest (- wheight pheight)))
3307 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
3312 (goto-char (point-min))
3313 (search-forward "Praxis")
3314 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3315 (goto-char (point-min)))
3317 (defun gnus-group-startup-message-old (&optional x y)
3318 "Insert startup message in current buffer."
3319 ;; Insert the message.
3335 ;; And then hack it.
3336 ;; 18 is the longest line.
3337 (indent-rigidly (point-min) (point-max)
3338 (/ (max (- (window-width) (or x 28)) 0) 2))
3339 (goto-char (point-min))
3340 ;; +4 is fuzzy factor.
3341 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3344 (goto-char (point-min))
3345 (search-forward "Praxis")
3346 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3347 (goto-char (point-min)))
3349 (defun gnus-group-setup-buffer ()
3350 (or (get-buffer gnus-group-buffer)
3352 (switch-to-buffer gnus-group-buffer)
3353 (gnus-add-current-to-buffer-list)
3355 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3357 (defun gnus-group-list-groups (&optional level unread)
3358 "List newsgroups with level LEVEL or lower that have unread articles.
3359 Default is all subscribed groups.
3360 If argument UNREAD is non-nil, groups with no unread articles are also
3362 (interactive (list (if current-prefix-arg
3363 (prefix-numeric-value current-prefix-arg)
3365 (gnus-group-default-level nil t)
3366 gnus-level-subscribed))))
3368 (setq level (car gnus-group-list-mode)
3369 unread (cdr gnus-group-list-mode)))
3370 (setq level (gnus-group-default-level level))
3371 (gnus-group-setup-buffer) ;May call from out of group buffer
3372 (let ((case-fold-search nil)
3373 (group (gnus-group-group-name)))
3374 (funcall gnus-group-prepare-function level unread nil)
3375 (if (zerop (buffer-size))
3376 (gnus-message 5 gnus-no-groups-message)
3377 (goto-char (point-min))
3379 ;; Go to the first group with unread articles.
3380 (gnus-group-search-forward nil nil nil t)
3381 ;; Find the right group to put point on. If the current group
3382 ;; has disapeared in the new listing, try to find the next
3383 ;; one. If no next one can be found, just leave point at the
3384 ;; first newsgroup in the buffer.
3385 (if (not (gnus-goto-char
3386 (text-property-any (point-min) (point-max)
3387 'gnus-group (intern group))))
3388 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3390 (not (gnus-goto-char
3392 (point-min) (point-max) 'gnus-group
3393 (intern (car (car newsrc)))))))
3394 (setq newsrc (cdr newsrc)))
3395 (or newsrc (progn (goto-char (point-max))
3396 (forward-line -1))))))
3397 ;; Adjust cursor point.
3398 (gnus-group-position-cursor))))
3400 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3401 "List all newsgroups with unread articles of level LEVEL or lower.
3402 If ALL is non-nil, list groups that have no unread articles.
3403 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3404 If REGEXP, only list groups matching REGEXP."
3405 (set-buffer gnus-group-buffer)
3406 (let ((buffer-read-only nil)
3407 (newsrc (cdr gnus-newsrc-alist))
3408 (lowest (or lowest 1))
3409 info clevel unread group)
3411 (if (< lowest gnus-level-zombie)
3412 ;; List living groups.
3414 (setq info (car newsrc)
3417 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3418 (and unread ; This group might be bogus
3420 (string-match regexp group))
3421 (<= (setq clevel (car (cdr info))) level)
3423 (or all ; We list all groups?
3424 (eq unread t) ; We list unactivated groups
3425 (> unread 0) ; We list groups with unread articles
3426 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3427 (gnus-group-insert-group-line
3428 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3430 ;; List dead groups.
3431 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3432 (gnus-group-prepare-flat-list-dead
3433 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3434 gnus-level-zombie ?Z
3436 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3437 (gnus-group-prepare-flat-list-dead
3438 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3439 gnus-level-killed ?K regexp))
3441 (gnus-group-set-mode-line)
3442 (setq gnus-group-list-mode (cons level all))
3443 (run-hooks 'gnus-group-prepare-hook)))
3445 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3446 ;; List zombies and killed lists somehwat faster, which was
3447 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3448 ;; this by ignoring the group format specification altogether.
3451 (setq group (car groups)
3452 groups (cdr groups))
3453 (if (or (not regexp)
3454 (string-match regexp group))
3457 (insert (format " %c *: %s\n" mark group))
3458 (add-text-properties
3460 (list 'gnus-group (intern group)
3462 'gnus-level level)))))))
3464 (defun gnus-group-real-name (group)
3465 "Find the real name of a foreign newsgroup."
3466 (if (string-match ":[^:]+$" group)
3467 (substring group (1+ (match-beginning 0)))
3470 (defun gnus-group-prefixed-name (group method)
3471 "Return the whole name from GROUP and METHOD."
3472 (and (stringp method) (setq method (gnus-server-to-method method)))
3473 (concat (format "%s" (car method))
3475 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3476 (not (string= (nth 1 method) "")))
3477 (concat "+" (nth 1 method)))
3480 (defun gnus-group-real-prefix (group)
3481 "Return the prefix of the current group name."
3482 (if (string-match "^[^:]+:" group)
3483 (substring group 0 (match-end 0))
3486 (defun gnus-group-method-name (group)
3487 "Return the method used for selecting GROUP."
3488 (let ((prefix (gnus-group-real-prefix group)))
3489 (if (equal prefix "")
3491 (if (string-match "^[^\\+]+\\+" prefix)
3492 (list (intern (substring prefix 0 (1- (match-end 0))))
3493 (substring prefix (match-end 0) (1- (length prefix))))
3494 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3496 (defun gnus-group-foreign-p (group)
3497 "Return nil if GROUP is native, non-nil if it is foreign."
3498 (string-match ":" group))
3500 (defun gnus-group-set-info (info &optional method-only-group part)
3501 (let* ((entry (gnus-gethash
3502 (or method-only-group (car info)) gnus-newsrc-hashtb))
3504 (info (if method-only-group (nth 2 entry) info)))
3505 (if (not method-only-group)
3508 (error "Trying to change non-existent group %s" method-only-group))
3509 ;; We have recevied parts of the actual group info - either the
3510 ;; select method or the group parameters. We first check
3511 ;; whether we have to extend the info, and if so, do that.
3512 (let ((len (length info))
3513 (total (if (eq part 'method) 5 6)))
3515 (setcdr (nthcdr (1- len) info)
3516 (make-list (- total len) nil)))
3517 ;; Then we enter the new info.
3518 (setcar (nthcdr (1- total) info) part-info)))
3519 ;; We uncompress some lists of marked articles.
3521 (if (not (setq marked (nth 3 info)))
3524 (or (eq 'score (car (car marked)))
3525 (eq 'bookmark (car (car marked)))
3526 (eq 'killed (car (car marked)))
3527 (setcdr (car marked)
3528 (gnus-uncompress-range (cdr (car marked)))))
3529 (setq marked (cdr marked)))))
3532 ;; This is a new group, so we just create it.
3534 (set-buffer gnus-group-buffer)
3536 ;; It's a foreign group...
3537 (gnus-group-make-group
3538 (gnus-group-real-name (car info))
3539 (prin1-to-string (car (nth 4 info)))
3540 (nth 1 (nth 4 info)))
3541 ;; It's a native group.
3542 (gnus-group-make-group
3544 (prin1-to-string (car gnus-select-method))
3545 (nth 1 gnus-select-method)))
3546 (gnus-message 6 "Note: New group created")
3548 (gnus-gethash (gnus-group-prefixed-name
3549 (gnus-group-real-name (car info))
3550 (or (nth 4 info) gnus-select-method))
3551 gnus-newsrc-hashtb))))
3552 ;; Whether it was a new group or not, we now have the entry, so we
3553 ;; can do the update.
3556 (setcar (nthcdr 2 entry) info)
3557 (if (and (not (eq (car entry) t))
3558 (gnus-gethash (car info) gnus-active-hashtb))
3559 (let ((marked (nth 3 info)))
3561 (max 0 (- (length (gnus-list-of-unread-articles
3563 (length (cdr (assq 'tick marked)))
3564 (length (cdr (assq 'dormant marked)))))))))
3565 (error "No such group: %s" (car info)))))
3567 (defun gnus-group-set-method-info (group select-method)
3568 (gnus-group-set-info select-method group 'method))
3570 (defun gnus-group-set-params-info (group params)
3571 (gnus-group-set-info params group 'params))
3573 (defun gnus-group-update-group-line ()
3574 "This function updates the current line in the newsgroup buffer and
3575 moves the point to the colon."
3576 (let* ((buffer-read-only nil)
3577 (group (gnus-group-group-name))
3578 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3581 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3584 (delete-region (point) (progn (forward-line 1) (point)))
3585 (gnus-group-insert-group-line-info group)
3587 (gnus-group-position-cursor)))
3589 (defun gnus-group-insert-group-line-info (group)
3590 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3594 (setq info (nth 2 entry))
3595 (gnus-group-insert-group-line
3596 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3597 (setq active (gnus-gethash group gnus-active-hashtb))
3598 (gnus-group-insert-group-line
3600 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3601 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3603 (defun gnus-group-insert-group-line (gformat group level marked number method)
3604 (let* ((gformat (or gformat gnus-group-line-format-spec))
3605 (active (gnus-gethash group gnus-active-hashtb))
3606 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3607 (number-of-dormant (length (cdr (assq 'dormant marked))))
3608 (number-of-ticked (length (cdr (assq 'tick marked))))
3609 (number-of-ticked-and-dormant
3610 (+ number-of-ticked number-of-dormant))
3611 (number-of-unread-unticked
3612 (if (numberp number) (int-to-string (max 0 number))
3615 (if (numberp number)
3616 (max 0 (- number-total number))
3618 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3619 ((<= level gnus-level-unsubscribed) ?U)
3620 ((= level gnus-level-zombie) ?Z)
3622 (qualified-group (gnus-group-real-name group))
3623 (newsgroup-description
3624 (if gnus-description-hashtb
3625 (or (gnus-gethash group gnus-description-hashtb) "")
3627 (moderated (if (member group gnus-moderated-list) ?m ? ))
3628 (moderated-string (if (eq moderated ?m) "(m)" ""))
3629 (method (gnus-server-get-method group method))
3630 (news-server (or (car (cdr method)) ""))
3631 (news-method (or (car method) ""))
3633 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3637 (> number-of-ticked 0))
3639 (number (if (eq number t) "*" (+ number number-of-dormant
3641 (process-marked (if (member qualified-group gnus-group-marked)
3642 gnus-process-mark ? ))
3643 (buffer-read-only nil)
3644 header ; passed as parameter to user-funcs.
3649 (insert (eval gformat))
3651 (add-text-properties
3652 b (1+ b) (list 'gnus-group (intern group)
3653 'gnus-unread (if (numberp number)
3654 (string-to-int number-of-unread-unticked)
3657 'gnus-level level))))
3659 (defun gnus-group-update-group (group &optional visible-only)
3660 "Update newsgroup info of GROUP.
3661 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3663 (set-buffer gnus-group-buffer)
3664 (let ((buffer-read-only nil)
3666 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3669 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3671 ;; Buffer may be narrowed.
3674 ;; Search a line to modify. If the buffer is large, the search
3675 ;; takes long time. In most cases, current point is on the line
3676 ;; we are looking for. So, first of all, check current line.
3679 (eq (get-text-property (point) 'gnus-group)
3684 (point-min) (point-max) 'gnus-group (intern group)))))
3685 ;; GROUP is listed in current buffer. So, delete old line.
3689 (delete-region (point) (progn (forward-line 1) (point))))
3690 ;; No such line in the buffer, find out where it's supposed to
3691 ;; go, and insert it there (or at the end of the buffer).
3692 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3695 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3701 (point-min) (point-max)
3702 'gnus-group (intern (car (car entry)))))))
3703 (setq entry (cdr entry)))
3704 (or entry (goto-char (point-max)))))))
3705 (if (or visible (not visible-only))
3706 (gnus-group-insert-group-line-info group))
3707 (gnus-group-set-mode-line))))
3709 (defun gnus-group-set-mode-line ()
3710 (if (memq 'group gnus-updated-mode-lines)
3711 (let* ((gformat (or gnus-group-mode-line-format-spec
3712 (setq gnus-group-mode-line-format-spec
3714 gnus-group-mode-line-format
3715 gnus-group-mode-line-format-alist))))
3716 (news-server (car (cdr gnus-select-method)))
3717 (news-method (car gnus-select-method))
3719 (mode-string (eval gformat)))
3720 (setq mode-string (eval gformat))
3721 (if (> (length mode-string) max-len)
3722 (setq mode-string (substring mode-string 0 (- max-len 4))))
3723 (setq mode-line-buffer-identification mode-string)
3724 (set-buffer-modified-p t))))
3726 (defun gnus-group-group-name ()
3727 "Get the name of the newsgroup on the current line."
3728 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3729 (and group (symbol-name group))))
3731 (defun gnus-group-group-level ()
3732 "Get the level of the newsgroup on the current line."
3733 (get-text-property (gnus-point-at-bol) 'gnus-level))
3735 (defun gnus-group-group-unread ()
3736 "Get the number of unread articles of the newsgroup on the current line."
3737 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3739 (defun gnus-group-search-forward (&optional backward all level first-too)
3740 "Find the next newsgroup with unread articles.
3741 If BACKWARD is non-nil, find the previous newsgroup instead.
3742 If ALL is non-nil, just find any newsgroup.
3743 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3745 If FIRST-TOO, the current line is also eligible as a target."
3746 (let ((way (if backward -1 1))
3747 (low gnus-level-killed)
3750 (if (and backward (progn (beginning-of-line)) (bobp))
3752 (or first-too (forward-line way))
3760 (get-text-property (point) 'gnus-unread)))
3761 (or (eq unread t) (and unread (> unread 0))))
3762 (setq lev (get-text-property (point)
3764 (<= lev gnus-level-subscribed)))
3766 (and (setq lev (get-text-property (point)
3775 (zerop (forward-line way)))))
3777 (progn (gnus-group-position-cursor) t)
3778 (goto-char (or pos beg))
3781 ;;; Gnus group mode commands
3785 (defun gnus-group-mark-group (n &optional unmark no-advance)
3786 "Mark the current group."
3788 (let ((buffer-read-only nil)
3792 (setq group (gnus-group-group-name))
3796 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
3801 (setq gnus-group-marked (delete group gnus-group-marked)))
3803 (setq gnus-group-marked
3804 (cons group (delete group gnus-group-marked))))
3806 (or no-advance (zerop (gnus-group-next-group 1))))
3808 (gnus-summary-position-cursor)
3811 (defun gnus-group-unmark-group (n)
3812 "Remove the mark from the current group."
3814 (gnus-group-mark-group n 'unmark))
3816 (defun gnus-group-mark-region (unmark beg end)
3817 "Mark all groups between point and mark.
3818 If UNMARK, remove the mark instead."
3819 (interactive "P\nr")
3820 (let ((num (count-lines beg end)))
3823 (- num (gnus-group-mark-group num unmark)))))
3825 (defun gnus-group-remove-mark (group)
3826 (and (gnus-group-goto-group group)
3828 (gnus-group-mark-group 1 'unmark t))))
3830 ;; Return a list of groups to work on. Take into consideration N (the
3831 ;; prefix) and the list of marked groups.
3832 (defun gnus-group-process-prefix (n)
3834 (setq n (prefix-numeric-value n))
3835 ;; There is a prefix, so we return a list of the N next
3837 (let ((way (if (< n 0) -1 1))
3842 (setq group (gnus-group-group-name)))
3843 (setq groups (cons group groups))
3845 (forward-line way)))
3848 ;; No prefix, but a list of marked articles.
3849 (reverse gnus-group-marked))
3851 ;; Neither marked articles or a prefix, so we return the
3853 (let ((group (gnus-group-group-name)))
3854 (and group (list group))))))
3856 ;; Selecting groups.
3858 (defun gnus-group-read-group (&optional all no-article group)
3859 "Read news in this newsgroup.
3860 If the prefix argument ALL is non-nil, already read articles become
3861 readable. If the optional argument NO-ARTICLE is non-nil, no article
3862 will be auto-selected upon group entry."
3864 (let ((group (or group (gnus-group-group-name)))
3865 number active marked entry)
3866 (or group (error "No group on current line"))
3868 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3869 ;; This group might be a dead group. In that case we have to get
3870 ;; the number of unread articles from `gnus-active-hashtb'.
3872 (setq number (car entry))
3873 (if (setq active (gnus-gethash group gnus-active-hashtb))
3874 (setq number (- (1+ (cdr active)) (car active)))))
3875 (gnus-summary-read-group
3876 group (or all (and (numberp number)
3877 (zerop (+ number (length (cdr (assq 'tick marked)))
3878 (length (cdr (assq 'dormant marked)))))))
3881 (defun gnus-group-select-group (&optional all)
3882 "Select this newsgroup.
3883 No article is selected automatically.
3884 If argument ALL is non-nil, already read articles become readable."
3886 (gnus-group-read-group all t))
3888 (defun gnus-group-select-group-all ()
3889 "Select the current group and display all articles in it."
3891 (gnus-group-select-group 'all))
3893 ;; Enter a group that is not in the group buffer. Non-nil is returned
3894 ;; if selection was successful.
3895 (defun gnus-group-read-ephemeral-group
3896 (group method &optional activate quit-config)
3897 (let ((group (if (gnus-group-foreign-p group) group
3898 (gnus-group-prefixed-name group method))))
3901 (list t nil (list group gnus-level-default-subscribed nil nil
3905 (if quit-config quit-config
3906 (cons (current-buffer) 'summary)))))))
3908 (set-buffer gnus-group-buffer)
3909 (or (gnus-check-server method)
3910 (error "Unable to contact server: %s" (gnus-status-message method)))
3911 (if activate (or (gnus-request-group group)
3912 (error "Couldn't request group")))
3914 (gnus-group-read-group t t group)
3917 (not (equal major-mode 'gnus-group-mode))))
3919 (defun gnus-group-jump-to-group (group)
3920 "Jump to newsgroup GROUP."
3922 (list (completing-read
3923 "Group: " gnus-active-hashtb nil
3924 (memq gnus-select-method gnus-have-read-active-file))))
3926 (if (equal group "")
3927 (error "Empty group name"))
3929 (let ((b (text-property-any
3930 (point-min) (point-max) 'gnus-group (intern group))))
3932 ;; Either go to the line in the group buffer...
3934 ;; ... or insert the line.
3936 (gnus-gethash group gnus-active-hashtb)
3937 (gnus-activate-group group)
3938 (error "%s error: %s" group (gnus-status-message group)))
3940 (gnus-group-update-group group)
3941 (goto-char (text-property-any
3942 (point-min) (point-max) 'gnus-group (intern group)))))
3943 ;; Adjust cursor point.
3944 (gnus-group-position-cursor))
3946 (defun gnus-group-goto-group (group)
3947 "Goto to newsgroup GROUP."
3948 (let ((b (text-property-any (point-min) (point-max)
3949 'gnus-group (intern group))))
3950 (and b (goto-char b))))
3952 (defun gnus-group-next-group (n)
3953 "Go to next N'th newsgroup.
3954 If N is negative, search backward instead.
3955 Returns the difference between N and the number of skips actually
3958 (gnus-group-next-unread-group n t))
3960 (defun gnus-group-next-unread-group (n &optional all level)
3961 "Go to next N'th unread newsgroup.
3962 If N is negative, search backward instead.
3963 If ALL is non-nil, choose any newsgroup, unread or not.
3964 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3965 such group can be found, the next group with a level higher than
3967 Returns the difference between N and the number of skips actually
3970 (let ((backward (< n 0))
3973 (gnus-group-search-forward
3974 backward (or (not gnus-group-goto-unread) all) level))
3976 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3977 (if level " on this level or higher" "")))
3980 (defun gnus-group-prev-group (n)
3981 "Go to previous N'th newsgroup.
3982 Returns the difference between N and the number of skips actually
3985 (gnus-group-next-unread-group (- n) t))
3987 (defun gnus-group-prev-unread-group (n)
3988 "Go to previous N'th unread newsgroup.
3989 Returns the difference between N and the number of skips actually
3992 (gnus-group-next-unread-group (- n)))
3994 (defun gnus-group-next-unread-group-same-level (n)
3995 "Go to next N'th unread newsgroup on the same level.
3996 If N is negative, search backward instead.
3997 Returns the difference between N and the number of skips actually
4000 (gnus-group-next-unread-group n t (gnus-group-group-level))
4001 (gnus-group-position-cursor))
4003 (defun gnus-group-prev-unread-group-same-level (n)
4004 "Go to next N'th unread newsgroup on the same level.
4005 Returns the difference between N and the number of skips actually
4008 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
4009 (gnus-group-position-cursor))
4011 (defun gnus-group-best-unread-group (&optional exclude-group)
4012 "Go to the group with the highest level.
4013 If EXCLUDE-GROUP, do not go to that group."
4015 (goto-char (point-min))
4018 (while (setq unread (get-text-property (point) 'gnus-unread))
4019 (if (and (numberp unread) (> unread 0))
4021 (if (and (< (get-text-property (point) 'gnus-level) best)
4022 (or (not exclude-group)
4023 (not (equal exclude-group (gnus-group-group-name)))))
4025 (setq best (get-text-property (point) 'gnus-level))
4026 (setq best-point (point))))))
4028 (if best-point (goto-char best-point))
4029 (gnus-summary-position-cursor)
4030 (and best-point (gnus-group-group-name))))
4032 (defun gnus-group-first-unread-group ()
4033 "Go to the first group with unread articles."
4036 (let ((opoint (point))
4038 (goto-char (point-min))
4039 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
4040 (not (zerop unread)) ; Has unread articles.
4041 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
4044 nil)) ; Not success.
4045 (gnus-group-position-cursor)))
4047 (defun gnus-group-enter-server-mode ()
4048 "Jump to the server buffer."
4050 (gnus-server-setup-buffer)
4051 (gnus-configure-windows 'server)
4052 (gnus-server-prepare))
4054 (defun gnus-group-make-group (name method &optional address)
4055 "Add a new newsgroup.
4056 The user will be prompted for a NAME, for a select METHOD, and an
4060 (read-string "Group name: ")
4063 "Method: " (append gnus-valid-select-methods gnus-server-alist)
4065 (if (assoc method gnus-valid-select-methods)
4067 (if (memq 'prompt-address
4068 (assoc method gnus-valid-select-methods))
4069 (read-string "Address: ")
4071 (list method nil)))))
4073 (let* ((meth (if address (list (intern method) address) method))
4074 (nname (gnus-group-prefixed-name name meth))
4076 (and (gnus-gethash nname gnus-newsrc-hashtb)
4077 (error "Group %s already exists" nname))
4078 (gnus-group-change-level
4079 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
4080 gnus-level-default-subscribed gnus-level-killed
4081 (and (gnus-group-group-name)
4082 (gnus-gethash (gnus-group-group-name)
4083 gnus-newsrc-hashtb))
4085 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
4087 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
4088 (gnus-group-insert-group-line-info nname)
4090 (if (assoc method gnus-valid-select-methods)
4091 (require (intern method)))
4092 (and (gnus-check-backend-function 'request-create-group nname)
4093 (gnus-request-create-group nname))))
4095 (defun gnus-group-edit-group (group &optional part)
4096 "Edit the group on the current line."
4097 (interactive (list (gnus-group-group-name)))
4098 (let ((done-func '(lambda ()
4099 "Exit editing mode and update the information."
4101 (gnus-group-edit-group-done 'part 'group)))
4102 (part (or part 'info))
4103 (winconf (current-window-configuration))
4105 (or group (error "No group on current line"))
4106 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4107 (error "Killed group; can't be edited"))
4108 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4109 (gnus-configure-windows 'edit-group)
4110 (gnus-add-current-to-buffer-list)
4112 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4113 (use-local-map (copy-keymap emacs-lisp-mode-map))
4114 (local-set-key "\C-c\C-c" done-func)
4115 (make-local-variable 'gnus-prev-winconf)
4116 (setq gnus-prev-winconf winconf)
4117 ;; We modify the func to let it know what part it is editing.
4118 (setcar (cdr (nth 4 done-func)) (list 'quote part))
4119 (setcar (cdr (cdr (nth 4 done-func))) group)
4124 ";; Type `C-c C-c' after editing the select method.\n\n")
4126 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4128 ";; Type `C-c C-c' after editing the group info.\n\n")))
4129 (let ((cinfo (gnus-copy-sequence info))
4131 (if (not (setq marked (nth 3 cinfo)))
4134 (or (eq 'score (car (car marked)))
4135 (eq 'bookmark (car (car marked)))
4136 (eq 'killed (car (car marked)))
4137 (not (numberp (car (cdr (car marked)))))
4138 (setcdr (car marked)
4139 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4140 (setq marked (cdr marked))))
4143 (cond ((eq part 'method)
4144 (or (nth 4 info) "native"))
4151 (defun gnus-group-edit-group-method (group)
4152 "Edit the select method of GROUP."
4153 (interactive (list (gnus-group-group-name)))
4154 (gnus-group-edit-group group 'method))
4156 (defun gnus-group-edit-group-parameters (group)
4157 "Edit the group parameters of GROUP."
4158 (interactive (list (gnus-group-group-name)))
4159 (gnus-group-edit-group group 'params))
4161 (defun gnus-group-edit-group-done (part group)
4162 "Get info from buffer, update variables and jump to the group buffer."
4163 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4164 (goto-char (point-min))
4165 (let ((form (read (current-buffer)))
4166 (winconf gnus-prev-winconf))
4168 (gnus-group-set-info form)
4169 (gnus-group-set-info form group part))
4170 (kill-buffer (current-buffer))
4171 (and winconf (set-window-configuration winconf))
4172 (set-buffer gnus-group-buffer)
4173 (gnus-group-update-group (gnus-group-group-name))
4174 (gnus-group-position-cursor)))
4176 (defun gnus-group-make-help-group ()
4177 "Create the (ding) Gnus documentation group."
4179 (let ((path load-path)
4181 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4182 "gnus-help" '(nndoc "gnus-help")))
4184 (error "Documentation group already exists"))
4186 (not (file-exists-p (concat (file-name-as-directory (car path))
4188 (setq path (cdr path)))
4189 (or path (error "Couldn't find doc group"))
4190 (gnus-group-make-group
4191 (gnus-group-real-name name)
4193 (list 'nndoc-address (concat (file-name-as-directory (car path)) "doc.txt"))
4194 (list 'nndoc-article-type 'mbox))))
4195 (gnus-group-position-cursor))
4197 (defun gnus-group-make-doc-group (file type)
4198 "Create a group that uses a single file as the source."
4200 (list (read-file-name "File name: ")
4204 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4205 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4206 ((= char ?b) 'babyl)
4207 ((= char ?d) 'digest)
4208 (t (setq err (format "%c unknown. " char))
4211 (let* ((file (expand-file-name file))
4212 (name (gnus-generate-new-group-name
4213 (gnus-group-prefixed-name
4214 (file-name-nondirectory file) '(nndoc "")))))
4215 (gnus-group-make-group
4216 (gnus-group-real-name name)
4218 (list 'nndoc-address file)
4219 (list 'nndoc-article-type type)))))
4221 (defun gnus-group-make-archive-group ()
4222 "Create the (ding) Gnus archive group."
4224 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
4226 (error "Archive group already exists"))
4227 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
4228 (gnus-group-position-cursor))
4230 (defun gnus-group-make-directory-group (dir)
4231 "Create an nndir group.
4232 The user will be prompted for a directory. The contents of this
4233 directory will be used as a newsgroup. The directory should contain
4234 mail messages or news articles in files that have numeric names."
4236 (list (read-file-name "Create group from directory: ")))
4237 (or (file-exists-p dir) (error "No such directory"))
4238 (or (file-directory-p dir) (error "Not a directory"))
4239 (gnus-group-make-group dir "nndir" dir)
4240 (gnus-group-position-cursor))
4242 (defun gnus-group-make-kiboze-group (group address scores)
4243 "Create an nnkiboze group.
4244 The user will be prompted for a name, a regexp to match groups, and
4245 score file entries for articles to include in the group."
4248 (read-string "nnkiboze group name: ")
4249 (read-string "Source groups (regexp): ")
4250 (let ((headers (mapcar (lambda (group) (list group))
4251 '("subject" "from" "number" "date" "message-id"
4252 "references" "chars" "lines" "xref")))
4253 scores header regexp regexps)
4254 (while (not (equal "" (setq header (completing-read
4255 "Match on header: " headers nil t))))
4257 (while (not (equal "" (setq regexp (read-string
4258 (format "Match on %s (string): "
4260 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4261 (setq scores (cons (cons header regexps) scores)))
4263 (gnus-group-make-group group "nnkiboze" address)
4265 (gnus-set-work-buffer)
4266 (let (emacs-lisp-mode-hook)
4267 (pp scores (current-buffer)))
4268 (write-region (point-min) (point-max)
4269 (concat (or gnus-kill-files-directory "~/News")
4270 "nnkiboze:" group "." gnus-score-file-suffix)))
4271 (gnus-group-position-cursor))
4273 (defun gnus-group-add-to-virtual (n vgroup)
4274 "Add the current group to a virtual group."
4276 (list current-prefix-arg
4277 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4279 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4280 (error "%s is not an nnvirtual group" vgroup))
4281 (let* ((groups (gnus-group-process-prefix n))
4282 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4283 (setcar (cdr method)
4285 (nth 1 method) "\\|"
4288 (gnus-group-remove-mark s)
4289 (concat "\\(^" (regexp-quote s) "$\\)"))
4291 (gnus-group-position-cursor))
4293 (defun gnus-group-make-empty-virtual (group)
4294 "Create a new, fresh, empty virtual group."
4295 (interactive "sCreate new, empty virtual group: ")
4296 (let* ((method (list 'nnvirtual "^$"))
4297 (pgroup (gnus-group-prefixed-name group method)))
4298 ;; Check whether it exists already.
4299 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4300 (error "Group %s already exists." pgroup))
4301 ;; Subscribe the new group after the group on the current line.
4302 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4303 (gnus-group-update-group pgroup)
4305 (gnus-group-position-cursor)))
4307 (defun gnus-group-enter-directory (dir)
4308 "Enter an ephemeral nneething group."
4309 (interactive "DDirectory to read: ")
4310 (let* ((method (list 'nneething dir))
4311 (leaf (gnus-group-prefixed-name
4312 (file-name-nondirectory (directory-file-name dir))
4314 (name (gnus-generate-new-group-name leaf)))
4315 (let ((nneething-read-only t))
4316 (or (gnus-group-read-ephemeral-group
4318 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4320 (error "Couldn't enter %s" dir)))))
4322 ;; Group sorting commands
4323 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4325 (defun gnus-group-sort-groups ()
4326 "Sort the group buffer using `gnus-group-sort-function'."
4328 (setq gnus-newsrc-alist
4329 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4330 (gnus-make-hashtable-from-newsrc-alist)
4331 (gnus-group-list-groups))
4333 (defun gnus-group-sort-by-alphabet (info1 info2)
4334 (string< (car info1) (car info2)))
4336 (defun gnus-group-sort-by-unread (info1 info2)
4337 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4338 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4339 (< (or (and (numberp n1) n1) 0)
4340 (or (and (numberp n2) n2) 0))))
4342 (defun gnus-group-sort-by-level (info1 info2)
4343 (< (nth 1 info1) (nth 1 info2)))
4345 ;; Group catching up.
4347 (defun gnus-group-catchup-current (&optional n all)
4348 "Mark all articles not marked as unread in current newsgroup as read.
4349 If prefix argument N is numeric, the ARG next newsgroups will be
4350 caught up. If ALL is non-nil, marked articles will also be marked as
4351 read. Cross references (Xref: header) of articles are ignored.
4352 The difference between N and actual number of newsgroups that were
4353 caught up is returned."
4355 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4359 "Do you really want to mark all articles as read? "
4360 "Mark all unread articles as read? "))))
4362 (let ((groups (gnus-group-process-prefix n))
4365 ;; Virtual groups have to be given special treatment.
4366 (let ((method (gnus-find-method-for-group (car groups))))
4367 (if (eq 'nnvirtual (car method))
4368 (nnvirtual-catchup-group
4369 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4370 (gnus-group-remove-mark (car groups))
4372 (gnus-group-goto-group (car groups))
4373 (gnus-group-catchup (car groups) all))
4374 (gnus-group-update-group-line)
4375 (setq ret (1+ ret)))
4376 (setq groups (cdr groups)))
4377 (gnus-group-next-unread-group 1)
4380 (defun gnus-group-catchup-current-all (&optional n)
4381 "Mark all articles in current newsgroup as read.
4382 Cross references (Xref: header) of articles are ignored."
4384 (gnus-group-catchup-current n 'all))
4386 (defun gnus-group-catchup (group &optional all)
4387 "Mark all articles in GROUP as read.
4388 If ALL is non-nil, all articles are marked as read.
4389 The return value is the number of articles that were marked as read,
4390 or nil if no action could be taken."
4391 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4393 (marked (nth 3 (nth 2 entry))))
4394 (if (not (numberp (car entry)))
4395 (gnus-message 1 "Can't catch up; non-active group")
4396 ;; Do the updating only if the newsgroup isn't killed.
4399 (gnus-update-read-articles
4400 group (and (not all) (append (cdr (assq 'tick marked))
4401 (cdr (assq 'dormant marked))))
4402 nil (and (not all) (cdr (assq 'tick marked))))
4404 (setq marked (nth 3 (nth 2 entry)))
4405 (setcar (nthcdr 3 (nth 2 entry))
4406 (delq (assq 'dormant marked)
4407 (nth 3 (nth 2 entry)))))))
4410 (defun gnus-group-expire-articles (&optional n)
4411 "Expire all expirable articles in the current newsgroup."
4413 (let ((groups (gnus-group-process-prefix n))
4415 (or groups (error "No groups to expire"))
4417 (setq group (car groups)
4418 groups (cdr groups))
4419 (gnus-group-remove-mark group)
4420 (if (not (gnus-check-backend-function 'request-expire-articles group))
4422 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4423 (expirable (if (memq 'total-expire (nth 5 info))
4424 (cons nil (gnus-list-of-read-articles group))
4425 (assq 'expire (nth 3 info)))))
4428 (gnus-request-expire-articles
4429 (cdr expirable) group))))))))
4431 (defun gnus-group-expire-all-groups ()
4432 "Expire all expirable articles in all newsgroups."
4435 (gnus-message 5 "Expiring...")
4436 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4437 (cdr gnus-newsrc-alist))))
4438 (gnus-group-expire-articles nil)))
4439 (gnus-group-position-cursor)
4440 (gnus-message 5 "Expiring...done"))
4442 (defun gnus-group-set-current-level (n level)
4443 "Set the level of the next N groups to LEVEL."
4444 (interactive "P\nnLevel: ")
4445 (or (and (>= level 1) (<= level gnus-level-killed))
4446 (error "Illegal level: %d" level))
4447 (let ((groups (gnus-group-process-prefix n))
4450 (setq group (car groups)
4451 groups (cdr groups))
4452 (gnus-group-remove-mark group)
4453 (gnus-message 6 "Changed level of %s from %d to %d"
4454 group (gnus-group-group-level) level)
4455 (gnus-group-change-level group level
4456 (gnus-group-group-level))
4457 (gnus-group-update-group-line)))
4458 (gnus-group-position-cursor))
4460 (defun gnus-group-unsubscribe-current-group (&optional n)
4461 "Toggle subscription of the current group.
4462 If given numerical prefix, toggle the N next groups."
4464 (let ((groups (gnus-group-process-prefix n))
4467 (setq group (car groups)
4468 groups (cdr groups))
4469 (gnus-group-remove-mark group)
4470 (gnus-group-unsubscribe-group
4471 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4472 gnus-level-default-unsubscribed
4473 gnus-level-default-subscribed))
4474 (gnus-group-update-group-line))
4475 (gnus-group-next-group 1)))
4477 (defun gnus-group-unsubscribe-group (group &optional level)
4478 "Toggle subscribe from/to unsubscribe GROUP.
4479 New newsgroup is added to .newsrc automatically."
4481 (list (completing-read
4482 "Group: " gnus-active-hashtb nil
4483 (memq gnus-select-method gnus-have-read-active-file))))
4484 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4486 ;; Toggle subscription flag.
4487 (gnus-group-change-level
4488 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4489 gnus-level-subscribed)
4490 (1+ gnus-level-subscribed)
4491 gnus-level-default-subscribed)))
4492 (gnus-group-update-group group))
4493 ((and (stringp group)
4494 (or (not (memq gnus-select-method gnus-have-read-active-file))
4495 (gnus-gethash group gnus-active-hashtb)))
4496 ;; Add new newsgroup.
4497 (gnus-group-change-level
4499 (if level level gnus-level-default-subscribed)
4500 (or (and (member group gnus-zombie-list)
4503 (and (gnus-group-group-name)
4504 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4505 (gnus-group-update-group group))
4506 (t (error "No such newsgroup: %s" group)))
4507 (gnus-group-position-cursor)))
4509 (defun gnus-group-transpose-groups (n)
4510 "Move the current newsgroup up N places.
4511 If given a negative prefix, move down instead. The difference between
4512 N and the number of steps taken is returned."
4514 (or (gnus-group-group-name)
4515 (error "No group on current line"))
4516 (gnus-group-kill-group 1)
4518 (forward-line (- n))
4519 (gnus-group-yank-group)
4520 (gnus-group-position-cursor)))
4522 (defun gnus-group-kill-all-zombies ()
4523 "Kill all zombie newsgroups."
4525 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4526 (setq gnus-zombie-list nil)
4527 (gnus-group-list-groups))
4529 (defun gnus-group-kill-region (begin end)
4530 "Kill newsgroups in current region (excluding current point).
4531 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4546 (beginning-of-line) ;Important when LINES < 1
4547 (gnus-group-kill-group lines)))
4549 (defun gnus-group-kill-group (&optional n)
4550 "The the next N groups.
4551 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4552 However, only groups that were alive can be yanked; already killed
4553 groups or zombie groups can't be yanked.
4554 The return value is the name of the (last) group that was killed."
4556 (let ((buffer-read-only nil)
4557 (groups (gnus-group-process-prefix n))
4560 (setq group (car groups)
4561 groups (cdr groups))
4562 (gnus-group-remove-mark group)
4563 (setq level (gnus-group-group-level))
4565 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4566 (setq gnus-list-of-killed-groups
4567 (cons (cons (car entry) (nth 2 entry))
4568 gnus-list-of-killed-groups)))
4569 (gnus-group-change-level
4570 (if entry entry group) gnus-level-killed (if entry nil level)))
4571 (gnus-group-position-cursor)
4574 (defun gnus-group-yank-group (&optional arg)
4575 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4576 inserting it before the current newsgroup. The numeric ARG specifies
4577 how many newsgroups are to be yanked. The name of the (last)
4578 newsgroup yanked is returned."
4580 (if (not arg) (setq arg 1))
4581 (let (info group prev)
4582 (while (>= (setq arg (1- arg)) 0)
4583 (if (not (setq info (car gnus-list-of-killed-groups)))
4584 (error "No more newsgroups to yank"))
4585 (setq group (nth 2 info))
4586 ;; Find which newsgroup to insert this one before - search
4587 ;; backward until something suitable is found. If there are no
4588 ;; other newsgroups in this buffer, just make this newsgroup the
4590 (setq prev (gnus-group-group-name))
4591 (gnus-group-change-level
4592 info (nth 2 info) gnus-level-killed
4593 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4595 (gnus-group-insert-group-line-info (nth 1 info))
4596 (setq gnus-list-of-killed-groups
4597 (cdr gnus-list-of-killed-groups)))
4599 (gnus-group-position-cursor)
4602 (defun gnus-group-list-all-groups (&optional arg)
4603 "List all newsgroups with level ARG or lower.
4604 Default is gnus-level-unsubscribed, which lists all subscribed and most
4605 unsubscribed groups."
4607 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
4609 (defun gnus-group-list-killed ()
4610 "List all killed newsgroups in the group buffer."
4612 (if (not gnus-killed-list)
4613 (gnus-message 6 "No killed groups")
4614 (let (gnus-group-list-mode)
4615 (funcall gnus-group-prepare-function
4616 gnus-level-killed t gnus-level-killed))
4617 (goto-char (point-min)))
4618 (gnus-group-position-cursor))
4620 (defun gnus-group-list-zombies ()
4621 "List all zombie newsgroups in the group buffer."
4623 (if (not gnus-zombie-list)
4624 (gnus-message 6 "No zombie groups")
4625 (let (gnus-group-list-mode)
4626 (funcall gnus-group-prepare-function
4627 gnus-level-zombie t gnus-level-zombie))
4628 (goto-char (point-min)))
4629 (gnus-group-position-cursor))
4631 (defun gnus-group-get-new-news (&optional arg)
4632 "Get newly arrived articles.
4633 If ARG is non-nil, it should be a number between one and nine to
4634 specify which levels you are interested in re-scanning."
4636 (run-hooks 'gnus-get-new-news-hook)
4637 (setq arg (gnus-group-default-level arg t))
4638 (if (and gnus-read-active-file (not arg))
4640 (gnus-read-active-file)
4641 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4642 (let ((gnus-read-active-file (not arg))
4643 (gnus-have-read-active-file
4644 (and (not arg) gnus-have-read-active-file)))
4645 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4646 (gnus-group-list-groups))
4648 (defun gnus-group-get-new-news-this-group (&optional n)
4649 "Check for newly arrived news in the current group (and the N-1 next groups).
4650 The difference between N and the number of newsgroup checked is returned.
4651 If N is negative, this group and the N-1 previous groups will be checked."
4653 (let* ((groups (gnus-group-process-prefix n))
4654 (ret (if (numberp n) (- n (length groups)) 0))
4657 (setq group (car groups)
4658 groups (cdr groups))
4659 (gnus-group-remove-mark group)
4660 (or (gnus-get-new-news-in-group group)
4663 (message "%s error: %s" group (gnus-status-message group))
4665 (gnus-group-next-unread-group 1 t)
4666 (gnus-summary-position-cursor)
4669 (defun gnus-get-new-news-in-group (group)
4671 (gnus-activate-group group)
4673 (gnus-get-unread-articles-in-group
4674 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4675 (gnus-gethash group gnus-active-hashtb))
4676 (gnus-group-update-group-line)
4679 (defun gnus-group-fetch-faq (group)
4680 "Fetch the FAQ for the current group."
4681 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4682 (or group (error "No group name given"))
4683 (let ((file (concat gnus-group-faq-directory group)))
4684 (if (not (file-exists-p file))
4685 (error "No such file: %s" file)
4688 (defun gnus-group-describe-group (force &optional group)
4689 "Display a description of the current newsgroup."
4690 (interactive (list current-prefix-arg (gnus-group-group-name)))
4691 (and force (setq gnus-description-hashtb nil))
4692 (let ((method (gnus-find-method-for-group group))
4694 (or group (error "No group name given"))
4695 (and (or (and gnus-description-hashtb
4696 ;; We check whether this group's method has been
4697 ;; queried for a description file.
4699 (gnus-group-prefixed-name "" method)
4700 gnus-description-hashtb))
4701 (setq desc (gnus-group-get-description group))
4702 (gnus-read-descriptions-file method))
4704 (or desc (gnus-gethash group gnus-description-hashtb)
4705 "No description available")))))
4707 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4708 (defun gnus-group-describe-all-groups (&optional force)
4709 "Pop up a buffer with descriptions of all newsgroups."
4711 (and force (setq gnus-description-hashtb nil))
4712 (if (not (or gnus-description-hashtb
4713 (gnus-read-all-descriptions-files)))
4714 (error "Couldn't request descriptions file"))
4715 (let ((buffer-read-only nil)
4721 (insert (format " *: %-20s %s\n" (symbol-name group)
4722 (symbol-value group)))
4723 (add-text-properties
4724 b (1+ b) (list 'gnus-group group
4725 'gnus-unread t 'gnus-marked nil
4726 'gnus-level (1+ gnus-level-subscribed))))
4727 gnus-description-hashtb)
4728 (goto-char (point-min))
4729 (gnus-group-position-cursor)))
4731 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4732 (defun gnus-group-apropos (regexp &optional search-description)
4733 "List all newsgroups that have names that match a regexp."
4734 (interactive "sGnus apropos (regexp): ")
4736 (obuf (current-buffer))
4738 ;; Go through all newsgroups that are known to Gnus.
4741 (and (symbol-name group)
4742 (string-match regexp (symbol-name group))
4743 (setq groups (cons (symbol-name group) groups))))
4745 ;; Go through all descriptions that are known to Gnus.
4746 (if search-description
4749 (and (string-match regexp (symbol-value group))
4750 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4751 (setq groups (cons (symbol-name group) groups))))
4752 gnus-description-hashtb))
4754 (gnus-message 3 "No groups matched \"%s\"." regexp)
4755 ;; Print out all the groups.
4757 (pop-to-buffer "*Gnus Help*")
4758 (buffer-disable-undo (current-buffer))
4760 (setq groups (sort groups 'string<))
4762 ;; Groups may be entered twice into the list of groups.
4763 (if (not (string= (car groups) prev))
4765 (insert (setq prev (car groups)) "\n")
4766 (if (and gnus-description-hashtb
4767 (setq des (gnus-gethash (car groups)
4768 gnus-description-hashtb)))
4769 (insert " " des "\n"))))
4770 (setq groups (cdr groups)))
4771 (goto-char (point-min))))
4772 (pop-to-buffer obuf)))
4774 (defun gnus-group-description-apropos (regexp)
4775 "List all newsgroups that have names or descriptions that match a regexp."
4776 (interactive "sGnus description apropos (regexp): ")
4777 (if (not (or gnus-description-hashtb
4778 (gnus-read-all-descriptions-files)))
4779 (error "Couldn't request descriptions file"))
4780 (gnus-group-apropos regexp t))
4782 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4783 (defun gnus-group-list-matching (level regexp &optional all lowest)
4784 "List all groups with unread articles that match REGEXP.
4785 If the prefix LEVEL is non-nil, it should be a number that says which
4786 level to cut off listing groups.
4787 If ALL, also list groups with no unread articles.
4788 If LOWEST, don't list groups with level lower than LOWEST."
4789 (interactive "P\nsList newsgroups matching: ")
4790 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4791 all (or lowest 1) regexp)
4792 (goto-char (point-min))
4793 (gnus-group-position-cursor))
4795 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4796 "List all groups that match REGEXP.
4797 If the prefix LEVEL is non-nil, it should be a number that says which
4798 level to cut off listing groups.
4799 If LOWEST, don't list groups with level lower than LOWEST."
4800 (interactive "P\nsList newsgroups matching: ")
4801 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4803 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4804 (defun gnus-group-save-newsrc ()
4805 "Save the Gnus startup files."
4807 (gnus-save-newsrc-file))
4809 (defun gnus-group-restart (&optional arg)
4810 "Force Gnus to read the .newsrc file."
4812 (gnus-save-newsrc-file)
4813 (gnus-setup-news 'force)
4814 (gnus-group-list-groups arg))
4816 (defun gnus-group-read-init-file ()
4817 "Read the Gnus elisp init file."
4819 (gnus-read-init-file))
4821 (defun gnus-group-check-bogus-groups (&optional silent)
4822 "Check bogus newsgroups.
4823 If given a prefix, don't ask for confirmation before removing a bogus
4826 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4827 (gnus-group-list-groups))
4829 (defun gnus-group-edit-global-kill (&optional article group)
4830 "Edit the global kill file.
4831 If GROUP, edit that local kill file instead."
4833 (setq gnus-current-kill-article article)
4834 (gnus-kill-file-edit-file group)
4836 (substitute-command-keys
4837 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4839 (defun gnus-group-edit-local-kill (article group)
4840 "Edit a local kill file."
4841 (interactive (list nil (gnus-group-group-name)))
4842 (gnus-group-edit-global-kill article group))
4844 (defun gnus-group-force-update ()
4845 "Update `.newsrc' file."
4847 (gnus-save-newsrc-file))
4849 (defun gnus-group-suspend ()
4850 "Suspend the current Gnus session.
4851 In fact, cleanup buffers except for group mode buffer.
4852 The hook gnus-suspend-gnus-hook is called before actually suspending."
4854 (run-hooks 'gnus-suspend-gnus-hook)
4855 ;; Kill Gnus buffers except for group mode buffer.
4856 (let ((group-buf (get-buffer gnus-group-buffer)))
4857 ;; Do this on a separate list in case the user does a ^G before we finish
4858 (let ((gnus-buffer-list
4859 (delq group-buf (delq gnus-dribble-buffer
4860 (append gnus-buffer-list nil)))))
4861 (while gnus-buffer-list
4862 (gnus-kill-buffer (car gnus-buffer-list))
4863 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4866 (setq gnus-buffer-list (list group-buf))
4867 (bury-buffer group-buf)
4868 (delete-windows-on group-buf t)))))
4870 (defun gnus-group-clear-dribble ()
4871 "Clear all information from the dribble buffer."
4873 (gnus-dribble-clear))
4875 (defun gnus-group-exit ()
4876 "Quit reading news after updating .newsrc.eld and .newsrc.
4877 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4879 (if (or noninteractive ;For gnus-batch-kill
4880 (zerop (buffer-size)) ;No news is good news.
4881 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4882 (not gnus-interactive-exit) ;Without confirmation
4884 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4886 (run-hooks 'gnus-exit-gnus-hook)
4887 ;; Offer to save data from non-quitted summary buffers.
4888 (gnus-offer-save-summaries)
4889 ;; Save the newsrc file(s).
4890 (gnus-save-newsrc-file)
4892 (gnus-close-backends)
4893 ;; Reset everything.
4894 (gnus-clear-system))))
4896 (defun gnus-close-backends ()
4897 ;; Send a close request to all backends that support such a request.
4898 (let ((methods gnus-valid-select-methods)
4901 (if (fboundp (setq func (intern (concat (car (car methods))
4902 "-request-close"))))
4904 (setq methods (cdr methods)))))
4906 (defun gnus-group-quit ()
4907 "Quit reading news without updating .newsrc.eld or .newsrc.
4908 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4910 (if (or noninteractive ;For gnus-batch-kill
4911 (zerop (buffer-size))
4912 (not (gnus-server-opened gnus-select-method))
4914 (not gnus-current-startup-file)
4916 (format "Quit reading news without saving %s? "
4917 (file-name-nondirectory gnus-current-startup-file))))
4919 (run-hooks 'gnus-exit-gnus-hook)
4920 (if gnus-use-full-window
4921 (delete-other-windows)
4922 (gnus-remove-some-windows))
4924 (gnus-close-backends)
4925 (gnus-clear-system))))
4927 (defun gnus-offer-save-summaries ()
4928 (let ((buffers (buffer-list))
4931 (while (and buffers (not (eq answer ?q)))
4933 ;; We look for buffers with "Summary" in the name.
4934 (string-match "Summary" (or (buffer-name (car buffers)) ""))
4936 (set-buffer (car buffers))
4937 ;; We check that this is, indeed, a summary buffer.
4938 (eq major-mode 'gnus-summary-mode))
4939 ;; We ask the user whether she wants to save the info.
4943 (while (not (memq answer '(?y ?n ?! ?q)))
4944 (message (format "%sUpdate summary buffer %s? (y, n, !, q)"
4945 (if answer "Illegal char. " "")
4947 (setq answer (read-char)))
4948 (or (eq answer ?y) (eq answer ?!))))
4949 ;; We do it by simply exiting.
4950 (gnus-summary-exit))
4951 (setq buffers (cdr buffers))))))
4953 (defun gnus-group-describe-briefly ()
4954 "Give a one line description of the group mode commands."
4956 (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")))
4958 (defun gnus-group-browse-foreign-server (method)
4959 "Browse a foreign news server.
4960 If called interactively, this function will ask for a select method
4961 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4962 If not, METHOD should be a list where the first element is the method
4963 and the second element is the address."
4965 (list (let ((how (completing-read
4967 (append gnus-valid-select-methods gnus-server-alist)
4969 ;; We either got a backend name or a virtual server name.
4970 ;; If the first, we also need an address.
4971 (if (assoc how gnus-valid-select-methods)
4973 ;; Suggested by mapjph@bath.ac.uk.
4976 (mapcar (lambda (server) (list server))
4977 gnus-secondary-servers)))
4978 ;; We got a server name, so we find the method.
4979 (gnus-server-to-method how)))))
4980 (gnus-browse-foreign-server method))
4984 ;;; Browse Server Mode
4987 (defvar gnus-browse-mode-hook nil)
4988 (defvar gnus-browse-mode-map nil)
4989 (put 'gnus-browse-mode 'mode-class 'special)
4991 (if gnus-browse-mode-map
4993 (setq gnus-browse-mode-map (make-keymap))
4994 (suppress-keymap gnus-browse-mode-map)
4995 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
4996 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
4997 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
4998 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
4999 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
5000 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
5001 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
5002 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
5003 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
5004 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
5005 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
5006 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
5007 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
5008 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
5009 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
5010 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
5011 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
5012 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
5015 (defvar gnus-browse-current-method nil)
5016 (defvar gnus-browse-return-buffer nil)
5018 (defvar gnus-browse-buffer "*Gnus Browse Server*")
5020 (defun gnus-browse-foreign-server (method &optional return-buffer)
5021 (setq gnus-browse-current-method method)
5022 (setq gnus-browse-return-buffer return-buffer)
5023 (let ((gnus-select-method method)
5025 (gnus-message 5 "Connecting to %s..." (nth 1 method))
5026 (or (gnus-check-server method)
5027 (error "Unable to contact server: %s" (gnus-status-message method)))
5028 (or (gnus-request-list method)
5029 (error "Couldn't request list: %s" (gnus-status-message method)))
5030 (get-buffer-create gnus-browse-buffer)
5031 (gnus-add-current-to-buffer-list)
5032 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
5033 (gnus-configure-windows 'browse)
5034 (buffer-disable-undo (current-buffer))
5035 (let ((buffer-read-only nil))
5038 (setq mode-line-buffer-identification
5040 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
5042 (set-buffer nntp-server-buffer)
5043 (let ((cur (current-buffer)))
5044 (goto-char (point-min))
5045 (or (string= gnus-ignored-newsgroups "")
5046 (delete-matching-lines gnus-ignored-newsgroups))
5047 (while (re-search-forward
5048 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
5049 (goto-char (match-end 1))
5050 (setq groups (cons (cons (buffer-substring (match-beginning 1)
5052 (max 0 (- (1+ (read cur)) (read cur))))
5054 (setq groups (sort groups
5056 (string< (car l1) (car l2)))))
5057 (let ((buffer-read-only nil))
5059 (setq group (car groups))
5061 (format "K%7d: %s\n" (cdr group) (car group)))
5062 (setq groups (cdr groups))))
5063 (switch-to-buffer (current-buffer))
5064 (goto-char (point-min))
5065 (gnus-group-position-cursor)))
5067 (defun gnus-browse-mode ()
5068 "Major mode for browsing a foreign server.
5070 All normal editing commands are switched off.
5072 \\<gnus-browse-mode-map>
5073 The only things you can do in this buffer is
5075 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
5076 The group will be inserted into the group buffer upon exit from this
5079 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
5081 3) `\\[gnus-browse-exit]' to return to the group buffer."
5083 (kill-all-local-variables)
5084 (if gnus-visual (gnus-browse-make-menu-bar))
5085 (setq mode-line-modified "-- ")
5086 (make-local-variable 'mode-line-format)
5087 (setq mode-line-format (copy-sequence mode-line-format))
5088 (and (equal (nth 3 mode-line-format) " ")
5089 (setcar (nthcdr 3 mode-line-format) ""))
5090 (setq major-mode 'gnus-browse-mode)
5091 (setq mode-name "Browse Server")
5092 (setq mode-line-process nil)
5093 (use-local-map gnus-browse-mode-map)
5094 (buffer-disable-undo (current-buffer))
5095 (setq truncate-lines t)
5096 (setq buffer-read-only t)
5097 (run-hooks 'gnus-browse-mode-hook))
5099 (defun gnus-browse-read-group (&optional no-article)
5100 "Enter the group at the current line."
5102 (let ((group (gnus-browse-group-name)))
5103 (or (gnus-group-read-ephemeral-group
5104 group gnus-browse-current-method nil
5105 (cons (current-buffer) 'browse))
5106 (error "Couldn't enter %s" group))))
5108 (defun gnus-browse-select-group ()
5109 "Select the current group."
5111 (gnus-browse-read-group 'no))
5113 (defun gnus-browse-next-group (n)
5114 "Go to the next group."
5118 (gnus-group-position-cursor)))
5120 (defun gnus-browse-prev-group (n)
5121 "Go to the next group."
5123 (gnus-browse-next-group (- n)))
5125 (defun gnus-browse-unsubscribe-current-group (arg)
5126 "(Un)subscribe to the next ARG groups."
5129 (error "No group at current line."))
5130 (let ((ward (if (< arg 0) -1 1))
5132 (while (and (> arg 0)
5134 (gnus-browse-unsubscribe-group)
5135 (zerop (gnus-browse-next-group ward)))
5136 (setq arg (1- arg)))
5137 (gnus-group-position-cursor)
5138 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5141 (defun gnus-browse-group-name ()
5144 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5146 (gnus-group-prefixed-name
5147 (buffer-substring (match-beginning 1) (match-end 1))
5148 gnus-browse-current-method))))
5150 (defun gnus-browse-unsubscribe-group ()
5152 (buffer-read-only nil)
5156 (if (= (following-char) ?K) (setq sub t))
5157 (setq group (gnus-browse-group-name))
5162 (gnus-group-change-level
5163 (list t group gnus-level-default-subscribed
5164 nil nil gnus-browse-current-method)
5165 gnus-level-default-subscribed gnus-level-killed
5166 (and (car (nth 1 gnus-newsrc-alist))
5167 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5168 gnus-newsrc-hashtb))
5171 (gnus-group-change-level
5172 group gnus-level-killed gnus-level-default-subscribed)
5176 (defun gnus-browse-exit ()
5177 "Quit browsing and return to the group buffer."
5179 (if (eq major-mode 'gnus-browse-mode)
5180 (kill-buffer (current-buffer)))
5181 (if gnus-browse-return-buffer
5182 (gnus-configure-windows 'server 'force)
5183 (gnus-configure-windows 'group 'force)
5184 (gnus-group-list-groups nil)))
5186 (defun gnus-browse-describe-briefly ()
5187 "Give a one line description of the group mode commands."
5190 (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")))
5194 ;;; Gnus summary mode
5197 (defvar gnus-summary-mode-map nil)
5198 (defvar gnus-summary-mark-map nil)
5199 (defvar gnus-summary-mscore-map nil)
5200 (defvar gnus-summary-article-map nil)
5201 (defvar gnus-summary-thread-map nil)
5202 (defvar gnus-summary-goto-map nil)
5203 (defvar gnus-summary-exit-map nil)
5204 (defvar gnus-summary-interest-map nil)
5205 (defvar gnus-summary-sort-map nil)
5206 (defvar gnus-summary-backend-map nil)
5207 (defvar gnus-summary-save-map nil)
5208 (defvar gnus-summary-wash-map nil)
5209 (defvar gnus-summary-wash-hide-map nil)
5210 (defvar gnus-summary-wash-highlight-map nil)
5211 (defvar gnus-summary-wash-time-map nil)
5212 (defvar gnus-summary-help-map nil)
5214 (put 'gnus-summary-mode 'mode-class 'special)
5216 (if gnus-summary-mode-map
5218 (setq gnus-summary-mode-map (make-keymap))
5219 (suppress-keymap gnus-summary-mode-map)
5221 ;; Non-orthogonal keys
5223 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5224 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5225 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5226 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5227 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5228 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5229 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5230 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5231 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5232 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5233 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5234 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5235 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5236 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
5237 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
5238 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5239 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5240 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5241 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5242 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5243 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5244 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5245 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5246 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5247 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5248 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5249 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5250 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5251 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
5252 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5253 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5254 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5255 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5256 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5257 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5258 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5259 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5260 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5261 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5262 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5263 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5264 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5265 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5266 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5267 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5268 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5269 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5270 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5271 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5272 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5273 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5274 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5275 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5276 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5277 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
5278 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5279 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5280 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5281 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5282 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5283 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5284 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5285 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5286 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5287 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5288 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5289 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5290 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5291 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5292 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5293 (define-key gnus-summary-mode-map "V" 'gnus-version)
5294 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5295 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5296 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5297 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5298 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5299 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5300 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5301 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
5302 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5303 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5304 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5305 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5306 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5307 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5308 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5309 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5310 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5311 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5314 ;; Sort of orthogonal keymap
5315 (define-prefix-command 'gnus-summary-mark-map)
5316 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5317 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5318 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5319 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5320 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5321 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5322 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5323 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5324 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5325 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5326 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5327 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5328 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5329 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5330 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5331 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5332 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5333 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5334 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5335 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5336 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5337 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5338 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
5339 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5341 (define-prefix-command 'gnus-summary-mscore-map)
5342 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map)
5343 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5344 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5345 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5346 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5348 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map)
5350 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5352 (define-prefix-command 'gnus-summary-goto-map)
5353 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5354 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5355 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5356 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5357 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5358 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5359 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5360 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5361 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5362 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5363 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5364 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5365 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5366 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5369 (define-prefix-command 'gnus-summary-thread-map)
5370 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5371 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5372 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5373 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5374 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5375 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5376 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5377 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5378 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5379 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5380 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5381 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5382 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5383 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5386 (define-prefix-command 'gnus-summary-exit-map)
5387 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5388 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5389 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5390 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5391 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5392 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5393 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
5394 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5395 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5396 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5397 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5400 (define-prefix-command 'gnus-summary-article-map)
5401 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5402 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5403 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5404 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5405 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5406 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5407 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5408 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5409 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5410 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5411 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5412 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5413 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5414 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5418 (define-prefix-command 'gnus-summary-wash-map)
5419 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5421 (define-prefix-command 'gnus-summary-wash-hide-map)
5422 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map)
5423 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide)
5424 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers)
5425 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature)
5426 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation)
5427 (define-key gnus-summary-wash-hide-map "\C-c" 'gnus-article-hide-citation-maybe)
5429 (define-prefix-command 'gnus-summary-wash-highlight-map)
5430 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map)
5431 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight)
5432 (define-key gnus-summary-wash-highlight-map "h" 'gnus-article-highlight-headers)
5433 (define-key gnus-summary-wash-highlight-map "c" 'gnus-article-highlight-citation)
5434 (define-key gnus-summary-wash-highlight-map "s" 'gnus-article-highlight-signature)
5436 (define-prefix-command 'gnus-summary-wash-time-map)
5437 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map)
5438 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut)
5439 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut)
5440 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local)
5441 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed)
5443 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5444 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5445 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5446 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr)
5447 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5448 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5449 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
5450 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
5451 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header)
5452 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
5455 (define-prefix-command 'gnus-summary-help-map)
5456 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5457 (define-key gnus-summary-help-map "v" 'gnus-version)
5458 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5459 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5460 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5461 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5464 (define-prefix-command 'gnus-summary-backend-map)
5465 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5466 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5467 (define-key gnus-summary-backend-map "\M-\C-e"
5468 'gnus-summary-expire-articles-now)
5469 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5470 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5471 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5472 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5473 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5474 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5475 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5478 (define-prefix-command 'gnus-summary-save-map)
5479 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5480 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5481 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5482 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5483 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5484 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5485 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5486 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5487 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5489 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5491 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
5492 ; (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5493 ; (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5494 ; (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5495 ; (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5496 ; (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5497 ; (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5498 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
5499 ; (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5500 ; (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5502 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map)
5504 ; (define-prefix-command 'gnus-summary-sort-map)
5505 ; (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5506 ; (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5507 ; (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5508 ; (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5509 ; (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5510 ; (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5512 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5513 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5519 (defun gnus-summary-mode (&optional group)
5520 "Major mode for reading articles.
5522 All normal editing commands are switched off.
5523 \\<gnus-summary-mode-map>
5524 Each line in this buffer represents one article. To read an
5525 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5526 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5529 You can also post articles and send mail from this buffer. To
5530 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5531 of an article, type `\\[gnus-summary-reply]'.
5533 There are approx. one gazillion commands you can execute in this
5534 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5536 The following commands are available:
5538 \\{gnus-summary-mode-map}"
5540 (if gnus-visual (gnus-summary-make-menu-bar))
5541 (kill-all-local-variables)
5542 (let ((locals gnus-summary-local-variables))
5544 (if (consp (car locals))
5546 (make-local-variable (car (car locals)))
5547 (set (car (car locals)) (eval (cdr (car locals)))))
5548 (make-local-variable (car locals))
5549 (set (car locals) nil))
5550 (setq locals (cdr locals))))
5551 (gnus-make-thread-indent-array)
5552 (setq mode-line-modified "-- ")
5553 (make-local-variable 'mode-line-format)
5554 (setq mode-line-format (copy-sequence mode-line-format))
5555 (and (equal (nth 3 mode-line-format) " ")
5556 (setcar (nthcdr 3 mode-line-format) ""))
5557 (setq major-mode 'gnus-summary-mode)
5558 (setq mode-name "Summary")
5559 (make-local-variable 'minor-mode-alist)
5560 (use-local-map gnus-summary-mode-map)
5561 (buffer-disable-undo (current-buffer))
5562 (setq buffer-read-only t) ;Disable modification
5563 (setq truncate-lines t)
5564 (setq selective-display t)
5565 (setq selective-display-ellipses t) ;Display `...'
5566 (setq buffer-display-table gnus-summary-display-table)
5567 (setq gnus-newsgroup-name group)
5568 (run-hooks 'gnus-summary-mode-hook))
5570 (defun gnus-summary-make-display-table ()
5571 ;; Change the display table. Odd characters have a tendency to mess
5572 ;; up nicely formatted displays - we make all possible glyphs
5573 ;; display only a single character.
5575 ;; We start from the standard display table, if any.
5576 (setq gnus-summary-display-table
5577 (or (copy-sequence standard-display-table)
5578 (make-display-table)))
5579 ;; Nix out all the control chars...
5581 (while (>= (setq i (1- i)) 0)
5582 (aset gnus-summary-display-table i [??])))
5583 ;; ... but not newline and cr, of course. (cr is necessary for the
5584 ;; selective display).
5585 (aset gnus-summary-display-table ?\n nil)
5586 (aset gnus-summary-display-table ?\r nil)
5587 ;; We nix out any glyphs over 126 that are not set already.
5589 (while (>= (setq i (1- i)) 127)
5590 ;; Only modify if the entry is nil.
5591 (or (aref gnus-summary-display-table i)
5592 (aset gnus-summary-display-table i [??])))))
5594 (defun gnus-summary-clear-local-variables ()
5595 (let ((locals gnus-summary-local-variables))
5597 (if (consp (car locals))
5598 (and (vectorp (car (car locals)))
5599 (set (car (car locals)) nil))
5600 (and (vectorp (car locals))
5601 (set (car locals) nil)))
5602 (setq locals (cdr locals)))))
5604 ;; Some summary mode macros.
5606 ;; Return a header specified by a NUMBER.
5607 (defun gnus-get-header-by-number (number)
5609 (set-buffer gnus-summary-buffer)
5610 (or gnus-newsgroup-headers-hashtb-by-number
5611 (gnus-make-headers-hashtable-by-number))
5612 (gnus-gethash (int-to-string number)
5613 gnus-newsgroup-headers-hashtb-by-number)))
5615 ;; Fast version of the function above.
5616 (defmacro gnus-get-header-by-num (number)
5617 (` (gnus-gethash (int-to-string (, number))
5618 gnus-newsgroup-headers-hashtb-by-number)))
5620 (defmacro gnus-summary-search-forward (&optional unread subject backward)
5621 "Search for article forward.
5622 If UNREAD is non-nil, only unread articles are selected.
5623 If SUBJECT is non-nil, the article which has the same subject will be
5625 If BACKWARD is non-nil, the search will be performed backwards instead."
5626 (` (gnus-summary-search-subject (, backward) (, unread) (, subject))))
5628 (defmacro gnus-summary-search-backward (&optional unread subject)
5629 "Search for article backward.
5630 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5631 If 2nd optional argument SUBJECT is non-nil, the article which has
5632 the same subject will be searched for."
5633 (` (gnus-summary-search-forward (, unread) (, subject) t)))
5635 (defmacro gnus-summary-article-number (&optional number-or-nil)
5636 "The article number of the article on the current line.
5637 If there isn's an article number here, then we return the current
5640 '(get-text-property (gnus-point-at-bol) 'gnus-number)
5641 '(or (get-text-property (gnus-point-at-bol) 'gnus-number)
5642 gnus-current-article)))
5644 (defmacro gnus-summary-thread-level ()
5645 "The thread level of the article on the current line."
5646 '(or (get-text-property (gnus-point-at-bol) 'gnus-level)
5649 (defmacro gnus-summary-article-mark ()
5650 "The mark on the current line."
5651 '(get-text-property (gnus-point-at-bol) 'gnus-mark))
5653 (defun gnus-summary-subject-string ()
5654 "Return current subject string or nil if nothing."
5655 (let ((article (gnus-summary-article-number))
5658 (setq header (gnus-get-header-by-num article))
5660 (header-subject header))))
5662 ;; Various summary mode internalish functions.
5664 (defun gnus-mouse-pick-article (e)
5667 (gnus-summary-next-page nil t))
5669 (defun gnus-summary-setup-buffer (group)
5670 "Initialize summary buffer."
5671 (let ((buffer (concat "*Summary " group "*")))
5672 (if (get-buffer buffer)
5675 (not gnus-newsgroup-begin))
5676 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5677 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5678 (gnus-add-current-to-buffer-list)
5679 (gnus-summary-mode group)
5680 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5681 (setq gnus-newsgroup-name group)
5684 (defun gnus-set-global-variables ()
5685 ;; Set the global equivalents of the summary buffer-local variables
5686 ;; to the latest values they had. These reflect the summary buffer
5687 ;; that was in action when the last article was fetched.
5688 (if (eq major-mode 'gnus-summary-mode)
5690 (setq gnus-summary-buffer (current-buffer))
5691 (let ((name gnus-newsgroup-name)
5692 (marked gnus-newsgroup-marked)
5693 (unread gnus-newsgroup-unreads)
5694 (headers gnus-current-headers)
5695 (score-file gnus-current-score-file))
5697 (set-buffer gnus-group-buffer)
5698 (setq gnus-newsgroup-name name)
5699 (setq gnus-newsgroup-marked marked)
5700 (setq gnus-newsgroup-unreads unread)
5701 (setq gnus-current-headers headers)
5702 (setq gnus-current-score-file score-file))))))
5704 (defun gnus-summary-insert-dummy-line (sformat subject number)
5706 (setq sformat gnus-summary-dummy-line-format-spec))
5710 (insert (eval sformat))
5711 (add-text-properties
5713 (list 'gnus-number number
5714 'gnus-mark gnus-dummy-mark
5717 (defvar gnus-thread-indent-array nil)
5718 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5719 (defun gnus-make-thread-indent-array ()
5721 (if (and gnus-thread-indent-array
5722 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5724 (setq gnus-thread-indent-array (make-vector 201 "")
5725 gnus-thread-indent-array-level gnus-thread-indent-level)
5727 (aset gnus-thread-indent-array n
5728 (make-string (* n gnus-thread-indent-level) ? ))
5731 (defun gnus-summary-insert-line
5732 (sformat header level current unread replied expirable subject-or-nil
5733 &optional dummy score)
5734 (or sformat (setq sformat gnus-summary-line-format-spec))
5735 (let* ((indentation (aref gnus-thread-indent-array level))
5736 (lines (header-lines header))
5737 (score (or score gnus-summary-default-score 0))
5739 (if (or (null gnus-summary-default-score)
5740 (<= (abs (- score gnus-summary-default-score))
5741 gnus-summary-zcore-fuzz)) ?
5742 (if (< score gnus-summary-default-score)
5743 gnus-score-below-mark gnus-score-over-mark)))
5744 (replied (if replied gnus-replied-mark ? ))
5745 (from (header-from header))
5747 ((string-match "(.+)" from)
5748 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
5749 ((string-match "<[^>]+> *$" from)
5750 (let ((beg (match-beginning 0)))
5751 (or (and (string-match "^\"[^\"]*\"" from)
5752 (substring from (1+ (match-beginning 0))
5753 (1- (match-end 0))))
5754 (substring from 0 beg))))
5756 (subject (header-subject header))
5757 (number (header-number header))
5758 (opening-bracket (if dummy ?\< ?\[))
5759 (closing-bracket (if dummy ?\> ?\]))
5760 (buffer-read-only nil)
5761 (b (progn (beginning-of-line) (point))))
5762 (or (numberp lines) (setq lines 0))
5763 (insert (eval sformat))
5764 (add-text-properties
5765 b (1+ b) (list 'gnus-number number
5766 'gnus-mark (or unread gnus-unread-mark)
5767 'gnus-level level))))
5769 (defun gnus-summary-update-line (&optional dont-update)
5770 ;; Update summary line after change.
5771 (or (not gnus-summary-default-score)
5772 gnus-summary-inhibit-highlight
5773 (let ((gnus-summary-inhibit-highlight t)
5774 (article (gnus-summary-article-number)))
5777 (if (and gnus-summary-mark-below
5778 (< (gnus-summary-article-score)
5779 gnus-summary-mark-below))
5780 (and (not (memq article gnus-newsgroup-marked))
5781 (not (memq article gnus-newsgroup-dormant))
5782 (memq article gnus-newsgroup-unreads)
5783 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5784 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5785 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
5787 (run-hooks 'gnus-summary-update-hook))))))
5789 (defun gnus-summary-update-lines (&optional beg end)
5790 ;; Mark article as read (or not) by taking into account scores.
5791 (let ((beg (or beg (point-min)))
5792 (end (or end (point-max))))
5793 (if (or (not gnus-summary-default-score)
5794 gnus-summary-inhibit-highlight)
5796 (let ((gnus-summary-inhibit-highlight t)
5799 (set-buffer gnus-summary-buffer)
5802 (while (and (not (eobp)) (< (point) end))
5803 (if (and gnus-summary-mark-below
5805 (setq article (get-text-property
5806 (point) 'gnus-number))
5807 gnus-newsgroup-scored))
5808 gnus-summary-default-score 0)
5809 gnus-summary-mark-below))
5810 ;; We want to possibly mark it as read...
5811 (and (not (memq article gnus-newsgroup-marked))
5812 (not (memq article gnus-newsgroup-dormant))
5813 (memq article gnus-newsgroup-unreads)
5814 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5815 ;; We want to possibly mark it as unread.
5816 (and (eq (get-text-property (point) 'gnus-mark)
5817 gnus-low-score-mark)
5818 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
5819 ;; Do the visual highlights at the same time.
5820 (and gnus-visual (run-hooks 'gnus-summary-update-hook))
5821 (forward-line 1)))))))
5823 (defvar gnus-tmp-gathered nil)
5825 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5826 ;; Sum up all elements (and sub-elements) in a list.
5828 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
5829 (if (and (consp thread) (cdr thread))
5832 'gnus-summary-number-of-articles-in-thread
5836 (if (> number 1) gnus-not-empty-thread-mark
5837 gnus-empty-thread-mark)
5840 (defun gnus-summary-read-group
5841 (group &optional show-all no-article kill-buffer)
5842 "Start reading news in newsgroup GROUP.
5843 If SHOW-ALL is non-nil, already read articles are also listed.
5844 If NO-ARTICLE is non-nil, no article is selected initially."
5845 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5846 (let* ((new-group (gnus-summary-setup-buffer group))
5847 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
5849 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5852 (gnus-set-global-variables)
5853 (gnus-kill-buffer kill-buffer)
5854 (gnus-configure-windows 'summary)
5855 (gnus-set-mode-line 'summary)
5856 (gnus-summary-position-cursor)
5860 (and (eq major-mode 'gnus-summary-mode)
5861 (not (equal (current-buffer) kill-buffer))
5863 (kill-buffer (current-buffer))
5864 (if (not quit-config)
5866 (set-buffer gnus-group-buffer)
5867 (gnus-group-jump-to-group group)
5868 (gnus-group-next-unread-group 1))
5869 (if (not (buffer-name (car quit-config)))
5870 (gnus-configure-windows 'group 'force)
5871 (set-buffer (car quit-config))
5872 (and (eq major-mode 'gnus-summary-mode)
5873 (gnus-set-global-variables))
5874 (gnus-configure-windows (cdr quit-config))))))
5875 (message "Can't select group")
5877 ((eq did-select 'quit)
5878 (and (eq major-mode 'gnus-summary-mode)
5879 (not (equal (current-buffer) kill-buffer))
5880 (kill-buffer (current-buffer)))
5881 (gnus-kill-buffer kill-buffer)
5882 (if (not quit-config)
5884 (set-buffer gnus-group-buffer)
5885 (gnus-group-jump-to-group group)
5886 (gnus-group-next-unread-group 1)
5887 (gnus-configure-windows 'group 'force))
5888 (if (not (buffer-name (car quit-config)))
5889 (gnus-configure-windows 'group 'force)
5890 (set-buffer (car quit-config))
5891 (and (eq major-mode 'gnus-summary-mode)
5892 (gnus-set-global-variables))
5893 (gnus-configure-windows (cdr quit-config))))
5896 (gnus-set-global-variables)
5897 ;; Save the active value in effect when the group was entered.
5898 (setq gnus-newsgroup-active
5900 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5901 ;; You can change the subjects in this hook.
5902 (run-hooks 'gnus-select-group-hook)
5903 ;; Do score processing.
5904 (and gnus-use-scoring (gnus-possibly-score-headers))
5905 (gnus-update-format-specifications)
5906 ;; Generate the summary buffer.
5907 (gnus-summary-prepare)
5908 ;; Create the header hashtb.
5909 (gnus-make-headers-hashtable-by-number)
5910 (if (zerop (buffer-size))
5911 (cond (gnus-newsgroup-dormant
5912 (gnus-summary-show-all-dormant))
5913 ((and gnus-newsgroup-scored show-all)
5914 (gnus-summary-show-all-expunged))))
5915 ;; Function `gnus-apply-kill-file' must be called in this hook.
5916 (run-hooks 'gnus-apply-kill-hook)
5917 (if (zerop (buffer-size))
5919 ;; This newsgroup is empty.
5920 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5921 (gnus-message 6 "No unread news")
5922 (gnus-kill-buffer kill-buffer)
5926 ;; (let ((gnus-summary-buffer kill-buffer))
5927 ;; (gnus-configure-windows 'group))))
5928 ;; Hide conversation thread subtrees. We cannot do this in
5929 ;; gnus-summary-prepare-hook since kill processing may not
5930 ;; work with hidden articles.
5931 (and gnus-show-threads
5932 gnus-thread-hide-subtree
5933 (gnus-summary-hide-all-threads))
5934 ;; Show first unread article if requested.
5935 (goto-char (point-min))
5936 (if (and (not no-article)
5937 gnus-auto-select-first
5938 (gnus-summary-first-unread-article))
5940 (gnus-configure-windows 'summary))
5941 (gnus-set-mode-line 'summary)
5942 (gnus-summary-position-cursor)
5943 ;; If in async mode, we send some info to the backend.
5944 (and gnus-newsgroup-async
5945 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5946 (gnus-request-asynchronous
5948 (if (and gnus-asynchronous-article-function
5949 (fboundp gnus-asynchronous-article-function))
5950 (funcall gnus-asynchronous-article-function
5951 gnus-newsgroup-threads)
5952 gnus-newsgroup-threads)))
5953 (gnus-kill-buffer kill-buffer)
5954 (if (not (get-buffer-window gnus-group-buffer))
5956 ;; gotta use windows, because recenter does wierd stuff if
5957 ;; the current buffer ain't the displayed window.
5958 (let ((owin (selected-window)))
5959 (select-window (get-buffer-window gnus-group-buffer))
5960 (and (gnus-group-goto-group group)
5962 (select-window owin))))
5965 (defun gnus-summary-prepare ()
5966 ;; Generate the summary buffer.
5967 (let ((buffer-read-only nil))
5969 (gnus-summary-prepare-threads
5970 (if gnus-show-threads
5971 (gnus-gather-threads
5973 (if (and gnus-summary-expunge-below
5974 (not gnus-fetch-old-headers))
5975 (gnus-make-threads-and-expunge)
5976 (gnus-make-threads))))
5977 gnus-newsgroup-headers)
5979 (gnus-summary-update-lines)
5980 ;; Remove the final newline.
5981 ;;(goto-char (point-max))
5983 ;; Call hooks for modifying summary buffer.
5984 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5985 (goto-char (point-min))
5986 (run-hooks 'gnus-summary-prepare-hook)))
5988 (defun gnus-gather-threads (threads)
5989 "Gather threads that have lost their roots."
5990 (if (not gnus-summary-make-false-root)
5992 (let ((hashtb (gnus-make-hashtable 1023))
5995 subject hthread whole-subject)
5998 (setq subject (header-subject (car (car threads)))))
5999 (if gnus-summary-gather-subject-limit
6000 (or (and (numberp gnus-summary-gather-subject-limit)
6001 (> (length subject) gnus-summary-gather-subject-limit)
6003 (substring subject 0
6004 gnus-summary-gather-subject-limit)))
6005 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
6006 (setq subject (gnus-simplify-subject-fuzzy subject))))
6007 (setq subject (gnus-simplify-subject-re subject)))
6009 (gnus-gethash subject hashtb))
6011 (or (stringp (car (car hthread)))
6012 (setcar hthread (list whole-subject (car hthread))))
6013 (setcdr (car hthread) (nconc (cdr (car hthread))
6014 (list (car threads))))
6015 (setcdr prev (cdr threads))
6016 (setq threads prev))
6017 (gnus-sethash subject threads hashtb))
6019 (setq threads (cdr threads)))
6022 (defun gnus-make-threads ()
6023 ;; This function takes the dependencies already made by
6024 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6025 ;; through the dependecies in the hash table and finds all the
6026 ;; roots. Roots do not refer back to any valid articles.
6027 (gnus-message 6 "Threading...")
6028 (let (roots new-roots)
6029 (and gnus-fetch-old-headers
6030 (eq gnus-headers-retrieved-by 'nov)
6031 (gnus-build-old-threads))
6034 (if (not (car (symbol-value refs)))
6035 (setq roots (append (cdr (symbol-value refs)) roots))
6036 ;; Ok, these refer back to valid articles, but if
6037 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6038 ;; the root has the same subject as its children. The children
6039 ;; that do not are made into roots and removed from the list
6041 (or gnus-thread-ignore-subject
6042 (let* ((prev (symbol-value refs))
6043 (subject (gnus-simplify-subject-re
6044 (header-subject (car prev))))
6045 (headers (cdr prev)))
6047 (if (not (string= subject
6048 (gnus-simplify-subject-re
6049 (header-subject (car headers)))))
6051 (setq new-roots (cons (car headers) new-roots))
6052 (setcdr prev (cdr headers)))
6053 (setq prev headers))
6054 (setq headers (cdr headers)))))))
6055 gnus-newsgroup-dependencies)
6057 ;; We enter the new roots into the dependencies structure to
6058 ;; ensure that any possible later thread-regeneration will be
6060 (let ((r new-roots))
6062 (gnus-sethash (concat (header-id (car r)) ".boo")
6063 (list nil (car r)) gnus-newsgroup-dependencies)
6066 (setq roots (nconc new-roots roots))
6069 (mapcar 'gnus-trim-thread
6071 (mapcar 'gnus-cut-thread
6072 (mapcar 'gnus-make-sub-thread roots))))
6073 (gnus-message 6 "Threading...done"))))
6076 (defun gnus-make-threads-and-expunge ()
6077 ;; This function takes the dependencies already made by
6078 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6079 ;; through the dependecies in the hash table and finds all the
6080 ;; roots. Roots do not refer back to any valid articles.
6081 (gnus-message 6 "Threading...")
6082 (let ((default (or gnus-summary-default-score 0))
6083 (below gnus-summary-expunge-below)
6084 roots article new-roots)
6085 (and gnus-fetch-old-headers
6086 (eq gnus-headers-retrieved-by 'nov)
6087 (gnus-build-old-threads))
6090 (if (not (car (symbol-value refs)))
6091 ;; These articles do not refer back to any other articles -
6093 (let ((headers (cdr (symbol-value refs))))
6094 ;; We weed out the low-scored articles.
6096 (if (not (< (or (cdr (assq (header-number (car headers))
6097 gnus-newsgroup-scored)) default)
6100 (setq roots (cons (car headers) roots))
6101 ;; It is below, so we mark it as read.
6102 (setq gnus-newsgroup-unreads
6103 (delq (header-number (car headers))
6104 gnus-newsgroup-unreads))
6105 (setq gnus-newsgroup-reads
6106 (cons (cons (header-number (car headers))
6107 gnus-low-score-mark)
6108 gnus-newsgroup-reads)))
6109 (setq headers (cdr headers))))
6110 ;; Ok, these refer back to valid articles, but if
6111 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6112 ;; the root has the same subject as its children. The children
6113 ;; that do not are made into roots and removed from the list
6115 (or gnus-thread-ignore-subject
6116 (let* ((prev (symbol-value refs))
6117 (subject (gnus-simplify-subject-re
6118 (header-subject (car prev))))
6119 (headers (cdr prev)))
6121 (if (not (string= subject
6122 (gnus-simplify-subject-re
6123 (header-subject (car headers)))))
6125 (if (not (< (or (cdr (assq (header-number (car headers))
6126 gnus-newsgroup-scored))
6128 (setq new-roots (cons (car headers) new-roots))
6129 (setq gnus-newsgroup-unreads
6130 (delq (header-number (car headers))
6131 gnus-newsgroup-unreads))
6132 (setq gnus-newsgroup-reads
6133 (cons (cons (header-number (car headers))
6134 gnus-low-score-mark)
6135 gnus-newsgroup-reads)))
6136 (setcdr prev (cdr headers)))
6137 (setq prev headers))
6138 (setq headers (cdr headers)))))
6139 ;; If this article is expunged, some of the children might be
6141 (if (< (or (cdr (assq (header-number (car (symbol-value refs)))
6142 gnus-newsgroup-scored)) default)
6144 (let* ((prev (symbol-value refs))
6145 (headers (cdr prev)))
6147 (setq article (header-number (car headers)))
6148 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6150 (progn (setq new-roots (cons (car headers) new-roots))
6151 (setq prev headers))
6152 (setq gnus-newsgroup-unreads
6153 (delq article gnus-newsgroup-unreads))
6154 (setq gnus-newsgroup-reads
6155 (cons (cons article gnus-low-score-mark)
6156 gnus-newsgroup-reads))
6157 (setcdr prev (cdr headers)))
6158 (setq headers (cdr headers))))
6159 ;; It was not expunged, but we look at expunged children.
6160 (let* ((prev (symbol-value refs))
6161 (headers (cdr prev))
6164 (setq article (header-number (car headers)))
6165 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6168 (setq gnus-newsgroup-unreads
6169 (delq article gnus-newsgroup-unreads))
6170 (setq gnus-newsgroup-reads
6171 (cons (cons article gnus-low-score-mark)
6172 gnus-newsgroup-reads))
6173 (setcdr prev (cdr headers)))
6174 (setq headers (cdr headers)))))))
6175 gnus-newsgroup-dependencies)
6177 ;; We enter the new roots into the dependencies structure to
6178 ;; ensure that any possible later thread-regeneration will be
6180 (let ((r new-roots))
6182 (gnus-sethash (concat (header-id (car r)) ".boo")
6183 (list nil (car r)) gnus-newsgroup-dependencies)
6186 (setq roots (nconc new-roots roots))
6189 (mapcar 'gnus-trim-thread
6191 (mapcar 'gnus-cut-thread
6192 (mapcar 'gnus-make-sub-thread roots))))
6193 (gnus-message 6 "Threading...done"))))
6196 (defun gnus-cut-thread (thread)
6197 ;; Remove leaf dormant or ancient articles from THREAD.
6198 (let ((head (car thread))
6199 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6200 (if (and (null tail)
6201 (let ((number (header-number head)))
6202 (or (memq number gnus-newsgroup-ancient)
6203 (memq number gnus-newsgroup-dormant)
6204 (and gnus-summary-expunge-below
6205 (eq gnus-fetch-old-headers 'some)
6206 (< (or (cdr (assq number gnus-newsgroup-scored))
6207 gnus-summary-default-score 0)
6208 gnus-summary-expunge-below)
6210 (setq gnus-newsgroup-unreads
6211 (delq number gnus-newsgroup-unreads))
6212 (setq gnus-newsgroup-reads
6213 (cons (cons number gnus-low-score-mark)
6214 gnus-newsgroup-reads))
6217 (list (cons head tail)))))
6219 (defun gnus-trim-thread (thread)
6220 ;; Remove root ancient articles with only one child from THREAD.
6221 (if (and (eq gnus-fetch-old-headers 'some)
6222 (memq (header-number (car thread)) gnus-newsgroup-ancient)
6223 (= (length thread) 2))
6224 (gnus-trim-thread (nth 1 thread))
6227 (defun gnus-make-sub-thread (root)
6228 ;; This function makes a sub-tree for a node in the tree.
6229 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
6230 gnus-newsgroup-dependencies)))))
6231 (cons root (mapcar 'gnus-make-sub-thread children))))
6233 (defun gnus-build-old-threads ()
6234 ;; Look at all the articles that refer back to old articles, and
6235 ;; fetch the headers for the articles that aren't there. This will
6236 ;; build complete threads - if the roots haven't been expired by the
6241 (if (not (car (symbol-value refs)))
6243 (setq heads (cdr (symbol-value refs)))
6245 (if (not (memq (header-number (car heads))
6246 gnus-newsgroup-dormant))
6248 (setq id (symbol-name refs))
6249 (while (and (setq id (gnus-build-get-header id))
6250 (not (car (gnus-gethash
6251 id gnus-newsgroup-dependencies)))))
6253 (setq heads (cdr heads)))))))
6254 gnus-newsgroup-dependencies)))
6256 (defun gnus-build-get-header (id)
6257 ;; Look through the buffer of NOV lines and find the header to
6258 ;; ID. Enter this line into the dependencies hash table, and return
6259 ;; the id of the parent article (if any).
6260 (let ((deps gnus-newsgroup-dependencies)
6264 (set-buffer nntp-server-buffer)
6265 (goto-char (point-min))
6266 (while (and (not found) (search-forward id nil t))
6268 (setq found (looking-at
6269 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6270 (regexp-quote id))))
6271 (or found (beginning-of-line 2)))
6276 (setq header (gnus-nov-parse-line
6277 (read (current-buffer)) deps))
6278 (setq ref (header-references header))
6279 (string-match "\\(<[^>]+>\\) *$" ref)
6280 (substring ref (match-beginning 1) (match-end 1))))))
6282 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6283 gnus-newsgroup-ancient (cons (header-number header)
6284 gnus-newsgroup-ancient))))))
6286 ;; Re-build the thread containing ID.
6287 (defun gnus-rebuild-thread (id)
6288 (let ((dep gnus-newsgroup-dependencies)
6289 (buffer-read-only nil)
6290 parent headers refs thread art)
6291 (while (and id (setq headers
6292 (car (setq art (gnus-gethash (downcase id) dep)))))
6294 (setq id (and (setq refs (header-references headers))
6295 (string-match "\\(<[^>]+>\\) *$" refs)
6296 (substring refs (match-beginning 1) (match-end 1)))))
6297 (setq thread (gnus-make-sub-thread (car parent)))
6298 (gnus-rebuild-remove-articles thread)
6299 (let ((beg (point)))
6300 (gnus-summary-prepare-threads (list thread))
6301 (gnus-summary-update-lines beg (point)))))
6303 ;; Delete all lines in the summary buffer that correspond to articles
6305 (defun gnus-rebuild-remove-articles (thread)
6306 (and (gnus-summary-goto-subject (header-number (car thread)))
6308 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6310 (defun gnus-sort-threads (threads)
6311 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6312 (let ((fun gnus-thread-sort-functions))
6314 (setq threads (sort threads (car fun))
6318 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6319 (defmacro gnus-thread-header (thread)
6320 ;; Return header of first article in THREAD.
6321 ;; Note that THREAD must never, evr be anything else than a variable -
6322 ;; using some other form will lead to serious barfage.
6323 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
6324 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6325 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6328 (defun gnus-thread-sort-by-number (h1 h2)
6329 "Sort threads by root article number."
6330 (< (header-number (gnus-thread-header h1))
6331 (header-number (gnus-thread-header h2))))
6333 (defun gnus-thread-sort-by-author (h1 h2)
6334 "Sort threads by root author."
6336 (let ((extract (funcall
6337 gnus-extract-address-components
6338 (header-from (gnus-thread-header h1)))))
6339 (or (car extract) (cdr extract)))
6340 (let ((extract (funcall
6341 gnus-extract-address-components
6342 (header-from (gnus-thread-header h2)))))
6343 (or (car extract) (cdr extract)))))
6345 (defun gnus-thread-sort-by-subject (h1 h2)
6346 "Sort threads by root subject."
6348 (downcase (gnus-simplify-subject
6349 (header-subject (gnus-thread-header h1))))
6350 (downcase (gnus-simplify-subject
6351 (header-subject (gnus-thread-header h2))))))
6353 (defun gnus-thread-sort-by-date (h1 h2)
6354 "Sort threads by root article date."
6356 (gnus-sortable-date (header-date (gnus-thread-header h1)))
6357 (gnus-sortable-date (header-date (gnus-thread-header h2)))))
6359 (defun gnus-thread-sort-by-score (h1 h2)
6360 "Sort threads by root article score.
6361 Unscored articles will be counted as having a score of zero."
6362 (> (or (cdr (assq (header-number (gnus-thread-header h1))
6363 gnus-newsgroup-scored))
6364 gnus-summary-default-score 0)
6365 (or (cdr (assq (header-number (gnus-thread-header h2))
6366 gnus-newsgroup-scored))
6367 gnus-summary-default-score 0)))
6369 (defun gnus-thread-sort-by-total-score (h1 h2)
6370 "Sort threads by the sum of all scores in the thread.
6371 Unscored articles will be counted as having a score of zero."
6372 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6374 (defun gnus-thread-total-score (thread)
6375 ;; This function find the total score of THREAD.
6377 (if (stringp (car thread))
6378 (apply gnus-thread-score-function 0
6379 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6380 (gnus-thread-total-score-1 thread))
6381 (gnus-thread-total-score-1 (list thread))))
6383 (defun gnus-thread-total-score-1 (root)
6384 ;; This function find the total score of the thread below ROOT.
6385 (setq root (car root))
6386 (apply gnus-thread-score-function
6387 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
6388 gnus-summary-default-score 0)
6389 (mapcar 'gnus-thread-total-score
6390 (cdr (gnus-gethash (downcase (header-id root))
6391 gnus-newsgroup-dependencies)))))
6393 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6394 (defvar gnus-tmp-prev-subject "")
6396 (defun gnus-summary-prepare-threads (threads &optional cull)
6397 "Prepare summary buffer from THREADS and indentation LEVEL.
6398 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6399 or a straight list of headers."
6400 (message "Generating summary...")
6402 thread header number subject stack state gnus-tmp-gathered)
6403 (if (vectorp (car threads))
6404 ;; If this is a straight (sic) list of headers, then a
6405 ;; threaded summary display isn't required, so we just create
6406 ;; an unthreaded one.
6407 (gnus-summary-prepare-unthreaded threads cull)
6409 ;; Do the threaded display.
6411 (while (or threads stack)
6414 ;; If there are some threads, we do them before the
6415 ;; threads on the stack.
6416 (setq thread threads
6417 header (car (car thread)))
6418 ;; There were no current threads, so we pop something off
6420 (setq state (car stack)
6424 header (car (car thread))))
6426 (if (stringp header)
6428 ;; The header is a dummy root.
6430 ((eq gnus-summary-make-false-root 'adopt)
6431 ;; We let the first article adopt the rest.
6432 (let ((th (car (cdr (car thread)))))
6435 (setcdr th (cdr (cdr (car thread))))
6436 (setq gnus-tmp-gathered
6438 (lambda (h) (header-number (car h)))
6439 (cdr (cdr (car thread))))
6441 (setcdr (cdr (car thread)) nil))
6443 ((eq gnus-summary-make-false-root 'empty)
6444 ;; We print adopted articles with empty subject fields.
6445 (setq gnus-tmp-gathered
6447 (lambda (h) (header-number (car h)))
6448 (cdr (cdr (car thread))))
6451 ((eq gnus-summary-make-false-root 'dummy)
6452 ;; We output a dummy root.
6453 (gnus-summary-insert-dummy-line
6454 nil header (header-number (car (car (cdr (car thread)))))))
6456 ;; We do not make a root for the gathered
6457 ;; sub-threads at all.
6460 (setq number (header-number header)
6461 subject (header-subject header))
6463 ;; Do the async thing.
6464 (and gnus-newsgroup-async
6465 (setq gnus-newsgroup-threads
6466 (cons (cons number (header-lines header))
6467 gnus-newsgroup-threads)))
6469 ;; We may have to root out some bad articles...
6472 (cond ((and (memq (setq number (header-number header))
6473 gnus-newsgroup-dormant)
6476 ((and gnus-summary-expunge-below
6477 (< (or (cdr (assq number gnus-newsgroup-scored))
6478 gnus-summary-default-score 0)
6479 gnus-summary-expunge-below))
6481 (setq gnus-newsgroup-unreads
6482 (delq number gnus-newsgroup-unreads))
6483 (setq gnus-newsgroup-reads
6484 (cons (cons number gnus-low-score-mark)
6485 gnus-newsgroup-reads)))))
6491 (gnus-summary-insert-line
6492 nil header level nil
6494 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6495 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6496 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6497 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6498 (t (or (cdr (assq number gnus-newsgroup-reads))
6499 gnus-ancient-mark)))
6500 (memq number gnus-newsgroup-replied)
6501 (memq number gnus-newsgroup-expirable)
6502 (if (and (eq gnus-summary-make-false-root 'empty)
6503 (memq number gnus-tmp-gathered))
6504 gnus-summary-same-subject
6505 (if (or (zerop level)
6506 (and gnus-thread-ignore-subject
6508 (gnus-simplify-subject-re
6509 gnus-tmp-prev-subject)
6510 (gnus-simplify-subject-re
6513 gnus-summary-same-subject))
6514 (and (eq gnus-summary-make-false-root 'adopt)
6515 (memq number gnus-tmp-gathered))
6516 (cdr (assq number gnus-newsgroup-scored)))
6518 (setq gnus-tmp-prev-subject subject)))))
6521 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6522 (setq level (1+ level))
6523 (setq threads (cdr (car thread))))))
6524 (message "Generating summary...done"))
6528 (defun gnus-summary-prepare-unthreaded (headers &optional cull)
6529 (let (header number)
6531 ;; Do the async thing, if that is required.
6532 (if gnus-newsgroup-async
6533 (setq gnus-newsgroup-threads
6534 (mapcar (lambda (h) (cons (header-number h) (header-lines h)))
6538 (setq header (car headers)
6539 headers (cdr headers)
6540 number (header-number header))
6542 ;; We may have to root out some bad articles...
6545 (memq (setq number (header-number header))
6546 gnus-newsgroup-dormant)))
6547 ((and cull gnus-summary-expunge-below
6548 (< (or (cdr (assq number gnus-newsgroup-scored))
6549 gnus-summary-default-score 0)
6550 gnus-summary-expunge-below))
6551 (setq gnus-newsgroup-unreads
6552 (delq number gnus-newsgroup-unreads))
6553 (setq gnus-newsgroup-reads
6554 (cons (cons number gnus-low-score-mark)
6555 gnus-newsgroup-reads)))
6557 (gnus-summary-insert-line
6559 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6560 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6561 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6562 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6563 (t (or (cdr (assq number gnus-newsgroup-reads))
6564 gnus-ancient-mark)))
6565 (memq number gnus-newsgroup-replied)
6566 (memq number gnus-newsgroup-expirable)
6567 (header-subject header) nil
6568 (cdr (assq number gnus-newsgroup-scored))))))))
6570 (defun gnus-select-newsgroup (group &optional read-all)
6571 "Select newsgroup GROUP.
6572 If READ-ALL is non-nil, all articles in the group are selected."
6573 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6574 (info (nth 2 entry))
6577 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6579 (or (gnus-check-server gnus-current-select-method)
6580 (error "Couldn't open server"))
6582 (or (and (null entry)
6583 (gnus-activate-group group))
6584 (and (eq (car entry) t)
6585 (gnus-activate-group (car info)))
6586 (gnus-request-group group t)
6588 (kill-buffer (current-buffer))
6589 (error "Couldn't request group %s: %s"
6590 group (gnus-status-message group))))
6592 (setq gnus-newsgroup-name group)
6593 (setq gnus-newsgroup-unselected nil)
6594 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6596 (and gnus-asynchronous
6597 (gnus-check-backend-function
6598 'request-asynchronous gnus-newsgroup-name)
6599 (setq gnus-newsgroup-async
6600 (gnus-request-asynchronous gnus-newsgroup-name)))
6602 (setq articles (gnus-articles-to-read group read-all))
6606 (gnus-message 3 "Couldn't select newsgroup")
6608 ((eq articles 0) nil)
6610 ;; Init the dependencies hash table.
6611 (setq gnus-newsgroup-dependencies
6612 (gnus-make-hashtable (length articles)))
6613 ;; Retrieve the headers and read them in.
6614 (gnus-message 5 "Fetching headers...")
6615 (setq gnus-newsgroup-headers
6616 (if (eq 'nov (setq gnus-headers-retrieved-by
6617 ;; This is a naughty hack. To get the
6618 ;; retrieval of old headers to work, we
6619 ;; set `nntp-nov-gap' to nil (locally),
6620 ;; and then just retrieve the headers.
6622 (if gnus-fetch-old-headers
6624 (gnus-retrieve-headers
6625 (if (not (eq 1 (car articles)))
6628 gnus-newsgroup-name))
6629 (gnus-retrieve-headers
6630 articles gnus-newsgroup-name))))
6632 (gnus-get-newsgroup-headers-xover articles))
6633 ;; If we were to fetch old headers, but the backend didn't
6634 ;; support XOVER, then it is possible we fetched one article
6635 ;; that we shouldn't have. If that's the case, we remove it.
6636 (if (or (not gnus-fetch-old-headers)
6637 (eq 1 (car articles)))
6640 (set-buffer nntp-server-buffer)
6641 (goto-char (point-min))
6643 (looking-at "[0-9]+[ \t]+1[ \t]") ; This is not a NOV line.
6644 (delete-region ; So we delete this head.
6646 (search-forward "\n.\n" nil t)))))
6647 (gnus-get-newsgroup-headers)))
6648 (gnus-message 5 "Fetching headers...done")
6649 ;; Remove canceled articles from the list of unread articles.
6650 (setq gnus-newsgroup-unreads
6651 (gnus-set-sorted-intersection
6652 gnus-newsgroup-unreads
6653 (mapcar (lambda (headers) (header-number headers))
6654 gnus-newsgroup-headers)))
6655 ;; Adjust and set lists of article marks.
6658 (gnus-adjust-marked-articles info)
6659 (setq gnus-newsgroup-marked
6661 (cdr (assq 'tick (setq marked (nth 3 info))))))
6662 (setq gnus-newsgroup-replied
6663 (copy-sequence (cdr (assq 'reply marked))))
6664 (setq gnus-newsgroup-expirable
6665 (copy-sequence (cdr (assq 'expire marked))))
6666 (setq gnus-newsgroup-killed
6667 (copy-sequence (cdr (assq 'killed marked))))
6668 (setq gnus-newsgroup-bookmarks
6669 (copy-sequence (cdr (assq 'bookmark marked))))
6670 (setq gnus-newsgroup-dormant
6671 (copy-sequence (cdr (assq 'dormant marked))))
6672 (setq gnus-newsgroup-scored
6673 (copy-sequence (cdr (assq 'score marked))))
6674 (setq gnus-newsgroup-processable nil)))
6675 ;; Check whether auto-expire is to be done in this group.
6676 (setq gnus-newsgroup-auto-expire
6677 (or (and (stringp gnus-auto-expirable-newsgroups)
6678 (string-match gnus-auto-expirable-newsgroups group))
6679 (memq 'auto-expire (nth 5 info))))
6680 ;; First and last article in this newsgroup.
6681 (and gnus-newsgroup-headers
6682 (setq gnus-newsgroup-begin
6683 (header-number (car gnus-newsgroup-headers)))
6684 (setq gnus-newsgroup-end
6685 (header-number (gnus-last-element gnus-newsgroup-headers))))
6686 (setq gnus-reffed-article-number -1)
6687 ;; GROUP is successfully selected.
6688 (or gnus-newsgroup-headers t)))))
6690 (defun gnus-articles-to-read (group read-all)
6691 ;; Find out what articles the user wants to read.
6693 ;; Select all articles if `read-all' is non-nil, or if all the
6694 ;; unread articles are dormant articles.
6695 (if (or (and read-all (not (numberp read-all)))
6696 (= (length gnus-newsgroup-unreads)
6697 (length gnus-newsgroup-dormant)))
6698 (gnus-uncompress-range
6699 (gnus-gethash group gnus-active-hashtb))
6700 gnus-newsgroup-unreads))
6701 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6702 (scored (length scored-list))
6703 (number (length articles))
6704 (marked (+ (length gnus-newsgroup-marked)
6705 (length gnus-newsgroup-dormant)))
6712 (cond ((and (or (<= scored marked)
6714 (numberp gnus-large-newsgroup)
6715 (> number gnus-large-newsgroup))
6719 "How many articles from %s (default %d): "
6720 gnus-newsgroup-name number))))
6721 (if (string-match "^[ \t]*$" input)
6723 ((and (> scored marked) (< scored number))
6727 "%s %s (%d scored, %d total): "
6728 "How many articles from"
6729 group scored number))))
6730 (if (string-match "^[ \t]*$" input)
6734 (setq select (if (stringp select) (string-to-number select) select))
6735 (if (or (null select) (zerop select))
6737 (if (and (not (zerop scored)) (<= (abs select) scored))
6739 (setq articles (sort scored-list '<))
6740 (setq number (length articles)))
6741 (setq articles (copy-sequence articles)))
6743 (if (< (abs select) number)
6745 ;; Select the N oldest articles.
6746 (setcdr (nthcdr (1- (abs select)) articles) nil)
6747 ;; Select the N most recent articles.
6748 (setq articles (nthcdr (- number select) articles))))
6749 (setq gnus-newsgroup-unselected
6750 (gnus-sorted-intersection
6751 gnus-newsgroup-unreads
6752 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6755 (defun gnus-killed-articles (killed articles)
6758 (if (inline (gnus-member-of-range (car articles) killed))
6759 (setq out (cons (car articles) out)))
6760 (setq articles (cdr articles)))
6763 (defun gnus-adjust-marked-articles (info &optional active)
6764 "Remove all marked articles that are no longer legal."
6765 (let ((marked-lists (nth 3 info))
6766 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6768 ;; There are many types of marked articles.
6770 (setq m (cdr (setq prev (car marked-lists))))
6771 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6772 ;; Make sure that all ticked articles are a subset of the
6773 ;; unread/unselected articles.
6775 (if (or (memq (car m) gnus-newsgroup-unreads)
6776 (memq (car m) gnus-newsgroup-unselected))
6778 (setcdr prev (cdr m)))
6780 ((eq 'score (car prev))
6781 ;; Scored articles should be a subset of
6782 ;; unread/unselected articles.
6784 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6785 (memq (car (car m)) gnus-newsgroup-unreads))
6787 (setcdr prev (cdr m)))
6789 ((eq 'bookmark (car prev))
6790 ;; Bookmarks should be a subset of active articles.
6792 (if (< (car (car m)) (car active))
6793 (setcdr prev (cdr m))
6796 ((eq 'killed (car prev))
6797 ;; Articles that have been through the kill process are
6798 ;; to be a subset of active articles.
6799 (while (and m (< (or (and (numberp (car m)) (car m))
6802 (setcdr prev (cdr m))
6804 (if (and m (< (or (and (numberp (car m)) (car m))
6807 (setcar (if (numberp (car m)) m (car m)) (car active))))
6808 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6809 ;; The replied and expirable articles have to be articles
6812 (if (< (car m) (car active))
6813 (setcdr prev (cdr m))
6816 (setq marked-lists (cdr marked-lists)))
6817 ;; Remove all lists that are empty.
6818 (setq marked-lists (nth 3 info))
6821 (while (= 1 (length (car marked-lists)))
6822 (setq marked-lists (cdr marked-lists)))
6823 (setq m (cdr (setq prev marked-lists)))
6825 (if (= 1 (length (car m)))
6826 (setcdr prev (cdr m))
6829 (setcar (nthcdr 3 info) marked-lists)))
6830 ;; Finally, if there are no marked lists at all left, and if there
6831 ;; are no elements after the lists in the info list, we just chop
6832 ;; the info list off before the marked lists.
6833 (and (null marked-lists)
6834 (not (nthcdr 4 info))
6835 (setcdr (nthcdr 2 info) nil)))
6838 (defun gnus-set-marked-articles
6839 (info ticked replied expirable killed dormant bookmark score)
6840 "Enter the various lists of marked articles into the newsgroup info list."
6842 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6843 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6844 (and expirable (setq newmarked (cons (cons 'expire expirable)
6846 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6847 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6848 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6850 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6853 (setcar (nthcdr 3 info) newmarked)
6854 (and (not newmarked)
6855 (not (nthcdr 4 info))
6856 (setcdr (nthcdr 2 info) nil)))
6858 (setcdr (nthcdr 2 info) (list newmarked))))))
6860 (defun gnus-add-marked-articles (group type articles &optional info force)
6861 ;; Add ARTICLES of TYPE to the info of GROUP.
6862 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6863 ;; add, but replace marked articles of TYPE with ARTICLES.
6864 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6867 (and (not (setq marked (nthcdr 3 info)))
6868 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6869 (and (not (setq m (assq type (car marked))))
6870 (setcar marked (cons (cons type articles) (car marked))))
6873 (nconc m articles)))))
6875 (defun gnus-set-mode-line (where)
6876 "This function sets the mode line of the article or summary buffers.
6877 If WHERE is `summary', the summary mode line format will be used."
6878 (if (memq where gnus-updated-mode-lines)
6881 (set-buffer gnus-summary-buffer)
6882 (let* ((mformat (if (eq where 'article)
6883 gnus-article-mode-line-format-spec
6884 gnus-summary-mode-line-format-spec))
6885 (group-name gnus-newsgroup-name)
6886 (article-number (or gnus-current-article 0))
6887 (unread (- (length gnus-newsgroup-unreads)
6888 (length gnus-newsgroup-dormant)))
6889 (unread-and-unticked
6890 (- unread (length gnus-newsgroup-marked)))
6891 (unselected (length gnus-newsgroup-unselected))
6892 (unread-and-unselected
6893 (cond ((and (zerop unread-and-unticked)
6894 (zerop unselected)) "")
6896 (format "{%d more}" unread-and-unticked))
6897 (t (format "{%d(+%d) more}"
6898 unread-and-unticked unselected))))
6900 (if gnus-current-headers
6901 (header-subject gnus-current-headers) ""))
6902 (max-len (and gnus-mode-non-string-length
6903 (- (frame-width) gnus-mode-non-string-length)))
6904 header) ;; passed as argument to any user-format-funcs
6905 (setq mode-string (eval mformat))
6906 (or (numberp max-len)
6907 (setq max-len (length mode-string)))
6908 (if (< max-len 4) (setq max-len 4))
6909 (if (> (length mode-string) max-len)
6910 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
6911 ;; function `substring' might cut on a middle
6912 ;; of multi-octet character.
6914 (concat (gnus-truncate-string mode-string (- max-len 3))
6916 (setq mode-string (format (format "%%-%ds" max-len)
6918 (setq mode-line-buffer-identification mode-string)
6919 (set-buffer-modified-p t))))
6921 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6922 "Go through the HEADERS list and add all Xrefs to a hash table.
6923 The resulting hash table is returned, or nil if no Xrefs were found."
6924 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6926 (gnus-group-foreign-p from-newsgroup)
6928 (assoc (symbol-name (car from-method))
6929 gnus-valid-select-methods))))
6930 (gnus-group-real-prefix from-newsgroup)))
6931 (xref-hashtb (make-vector 63 0))
6932 start group entry number xrefs header)
6934 (setq header (car headers))
6935 (if (and (setq xrefs (header-xref header))
6936 (not (memq (header-number header) unreads)))
6939 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6940 (setq start (match-end 0))
6941 (setq group (concat prefix (substring xrefs (match-beginning 1)
6944 (string-to-int (substring xrefs (match-beginning 2)
6946 (if (setq entry (gnus-gethash group xref-hashtb))
6947 (setcdr entry (cons number (cdr entry)))
6948 (gnus-sethash group (cons number nil) xref-hashtb)))))
6949 (setq headers (cdr headers)))
6950 (if start xref-hashtb nil)))
6952 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6953 "Look through all the headers and mark the Xrefs as read."
6954 (let ((virtual (memq 'virtual
6955 (assoc (symbol-name (car (gnus-find-method-for-group
6957 gnus-valid-select-methods)))
6958 name entry info xref-hashtb idlist method
6961 (set-buffer gnus-group-buffer)
6962 (if (setq xref-hashtb
6963 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6966 (if (string= from-newsgroup (setq name (symbol-name group)))
6968 (setq idlist (symbol-value group))
6969 ;; Dead groups are not updated.
6971 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6973 (if (stringp (setq nth4 (nth 4 info)))
6974 (setq nth4 (gnus-server-to-method nth4))))
6975 ;; Only do the xrefs if the group has the same
6976 ;; select method as the group we have just read.
6977 (or (gnus-methods-equal-p
6978 nth4 (gnus-find-method-for-group from-newsgroup))
6981 (setq method (gnus-find-method-for-group
6983 (and (equal (car nth4) (car method))
6984 (equal (nth 1 nth4) (nth 1 method))))
6985 gnus-use-cross-reference
6986 (or (not (eq gnus-use-cross-reference t))
6988 ;; Only do cross-references on subscribed
6989 ;; groups, if that is what is wanted.
6990 (<= (nth 1 info) gnus-level-subscribed)))
6991 (gnus-group-make-articles-read name idlist expirable))))
6994 (defun gnus-group-make-articles-read (group articles expirable)
6996 (entry (gnus-gethash group gnus-newsrc-hashtb))
6997 (info (nth 2 entry))
6998 (active (gnus-gethash group gnus-active-hashtb))
6999 exps expirable range)
7000 ;; First peel off all illegal article numbers.
7002 (let ((ids articles)
7003 (ticked (cdr (assq 'tick (nth 3 info))))
7004 (dormant (cdr (assq 'dormant (nth 3 info))))
7009 (if (or (> id (cdr active))
7013 (setq articles (delq id articles)))
7014 (and (memq id expirable)
7015 (setq exps (cons id exps)))
7016 (setq ids (cdr ids)))))
7017 ;; Update expirable articles.
7018 (gnus-add-marked-articles nil 'expirable exps info)
7022 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
7023 (setcar (nthcdr 2 info)
7027 (setq articles (sort articles '<)))))
7028 ;; Then we have to re-compute how many unread
7029 ;; articles there are in this group.
7034 (setq num (- (1+ (cdr active)) (car active))))
7035 ((not (listp (cdr range)))
7036 (setq num (- (cdr active) (- (1+ (cdr range))
7040 (if (numberp (car range))
7042 (setq num (+ num (- (1+ (cdr (car range)))
7043 (car (car range))))))
7044 (setq range (cdr range)))
7045 (setq num (- (cdr active) num))))
7046 ;; Update the number of unread articles.
7050 (length (cdr (assq 'tick (nth 3 info))))
7052 (cdr (assq 'dormant (nth 3 info)))))))
7053 ;; Update the group buffer.
7054 (gnus-group-update-group group t)))))
7056 (defun gnus-methods-equal-p (m1 m2)
7057 (let ((m1 (or m1 gnus-select-method))
7058 (m2 (or m2 gnus-select-method)))
7060 (and (eq (car m1) (car m2))
7061 (or (not (memq 'address (assoc (symbol-name (car m1))
7062 gnus-valid-select-methods)))
7063 (equal (nth 1 m1) (nth 1 m2)))))))
7065 (defsubst gnus-header-value ()
7066 (buffer-substring (match-end 0) (gnus-point-at-eol)))
7068 (defvar gnus-newsgroup-none-id 0)
7070 (defun gnus-get-newsgroup-headers ()
7071 (setq gnus-article-internal-prepare-hook nil)
7072 (let ((cur nntp-server-buffer)
7073 (dependencies gnus-newsgroup-dependencies)
7074 headers id dep end ref)
7076 (set-buffer nntp-server-buffer)
7077 (goto-char (point-min))
7078 ;; Search to the beginning of the next header. Error messages
7079 ;; do not begin with 2 or 3.
7080 (while (re-search-forward "^[23][0-9]+ " nil t)
7081 (let ((header (make-vector 9 nil))
7082 (case-fold-search t)
7087 (header-set-number header (read cur))
7088 ;; This implementation of this function, with nine
7089 ;; search-forwards instead of the one re-search-forward and
7090 ;; a case (which basically was the old function) is actually
7091 ;; about twice as fast, even though it looks messier. You
7092 ;; can't have everything, I guess. Speed and elegance
7093 ;; doesn't always come hand in hand.
7095 (narrow-to-region (point) (or (save-excursion
7096 (search-forward "\n.\n" nil t))
7098 (if (search-forward "\nfrom: " nil t)
7099 (header-set-from header (gnus-header-value))
7100 (header-set-from header "(nobody)"))
7102 (if (search-forward "\nsubject: " nil t)
7103 (header-set-subject header (gnus-header-value))
7104 (header-set-subject header "(none)"))
7106 (and (search-forward "\nxref: " nil t)
7107 (header-set-xref header (gnus-header-value)))
7109 (or (numberp (and (search-forward "\nlines: " nil t)
7110 (header-set-lines header (read cur))))
7111 (header-set-lines header 0))
7113 (and (search-forward "\ndate: " nil t)
7114 (header-set-date header (gnus-header-value)))
7116 (if (search-forward "\nmessage-id: " nil t)
7117 (header-set-id header (setq id (gnus-header-value)))
7118 ;; If there was no message-id, we just fake one to make
7119 ;; subsequent routines simpler.
7122 (setq id (concat "none+"
7124 (setq gnus-newsgroup-none-id
7125 (1+ gnus-newsgroup-none-id)))))))
7127 (if (search-forward "\nreferences: " nil t)
7129 (header-set-references header (gnus-header-value))
7130 (setq end (match-end 0))
7137 (search-backward ">" end t)
7140 (search-backward "<" end t)
7142 ;; Get the references from the in-reply-to header if there
7143 ;; ware no references and the in-reply-to header looks
7145 (if (and (search-forward "\nin-reply-to: " nil t)
7146 (setq in-reply-to (gnus-header-value))
7147 (string-match "<[^>]+>" in-reply-to))
7149 (header-set-references
7151 (setq ref (substring in-reply-to (match-beginning 0)
7153 (setq ref (downcase ref)))
7155 ;; We do some threading while we read the headers. The
7156 ;; message-id and the last reference are both entered into
7157 ;; the same hash table. Some tippy-toeing around has to be
7158 ;; done in case an article has arrived before the article
7159 ;; which it refers to.
7160 (if (boundp (setq dep (intern (downcase id) dependencies)))
7161 (if (car (symbol-value dep))
7162 ;; An article with this Message-ID has already
7163 ;; been seen, so we ignore this one, except we add
7164 ;; any additional Xrefs (in case the two articles
7165 ;; came from different servers.
7168 (car (symbol-value dep))
7169 (concat (or (header-xref (car (symbol-value dep))) "")
7170 (or (header-xref header) "")))
7172 (setcar (symbol-value dep) header))
7173 (set dep (list header)))
7176 (if (boundp (setq dep (intern ref dependencies)))
7177 (setcdr (symbol-value dep)
7178 (cons header (cdr (symbol-value dep))))
7179 (set dep (list nil header)))
7180 (setq headers (cons header headers))))
7181 (goto-char (point-max))))))
7182 (nreverse headers)))
7184 ;; The following macros and functions were written by Felix Lee
7185 ;; <flee@cse.psu.edu>.
7187 (defmacro gnus-nov-read-integer ()
7189 (if (= (following-char) ?\t)
7191 (let ((num (condition-case nil (read buffer) (error nil))))
7192 (if (numberp num) num 0)))
7193 (or (eobp) (forward-char 1))))
7195 (defmacro gnus-nov-skip-field ()
7196 '(search-forward "\t" eol 'move))
7198 (defmacro gnus-nov-field ()
7199 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
7201 ;; Goes through the xover lines and returns a list of vectors
7202 (defun gnus-get-newsgroup-headers-xover (sequence)
7203 "Parse the news overview data in the server buffer, and return a
7204 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7205 ;; Get the Xref when the users reads the articles since most/some
7206 ;; NNTP servers do not include Xrefs when using XOVER.
7207 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
7208 (let ((cur nntp-server-buffer)
7209 (dependencies gnus-newsgroup-dependencies)
7210 number headers header)
7212 (set-buffer nntp-server-buffer)
7213 (goto-char (point-min))
7214 (while (and sequence (not (eobp)))
7215 (setq number (read cur))
7216 (while (and sequence (< (car sequence) number))
7217 (setq sequence (cdr sequence)))
7219 (eq number (car sequence))
7221 (setq sequence (cdr sequence))
7223 (inline (gnus-nov-parse-line number dependencies)))
7224 (setq headers (cons header headers)))))
7226 (setq headers (nreverse headers)))
7229 ;; This function has to be called with point after the article number
7230 ;; on the beginning of the line.
7231 (defun gnus-nov-parse-line (number dependencies)
7233 (eol (gnus-point-at-eol))
7234 (buffer (current-buffer))
7237 ;; overview: [num subject from date id refs chars lines misc]
7238 (narrow-to-region (point) eol)
7245 (gnus-nov-field) ; subject
7246 (gnus-nov-field) ; from
7247 (gnus-nov-field) ; date
7248 (setq id (or (gnus-nov-field)
7251 (setq none (1+ none)))))) ; id
7254 (let ((beg (point)))
7255 (search-forward "\t" eol)
7256 (if (search-backward ">" beg t)
7262 (search-backward "<" beg t)
7265 (gnus-nov-field)) ; refs
7266 (gnus-nov-read-integer) ; chars
7267 (gnus-nov-read-integer) ; lines
7268 (if (= (following-char) ?\n)
7270 (gnus-nov-field)) ; misc
7274 (message "Strange nov line.")
7280 ;; We build the thread tree.
7282 (if (boundp (setq dep (intern (downcase id) dependencies)))
7283 (if (car (symbol-value dep))
7284 ;; An article with this Message-ID has already been seen,
7285 ;; so we ignore this one, except we add any additional
7286 ;; Xrefs (in case the two articles came from different
7290 (car (symbol-value dep))
7291 (concat (or (header-xref (car (symbol-value dep))) "")
7292 (or (header-xref header) "")))
7294 (setcar (symbol-value dep) header))
7295 (set dep (list header))))
7298 (if (boundp (setq dep (intern (or ref "none")
7300 (setcdr (symbol-value dep)
7301 (cons header (cdr (symbol-value dep))))
7302 (set dep (list nil header)))))
7305 (defun gnus-article-get-xrefs ()
7306 "Fill in the Xref value in `gnus-current-headers', if necessary.
7307 This is meant to be called in `gnus-article-internal-prepare-hook'."
7308 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7309 gnus-current-headers)))
7310 (or (not gnus-use-cross-reference)
7312 (and (header-xref headers)
7313 (not (string= (header-xref headers) "")))
7314 (let ((case-fold-search t)
7317 (gnus-narrow-to-headers)
7318 (goto-char (point-min))
7319 (if (or (and (eq (downcase (following-char)) ?x)
7320 (looking-at "Xref:"))
7321 (search-forward "\nXref:" nil t))
7323 (goto-char (1+ (match-end 0)))
7324 (setq xref (buffer-substring (point)
7325 (progn (end-of-line) (point))))
7326 (header-set-xref headers xref))))))))
7328 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
7329 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
7331 (defun gnus-make-headers-hashtable-by-number ()
7332 "Make hashtable for the variable gnus-newsgroup-headers by number."
7334 (set-buffer gnus-summary-buffer)
7335 (let ((headers gnus-newsgroup-headers)
7337 (setq gnus-newsgroup-headers-hashtb-by-number
7338 (gnus-make-hashtable (length headers)))
7340 (setq header (car headers))
7341 (gnus-sethash (int-to-string (header-number header))
7342 header gnus-newsgroup-headers-hashtb-by-number)
7343 (setq headers (cdr headers))))))
7345 (defun gnus-more-header-backward ()
7346 "Find new header backward."
7347 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7348 (artnum gnus-newsgroup-begin)
7350 (while (and (not header)
7352 (setq artnum (1- artnum))
7353 (setq header (gnus-read-header artnum)))
7356 (defun gnus-more-header-forward (&optional backward)
7357 "Find new header forward.
7358 If BACKWARD, find new header backward instead."
7360 (gnus-more-header-backward)
7361 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7362 (artnum gnus-newsgroup-end)
7364 (while (and (not header)
7366 (setq artnum (1+ artnum))
7367 (setq header (gnus-read-header artnum)))
7370 (defun gnus-extend-newsgroup (header &optional backward)
7371 "Extend newsgroup selection with HEADER.
7372 Optional argument BACKWARD means extend toward backward."
7374 (let ((artnum (header-number header)))
7375 (setq gnus-newsgroup-headers
7377 (cons header gnus-newsgroup-headers)
7378 (nconc gnus-newsgroup-headers (list header))))
7379 (setq gnus-newsgroup-unselected
7380 (delq artnum gnus-newsgroup-unselected))
7381 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
7382 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
7384 (defun gnus-summary-work-articles (n)
7385 "Return a list of articles to be worked upon. The prefix argument,
7386 the list of process marked articles, and the current article will be
7387 taken into consideration."
7389 (if (and n (numberp n))
7390 (let ((backward (< n 0))
7394 (setq articles (cons (gnus-summary-article-number)
7396 (gnus-summary-search-forward nil nil backward))
7398 (sort articles (function <)))
7399 (or (reverse gnus-newsgroup-processable)
7400 (list (gnus-summary-article-number))))))
7402 (defun gnus-summary-search-group (&optional backward use-level)
7403 "Search for next unread newsgroup.
7404 If optional argument BACKWARD is non-nil, search backward instead."
7406 (set-buffer gnus-group-buffer)
7407 (if (gnus-group-search-forward
7408 backward nil (if use-level (gnus-group-group-level) nil))
7409 (gnus-group-group-name))))
7411 (defun gnus-summary-best-group (&optional exclude-group)
7412 "Find the name of the best unread group.
7413 If EXCLUDE-GROUP, do not go to this group."
7415 (set-buffer gnus-group-buffer)
7417 (gnus-group-best-unread-group exclude-group))))
7419 (defun gnus-subject-equal (s1 s2)
7421 ((null gnus-summary-gather-subject-limit)
7422 (equal (gnus-simplify-subject-re s1)
7423 (gnus-simplify-subject-re s2)))
7424 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7425 (equal (gnus-simplify-subject-fuzzy s1)
7426 (gnus-simplify-subject-fuzzy s2)))
7427 ((numberp gnus-summary-gather-subject-limit)
7428 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7429 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7433 (defun gnus-summary-search-subject (&optional backward unread subject)
7434 "Search for article forward.
7435 If BACKWARD is non-nil, search backward.
7436 If UNREAD is non-nil, only unread articles are selected.
7437 If SUBJECT is non-nil, the article which has the same subject will be
7439 (let ((func (if backward 'previous-single-property-change
7440 'next-single-property-change))
7445 (and gnus-summary-check-current unread
7446 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7450 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7453 (setq pos (funcall func (point) 'gnus-number))
7454 (goto-char (if backward (1- pos) pos))
7458 (eq (get-text-property (point) 'gnus-mark)
7461 (and (setq psubject (inline (gnus-summary-subject-string)))
7462 (inline (gnus-subject-equal subject psubject)))))))
7463 (if backward (if (bobp) nil (forward-char -1) t)
7464 (if (eobp) nil (forward-char 1) t)))))
7466 (progn (goto-char beg) nil)
7468 (get-text-property (point) 'gnus-number)
7469 (gnus-summary-position-cursor)))))
7471 (defun gnus-summary-pseudo-article ()
7472 "The thread level of the article on the current line."
7473 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7475 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7476 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7477 (defun gnus-summary-article-score ()
7478 "Return current article score."
7479 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7480 gnus-summary-default-score 0))
7482 (defun gnus-summary-recenter ()
7483 "Center point in the summary window.
7484 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7485 displayed, no centering will be performed."
7486 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7487 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7488 (let* ((top (cond ((< (window-height) 4) 0)
7489 ((< (window-height) 7) 1)
7491 (height (1- (window-height)))
7492 (bottom (save-excursion (goto-char (point-max))
7493 (forward-line (- height))
7495 (window (get-buffer-window (current-buffer))))
7497 ;; The user has to want it,
7498 gnus-auto-center-summary
7499 ;; the article buffer must be displayed,
7500 (get-buffer-window gnus-article-buffer)
7501 ;; Set the window start to either `bottom', which is the biggest
7502 ;; possible valid number, or the second line from the top,
7503 ;; whichever is the least.
7505 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7507 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7508 (defun gnus-short-group-name (group &optional levels)
7509 "Collapse GROUP name LEVELS."
7510 (let* ((name "") (foreign "") (depth -1) (skip 1)
7513 (while (string-match "\\." group skip)
7514 (setq skip (match-end 0)
7517 (if (string-match ":" group)
7518 (setq foreign (substring group 0 (match-end 0))
7519 group (substring group (match-end 0))))
7521 (if (and (string-match "\\." group) (> levels 0))
7522 (setq name (concat name (substring group 0 1))
7523 group (substring group (match-end 0))
7525 name (concat name "."))
7526 (setq name (concat foreign name group)
7530 (defun gnus-summary-jump-to-group (newsgroup)
7531 "Move point to NEWSGROUP in group mode buffer."
7532 ;; Keep update point of group mode buffer if visible.
7533 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7534 (save-window-excursion
7535 ;; Take care of tree window mode.
7536 (if (get-buffer-window gnus-group-buffer)
7537 (pop-to-buffer gnus-group-buffer))
7538 (gnus-group-jump-to-group newsgroup))
7540 ;; Take care of tree window mode.
7541 (if (get-buffer-window gnus-group-buffer)
7542 (pop-to-buffer gnus-group-buffer)
7543 (set-buffer gnus-group-buffer))
7544 (gnus-group-jump-to-group newsgroup))))
7546 ;; This function returns a list of article numbers based on the
7547 ;; difference between the ranges of read articles in this group and
7548 ;; the range of active articles.
7549 (defun gnus-list-of-unread-articles (group)
7550 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7551 (active (gnus-gethash group gnus-active-hashtb))
7554 ;; If none are read, then all are unread.
7556 (setq first (car active))
7557 ;; If the range of read articles is a single range, then the
7558 ;; first unread article is the article after the last read
7559 ;; article. Sounds logical, doesn't it?
7560 (if (not (listp (cdr read)))
7561 (setq first (1+ (cdr read)))
7562 ;; `read' is a list of ranges.
7563 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7564 (car (car read)))) 1)
7568 (while (< first nlast)
7569 (setq unread (cons first unread))
7570 (setq first (1+ first))))
7571 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7572 (setq nlast (if (atom (car (cdr read)))
7574 (car (car (cdr read)))))
7575 (setq read (cdr read)))))
7576 ;; And add the last unread articles.
7577 (while (<= first last)
7578 (setq unread (cons first unread))
7579 (setq first (1+ first)))
7580 ;; Return the list of unread articles.
7583 (defun gnus-list-of-read-articles (group)
7584 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7585 (active (gnus-gethash group gnus-active-hashtb)))
7587 (gnus-sorted-complement
7588 (gnus-uncompress-range active)
7589 (gnus-list-of-unread-articles group)))))
7591 ;; Various summary commands
7593 (defun gnus-summary-universal-argument ()
7594 "Perform any operation on all articles marked with the process mark."
7596 (gnus-set-global-variables)
7597 (let ((articles (reverse gnus-newsgroup-processable))
7599 (or articles (error "No articles marked"))
7600 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7601 (error "Undefined key"))
7603 (gnus-summary-goto-subject (car articles))
7604 (command-execute func)
7605 (gnus-summary-remove-process-mark (car articles))
7606 (setq articles (cdr articles)))))
7608 (defun gnus-summary-toggle-truncation (&optional arg)
7609 "Toggle truncation of summary lines.
7610 With arg, turn line truncation on iff arg is positive."
7612 (setq truncate-lines
7613 (if (null arg) (not truncate-lines)
7614 (> (prefix-numeric-value arg) 0)))
7617 (defun gnus-summary-reselect-current-group (&optional all)
7618 "Once exit and then reselect the current newsgroup.
7619 The prefix argument ALL means to select all articles."
7621 (gnus-set-global-variables)
7622 (let ((current-subject (gnus-summary-article-number))
7623 (group gnus-newsgroup-name))
7624 (setq gnus-newsgroup-begin nil)
7625 (gnus-summary-exit t)
7626 ;; We have to adjust the point of group mode buffer because the
7627 ;; current point was moved to the next unread newsgroup by
7629 (gnus-summary-jump-to-group group)
7630 (gnus-group-read-group all t)
7631 (gnus-summary-goto-subject current-subject)))
7633 (defun gnus-summary-rescan-group (&optional all)
7634 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7636 (gnus-set-global-variables)
7637 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7638 (let ((group gnus-newsgroup-name))
7640 (gnus-summary-jump-to-group group)
7642 (set-buffer gnus-group-buffer)
7643 (gnus-group-get-new-news-this-group 1))
7644 (gnus-summary-jump-to-group group)
7645 (gnus-group-read-group all)))
7647 (defun gnus-summary-update-info ()
7648 (let* ((group gnus-newsgroup-name))
7649 (if gnus-newsgroup-kill-headers
7650 (setq gnus-newsgroup-killed
7651 (gnus-compress-sequence
7653 (gnus-set-sorted-intersection
7654 (gnus-uncompress-range gnus-newsgroup-killed)
7655 (setq gnus-newsgroup-unselected
7656 (sort gnus-newsgroup-unselected '<)))
7657 (setq gnus-newsgroup-unreads
7658 (sort gnus-newsgroup-unreads '<))) t)))
7659 (or (listp (cdr gnus-newsgroup-killed))
7660 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7661 (let ((headers gnus-newsgroup-headers))
7662 (gnus-close-group group)
7663 (run-hooks 'gnus-exit-group-hook)
7664 (gnus-update-read-articles
7665 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7666 gnus-newsgroup-marked
7667 t gnus-newsgroup-replied gnus-newsgroup-expirable
7668 gnus-newsgroup-killed gnus-newsgroup-dormant
7669 gnus-newsgroup-bookmarks
7670 (and gnus-save-score gnus-newsgroup-scored))
7671 (and gnus-use-cross-reference
7672 (gnus-mark-xrefs-as-read
7673 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7674 ;; Do adaptive scoring, and possibly save score files.
7675 (and gnus-newsgroup-adaptive
7676 (gnus-score-adaptive))
7677 (and gnus-use-scoring
7678 (fboundp 'gnus-score-save)
7679 (funcall 'gnus-score-save))
7680 ;; Do not switch windows but change the buffer to work.
7681 (set-buffer gnus-group-buffer)
7682 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7683 (gnus-group-update-group group)))))
7685 (defun gnus-summary-exit (&optional temporary)
7686 "Exit reading current newsgroup, and then return to group selection mode.
7687 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7689 (gnus-set-global-variables)
7690 (gnus-kill-save-kill-buffer)
7691 (let* ((group gnus-newsgroup-name)
7692 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
7693 gnus-newsgroup-name))))
7695 (buf (current-buffer)))
7696 (run-hooks 'gnus-summary-prepare-exit-hook)
7697 (gnus-summary-update-info) ; Make all changes in this group permanent.
7699 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7700 ;; Make sure where I was, and go to next newsgroup.
7701 (set-buffer gnus-group-buffer)
7704 (gnus-group-jump-to-group group)
7705 (gnus-group-next-unread-group 1)))
7708 ;; We set all buffer-local variables to nil. It is unclear why
7709 ;; this is needed, but if we don't, buffer-local variables are
7710 ;; not garbage-collected, it seems. This would the lead to en
7711 ;; ever-growing Emacs.
7713 (gnus-summary-clear-local-variables)
7714 ;; We clear the global counterparts of the buffer-local
7715 ;; variables as well, just to be on the safe side.
7716 (gnus-configure-windows 'group 'force)
7717 (gnus-summary-clear-local-variables)
7718 ;; Return to group mode buffer.
7719 (if (eq mode 'gnus-summary-mode)
7720 (gnus-kill-buffer buf))
7721 (if (get-buffer gnus-article-buffer)
7722 (bury-buffer gnus-article-buffer))
7723 (setq gnus-current-select-method gnus-select-method)
7724 (pop-to-buffer gnus-group-buffer)
7725 (if (not quit-config)
7727 (gnus-group-jump-to-group group)
7728 (gnus-group-next-unread-group 1))
7729 (if (not (buffer-name (car quit-config)))
7730 (gnus-configure-windows 'group 'force)
7731 (set-buffer (car quit-config))
7732 (and (eq major-mode 'gnus-summary-mode)
7733 (gnus-set-global-variables))
7734 (gnus-configure-windows (cdr quit-config))))
7735 (run-hooks 'gnus-summary-exit-hook))))
7737 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7738 (defun gnus-summary-exit-no-update (&optional no-questions)
7739 "Quit reading current newsgroup without updating read article info."
7741 (gnus-set-global-variables)
7742 (let* ((group gnus-newsgroup-name)
7743 (quit-config (nth 1 (assoc 'quit-config
7744 (gnus-find-method-for-group group)))))
7745 (if (or no-questions
7747 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7749 (gnus-close-group group)
7750 (gnus-summary-clear-local-variables)
7751 (set-buffer gnus-group-buffer)
7752 (gnus-summary-clear-local-variables)
7753 ;; Return to group selection mode.
7754 (gnus-configure-windows 'group 'force)
7755 (if (get-buffer gnus-summary-buffer)
7756 (kill-buffer gnus-summary-buffer))
7757 (if (get-buffer gnus-article-buffer)
7758 (bury-buffer gnus-article-buffer))
7759 (if (equal (gnus-group-group-name) group)
7760 (gnus-group-next-unread-group 1))
7763 (if (not (buffer-name (car quit-config)))
7764 (gnus-configure-windows 'group 'force)
7765 (set-buffer (car quit-config))
7766 (and (eq major-mode 'gnus-summary-mode)
7767 (gnus-set-global-variables))
7768 (gnus-configure-windows (cdr quit-config)))))))))
7770 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7771 (defun gnus-summary-fetch-faq (group)
7772 "Fetch the FAQ for the current group."
7773 (interactive (list gnus-newsgroup-name))
7774 (let ((gnus-faq-buffer
7775 (find-file (concat gnus-group-faq-directory
7776 (gnus-group-real-name group)))))
7777 (and gnus-faq-buffer (gnus-configure-windows 'summary-faq))))
7779 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7780 (defun gnus-summary-describe-group (&optional force)
7781 "Describe the current newsgroup."
7783 (gnus-group-describe-group force gnus-newsgroup-name))
7785 (defun gnus-summary-describe-briefly ()
7786 "Describe summary mode commands briefly."
7789 (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")))
7791 ;; Walking around group mode buffer from summary mode.
7793 (defun gnus-summary-next-group (&optional no-article target-group backward)
7794 "Exit current newsgroup and then select next unread newsgroup.
7795 If prefix argument NO-ARTICLE is non-nil, no article is selected
7796 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7797 previous group instead."
7799 (gnus-set-global-variables)
7800 (let ((current-group gnus-newsgroup-name)
7801 (current-buffer (current-buffer))
7803 ;; First we semi-exit this group to update Xrefs and all variables.
7804 ;; We can't do a real exit, because the window conf must remain
7805 ;; the same in case the user is prompted for info, and we don't
7806 ;; want the window conf to change before that...
7807 (gnus-summary-exit t)
7808 (while (not entered)
7809 ;; Then we find what group we are supposed to enter.
7810 (set-buffer gnus-group-buffer)
7811 (gnus-group-jump-to-group current-group)
7814 (if (eq gnus-keep-same-level 'best)
7815 (gnus-summary-best-group gnus-newsgroup-name)
7816 (gnus-summary-search-group backward gnus-keep-same-level))))
7817 (if (not target-group)
7818 ;; There are no further groups, so we return to the group
7821 (gnus-message 5 "Returning to the group buffer")
7823 (set-buffer current-buffer)
7824 (gnus-summary-exit))
7825 ;; We try to enter the target group.
7826 (gnus-group-jump-to-group target-group)
7827 (let ((unreads (gnus-group-group-unread)))
7828 (if (and (or (eq t unreads)
7829 (and unreads (not (zerop unreads))))
7830 (gnus-summary-read-group
7831 target-group nil no-article current-buffer))
7833 (setq current-group target-group
7834 target-group nil)))))))
7836 (defun gnus-summary-next-group-old (&optional no-article group backward)
7837 "Exit current newsgroup and then select next unread newsgroup.
7838 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7839 If BACKWARD, go to previous group instead."
7841 (gnus-set-global-variables)
7842 (let ((ingroup gnus-newsgroup-name)
7843 (sumbuf (current-buffer))
7845 (set-buffer gnus-group-buffer)
7847 (or (and (numberp (setq num (car (gnus-gethash
7848 group gnus-newsrc-hashtb))))
7852 (gnus-group-jump-to-group group)
7854 (gnus-group-jump-to-group ingroup))
7855 (gnus-summary-search-group backward)
7856 (let ((group (or group (gnus-summary-search-group backward))))
7858 (gnus-summary-exit t) ;Update all information.
7860 (gnus-summary-exit-no-update t)
7861 (gnus-group-jump-to-group ingroup)
7862 (setq group (gnus-summary-search-group backward))
7863 (gnus-message 5 "Selecting %s..." group)
7864 (set-buffer gnus-group-buffer)
7865 ;; We are now in group mode buffer.
7866 ;; Make sure group mode buffer point is on GROUP.
7867 (gnus-group-jump-to-group group)
7868 (if (not (eq gnus-auto-select-next 'quietly))
7870 (gnus-summary-read-group group nil no-article sumbuf)
7871 (and (string= gnus-newsgroup-name ingroup)
7872 (bufferp sumbuf) (buffer-name sumbuf)
7874 (set-buffer (setq gnus-summary-buffer sumbuf))
7875 (gnus-summary-exit-no-update t))))
7876 (let ((prevgroup group))
7877 (gnus-group-jump-to-group ingroup)
7878 (setq group (gnus-summary-search-group backward))
7879 (gnus-summary-read-group group nil no-article sumbuf)
7880 (while (and (string= gnus-newsgroup-name ingroup)
7882 (buffer-name sumbuf)
7883 (not (string= prevgroup (gnus-group-group-name))))
7884 (set-buffer gnus-group-buffer)
7885 (gnus-summary-read-group
7886 (setq prevgroup (gnus-group-group-name))
7887 nil no-article sumbuf))
7888 (and (string= prevgroup (gnus-group-group-name))
7889 ;; We have reached the final group in the group
7892 (if (buffer-name sumbuf)
7895 (gnus-summary-exit)))))))))))
7897 (defun gnus-summary-prev-group (&optional no-article)
7898 "Exit current newsgroup and then select previous unread newsgroup.
7899 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7901 (gnus-summary-next-group no-article nil t))
7903 ;; Walking around summary lines.
7905 (defun gnus-summary-first-subject (&optional unread)
7906 "Go to the first unread subject.
7907 If UNREAD is non-nil, go to the first unread article.
7908 Returns nil if there are no unread articles."
7912 (goto-char (point-min)))
7915 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
7918 ;; There are no unread articles.
7919 (gnus-message 3 "No more unread articles")
7921 (gnus-summary-position-cursor)))
7923 (defun gnus-summary-next-subject (n &optional unread dont-display)
7924 "Go to next N'th summary line.
7925 If N is negative, go to the previous N'th subject line.
7926 If UNREAD is non-nil, only unread articles are selected.
7927 The difference between N and the actual number of steps taken is
7930 (let ((backward (< n 0))
7933 (gnus-summary-search-forward unread nil backward))
7935 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7936 (if unread " unread" "")))
7939 (gnus-summary-recenter)
7940 (gnus-summary-position-cursor)))
7943 (defun gnus-summary-next-unread-subject (n)
7944 "Go to next N'th unread summary line."
7946 (gnus-summary-next-subject n t))
7948 (defun gnus-summary-prev-subject (n &optional unread)
7949 "Go to previous N'th summary line.
7950 If optional argument UNREAD is non-nil, only unread article is selected."
7952 (gnus-summary-next-subject (- n) unread))
7954 (defun gnus-summary-prev-unread-subject (n)
7955 "Go to previous N'th unread summary line."
7957 (gnus-summary-next-subject (- n) t))
7959 (defun gnus-summary-goto-subject (article)
7960 "Go the subject line of ARTICLE."
7964 (completing-read "Article number: "
7968 (int-to-string (header-number headers))))
7969 gnus-newsgroup-headers)
7970 nil 'require-match))))
7971 (or article (error "No article number"))
7973 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
7974 'gnus-number article)))
7976 (gnus-summary-show-thread)
7977 ;; Skip dummy articles.
7978 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7985 (gnus-summary-position-cursor)))))
7987 ;; Walking around summary lines with displaying articles.
7989 (defun gnus-summary-expand-window (&optional arg)
7990 "Make the summary buffer take up the entire Emacs frame.
7991 Given a prefix, will force an `article' buffer configuration."
7993 (gnus-set-global-variables)
7995 (gnus-configure-windows 'article 'force)
7996 (gnus-configure-windows 'summary 'force)))
7998 (defun gnus-summary-display-article (article &optional all-header)
7999 "Display ARTICLE in article buffer."
8000 (gnus-set-global-variables)
8004 (gnus-article-prepare article all-header)
8005 (gnus-summary-show-thread)
8006 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8009 (gnus-summary-position-cursor)))
8010 (run-hooks 'gnus-select-article-hook)
8011 (gnus-summary-recenter)
8012 (gnus-summary-goto-subject article)
8013 ;; Successfully display article.
8014 (gnus-summary-update-line)
8015 (gnus-article-set-window-start
8016 (cdr (assq article gnus-newsgroup-bookmarks)))
8019 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
8020 "Select the current article.
8021 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
8022 non-nil, the article will be re-fetched even if it already present in
8023 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
8025 (and (not pseudo) (gnus-summary-pseudo-article)
8026 (error "This is a pseudo-article."))
8027 (let ((article (or article (gnus-summary-article-number)))
8028 (all-headers (not (not all-headers))) ;Must be T or NIL.
8032 (set-buffer gnus-summary-buffer)
8033 (if (or (null gnus-current-article)
8034 (null gnus-article-current)
8035 (null (get-buffer gnus-article-buffer))
8036 (not (eq article (cdr gnus-article-current)))
8037 (not (equal (car gnus-article-current) gnus-newsgroup-name))
8039 ;; The requested article is different from the current article.
8041 (gnus-summary-display-article article all-headers)
8043 (if (or all-headers gnus-show-all-headers)
8044 (gnus-article-show-all-headers))
8047 (gnus-article-set-window-start
8048 (cdr (assq article gnus-newsgroup-bookmarks)))))))
8050 (defun gnus-summary-set-current-mark (&optional current-mark)
8051 "Obsolete function."
8054 (defun gnus-summary-next-article (&optional unread subject backward)
8055 "Select the next article.
8056 If UNREAD, only unread articles are selected.
8057 If SUBJECT, only articles with SUBJECT are selected.
8058 If BACKWARD, the previous article is selected instead of the next."
8060 (gnus-set-global-variables)
8063 ;; Is there such an article?
8064 ((or (gnus-summary-display-article
8065 (gnus-summary-search-forward unread subject backward))
8066 (eq (gnus-summary-article-mark) gnus-canceled-mark))
8067 (gnus-summary-position-cursor))
8068 ;; If not, we try the first unread, if that is wanted.
8070 gnus-auto-select-same
8071 (gnus-summary-first-unread-article))
8072 (gnus-message 6 "Wrapped"))
8073 ;; Try to get next/previous article not displayed in this group.
8074 ((and gnus-auto-extend-newsgroup
8075 (not unread) (not subject)
8076 (setq header (gnus-more-header-forward backward)))
8077 (gnus-extend-newsgroup header backward)
8078 (let ((buffer-read-only nil))
8079 (goto-char (if backward (point-min) (point-max)))
8080 (gnus-summary-prepare-threads (list header)))
8081 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
8082 gnus-newsgroup-end)))
8083 ;; Go to next/previous group.
8085 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
8086 (gnus-summary-jump-to-group gnus-newsgroup-name))
8087 (let ((cmd (aref (this-command-keys) 0))
8089 (if (eq gnus-keep-same-level 'best)
8090 (gnus-summary-best-group gnus-newsgroup-name)
8091 (gnus-summary-search-group backward gnus-keep-same-level))))
8092 ;; For some reason, the group window gets selected. We change
8094 (select-window (get-buffer-window (current-buffer)))
8095 ;; Keep just the event type of CMD.
8096 (and (listp cmd) (setq cmd (car cmd)))
8097 ;; Select next unread newsgroup automagically.
8099 ((not gnus-auto-select-next)
8100 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
8101 ((eq gnus-auto-select-next 'quietly)
8103 (if (assoc 'quit-config (gnus-find-method-for-group
8104 gnus-newsgroup-name))
8106 (gnus-message 7 "No more%s articles (%s)..."
8107 (if unread " unread" "")
8108 (if group (concat "selecting " group)
8110 (gnus-summary-next-group nil group backward)))
8112 (let ((keystrokes '(?\C-n ?\C-p))
8114 (while (or (null key) (memq key keystrokes))
8116 7 "No more%s articles%s" (if unread " unread" "")
8117 (if (and group (not (assoc 'quit-config
8118 (gnus-find-method-for-group
8119 gnus-newsgroup-name))))
8120 (format " (Type %s for %s [%s])"
8121 (single-key-description cmd) group
8122 (car (gnus-gethash group gnus-newsrc-hashtb)))
8123 (format " (Type %s to exit %s)"
8124 (single-key-description cmd)
8125 gnus-newsgroup-name)))
8126 ;; Confirm auto selection.
8127 (let* ((event (read-event)))
8128 (setq key (if (listp event) (car event) event))
8129 (if (memq key keystrokes)
8130 (let ((obuf (current-buffer)))
8131 (switch-to-buffer gnus-group-buffer)
8133 (gnus-group-jump-to-group group))
8135 (execute-kbd-macro (char-to-string key))
8137 (setq group (gnus-group-group-name))
8138 (switch-to-buffer obuf)))))
8140 (if (or (not group) (assoc 'quit-config
8141 (gnus-find-method-for-group
8142 gnus-newsgroup-name)))
8144 (gnus-summary-next-group nil group backward))
8145 (setq unread-command-events (list key)))))))))))
8147 (defun gnus-summary-next-unread-article ()
8148 "Select unread article after current one."
8150 (gnus-summary-next-article t (and gnus-auto-select-same
8151 (gnus-summary-subject-string))))
8153 (defun gnus-summary-prev-article (&optional unread subject)
8154 "Select the article after the current one.
8155 If UNREAD is non-nil, only unread articles are selected."
8157 (gnus-summary-next-article unread subject t))
8159 (defun gnus-summary-prev-unread-article ()
8160 "Select unred article before current one."
8162 (gnus-summary-prev-article t (and gnus-auto-select-same
8163 (gnus-summary-subject-string))))
8165 (defun gnus-summary-next-page (&optional lines circular)
8166 "Show next page of selected article.
8167 If end of article, select next article.
8168 Argument LINES specifies lines to be scrolled up.
8169 If CIRCULAR is non-nil, go to the start of the article instead of
8170 instead of selecting the next article when reaching the end of the
8173 (setq gnus-summary-buffer (current-buffer))
8174 (gnus-set-global-variables)
8175 (let ((article (gnus-summary-article-number))
8177 (gnus-configure-windows 'article)
8178 (if (or (null gnus-current-article)
8179 (null gnus-article-current)
8180 (/= article (cdr gnus-article-current))
8181 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8182 ;; Selected subject is different from current article's.
8183 (gnus-summary-display-article article)
8184 (gnus-eval-in-buffer-window
8186 (setq endp (gnus-article-next-page lines)))
8189 (gnus-summary-beginning-of-article))
8191 (gnus-message 3 "End of message"))
8193 (gnus-summary-next-unread-article)))))
8194 (gnus-summary-recenter)
8195 (gnus-summary-position-cursor)))
8197 (defun gnus-summary-prev-page (&optional lines)
8198 "Show previous page of selected article.
8199 Argument LINES specifies lines to be scrolled down."
8201 (gnus-set-global-variables)
8202 (let ((article (gnus-summary-article-number)))
8203 (gnus-configure-windows 'article)
8204 (if (or (null gnus-current-article)
8205 (null gnus-article-current)
8206 (/= article (cdr gnus-article-current))
8207 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8208 ;; Selected subject is different from current article's.
8209 (gnus-summary-display-article article)
8210 (gnus-summary-recenter)
8211 (gnus-eval-in-buffer-window gnus-article-buffer
8212 (gnus-article-prev-page lines))))
8213 (gnus-summary-position-cursor))
8215 (defun gnus-summary-scroll-up (lines)
8216 "Scroll up (or down) one line current article.
8217 Argument LINES specifies lines to be scrolled up (or down if negative)."
8219 (gnus-set-global-variables)
8220 (gnus-configure-windows 'article)
8221 (or (gnus-summary-select-article nil nil 'pseudo)
8222 (gnus-eval-in-buffer-window
8225 (if (gnus-article-next-page lines)
8226 (gnus-message 3 "End of message")))
8228 (gnus-article-prev-page (- lines))))))
8229 (gnus-summary-recenter)
8230 (gnus-summary-position-cursor))
8232 (defun gnus-summary-next-same-subject ()
8233 "Select next article which has the same subject as current one."
8235 (gnus-set-global-variables)
8236 (gnus-summary-next-article nil (gnus-summary-subject-string)))
8238 (defun gnus-summary-prev-same-subject ()
8239 "Select previous article which has the same subject as current one."
8241 (gnus-set-global-variables)
8242 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
8244 (defun gnus-summary-next-unread-same-subject ()
8245 "Select next unread article which has the same subject as current one."
8247 (gnus-set-global-variables)
8248 (gnus-summary-next-article t (gnus-summary-subject-string)))
8250 (defun gnus-summary-prev-unread-same-subject ()
8251 "Select previous unread article which has the same subject as current one."
8253 (gnus-set-global-variables)
8254 (gnus-summary-prev-article t (gnus-summary-subject-string)))
8256 (defun gnus-summary-first-unread-article ()
8257 "Select the first unread article.
8258 Return nil if there are no unread articles."
8260 (gnus-set-global-variables)
8262 (if (gnus-summary-first-subject t)
8264 (gnus-summary-show-thread)
8265 (gnus-summary-first-subject t)
8266 (gnus-summary-display-article (gnus-summary-article-number))))
8267 (gnus-summary-position-cursor)))
8269 (defun gnus-summary-best-unread-article ()
8270 "Select the unread article with the highest score."
8272 (gnus-set-global-variables)
8273 (let ((scored gnus-newsgroup-scored)
8277 (or (> best (cdr (car scored)))
8278 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
8279 (not (memq art gnus-newsgroup-marked))
8280 (not (memq art gnus-newsgroup-dormant))
8281 (if (= best (cdr (car scored)))
8282 (setq article (min art article))
8284 (setq best (cdr (car scored))))))
8285 (setq scored (cdr scored)))
8287 ((or (not article) (null gnus-newsgroup-unreads))
8288 ;; We didn't find any scored articles, so we just jump to the
8290 (gnus-summary-first-unread-article))
8291 ((> best gnus-summary-default-score)
8292 ;; We found one, and it's bigger than the default score, so we
8294 (gnus-summary-goto-article article))
8296 ;; We found an article, but it has a score lower than the
8297 ;; defaults, so we try to find an article with the default
8299 (goto-char (point-min))
8300 (while (and (or (not (= (gnus-summary-article-mark) gnus-unread-mark))
8301 (not (eq (cdr (assq (gnus-summary-article-number)
8302 gnus-newsgroup-scored))
8303 gnus-summary-default-score)))
8304 (zerop (forward-line 1))
8306 (if (= (gnus-summary-article-mark) gnus-unread-mark)
8307 ;; We jump to the article we have finally found.
8308 (gnus-summary-goto-article (gnus-summary-article-number))
8309 ;; Or there were no default-scored articles.
8310 (gnus-summary-goto-article article))))
8311 (gnus-summary-position-cursor)))
8313 (defun gnus-summary-goto-article (article &optional all-headers)
8314 "Fetch ARTICLE and display it if it exists.
8315 If ALL-HEADERS is non-nil, no header lines are hidden."
8321 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
8322 gnus-newsgroup-headers)
8323 nil 'require-match))))
8325 (and (gnus-summary-goto-subject article)
8326 (gnus-summary-display-article article all-headers))
8327 (gnus-summary-position-cursor)))
8329 (defun gnus-summary-goto-last-article ()
8330 "Go to the previously read article."
8333 (and gnus-last-article
8334 (gnus-summary-goto-article gnus-last-article))
8335 (gnus-summary-position-cursor)))
8337 (defun gnus-summary-pop-article (number)
8338 "Pop one article off the history and go to the previous.
8339 NUMBER articles will be popped off."
8342 (setq gnus-newsgroup-history
8343 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8345 (gnus-summary-goto-article (car to))
8346 (error "Article history empty")))
8347 (gnus-summary-position-cursor))
8349 ;; Summary article oriented commands
8351 (defun gnus-summary-refer-parent-article (n)
8352 "Refer parent article N times.
8353 The difference between N and the number of articles fetched is returned."
8355 (gnus-set-global-variables)
8359 (let ((ref (header-references (gnus-get-header-by-num
8360 (gnus-summary-article-number)))))
8361 (if (and ref (not (equal ref ""))
8362 (string-match "<[^<>]*>[ \t]*$" ref))
8363 (gnus-summary-refer-article
8364 (substring ref (match-beginning 0) (match-end 0)))
8365 (gnus-message 1 "No references in article %d"
8366 (gnus-summary-article-number))
8369 (gnus-summary-position-cursor)
8372 (defun gnus-summary-refer-article (message-id)
8373 "Refer article specified by MESSAGE-ID.
8374 NOTE: This command only works with newsgroups that use real or simulated NNTP."
8375 (interactive "sMessage-ID: ")
8376 (if (or (not (stringp message-id))
8377 (zerop (length message-id)))
8379 ;; Construct the correct Message-ID if necessary.
8380 ;; Suggested by tale@pawl.rpi.edu.
8381 (or (string-match "^<" message-id)
8382 (setq message-id (concat "<" message-id)))
8383 (or (string-match ">$" message-id)
8384 (setq message-id (concat message-id ">")))
8385 (let ((header (car (gnus-gethash (downcase message-id)
8386 gnus-newsgroup-dependencies))))
8388 (or (gnus-summary-goto-article (header-number header))
8389 ;; The header has been read, but the article had been
8390 ;; expunged, so we insert it again.
8392 (gnus-summary-insert-line
8393 nil header 0 nil gnus-read-mark nil nil
8394 (header-subject header))
8396 (header-number header)))
8397 (let ((gnus-override-method gnus-refer-article-method)
8398 (gnus-ancient-mark gnus-read-mark)
8399 (tmp-point (window-start
8400 (get-buffer-window gnus-article-buffer)))
8402 (and gnus-refer-article-method
8403 (gnus-check-server gnus-refer-article-method))
8404 ;; Save the old article buffer.
8406 (set-buffer gnus-article-buffer)
8407 (gnus-kill-buffer " *temp Article*")
8408 (setq tmp-buf (rename-buffer " *temp Article*")))
8410 (if (gnus-article-prepare
8411 message-id nil (gnus-read-header message-id))
8413 (setq number (header-number gnus-current-headers))
8414 (gnus-rebuild-thread message-id)
8415 (gnus-summary-goto-subject number)
8416 (gnus-summary-recenter)
8417 (gnus-article-set-window-start
8418 (cdr (assq number gnus-newsgroup-bookmarks)))
8420 ;; We restore the old article buffer.
8422 (kill-buffer gnus-article-buffer)
8423 (set-buffer tmp-buf)
8424 (rename-buffer gnus-article-buffer)
8425 (let ((buffer-read-only nil))
8427 (set-window-start (get-buffer-window (current-buffer))
8428 tmp-point)))))))))))
8430 (defun gnus-summary-enter-digest-group ()
8431 "Enter a digest group based on the current article."
8433 (gnus-set-global-variables)
8434 (gnus-summary-select-article)
8435 ;; We do not want a narrowed article.
8436 (gnus-summary-stop-page-breaking)
8437 (let ((name (format "%s-%d"
8438 (gnus-group-prefixed-name
8439 gnus-newsgroup-name (list 'nndoc ""))
8440 gnus-current-article))
8441 (ogroup gnus-newsgroup-name)
8442 (buf (current-buffer)))
8443 (if (gnus-group-read-ephemeral-group
8444 name (list 'nndoc name
8445 (list 'nndoc-address (get-buffer gnus-article-buffer))
8446 '(nndoc-article-type digest))
8448 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8449 (list (list (cons 'to-group ogroup))))
8450 (switch-to-buffer buf)
8451 (gnus-set-global-variables)
8452 (gnus-configure-windows 'summary)
8453 (gnus-message 3 "Article not a digest?"))))
8455 (defun gnus-summary-isearch-article ()
8456 "Do incremental search forward on current article."
8458 (gnus-set-global-variables)
8459 (gnus-summary-select-article)
8460 (gnus-eval-in-buffer-window
8461 gnus-article-buffer (isearch-forward)))
8463 (defun gnus-summary-search-article-forward (regexp &optional backward)
8464 "Search for an article containing REGEXP forward.
8465 If BACKWARD, search backward instead."
8468 (format "Search article %s (regexp%s): "
8469 (if current-prefix-arg "backward" "forward")
8470 (if gnus-last-search-regexp
8471 (concat ", default " gnus-last-search-regexp)
8473 current-prefix-arg))
8474 (gnus-set-global-variables)
8475 (if (string-equal regexp "")
8476 (setq regexp (or gnus-last-search-regexp ""))
8477 (setq gnus-last-search-regexp regexp))
8478 (if (gnus-summary-search-article regexp backward)
8479 (gnus-article-set-window-start
8480 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8481 (error "Search failed: \"%s\"" regexp)))
8483 (defun gnus-summary-search-article-backward (regexp)
8484 "Search for an article containing REGEXP backward."
8487 (format "Search article backward (regexp%s): "
8488 (if gnus-last-search-regexp
8489 (concat ", default " gnus-last-search-regexp)
8491 (gnus-summary-search-article-forward regexp 'backward))
8493 (defun gnus-summary-search-article (regexp &optional backward)
8494 "Search for an article containing REGEXP.
8495 Optional argument BACKWARD means do search for backward.
8496 gnus-select-article-hook is not called during the search."
8497 (let ((gnus-select-article-hook nil) ;Disable hook.
8498 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8501 (function re-search-backward) (function re-search-forward)))
8504 ;; Hidden thread subtrees must be searched for ,too.
8505 (gnus-summary-show-all-threads)
8506 (if (eobp) (forward-line -1))
8507 ;; First of all, search current article.
8508 ;; We don't want to read article again from NNTP server nor reset
8510 (gnus-summary-select-article)
8511 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8512 (setq last gnus-current-article)
8513 (gnus-eval-in-buffer-window gnus-article-buffer
8516 ;; Begin search from current point.
8517 (setq found (funcall re-search regexp nil t))))
8518 ;; Then search next articles.
8519 (while (and (not found)
8520 (gnus-summary-display-article
8521 (gnus-summary-search-subject backward nil nil)))
8522 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8523 (gnus-eval-in-buffer-window gnus-article-buffer
8526 (goto-char (if backward (point-max) (point-min)))
8527 (setq found (funcall re-search regexp nil t)))))
8529 ;; Adjust article pointer.
8530 (or (eq last gnus-current-article)
8531 (setq gnus-last-article last))
8532 ;; Return T if found such article.
8535 (defun gnus-summary-execute-command (header regexp command &optional backward)
8536 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8537 If HEADER is an empty string (or nil), the match is done on the entire
8538 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8540 (list (let ((completion-ignore-case t))
8543 (mapcar (lambda (string) (list string))
8544 '("Number" "Subject" "From" "Lines" "Date"
8545 "Message-ID" "Xref" "References"))
8546 nil 'require-match))
8547 (read-string "Regexp: ")
8548 (read-key-sequence "Command: ")
8549 current-prefix-arg))
8550 (gnus-set-global-variables)
8551 ;; Hidden thread subtrees must be searched as well.
8552 (gnus-summary-show-all-threads)
8553 ;; We don't want to change current point nor window configuration.
8555 (save-window-excursion
8556 (gnus-message 6 "Executing %s..." (key-description command))
8557 ;; We'd like to execute COMMAND interactively so as to give arguments.
8558 (gnus-execute header regexp
8560 (call-interactively '(, (key-binding command)))))
8562 (gnus-message 6 "Executing %s...done" (key-description command)))))
8564 (defun gnus-summary-beginning-of-article ()
8565 "Scroll the article back to the beginning."
8567 (gnus-set-global-variables)
8568 (gnus-summary-select-article)
8569 (gnus-configure-windows 'article)
8570 (gnus-eval-in-buffer-window
8573 (goto-char (point-min))
8574 (and gnus-break-pages (gnus-narrow-to-page))))
8576 (defun gnus-summary-end-of-article ()
8577 "Scroll to the end of the article."
8579 (gnus-set-global-variables)
8580 (gnus-summary-select-article)
8581 (gnus-configure-windows 'article)
8582 (gnus-eval-in-buffer-window
8585 (goto-char (point-max))
8586 (and gnus-break-pages (gnus-narrow-to-page))))
8588 (defun gnus-summary-show-article ()
8589 "Force re-fetching of the current article."
8591 (gnus-set-global-variables)
8592 (or gnus-current-article
8593 (error "There is no current article"))
8594 (gnus-summary-goto-subject gnus-current-article)
8595 (gnus-summary-select-article nil 'force)
8596 (gnus-configure-windows 'article)
8597 (gnus-summary-position-cursor))
8599 (defun gnus-summary-verbose-headers (&optional arg)
8600 "Toggle permanent full header display.
8601 If ARG is a positive number, turn header display on.
8602 If ARG is a negative number, turn header display off."
8604 (gnus-set-global-variables)
8605 (gnus-summary-toggle-header arg)
8606 (setq gnus-show-all-headers
8607 (cond ((or (not (numberp arg))
8609 (not gnus-show-all-headers))
8613 (defun gnus-summary-toggle-header (&optional arg)
8614 "Show the headers if they are hidden, or hide them if they are shown.
8615 If ARG is a positive number, show the entire header.
8616 If ARG is a negative number, hide the unwanted header lines."
8618 (gnus-set-global-variables)
8620 (set-buffer gnus-article-buffer)
8621 (let ((buffer-read-only nil))
8623 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8624 gnus-hidden-properties)
8625 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8626 (if (text-property-any (point-min) (point-max) 'invisible t)
8627 (remove-text-properties
8628 (point-min) (point-max) gnus-hidden-properties)
8629 ;; We hide the headers. This song and dance act below is
8630 ;; done because `gnus-have-all-headers' is buffer-local to
8631 ;; the summary buffer, and we only want to temporarily
8632 ;; change it in that buffer. Ugh.
8633 (let ((have gnus-have-all-headers))
8635 (set-buffer gnus-summary-buffer)
8636 (setq gnus-have-all-headers nil)
8638 (set-buffer gnus-article-buffer)
8639 (run-hooks 'gnus-article-display-hook))
8640 (setq gnus-have-all-headers have)))))
8641 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8643 (defun gnus-summary-show-all-headers ()
8644 "Make all header lines visible."
8646 (gnus-set-global-variables)
8647 (gnus-article-show-all-headers))
8649 (defun gnus-summary-toggle-mime (&optional arg)
8650 "Toggle MIME processing.
8651 If ARG is a positive number, turn MIME processing on."
8653 (gnus-set-global-variables)
8654 (setq gnus-show-mime
8655 (if (null arg) (not gnus-show-mime)
8656 (> (prefix-numeric-value arg) 0)))
8657 (gnus-summary-select-article t 'force))
8659 (defun gnus-summary-caesar-message (&optional arg)
8660 "Caesar rotate the current article by 13.
8661 The numerical prefix specifies how manu places to rotate each letter
8664 (gnus-set-global-variables)
8665 (gnus-summary-select-article)
8666 (let ((mail-header-separator ""))
8667 (gnus-eval-in-buffer-window
8671 (let ((start (window-start)))
8672 (news-caesar-buffer-body arg)
8673 (set-window-start (get-buffer-window (current-buffer)) start))))))
8675 (defun gnus-summary-stop-page-breaking ()
8676 "Stop page breaking in the current article."
8678 (gnus-set-global-variables)
8679 (gnus-summary-select-article)
8680 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8682 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8684 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
8685 "Move the current article to a different newsgroup.
8686 If N is a positive number, move the N next articles.
8687 If N is a negative number, move the N previous articles.
8688 If N is nil and any articles have been marked with the process mark,
8689 move those articles instead.
8690 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8691 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8692 re-spool using this method.
8693 For this function to work, both the current newsgroup and the
8694 newsgroup that you want to move to have to support the `request-move'
8695 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8697 (gnus-set-global-variables)
8698 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8699 (error "The current newsgroup does not support article moving"))
8700 (let ((articles (gnus-summary-work-articles n))
8701 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8702 art-group to-method sel-met)
8703 (if (and (not to-newsgroup) (not select-method))
8706 (format "Where do you want to move %s? %s"
8707 (if (> (length articles) 1)
8708 (format "these %d articles" (length articles))
8710 (if gnus-current-move-group
8711 (format "(%s default) " gnus-current-move-group)
8713 gnus-active-hashtb nil nil prefix)))
8716 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8717 (setq to-newsgroup (or gnus-current-move-group "")))
8718 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8719 (gnus-activate-group to-newsgroup)
8720 (error "No such group: %s" to-newsgroup))
8721 (setq gnus-current-move-group to-newsgroup)))
8722 (setq to-method (if select-method (list select-method "")
8723 (gnus-find-method-for-group to-newsgroup)))
8724 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8725 (error "%s does not support article copying" (car to-method)))
8726 (or (gnus-check-server to-method)
8727 (error "Can't open server %s" (car to-method)))
8728 (gnus-message 6 "Moving to %s: %s..."
8729 (or select-method to-newsgroup) articles)
8732 (gnus-request-move-article
8733 (car articles) ; Article to move
8734 gnus-newsgroup-name ; From newsgrouo
8735 (nth 1 (gnus-find-method-for-group
8736 gnus-newsgroup-name)) ; Server
8737 (list 'gnus-request-accept-article
8739 (list 'quote select-method)
8741 (not (cdr articles))) ; Accept form
8742 (not (cdr articles)))) ; Only save nov last time
8743 (let* ((buffer-read-only nil)
8746 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8748 (gnus-group-prefixed-name
8750 (if select-method (list select-method "")
8751 (gnus-find-method-for-group to-newsgroup)))
8752 gnus-newsrc-hashtb)))
8753 (info (nth 2 entry))
8754 (article (car articles)))
8755 (gnus-summary-goto-subject article)
8757 (delete-region (point) (progn (forward-line 1) (point)))
8758 ;; Update the group that has been moved to.
8760 () ; This group does not exist yet.
8761 (if (not (memq article gnus-newsgroup-unreads))
8762 (setcar (cdr (cdr info))
8763 (gnus-add-to-range (nth 2 info)
8764 (list (cdr art-group)))))
8765 ;; Copy any marks over to the new group.
8766 (let ((marks '((tick . gnus-newsgroup-marked)
8767 (dormant . gnus-newsgroup-dormant)
8768 (expire . gnus-newsgroup-expirable)
8769 (bookmark . gnus-newsgroup-bookmarks)
8770 (reply . gnus-newsgroup-replied)))
8771 (to-article (cdr art-group)))
8773 (if (memq article (symbol-value (cdr (car marks))))
8774 (gnus-add-marked-articles
8775 (car info) (car (car marks)) (list to-article) info))
8776 (setq marks (cdr marks)))))
8778 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8779 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8780 (setq gnus-newsgroup-dormant
8781 (delq article gnus-newsgroup-dormant))
8782 (setq gnus-newsgroup-reads
8783 (cons (cons article gnus-canceled-mark)
8784 gnus-newsgroup-reads)))
8785 (gnus-message 1 "Couldn't move article %s" (car articles)))
8786 (gnus-summary-remove-process-mark (car articles))
8787 (setq articles (cdr articles)))))
8789 (defun gnus-summary-respool-article (&optional n respool-method)
8790 "Respool the current article.
8791 The article will be squeezed through the mail spooling process again,
8792 which means that it will be put in some mail newsgroup or other
8793 depending on `nnmail-split-methods'.
8794 If N is a positive number, respool the N next articles.
8795 If N is a negative number, respool the N previous articles.
8796 If N is nil and any articles have been marked with the process mark,
8797 respool those articles instead.
8799 Respooling can be done both from mail groups and \"real\" newsgroups.
8800 In the former case, the articles in question will be moved from the
8801 current group into whatever groups they are destined to. In the
8802 latter case, they will be copied into the relevant groups."
8804 (gnus-set-global-variables)
8805 (let ((respool-methods (gnus-methods-using 'respool))
8807 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8809 (setq respool-method
8811 "What method do you want to use when respooling? "
8812 respool-methods nil t methname)))
8813 (or (string= respool-method "")
8814 (if (assoc (symbol-name
8815 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8817 (gnus-summary-move-article n nil (intern respool-method))
8818 (gnus-summary-copy-article n nil (intern respool-method))))))
8820 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8821 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8822 "Move the current article to a different newsgroup.
8823 If N is a positive number, move the N next articles.
8824 If N is a negative number, move the N previous articles.
8825 If N is nil and any articles have been marked with the process mark,
8826 move those articles instead.
8827 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8828 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8829 re-spool using this method.
8830 For this function to work, the newsgroup that you want to move to have
8831 to support the `request-move' and `request-accept'
8832 functions. (Ie. mail newsgroups at present.)"
8834 (gnus-set-global-variables)
8835 (let ((articles (gnus-summary-work-articles n))
8836 (copy-buf (get-buffer-create "*copy work*"))
8837 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8838 art-group to-method)
8839 (buffer-disable-undo copy-buf)
8840 (if (and (not to-newsgroup) (not select-method))
8843 (format "Where do you want to copy %s? %s"
8844 (if (> (length articles) 1)
8845 (format "these %d articles" (length articles))
8847 (if gnus-current-move-group
8848 (format "(%s default) " gnus-current-move-group)
8850 gnus-active-hashtb nil nil prefix)))
8853 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8854 (setq to-newsgroup (or gnus-current-move-group "")))
8855 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8856 (gnus-activate-group to-newsgroup)
8857 (error "No such group: %s" to-newsgroup))
8858 (setq gnus-current-move-group to-newsgroup)))
8859 (setq to-method (if select-method (list select-method "")
8860 (gnus-find-method-for-group to-newsgroup)))
8861 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8862 (error "%s does not support article copying" (car to-method)))
8863 (or (gnus-check-server to-method)
8864 (error "Can't open server %s" (car to-method)))
8866 (gnus-message 6 "Copying to %s: %s..."
8867 (or select-method to-newsgroup) articles)
8870 (set-buffer copy-buf)
8871 (gnus-request-article-this-buffer
8872 (car articles) gnus-newsgroup-name)
8873 (gnus-request-accept-article
8874 (if select-method (quote select-method) to-newsgroup)
8875 (not (cdr articles)))))
8878 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8880 (gnus-group-prefixed-name
8882 (if select-method (list select-method "")
8883 (gnus-find-method-for-group to-newsgroup)))
8884 gnus-newsrc-hashtb)))
8885 (info (nth 2 entry))
8886 (article (car articles)))
8887 ;; We copy the info over to the new group.
8889 () ; This group does not exist (yet).
8890 (if (not (memq article gnus-newsgroup-unreads))
8891 (setcar (cdr (cdr info))
8892 (gnus-add-to-range (nth 2 info)
8893 (list (cdr art-group)))))
8894 ;; Copy any marks over to the new group.
8895 (let ((marks '((tick . gnus-newsgroup-marked)
8896 (dormant . gnus-newsgroup-dormant)
8897 (expire . gnus-newsgroup-expirable)
8898 (bookmark . gnus-newsgroup-bookmarks)
8899 (reply . gnus-newsgroup-replied)))
8900 (to-article (cdr art-group)))
8902 (if (memq article (symbol-value (cdr (car marks))))
8903 (gnus-add-marked-articles
8904 (car info) (car (car marks)) (list to-article) info))
8905 (setq marks (cdr marks))))))
8906 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8907 (gnus-summary-remove-process-mark (car articles))
8908 (setq articles (cdr articles)))
8909 (kill-buffer copy-buf)))
8911 (defun gnus-summary-import-article (file)
8912 "Import a random file into a mail newsgroup."
8913 (interactive "fImport file: ")
8914 (let ((group gnus-newsgroup-name)
8916 (or (gnus-check-backend-function 'request-accept-article group)
8917 (error "%s does not support article importing" group))
8918 (or (file-readable-p file)
8919 (not (file-regular-p file))
8920 (error "Can't read %s" file))
8922 (set-buffer (get-buffer-create " *import file*"))
8923 (buffer-disable-undo (current-buffer))
8925 (insert-file-contents file)
8926 (goto-char (point-min))
8927 (if (nnheader-article-p)
8929 (setq atts (file-attributes file))
8930 (insert "From: " (read-string "From: ") "\n"
8931 "Subject: " (read-string "Subject: ") "\n"
8932 "Date: " (current-time-string (nth 5 atts)) "\n"
8933 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8934 (gnus-request-accept-article group t)
8935 (kill-buffer (current-buffer)))))
8937 (defun gnus-summary-expire-articles ()
8938 "Expire all articles that are marked as expirable in the current group."
8940 (if (not (gnus-check-backend-function
8941 'request-expire-articles gnus-newsgroup-name))
8943 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
8944 gnus-newsrc-hashtb)))
8945 (total (memq 'total-expire (nth 5 info)))
8946 (expirable (if total
8947 (gnus-list-of-read-articles gnus-newsgroup-name)
8948 (setq gnus-newsgroup-expirable
8949 (sort gnus-newsgroup-expirable '<))))
8953 (gnus-message 6 "Expiring articles...")
8954 ;; The list of articles that weren't expired is returned.
8955 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
8956 (or total (setq gnus-newsgroup-expirable es))
8957 ;; We go through the old list of expirable, and mark all
8958 ;; really expired articles as non-existant.
8959 (or (eq es expirable) ; If nothing was expired, we don't mark.
8960 (let ((gnus-use-cache nil))
8962 (or (memq (car expirable) es)
8963 (gnus-summary-mark-article
8964 (car expirable) gnus-canceled-mark))
8965 (setq expirable (cdr expirable)))))
8966 (gnus-message 6 "Expiring articles...done")))))
8968 (defun gnus-summary-expire-articles-now ()
8969 "Expunge all expirable articles in the current group.
8970 This means that *all* articles that are marked as expirable will be
8971 deleted forever, right now."
8973 (or gnus-expert-user
8975 "Are you really, really, really sure you want to expunge? ")
8977 (let ((nnmail-expiry-wait -1)
8978 (nnmail-expiry-wait-function nil))
8979 (gnus-summary-expire-articles)))
8981 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8982 (defun gnus-summary-delete-article (&optional n)
8983 "Delete the N next (mail) articles.
8984 This command actually deletes articles. This is not a marking
8985 command. The article will disappear forever from you life, never to
8987 If N is negative, delete backwards.
8988 If N is nil and articles have been marked with the process mark,
8989 delete these instead."
8991 (or (gnus-check-backend-function 'request-expire-articles
8992 gnus-newsgroup-name)
8993 (error "The current newsgroup does not support article deletion."))
8994 ;; Compute the list of articles to delete.
8995 (let ((articles (gnus-summary-work-articles n))
8997 (if (and gnus-novice-user
8999 (format "Do you really want to delete %s forever? "
9000 (if (> (length articles) 1) "these articles"
9003 ;; Delete the articles.
9004 (setq not-deleted (gnus-request-expire-articles
9005 articles gnus-newsgroup-name 'force))
9007 (gnus-summary-remove-process-mark (car articles))
9008 ;; The backend might not have been able to delete the article
9010 (or (memq (car articles) not-deleted)
9011 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9012 (setq articles (cdr articles))))
9013 (gnus-summary-position-cursor)
9016 (defun gnus-summary-edit-article ()
9017 "Enter into a buffer and edit the current article.
9018 This will have permanent effect only in mail groups."
9020 (or (gnus-check-backend-function
9021 'request-replace-article gnus-newsgroup-name)
9022 (error "The current newsgroup does not support article editing."))
9023 (gnus-summary-select-article t)
9024 (gnus-configure-windows 'article)
9025 (select-window (get-buffer-window gnus-article-buffer))
9026 (gnus-message 6 "C-c C-c to end edits")
9027 (setq buffer-read-only nil)
9029 (use-local-map (copy-keymap (current-local-map)))
9030 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
9031 (buffer-enable-undo)
9033 (goto-char (point-min))
9034 (search-forward "\n\n" nil t))
9036 (defun gnus-summary-edit-article-done ()
9037 "Make edits to the current article permanent."
9039 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
9042 (if (not (gnus-request-replace-article
9043 (cdr gnus-article-current) (car gnus-article-current)
9045 (error "Couldn't replace article.")
9047 (use-local-map gnus-article-mode-map)
9048 (setq buffer-read-only t)
9049 (buffer-disable-undo (current-buffer))
9050 (gnus-configure-windows 'summary))
9051 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook))))
9053 (defun gnus-summary-edit-article-postpone ()
9054 "Postpone changes to the current article."
9057 (use-local-map gnus-article-mode-map)
9058 (setq buffer-read-only t)
9059 (buffer-disable-undo (current-buffer))
9060 (gnus-configure-windows 'summary)
9061 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))
9063 (defun gnus-summary-fancy-query ()
9064 "Query where the fancy respool algorithm would put this article."
9066 (gnus-summary-select-article)
9068 (set-buffer gnus-article-buffer)
9070 (goto-char (point-min))
9071 (search-forward "\n\n")
9072 (narrow-to-region (point-min) (point))
9073 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
9075 ;; Summary score commands.
9077 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
9079 (defun gnus-summary-raise-score (n)
9080 "Raise the score of the current article by N."
9082 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
9084 (defun gnus-summary-set-score (n)
9085 "Set the score of the current article to N."
9087 ;; Skip dummy header line.
9089 (gnus-summary-show-thread)
9090 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
9092 (let ((buffer-read-only nil))
9094 (gnus-summary-update-mark
9095 (if (= n (or gnus-summary-default-score 0)) ?
9096 (if (< n (or gnus-summary-default-score 0))
9097 gnus-score-below-mark gnus-score-over-mark)) 'score))
9098 (let* ((article (gnus-summary-article-number))
9099 (score (assq article gnus-newsgroup-scored)))
9100 (if score (setcdr score n)
9101 (setq gnus-newsgroup-scored
9102 (cons (cons article n) gnus-newsgroup-scored))))
9103 (gnus-summary-update-line)))
9105 (defun gnus-summary-current-score ()
9106 "Return the score of the current article."
9108 (message "%s" (gnus-summary-article-score)))
9110 ;; Summary marking commands.
9112 (defun gnus-summary-raise-same-subject-and-select (score)
9113 "Raise articles which has the same subject with SCORE and select the next."
9115 (let ((subject (gnus-summary-subject-string)))
9116 (gnus-summary-raise-score score)
9117 (while (gnus-summary-search-subject nil nil subject)
9118 (gnus-summary-raise-score score))
9119 (gnus-summary-next-article t)))
9121 (defun gnus-summary-raise-same-subject (score)
9122 "Raise articles which has the same subject with SCORE."
9124 (let ((subject (gnus-summary-subject-string)))
9125 (gnus-summary-raise-score score)
9126 (while (gnus-summary-search-subject nil nil subject)
9127 (gnus-summary-raise-score score))
9128 (gnus-summary-next-subject 1 t)))
9130 (defun gnus-score-default (level)
9131 (if level (prefix-numeric-value level)
9132 gnus-score-interactive-default-score))
9134 (defun gnus-summary-raise-thread (&optional score)
9135 "Raise the score of the articles in the current thread with SCORE."
9137 (setq score (1- (gnus-score-default score)))
9140 (let ((level (gnus-summary-thread-level)))
9141 (gnus-summary-raise-score score)
9142 (while (and (zerop (gnus-summary-next-subject 1 nil t))
9143 (> (gnus-summary-thread-level) level))
9144 (gnus-summary-raise-score score))
9146 (let ((gnus-summary-check-current t))
9147 (or (zerop (gnus-summary-next-subject 1 t))
9149 (gnus-summary-recenter)
9150 (gnus-summary-position-cursor)
9151 (gnus-set-mode-line 'summary))
9153 (defun gnus-summary-lower-same-subject-and-select (score)
9154 "Raise articles which has the same subject with SCORE and select the next."
9156 (gnus-summary-raise-same-subject-and-select (- score)))
9158 (defun gnus-summary-lower-same-subject (score)
9159 "Raise articles which has the same subject with SCORE."
9161 (gnus-summary-raise-same-subject (- score)))
9163 (defun gnus-summary-lower-thread (&optional score)
9164 "Lower score of articles in the current thread with SCORE."
9166 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
9168 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9169 "Mark articles which has the same subject as read, and then select the next.
9170 If UNMARK is positive, remove any kind of mark.
9171 If UNMARK is negative, tick articles."
9174 (setq unmark (prefix-numeric-value unmark)))
9176 (gnus-summary-mark-same-subject
9177 (gnus-summary-subject-string) unmark)))
9178 ;; Select next unread article. If auto-select-same mode, should
9179 ;; select the first unread article.
9180 (gnus-summary-next-article t (and gnus-auto-select-same
9181 (gnus-summary-subject-string)))
9182 (gnus-message 7 "%d article%s marked as %s"
9183 count (if (= count 1) " is" "s are")
9184 (if unmark "unread" "read"))))
9186 (defun gnus-summary-kill-same-subject (&optional unmark)
9187 "Mark articles which has the same subject as read.
9188 If UNMARK is positive, remove any kind of mark.
9189 If UNMARK is negative, tick articles."
9192 (setq unmark (prefix-numeric-value unmark)))
9194 (gnus-summary-mark-same-subject
9195 (gnus-summary-subject-string) unmark)))
9196 ;; If marked as read, go to next unread subject.
9198 ;; Go to next unread subject.
9199 (gnus-summary-next-subject 1 t))
9200 (gnus-message 7 "%d articles are marked as %s"
9201 count (if unmark "unread" "read"))))
9203 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9204 "Mark articles with same SUBJECT as read, and return marked number.
9205 If optional argument UNMARK is positive, remove any kinds of marks.
9206 If optional argument UNMARK is negative, mark articles as unread instead."
9210 ((null unmark) ; Mark as read.
9213 (gnus-summary-mark-article-as-read gnus-killed-mark)
9214 (gnus-summary-show-thread) t)
9215 (gnus-summary-search-forward nil subject))
9216 (setq count (1+ count))))
9217 ((> unmark 0) ; Tick.
9220 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9221 (gnus-summary-show-thread) t)
9222 (gnus-summary-search-forward nil subject))
9223 (setq count (1+ count))))
9224 (t ; Mark as unread.
9227 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9228 (gnus-summary-show-thread) t)
9229 (gnus-summary-search-forward nil subject))
9230 (setq count (1+ count)))))
9231 (gnus-set-mode-line 'summary)
9232 ;; Return the number of marked articles.
9235 (defun gnus-summary-mark-as-processable (n &optional unmark)
9236 "Set the process mark on the next N articles.
9237 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9238 the process mark instead. The difference between N and the actual
9239 number of articles marked is returned."
9241 (let ((backward (< n 0))
9246 (gnus-summary-remove-process-mark (gnus-summary-article-number))
9247 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9248 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9250 (if (/= 0 n) (gnus-message 7 "No more articles"))
9251 (gnus-summary-recenter)
9252 (gnus-summary-position-cursor)
9255 (defun gnus-summary-unmark-as-processable (n)
9256 "Remove the process mark from the next N articles.
9257 If N is negative, mark backward instead. The difference between N and
9258 the actual number of articles marked is returned."
9260 (gnus-summary-mark-as-processable n t))
9262 (defun gnus-summary-unmark-all-processable ()
9263 "Remove the process mark from all articles."
9266 (while gnus-newsgroup-processable
9267 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9268 (gnus-summary-position-cursor))
9270 (defun gnus-summary-mark-as-expirable (n)
9271 "Mark N articles forward as expirable.
9272 If N is negative, mark backward instead. The difference between N and
9273 the actual number of articles marked is returned."
9275 (gnus-summary-mark-forward n gnus-expirable-mark))
9277 (defun gnus-summary-mark-article-as-replied (article)
9278 "Mark ARTICLE replied and update the summary line."
9279 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
9280 (let ((buffer-read-only nil))
9281 (if (gnus-summary-goto-subject article)
9283 (gnus-summary-update-mark gnus-replied-mark 'replied)
9286 (defun gnus-summary-set-bookmark (article)
9287 "Set a bookmark in current article."
9288 (interactive (list (gnus-summary-article-number)))
9289 (if (or (not (get-buffer gnus-article-buffer))
9290 (not gnus-current-article)
9291 (not gnus-article-current)
9292 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9293 (error "No current article selected"))
9294 ;; Remove old bookmark, if one exists.
9295 (let ((old (assq article gnus-newsgroup-bookmarks)))
9296 (if old (setq gnus-newsgroup-bookmarks
9297 (delq old gnus-newsgroup-bookmarks))))
9298 ;; Set the new bookmark, which is on the form
9299 ;; (article-number . line-number-in-body).
9300 (setq gnus-newsgroup-bookmarks
9304 (set-buffer gnus-article-buffer)
9308 (goto-char (point-min))
9309 (search-forward "\n\n" nil t)
9312 gnus-newsgroup-bookmarks))
9313 (gnus-message 6 "A bookmark has been added to the current article."))
9315 (defun gnus-summary-remove-bookmark (article)
9316 "Remove the bookmark from the current article."
9317 (interactive (list (gnus-summary-article-number)))
9318 ;; Remove old bookmark, if one exists.
9319 (let ((old (assq article gnus-newsgroup-bookmarks)))
9322 (setq gnus-newsgroup-bookmarks
9323 (delq old gnus-newsgroup-bookmarks))
9324 (gnus-message 6 "Removed bookmark."))
9325 (gnus-message 6 "No bookmark in current article."))))
9327 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9328 (defun gnus-summary-mark-as-dormant (n)
9329 "Mark N articles forward as dormant.
9330 If N is negative, mark backward instead. The difference between N and
9331 the actual number of articles marked is returned."
9333 (gnus-summary-mark-forward n gnus-dormant-mark))
9335 (defun gnus-summary-set-process-mark (article)
9336 "Set the process mark on ARTICLE and update the summary line."
9337 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
9338 (let ((buffer-read-only nil))
9339 (if (gnus-summary-goto-subject article)
9341 (gnus-summary-show-thread)
9342 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9344 (gnus-summary-update-mark gnus-process-mark 'replied)
9347 (defun gnus-summary-remove-process-mark (article)
9348 "Remove the process mark from ARTICLE and update the summary line."
9349 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9350 (let ((buffer-read-only nil))
9351 (if (gnus-summary-goto-subject article)
9353 (gnus-summary-show-thread)
9354 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9356 (gnus-summary-update-mark ? 'replied)
9357 (if (memq article gnus-newsgroup-replied)
9358 (gnus-summary-update-mark gnus-replied-mark 'replied))
9361 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9362 "Mark N articles as read forwards.
9363 If N is negative, mark backwards instead.
9364 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9366 The difference between N and the actual number of articles marked is
9369 (gnus-set-global-variables)
9370 (let ((backward (< n 0))
9371 (gnus-summary-goto-unread
9372 (and gnus-summary-goto-unread
9373 (not (memq mark (list gnus-unread-mark
9374 gnus-ticked-mark gnus-dormant-mark)))))
9376 (mark (or mark gnus-del-mark)))
9378 (gnus-summary-mark-article nil mark no-expire)
9379 (zerop (gnus-summary-next-subject
9380 (if backward -1 1) gnus-summary-goto-unread t)))
9382 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9383 (gnus-summary-recenter)
9384 (gnus-summary-position-cursor)
9385 (gnus-set-mode-line 'summary)
9388 (defun gnus-summary-mark-article-as-read (mark)
9389 "Mark the current article quickly as read with MARK."
9390 (let ((article (gnus-summary-article-number)))
9391 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9392 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9393 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9394 (setq gnus-newsgroup-reads
9395 (cons (cons article mark) gnus-newsgroup-reads))
9396 ;; Possibly remove from cache, if that is used.
9397 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9398 (and gnus-newsgroup-auto-expire
9399 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9400 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9401 (= mark gnus-read-mark))
9403 (setq mark gnus-expirable-mark)
9404 (setq gnus-newsgroup-expirable
9405 (cons article gnus-newsgroup-expirable))))
9406 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9409 (gnus-summary-update-mark mark 'unread)
9412 (defun gnus-summary-mark-article-as-unread (mark)
9413 "Mark the current article quickly as unread with MARK."
9414 (let ((article (gnus-summary-article-number)))
9415 (or (memq article gnus-newsgroup-unreads)
9416 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9417 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9418 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9419 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9420 (setq gnus-newsgroup-reads
9421 (delq (assq article gnus-newsgroup-reads)
9422 gnus-newsgroup-reads))
9423 (if (= mark gnus-ticked-mark)
9424 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9425 (if (= mark gnus-dormant-mark)
9426 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
9428 ;; See whether the article is to be put in the cache.
9430 (vectorp (gnus-get-header-by-num article))
9432 (gnus-cache-possibly-enter-article
9433 gnus-newsgroup-name article
9434 (gnus-get-header-by-num article)
9435 (= mark gnus-ticked-mark)
9436 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9438 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9441 (gnus-summary-update-mark mark 'unread)
9444 (defun gnus-summary-mark-article (&optional article mark no-expire)
9445 "Mark ARTICLE with MARK. MARK can be any character.
9446 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
9447 (dormant) and `?E' (expirable).
9448 If MARK is nil, then the default character `?D' is used.
9449 If ARTICLE is nil, then the article on the current line will be
9452 (setq mark (aref mark 0)))
9453 ;; If no mark is given, then we check auto-expiring.
9454 (and (not no-expire)
9455 gnus-newsgroup-auto-expire
9458 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9459 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9460 (= mark gnus-read-mark))))
9461 (setq mark gnus-expirable-mark))
9462 (let* ((mark (or mark gnus-del-mark))
9463 (article (or article (gnus-summary-article-number))))
9464 (or article (error "No article on current line"))
9465 (if (or (= mark gnus-unread-mark)
9466 (= mark gnus-ticked-mark)
9467 (= mark gnus-dormant-mark))
9468 (gnus-mark-article-as-unread article mark)
9469 (gnus-mark-article-as-read article mark))
9471 ;; See whether the article is to be put in the cache.
9473 (not (= mark gnus-canceled-mark))
9474 (vectorp (gnus-get-header-by-num article))
9476 (gnus-cache-possibly-enter-article
9477 gnus-newsgroup-name article
9478 (gnus-get-header-by-num article)
9479 (= mark gnus-ticked-mark)
9480 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9482 (if (gnus-summary-goto-subject article)
9483 (let ((buffer-read-only nil))
9484 (gnus-summary-show-thread)
9485 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9488 (gnus-summary-update-mark mark 'unread)
9491 (defun gnus-summary-update-mark (mark type)
9493 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9494 (buffer-read-only nil)
9498 (forward-char forward)
9499 (setq plist (text-properties-at (point)))
9502 (and plist (add-text-properties (1- (point)) (point) plist))
9503 (and (eq type 'unread)
9504 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark)))
9505 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
9507 (defun gnus-mark-article-as-read (article &optional mark)
9508 "Enter ARTICLE in the pertinent lists and remove it from others."
9509 ;; Make the article expirable.
9510 (let ((mark (or mark gnus-del-mark)))
9511 (if (= mark gnus-expirable-mark)
9512 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9513 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9514 ;; Remove from unread and marked lists.
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))))
9523 (defun gnus-mark-article-as-unread (article &optional mark)
9524 "Enter ARTICLE in the pertinent lists and remove it from others."
9525 (let ((mark (or mark gnus-ticked-mark)))
9526 ;; Add to unread list.
9527 (or (memq article gnus-newsgroup-unreads)
9528 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9529 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9530 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9531 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9532 (setq gnus-newsgroup-reads
9533 (delq (assq article gnus-newsgroup-reads)
9534 gnus-newsgroup-reads))
9535 (if (= mark gnus-ticked-mark)
9536 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9537 (if (= mark gnus-dormant-mark)
9538 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9540 (defalias 'gnus-summary-mark-as-unread-forward
9541 'gnus-summary-tick-article-forward)
9542 (make-obsolete 'gnus-summary-mark-as-unread-forward
9543 'gnus-summary-tick-article-forward)
9544 (defun gnus-summary-tick-article-forward (n)
9545 "Tick N articles forwards.
9546 If N is negative, tick backwards instead.
9547 The difference between N and the number of articles ticked is returned."
9549 (gnus-summary-mark-forward n gnus-ticked-mark))
9551 (defalias 'gnus-summary-mark-as-unread-backward
9552 'gnus-summary-tick-article-backward)
9553 (make-obsolete 'gnus-summary-mark-as-unread-backward
9554 'gnus-summary-tick-article-backward)
9555 (defun gnus-summary-tick-article-backward (n)
9556 "Tick N articles backwards.
9557 The difference between N and the number of articles ticked is returned."
9559 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9561 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9562 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9563 (defun gnus-summary-tick-article (&optional article clear-mark)
9564 "Mark current article as unread.
9565 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9566 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9567 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9570 (defun gnus-summary-mark-as-read-forward (n)
9571 "Mark N articles as read forwards.
9572 If N is negative, mark backwards instead.
9573 The difference between N and the actual number of articles marked is
9576 (gnus-summary-mark-forward n gnus-del-mark t))
9578 (defun gnus-summary-mark-as-read-backward (n)
9579 "Mark the N articles as read backwards.
9580 The difference between N and the actual number of articles marked is
9583 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9585 (defun gnus-summary-mark-as-read (&optional article mark)
9586 "Mark current article as read.
9587 ARTICLE specifies the article to be marked as read.
9588 MARK specifies a string to be inserted at the beginning of the line."
9589 (gnus-summary-mark-article article mark))
9591 (defun gnus-summary-clear-mark-forward (n)
9592 "Clear marks from N articles forward.
9593 If N is negative, clear backward instead.
9594 The difference between N and the number of marks cleared is returned."
9596 (gnus-summary-mark-forward n gnus-unread-mark))
9598 (defun gnus-summary-clear-mark-backward (n)
9599 "Clear marks from N articles backward.
9600 The difference between N and the number of marks cleared is returned."
9602 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9604 (defun gnus-summary-mark-unread-as-read ()
9605 "Intended to be used by `gnus-summary-mark-article-hook'."
9606 (or (memq gnus-current-article gnus-newsgroup-marked)
9607 (memq gnus-current-article gnus-newsgroup-dormant)
9608 (memq gnus-current-article gnus-newsgroup-expirable)
9609 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9611 (defun gnus-summary-mark-region-as-read (point mark all)
9612 "Mark all unread articles between point and mark as read.
9613 If given a prefix, mark all articles between point and mark as read,
9614 even ticked and dormant ones."
9615 (interactive "r\nP")
9625 (not (memq (gnus-summary-article-number)
9626 gnus-newsgroup-marked))
9627 (not (memq (gnus-summary-article-number)
9628 gnus-newsgroup-dormant))))
9629 (gnus-summary-mark-article
9630 (gnus-summary-article-number) gnus-del-mark))
9632 (zerop (forward-line 1))))))
9634 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9635 (defalias 'gnus-summary-delete-marked-as-read
9636 'gnus-summary-remove-lines-marked-as-read)
9637 (make-obsolete 'gnus-summary-delete-marked-as-read
9638 'gnus-summary-remove-lines-marked-as-read)
9639 (defun gnus-summary-remove-lines-marked-as-read ()
9640 "Remove lines that are marked as read."
9642 (gnus-summary-remove-lines-marked-with
9644 (lambda (char) (char-to-string (symbol-value char)))
9645 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9646 gnus-killed-mark gnus-kill-file-mark
9647 gnus-low-score-mark gnus-expirable-mark
9648 gnus-canceled-mark gnus-catchup-mark)
9651 (defalias 'gnus-summary-delete-marked-with
9652 'gnus-summary-remove-lines-marked-with)
9653 (make-obsolete 'gnus-summary-delete-marked-with
9654 'gnus-summary-remove-lines-marked-with)
9655 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9656 (defun gnus-summary-remove-lines-marked-with (marks)
9657 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9658 (interactive "sMarks: ")
9659 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9660 (gnus-set-global-variables)
9661 (let ((buffer-read-only nil)
9662 (marks (concat "^[" marks "]")))
9663 (goto-char (point-min))
9664 (if gnus-newsgroup-adaptive
9665 (gnus-score-remove-lines-adaptive marks)
9666 (while (re-search-forward marks nil t)
9667 (gnus-delete-line)))
9668 ;; If we use dummy roots, we have to do an additional sweep over
9670 (if (not (eq gnus-summary-make-false-root 'dummy))
9672 (goto-char (point-min))
9673 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9674 (while (re-search-forward marks nil t)
9675 (if (gnus-subject-equal
9676 (gnus-summary-subject-string)
9679 (gnus-summary-subject-string)))
9682 (gnus-delete-line)))))
9683 (or (zerop (buffer-size))
9685 (gnus-summary-prev-subject 1)
9686 (gnus-summary-position-cursor))))
9688 (defun gnus-summary-expunge-below (&optional score)
9689 "Remove articles with score less than SCORE."
9691 (gnus-set-global-variables)
9692 (setq score (if score
9693 (prefix-numeric-value score)
9694 (or gnus-summary-default-score 0)))
9696 (set-buffer gnus-summary-buffer)
9697 (goto-char (point-min))
9698 (let ((buffer-read-only nil)
9701 (if (< (gnus-summary-article-score) score)
9705 (delete-region beg (point)))
9708 (or (zerop (buffer-size))
9710 (gnus-summary-prev-subject 1)
9711 (gnus-summary-position-cursor))))))
9713 (defun gnus-summary-mark-below (score mark)
9714 "Mark articles with score less than SCORE with MARK."
9715 (interactive "P\ncMark: ")
9716 (gnus-set-global-variables)
9717 (setq score (if score
9718 (prefix-numeric-value score)
9719 (or gnus-summary-default-score 0)))
9721 (set-buffer gnus-summary-buffer)
9722 (goto-char (point-min))
9724 (and (< (gnus-summary-article-score) score)
9725 (gnus-summary-mark-article nil mark))
9728 (defun gnus-summary-kill-below (&optional score)
9729 "Mark articles with score below SCORE as read."
9731 (gnus-set-global-variables)
9732 (gnus-summary-mark-below score gnus-killed-mark))
9734 (defun gnus-summary-clear-above (&optional score)
9735 "Clear all marks from articles with score above SCORE."
9737 (gnus-set-global-variables)
9738 (gnus-summary-mark-above score gnus-unread-mark))
9740 (defun gnus-summary-tick-above (&optional score)
9741 "Tick all articles with score above SCORE."
9743 (gnus-set-global-variables)
9744 (gnus-summary-mark-above score gnus-ticked-mark))
9746 (defun gnus-summary-mark-above (score mark)
9747 "Mark articles with score over SCORE with MARK."
9748 (interactive "P\ncMark: ")
9749 (gnus-set-global-variables)
9750 (setq score (if score
9751 (prefix-numeric-value score)
9752 (or gnus-summary-default-score 0)))
9754 (set-buffer gnus-summary-buffer)
9755 (goto-char (point-min))
9757 (if (> (gnus-summary-article-score) score)
9759 (gnus-summary-mark-article nil mark)
9761 (forward-line 1)))))
9763 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9764 (defun gnus-summary-show-all-expunged ()
9765 "Display all the hidden articles that were expunged for low scores."
9767 (gnus-set-global-variables)
9768 (let ((buffer-read-only nil))
9769 (let ((scored gnus-newsgroup-scored)
9772 (or (gnus-summary-goto-subject (car (car scored)))
9773 (and (setq h (gnus-get-header-by-num (car (car scored))))
9774 (< (cdr (car scored)) gnus-summary-expunge-below)
9775 (setq headers (cons h headers))))
9776 (setq scored (cdr scored)))
9777 (or headers (error "No expunged articles hidden."))
9778 (goto-char (point-min))
9780 (gnus-summary-update-lines
9783 (gnus-summary-prepare-unthreaded (nreverse headers))
9785 (goto-char (point-min))
9786 (gnus-summary-position-cursor)))
9788 (defun gnus-summary-show-all-dormant ()
9789 "Display all the hidden articles that are marked as dormant."
9791 (gnus-set-global-variables)
9792 (let ((buffer-read-only nil))
9793 (let ((dormant gnus-newsgroup-dormant)
9796 (or (gnus-summary-goto-subject (car dormant))
9797 (and (setq h (gnus-get-header-by-num (car dormant)))
9798 (setq headers (cons h headers))))
9799 (setq dormant (cdr dormant)))
9800 (or headers (error "No dormant articles hidden."))
9801 (goto-char (point-min))
9803 (gnus-summary-update-lines
9806 (gnus-summary-prepare-unthreaded (nreverse headers))
9808 (goto-char (point-min))
9809 (gnus-summary-position-cursor)))
9811 (defun gnus-summary-hide-all-dormant ()
9812 "Hide all dormant articles."
9814 (gnus-set-global-variables)
9815 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9816 (gnus-summary-position-cursor))
9818 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
9819 "Mark all articles not marked as unread in this newsgroup as read.
9820 If prefix argument ALL is non-nil, all articles are marked as read.
9821 If QUIETLY is non-nil, no questions will be asked.
9822 If TO-HERE is non-nil, it should be a point in the buffer. All
9823 articles before this point will be marked as read.
9824 The number of articles marked as read is returned."
9826 (gnus-set-global-variables)
9829 (not gnus-interactive-catchup) ;Without confirmation?
9833 "Mark absolutely all articles as read? "
9834 "Mark all unread articles as read? ")))
9836 (not gnus-newsgroup-adaptive)
9837 (not gnus-newsgroup-auto-expire))
9839 (and all (setq gnus-newsgroup-marked nil
9840 gnus-newsgroup-dormant nil))
9841 (setq gnus-newsgroup-unreads
9842 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9843 ;; We actually mark all articles as canceled, which we
9844 ;; have to do when using auto-expiry or adaptive scoring.
9845 (let ((unreads (length gnus-newsgroup-unreads)))
9846 (gnus-summary-show-all-threads)
9847 (if (gnus-summary-first-subject (not all))
9849 (if to-here (< (point) to-here) t)
9850 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9851 (gnus-summary-search-subject nil (not all)))))
9852 (- unreads (length gnus-newsgroup-unreads))
9854 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
9855 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9856 (if (and (not to-here) (eq 'nnvirtual (car method)))
9857 (nnvirtual-catchup-group
9858 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9859 (gnus-summary-position-cursor)))
9861 (defun gnus-summary-catchup-to-here (&optional all)
9862 "Mark all unticked articles before the current one as read.
9863 If ALL is non-nil, also mark ticked and dormant articles as read."
9865 (gnus-set-global-variables)
9867 (and (zerop (forward-line -1))
9870 (gnus-summary-catchup all t (point))
9871 (gnus-set-mode-line 'summary))))
9872 (gnus-summary-position-cursor))
9874 (defun gnus-summary-catchup-all (&optional quietly)
9875 "Mark all articles in this newsgroup as read."
9877 (gnus-set-global-variables)
9878 (gnus-summary-catchup t quietly))
9880 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9881 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9882 If prefix argument ALL is non-nil, all articles are marked as read."
9884 (gnus-set-global-variables)
9885 (gnus-summary-catchup all quietly nil 'fast)
9886 ;; Select next newsgroup or exit.
9887 (if (eq gnus-auto-select-next 'quietly)
9888 (gnus-summary-next-group nil)
9889 (gnus-summary-exit)))
9891 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9892 "Mark all articles in this newsgroup as read, and then exit."
9894 (gnus-set-global-variables)
9895 (gnus-summary-catchup-and-exit t quietly))
9897 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9898 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9899 "Mark all articles in this group as read and select the next group.
9900 If given a prefix, mark all articles, unread as well as ticked, as
9903 (gnus-set-global-variables)
9904 (gnus-summary-catchup all)
9905 (gnus-summary-next-group))
9907 ;; Thread-based commands.
9909 (defun gnus-summary-toggle-threads (&optional arg)
9910 "Toggle showing conversation threads.
9911 If ARG is positive number, turn showing conversation threads on."
9913 (gnus-set-global-variables)
9914 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9915 (setq gnus-show-threads
9916 (if (null arg) (not gnus-show-threads)
9917 (> (prefix-numeric-value arg) 0)))
9918 (gnus-summary-prepare)
9919 (gnus-summary-goto-subject current)
9920 (gnus-summary-position-cursor)))
9922 (defun gnus-summary-show-all-threads ()
9925 (gnus-set-global-variables)
9927 (let ((buffer-read-only nil))
9928 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9929 (gnus-summary-position-cursor))
9931 (defun gnus-summary-show-thread ()
9932 "Show thread subtrees.
9933 Returns nil if no thread was there to be shown."
9935 (gnus-set-global-variables)
9936 (let ((buffer-read-only nil)
9938 ;; first goto end then to beg, to have point at beg after let
9939 (end (progn (end-of-line) (point)))
9940 (beg (progn (beginning-of-line) (point))))
9942 ;; Any hidden lines here?
9943 (search-forward "\r" end t)
9944 (subst-char-in-region beg end ?\^M ?\n t)
9946 (gnus-summary-position-cursor))))
9948 (defun gnus-summary-hide-all-threads ()
9949 "Hide all thread subtrees."
9951 (gnus-set-global-variables)
9953 (goto-char (point-min))
9954 (gnus-summary-hide-thread)
9955 (while (and (not (eobp)) (zerop (forward-line 1)))
9956 (gnus-summary-hide-thread)))
9957 (gnus-summary-position-cursor))
9959 (defun gnus-summary-hide-thread ()
9960 "Hide thread subtrees.
9961 Returns nil if no threads were there to be hidden."
9963 (gnus-set-global-variables)
9964 (let ((buffer-read-only nil)
9966 (level (gnus-summary-thread-level))
9968 ;; Go forward until either the buffer ends or the subthread
9972 (while (and (zerop (forward-line 1))
9973 (> (gnus-summary-thread-level) level))
9978 (search-backward "\n" start t))
9979 (subst-char-in-region start end ?\n ?\^M t)
9980 (forward-line -1)))))
9982 (defun gnus-summary-go-to-next-thread (&optional previous)
9983 "Go to the same level (or less) next thread.
9984 If PREVIOUS is non-nil, go to previous thread instead.
9985 Return the article number moved to, or nil if moving was impossible."
9986 (let ((level (gnus-summary-thread-level))
9987 (article (gnus-summary-article-number)))
9989 (while (and (zerop (forward-line -1))
9990 (> (gnus-summary-thread-level) level)))
9991 (while (and (save-excursion
9994 (zerop (forward-line 1))
9995 (> (gnus-summary-thread-level) level))))
9996 (gnus-summary-recenter)
9997 (gnus-summary-position-cursor)
9998 (let ((oart (gnus-summary-article-number)))
9999 (and (/= oart article) oart))))
10001 (defun gnus-summary-next-thread (n)
10002 "Go to the same level next N'th thread.
10003 If N is negative, search backward instead.
10004 Returns the difference between N and the number of skips actually
10007 (gnus-set-global-variables)
10008 (let ((backward (< n 0))
10010 (while (and (> n 0)
10011 (gnus-summary-go-to-next-thread backward))
10013 (gnus-summary-position-cursor)
10014 (if (/= 0 n) (gnus-message 7 "No more threads"))
10017 (defun gnus-summary-prev-thread (n)
10018 "Go to the same level previous N'th thread.
10019 Returns the difference between N and the number of skips actually
10022 (gnus-set-global-variables)
10023 (gnus-summary-next-thread (- n)))
10025 (defun gnus-summary-go-down-thread (&optional same)
10026 "Go down one level in the current thread.
10027 If SAME is non-nil, also move to articles of the same level."
10028 (let ((level (gnus-summary-thread-level))
10030 (if (and (zerop (forward-line 1))
10031 (> (gnus-summary-thread-level) level))
10036 (defun gnus-summary-go-up-thread ()
10037 "Go up one level in the current thread."
10038 (let ((level (gnus-summary-thread-level))
10040 (while (and (zerop (forward-line -1))
10041 (>= (gnus-summary-thread-level) level)))
10042 (if (>= (gnus-summary-thread-level) level)
10048 (defun gnus-summary-down-thread (n)
10049 "Go down thread N steps.
10050 If N is negative, go up instead.
10051 Returns the difference between N and how many steps down that were
10054 (gnus-set-global-variables)
10057 (while (and (> n 0)
10058 (if up (gnus-summary-go-up-thread)
10059 (gnus-summary-go-down-thread)))
10061 (gnus-summary-position-cursor)
10062 (if (/= 0 n) (gnus-message 7 "Can't go further"))
10065 (defun gnus-summary-up-thread (n)
10066 "Go up thread N steps.
10067 If N is negative, go up instead.
10068 Returns the difference between N and how many steps down that were
10071 (gnus-set-global-variables)
10072 (gnus-summary-down-thread (- n)))
10074 (defun gnus-summary-kill-thread (&optional unmark)
10075 "Mark articles under current thread as read.
10076 If the prefix argument is positive, remove any kinds of marks.
10077 If the prefix argument is negative, tick articles instead."
10079 (gnus-set-global-variables)
10081 (setq unmark (prefix-numeric-value unmark)))
10083 (level (gnus-summary-thread-level)))
10086 ;; Mark the article...
10087 (cond ((null unmark) (gnus-summary-mark-article-as-read
10089 ((> unmark 0) (gnus-summary-mark-article-as-unread
10091 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10092 ;; ...and go forward until either the buffer ends or the subtree
10094 (if (not (and (zerop (forward-line 1))
10095 (> (gnus-summary-thread-level) level)))
10096 (setq killing nil))))
10097 ;; Hide killed subtrees.
10099 gnus-thread-hide-killed
10100 (gnus-summary-hide-thread))
10101 ;; If marked as read, go to next unread subject.
10103 ;; Go to next unread subject.
10104 (gnus-summary-next-subject 1 t)))
10105 (gnus-set-mode-line 'summary))
10107 ;; Summary sorting commands
10109 (defun gnus-summary-sort-by-number (&optional reverse)
10110 "Sort summary buffer by article number.
10111 Argument REVERSE means reverse order."
10113 (gnus-set-global-variables)
10115 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
10116 ;; a function, so we wrap it.
10117 (cons (lambda () (gnus-summary-article-number))
10118 'gnus-thread-sort-by-number) reverse))
10120 (defun gnus-summary-sort-by-author (&optional reverse)
10121 "Sort summary buffer by author name alphabetically.
10122 If case-fold-search is non-nil, case of letters is ignored.
10123 Argument REVERSE means reverse order."
10125 (gnus-set-global-variables)
10129 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10131 gnus-extract-address-components
10132 (header-from header))))
10133 (concat (or (car extract) (cdr extract))
10134 "\r" (header-subject header))))
10135 'gnus-thread-sort-by-author)
10138 (defun gnus-summary-sort-by-subject (&optional reverse)
10139 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10140 If case-fold-search is non-nil, case of letters is ignored.
10141 Argument REVERSE means reverse order."
10143 (gnus-set-global-variables)
10147 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10149 gnus-extract-address-components
10150 (header-from header))))
10152 (downcase (gnus-simplify-subject (gnus-summary-subject-string)))
10153 "\r" (or (car extract) (cdr extract)))))
10154 'gnus-thread-sort-by-subject)
10157 (defun gnus-summary-sort-by-date (&optional reverse)
10158 "Sort summary buffer by date.
10159 Argument REVERSE means reverse order."
10161 (gnus-set-global-variables)
10165 (gnus-sortable-date
10167 (gnus-get-header-by-num (gnus-summary-article-number)))))
10168 'gnus-thread-sort-by-date)
10171 (defun gnus-summary-sort-by-score (&optional reverse)
10172 "Sort summary buffer by score.
10173 Argument REVERSE means reverse order."
10175 (gnus-set-global-variables)
10177 (cons (lambda () (gnus-summary-article-score))
10178 'gnus-thread-sort-by-score)
10181 (defvar gnus-summary-already-sorted nil)
10182 (defun gnus-summary-sort (predicate reverse)
10183 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10184 (if gnus-summary-already-sorted
10186 (let (buffer-read-only)
10187 (if (not gnus-show-threads)
10188 ;; We do untreaded sorting...
10190 (goto-char (point-min))
10191 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
10192 ;; ... or we do threaded sorting.
10193 (let ((gnus-thread-sort-functions (list (cdr predicate)))
10194 (gnus-summary-prepare-hook nil)
10195 (gnus-summary-already-sorted nil))
10196 ;; We do that by simply regenerating the threads.
10197 (gnus-summary-prepare)
10198 (and gnus-show-threads
10199 gnus-thread-hide-subtree
10200 (gnus-summary-hide-all-threads))
10201 ;; If in async mode, we send some info to the backend.
10202 (and gnus-newsgroup-async
10203 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
10204 (gnus-request-asynchronous
10205 gnus-newsgroup-name
10206 (if (and gnus-asynchronous-article-function
10207 (fboundp gnus-asynchronous-article-function))
10208 (funcall gnus-asynchronous-article-function
10209 gnus-newsgroup-threads)))))))))
10212 (defun gnus-sortable-date (date)
10213 "Make sortable string by string-lessp from DATE.
10214 Timezone package is used."
10215 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
10216 (year (aref date 0))
10217 (month (aref date 1))
10218 (day (aref date 2)))
10219 (timezone-make-sortable-date
10221 (timezone-make-time-string
10222 (aref date 3) (aref date 4) (aref date 5)))))
10225 ;; Summary saving commands.
10227 (defun gnus-summary-save-article (&optional n)
10228 "Save the current article using the default saver function.
10229 If N is a positive number, save the N next articles.
10230 If N is a negative number, save the N previous articles.
10231 If N is nil and any articles have been marked with the process mark,
10232 save those articles instead.
10233 The variable `gnus-default-article-saver' specifies the saver function."
10235 (gnus-set-global-variables)
10236 (let ((articles (gnus-summary-work-articles n)))
10238 (let ((header (gnus-get-header-by-num (car articles))))
10239 (if (vectorp header)
10241 (save-window-excursion
10242 (gnus-summary-select-article t nil nil (car articles)))
10243 (or gnus-save-all-headers
10244 (gnus-article-hide-headers t))
10245 ;; Remove any X-Gnus lines.
10248 (set-buffer gnus-article-buffer)
10249 (let ((buffer-read-only nil))
10250 (goto-char (point-min))
10251 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
10253 (while (re-search-forward "^X-Gnus" nil t)
10254 (beginning-of-line)
10255 (delete-region (point)
10256 (progn (forward-line 1) (point))))
10258 (save-window-excursion
10259 (if gnus-default-article-saver
10260 (funcall gnus-default-article-saver)
10261 (error "No default saver is defined."))))
10262 (if (assq 'name header)
10263 (gnus-copy-file (cdr (assq 'name header)))
10264 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
10265 (gnus-summary-remove-process-mark (car articles))
10266 (setq articles (cdr articles)))
10267 (gnus-summary-position-cursor)
10270 (defun gnus-summary-pipe-output (&optional arg)
10271 "Pipe the current article to a subprocess.
10272 If N is a positive number, pipe the N next articles.
10273 If N is a negative number, pipe the N previous articles.
10274 If N is nil and any articles have been marked with the process mark,
10275 pipe those articles instead."
10277 (gnus-set-global-variables)
10278 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10279 (gnus-summary-save-article arg)))
10281 (defun gnus-summary-save-article-mail (&optional arg)
10282 "Append the current article to an mail file.
10283 If N is a positive number, save the N next articles.
10284 If N is a negative number, save the N previous articles.
10285 If N is nil and any articles have been marked with the process mark,
10286 save those articles instead."
10288 (gnus-set-global-variables)
10289 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10290 (gnus-summary-save-article arg)))
10292 (defun gnus-summary-save-article-rmail (&optional arg)
10293 "Append the current article to an rmail file.
10294 If N is a positive number, save the N next articles.
10295 If N is a negative number, save the N previous articles.
10296 If N is nil and any articles have been marked with the process mark,
10297 save those articles instead."
10299 (gnus-set-global-variables)
10300 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10301 (gnus-summary-save-article arg)))
10303 (defun gnus-summary-save-article-file (&optional arg)
10304 "Append the current article to a file.
10305 If N is a positive number, save the N next articles.
10306 If N is a negative number, save the N previous articles.
10307 If N is nil and any articles have been marked with the process mark,
10308 save those articles instead."
10310 (gnus-set-global-variables)
10311 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10312 (gnus-summary-save-article arg)))
10314 (defun gnus-read-save-file-name (prompt default-name)
10315 (let ((methods gnus-split-methods)
10317 (if (not gnus-split-methods)
10320 (set-buffer gnus-article-buffer)
10321 (gnus-narrow-to-headers)
10323 (goto-char (point-min))
10324 (and (condition-case ()
10325 (re-search-forward (car (car methods)) nil t)
10327 (setq split-name (cons (nth 1 (car methods)) split-name)))
10328 (setq methods (cdr methods)))
10330 (cond ((null split-name)
10332 (concat prompt " (default "
10333 (file-name-nondirectory default-name) ") ")
10334 (file-name-directory default-name)
10336 ((= 1 (length split-name))
10338 (concat prompt " (default " (car split-name) ") ")
10339 gnus-article-save-directory
10340 (concat gnus-article-save-directory (car split-name))))
10342 (setq split-name (mapcar (lambda (el) (list el))
10343 (nreverse split-name)))
10344 (let ((result (completing-read
10345 (concat prompt " ")
10346 split-name nil nil)))
10347 (concat gnus-article-save-directory
10348 (if (string= result "")
10349 (car (car split-name))
10352 (defun gnus-summary-save-in-rmail (&optional filename)
10353 "Append this article to Rmail file.
10354 Optional argument FILENAME specifies file name.
10355 Directory to save to is default to `gnus-article-save-directory' which
10356 is initialized from the SAVEDIR environment variable."
10358 (gnus-set-global-variables)
10359 (let ((default-name
10360 (funcall gnus-rmail-save-name gnus-newsgroup-name
10361 gnus-current-headers gnus-newsgroup-last-rmail)))
10363 (setq filename (gnus-read-save-file-name
10364 "Save in rmail file:" default-name)))
10365 (gnus-make-directory (file-name-directory filename))
10366 (gnus-eval-in-buffer-window
10367 gnus-article-buffer
10371 (gnus-output-to-rmail filename))))
10372 ;; Remember the directory name to save articles
10373 (setq gnus-newsgroup-last-rmail filename)))
10375 (defun gnus-summary-save-in-mail (&optional filename)
10376 "Append this article to Unix mail file.
10377 Optional argument FILENAME specifies file name.
10378 Directory to save to is default to `gnus-article-save-directory' which
10379 is initialized from the SAVEDIR environment variable."
10381 (gnus-set-global-variables)
10382 (let ((default-name
10383 (funcall gnus-mail-save-name gnus-newsgroup-name
10384 gnus-current-headers gnus-newsgroup-last-mail)))
10386 (setq filename (gnus-read-save-file-name
10387 "Save in Unix mail file:" default-name)))
10389 (expand-file-name filename
10391 (file-name-directory default-name))))
10392 (gnus-make-directory (file-name-directory filename))
10393 (gnus-eval-in-buffer-window
10394 gnus-article-buffer
10398 (if (and (file-readable-p filename) (rmail-file-p filename))
10399 (gnus-output-to-rmail filename)
10400 (rmail-output filename 1 t t)))))
10401 ;; Remember the directory name to save articles.
10402 (setq gnus-newsgroup-last-mail filename)))
10404 (defun gnus-summary-save-in-file (&optional filename)
10405 "Append this article to file.
10406 Optional argument FILENAME specifies file name.
10407 Directory to save to is default to `gnus-article-save-directory' which
10408 is initialized from the SAVEDIR environment variable."
10410 (gnus-set-global-variables)
10411 (let ((default-name
10412 (funcall gnus-file-save-name gnus-newsgroup-name
10413 gnus-current-headers gnus-newsgroup-last-file)))
10415 (setq filename (gnus-read-save-file-name
10416 "Save in file:" default-name)))
10417 (gnus-make-directory (file-name-directory filename))
10418 (gnus-eval-in-buffer-window
10419 gnus-article-buffer
10423 (gnus-output-to-file filename))))
10424 ;; Remember the directory name to save articles.
10425 (setq gnus-newsgroup-last-file filename)))
10427 (defun gnus-summary-save-in-pipe (&optional command)
10428 "Pipe this article to subprocess."
10430 (gnus-set-global-variables)
10431 (let ((command (read-string "Shell command on article: "
10432 gnus-last-shell-command)))
10433 (if (string-equal command "")
10434 (setq command gnus-last-shell-command))
10435 (gnus-eval-in-buffer-window
10436 gnus-article-buffer
10439 (shell-command-on-region (point-min) (point-max) command nil)))
10440 (setq gnus-last-shell-command command)))
10442 ;; Summary extract commands
10444 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10445 (let ((buffer-read-only nil)
10446 (article (gnus-summary-article-number))
10448 (or (gnus-summary-goto-subject article)
10449 (error (format "No such article: %d" article)))
10450 (gnus-summary-position-cursor)
10451 ;; If all commands are to be bunched up on one line, we collect
10453 (if gnus-view-pseudos-separately
10455 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10458 (setq action (cdr (assq 'action (car ps))))
10459 (setq files (list (cdr (assq 'name (car ps)))))
10460 (while (and ps (cdr ps)
10461 (string= (or action "1")
10462 (or (cdr (assq 'action (car (cdr ps)))) "2")))
10463 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
10464 (setcdr ps (cdr (cdr ps))))
10467 (if (not (string-match "%s" action))
10468 (setq files (cons " " files)))
10469 (setq files (cons " " files))
10470 (and (assq 'execute (car ps))
10471 (setcdr (assq 'execute (car ps))
10472 (funcall (if (string-match "%s" action)
10475 (mapconcat (lambda (f) f) files " ")))))
10476 (setq ps (cdr ps)))))
10477 (if (and gnus-view-pseudos (not not-view))
10479 (and (assq 'execute (car pslist))
10480 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10481 (eq gnus-view-pseudos 'not-confirm)))
10482 (setq pslist (cdr pslist)))
10485 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
10486 (gnus-summary-article-number)))
10489 (insert " " (file-name-nondirectory
10490 (cdr (assq 'name (car pslist))))
10491 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10492 (add-text-properties
10493 b (1+ b) (list 'gnus-number gnus-reffed-article-number
10494 'gnus-mark gnus-unread-mark
10496 'gnus-pseudo (car pslist)))
10498 (gnus-sethash (int-to-string gnus-reffed-article-number)
10499 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
10500 (setq gnus-newsgroup-unreads
10501 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
10502 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10503 (setq pslist (cdr pslist)))))))
10505 (defun gnus-pseudos< (p1 p2)
10506 (let ((c1 (cdr (assq 'action p1)))
10507 (c2 (cdr (assq 'action p2))))
10508 (and c1 c2 (string< c1 c2))))
10510 (defun gnus-request-pseudo-article (props)
10511 (cond ((assq 'execute props)
10512 (gnus-execute-command (cdr (assq 'execute props)))))
10513 (let ((gnus-current-article (gnus-summary-article-number)))
10514 (run-hooks 'gnus-mark-article-hook)))
10516 (defun gnus-execute-command (command &optional automatic)
10518 (gnus-article-setup-buffer)
10519 (set-buffer gnus-article-buffer)
10520 (let ((command (if automatic command (read-string "Command: " command)))
10521 (buffer-read-only nil))
10523 (insert "$ " command "\n\n")
10524 (if gnus-view-pseudo-asynchronously
10525 (start-process "gnus-execute" nil "sh" "-c" command)
10526 (call-process "sh" nil t nil "-c" command)))))
10528 (defun gnus-copy-file (file &optional to)
10531 (list (read-file-name "Copy file: " default-directory)
10532 (read-file-name "Copy file to: " default-directory)))
10533 (gnus-set-global-variables)
10534 (or to (setq to (read-file-name "Copy file to: " default-directory)))
10535 (and (file-directory-p to)
10536 (setq to (concat (file-name-as-directory to)
10537 (file-name-nondirectory file))))
10538 (copy-file file to))
10540 ;; Summary kill commands.
10542 (defun gnus-summary-edit-global-kill (article)
10543 "Edit the \"global\" kill file."
10544 (interactive (list (gnus-summary-article-number)))
10545 (gnus-set-global-variables)
10546 (gnus-group-edit-global-kill article))
10548 (defun gnus-summary-edit-local-kill ()
10549 "Edit a local kill file applied to the current newsgroup."
10551 (gnus-set-global-variables)
10552 (setq gnus-current-headers
10554 (int-to-string (gnus-summary-article-number))
10555 gnus-newsgroup-headers-hashtb-by-number))
10556 (gnus-set-global-variables)
10557 (gnus-group-edit-local-kill
10558 (gnus-summary-article-number) gnus-newsgroup-name))
10562 ;;; Gnus article mode
10565 (put 'gnus-article-mode 'mode-class 'special)
10567 (if gnus-article-mode-map
10569 (setq gnus-article-mode-map (make-keymap))
10570 (suppress-keymap gnus-article-mode-map)
10571 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10572 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10573 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10574 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10575 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10576 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10577 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
10578 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10579 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10580 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10581 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10582 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10584 ;; Duplicate almost all summary keystrokes in the article mode map.
10587 "p" "N" "P" "\M-\C-n" "\M-\C-p"
10588 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
10589 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10590 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10591 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10592 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10593 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10594 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10595 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10596 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
10597 "\C-c\C-v\C-v" "\C-d" "v"
10598 ;; "Mt" "M!" "Md" "Mr"
10599 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10600 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10601 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10602 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10603 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10604 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10605 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10606 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10607 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10608 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10609 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10611 (while (and nil commands) ; disabled
10612 (define-key gnus-article-mode-map (car commands)
10613 'gnus-article-summary-command)
10614 (setq commands (cdr commands))))
10616 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10617 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10618 "=" "n" "^" "\M-^")))
10619 (while (and nil commands) ; disabled
10620 (define-key gnus-article-mode-map (car commands)
10621 'gnus-article-summary-command-nosave)
10622 (setq commands (cdr commands)))))
10625 (defun gnus-article-mode ()
10626 "Major mode for displaying an article.
10628 All normal editing commands are switched off.
10630 The following commands are available:
10632 \\<gnus-article-mode-map>
10633 \\[gnus-article-next-page]\t Scroll the article one page forwards
10634 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10635 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10636 \\[gnus-article-show-summary]\t Display the summary buffer
10637 \\[gnus-article-mail]\t Send a reply to the address near point
10638 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
10639 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10640 \\[gnus-info-find-node]\t Go to the Gnus info node"
10642 (if gnus-visual (gnus-article-make-menu-bar))
10643 (kill-all-local-variables)
10644 (setq mode-line-modified "-- ")
10645 (make-local-variable 'mode-line-format)
10646 (setq mode-line-format (copy-sequence mode-line-format))
10647 (and (equal (nth 3 mode-line-format) " ")
10648 (setcar (nthcdr 3 mode-line-format) ""))
10649 (setq mode-name "Article")
10650 (setq major-mode 'gnus-article-mode)
10651 (make-local-variable 'minor-mode-alist)
10652 (or (assq 'gnus-show-mime minor-mode-alist)
10653 (setq minor-mode-alist
10654 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10655 (use-local-map gnus-article-mode-map)
10656 (make-local-variable 'page-delimiter)
10657 (setq page-delimiter gnus-page-delimiter)
10658 (buffer-disable-undo (current-buffer))
10659 (setq buffer-read-only t) ;Disable modification
10660 (run-hooks 'gnus-article-mode-hook))
10662 (defun gnus-article-setup-buffer ()
10663 "Initialize article mode buffer."
10664 (if (get-buffer gnus-article-buffer)
10666 (set-buffer gnus-article-buffer)
10667 (buffer-disable-undo (current-buffer))
10668 (setq buffer-read-only t)
10669 (gnus-add-current-to-buffer-list)
10670 (or (eq major-mode 'gnus-article-mode)
10671 (gnus-article-mode)))
10673 (set-buffer (get-buffer-create gnus-article-buffer))
10674 (gnus-add-current-to-buffer-list)
10675 (gnus-article-mode))))
10677 ;; Set article window start at LINE, where LINE is the number of lines
10678 ;; from the head of the article.
10679 (defun gnus-article-set-window-start (&optional line)
10681 (get-buffer-window gnus-article-buffer)
10683 (set-buffer gnus-article-buffer)
10684 (goto-char (point-min))
10687 (gnus-message 6 "Moved to bookmark")
10688 (search-forward "\n\n" nil t)
10689 (forward-line line)
10692 (defun gnus-request-article-this-buffer (article group)
10693 "Get an article and insert it into this buffer."
10694 (setq group (or group gnus-newsgroup-name))
10696 ;; Open server if it has closed.
10697 (gnus-check-server (gnus-find-method-for-group group))
10699 ;; Using `gnus-request-article' directly will insert the article into
10700 ;; `nntp-server-buffer' - so we'll save some time by not having to
10701 ;; copy it from the server buffer into the article buffer.
10703 ;; We only request an article by message-id when we do not have the
10704 ;; headers for it, so we'll have to get those.
10705 (and (stringp article)
10706 (let ((gnus-override-method gnus-refer-article-method))
10707 (gnus-read-header article)))
10709 ;; If the article number is negative, that means that this article
10710 ;; doesn't belong in this newsgroup (possibly), so we find its
10711 ;; message-id and request it by id instead of number.
10712 (if (not (numberp article))
10715 (set-buffer gnus-summary-buffer)
10716 (let ((header (gnus-get-header-by-num article)))
10718 (if (vectorp header)
10719 ;; It's a real article.
10720 (setq article (header-id header))
10721 ;; It is an extracted pseudo-article.
10722 (setq article 'pseudo)
10723 (gnus-request-pseudo-article header)))
10725 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10726 (if (not (eq (car method) 'nneething))
10728 (let ((dir (concat (file-name-as-directory (nth 1 method))
10729 (header-subject header))))
10730 (if (file-directory-p dir)
10732 (setq article 'nneething)
10733 (gnus-group-enter-directory dir)))))))))
10735 ;; Check the cache.
10736 (if (and gnus-use-cache
10738 (gnus-cache-request-article article group))
10740 ;; Get the article and into the article buffer.
10741 (if (or (stringp article) (numberp article))
10744 (let ((gnus-override-method
10745 (and (stringp article) gnus-refer-article-method)))
10746 (and (gnus-request-article article group (current-buffer))
10750 (defun gnus-read-header (id)
10751 "Read the headers of article ID and enter them into the Gnus system."
10753 (if (not (setq header
10754 (car (if (let ((gnus-nov-is-evil t))
10755 (gnus-retrieve-headers
10756 (list id) gnus-newsgroup-name))
10757 (gnus-get-newsgroup-headers)))))
10760 (header-set-number header gnus-reffed-article-number))
10761 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10762 (gnus-sethash (int-to-string (header-number header)) header
10763 gnus-newsgroup-headers-hashtb-by-number)
10765 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10766 (setq gnus-current-headers header)
10769 (defun gnus-article-prepare (article &optional all-headers header)
10770 "Prepare ARTICLE in article mode buffer.
10771 ARTICLE should either be an article number or a Message-ID.
10772 If ARTICLE is an id, HEADER should be the article headers.
10773 If ALL-HEADERS is non-nil, no headers are hidden."
10775 ;; Make sure we start in a summary buffer.
10776 (or (eq major-mode 'gnus-summary-mode)
10777 (set-buffer gnus-summary-buffer))
10778 (setq gnus-summary-buffer (current-buffer))
10779 ;; Make sure the connection to the server is alive.
10780 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10783 (gnus-find-method-for-group gnus-newsgroup-name))
10784 (gnus-request-group gnus-newsgroup-name t)))
10785 (let* ((article (if header (header-number header) article))
10786 (summary-buffer (current-buffer))
10787 (internal-hook gnus-article-internal-prepare-hook)
10788 (group gnus-newsgroup-name)
10791 (gnus-article-setup-buffer)
10792 (set-buffer gnus-article-buffer)
10793 (if (not (setq result (let ((buffer-read-only nil))
10794 (gnus-request-article-this-buffer
10796 ;; There is no such article.
10798 (if (not (numberp article))
10800 (setq gnus-article-current
10801 (cons gnus-newsgroup-name article))
10802 (set-buffer gnus-summary-buffer)
10803 (setq gnus-current-article article)
10804 (gnus-summary-mark-article article gnus-canceled-mark))
10805 (gnus-message 1 "No such article (may be canceled)")
10808 (if (or (eq result 'pseudo) (eq result 'nneething))
10811 (set-buffer summary-buffer)
10812 (setq gnus-last-article gnus-current-article
10813 gnus-newsgroup-history (cons gnus-current-article
10814 gnus-newsgroup-history)
10815 gnus-current-article 0
10816 gnus-current-headers nil
10817 gnus-article-current nil)
10818 (if (eq result 'nneething)
10819 (gnus-configure-windows 'summary)
10820 (gnus-configure-windows 'article))
10821 (gnus-set-global-variables))
10822 (gnus-set-mode-line 'article))
10823 ;; The result from the `request' was an actual article -
10824 ;; or at least some text that is now displayed in the
10826 (if (and (numberp article)
10827 (not (eq article gnus-current-article)))
10828 ;; Seems like a new article has been selected.
10829 ;; `gnus-current-article' must be an article number.
10831 (set-buffer summary-buffer)
10832 (setq gnus-last-article gnus-current-article
10833 gnus-newsgroup-history (cons gnus-current-article
10834 gnus-newsgroup-history)
10835 gnus-current-article article
10836 gnus-current-headers
10837 (gnus-get-header-by-num gnus-current-article)
10838 gnus-article-current
10839 (cons gnus-newsgroup-name gnus-current-article))
10840 (gnus-summary-show-thread)
10841 (run-hooks 'gnus-mark-article-hook)
10842 (gnus-set-mode-line 'summary)
10844 (run-hooks 'gnus-visual-mark-article-hook))
10845 ;; Set the global newsgroup variables here.
10846 ;; Suggested by Jim Sisolak
10847 ;; <sisolak@trans4.neep.wisc.edu>.
10848 (gnus-set-global-variables)
10849 (setq gnus-have-all-headers
10850 (or all-headers gnus-show-all-headers))
10851 (and gnus-use-cache
10852 (vectorp (gnus-get-header-by-number article))
10853 (gnus-cache-possibly-enter-article
10855 (gnus-get-header-by-number article)
10856 (memq article gnus-newsgroup-marked)
10857 (memq article gnus-newsgroup-dormant)
10858 (memq article gnus-newsgroup-unreads)))))
10859 ;; Hooks for getting information from the article.
10860 ;; This hook must be called before being narrowed.
10861 (let (buffer-read-only)
10862 (run-hooks 'internal-hook)
10863 (run-hooks 'gnus-article-prepare-hook)
10864 ;; Decode MIME message.
10865 (if (and gnus-show-mime
10866 (or (not gnus-strict-mime)
10867 (gnus-fetch-field "Mime-Version")))
10868 (funcall gnus-show-mime-method))
10869 ;; Perform the article display hooks.
10870 (run-hooks 'gnus-article-display-hook))
10872 (goto-char (point-min))
10873 (and gnus-break-pages (gnus-narrow-to-page))
10874 (gnus-set-mode-line 'article)
10875 (gnus-configure-windows 'article)
10876 (goto-char (point-min))
10879 (defun gnus-article-show-all-headers ()
10880 "Show all article headers in article mode buffer."
10882 (gnus-article-setup-buffer)
10883 (set-buffer gnus-article-buffer)
10884 (let ((buffer-read-only nil))
10885 (remove-text-properties (point-min) (point-max)
10886 gnus-hidden-properties))))
10888 (defun gnus-article-hide-headers-if-wanted ()
10889 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10890 Provided for backwards compatability."
10891 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
10892 (gnus-article-hide-headers)))
10894 (defun gnus-article-hide-headers (&optional delete)
10895 "Hide unwanted headers and possibly sort them as well."
10898 (set-buffer gnus-article-buffer)
10900 (let ((sorted gnus-sorted-header-list)
10901 (buffer-read-only nil)
10902 want-list beg want-l)
10903 ;; First we narrow to just the headers.
10905 (goto-char (point-min))
10906 ;; Hide any "From " lines at the beginning of (mail) articles.
10907 (while (looking-at "From ")
10910 (add-text-properties (point-min) (point) gnus-hidden-properties))
10911 ;; Then treat the rest of the header lines.
10914 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
10915 ;; Then we use the two regular expressions
10916 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
10917 ;; select which header lines is to remain visible in the
10919 (goto-char (point-min))
10920 (while (re-search-forward "^[^ \t]*:" nil t)
10921 (beginning-of-line)
10922 ;; We add the headers we want to keep to a list and delete
10923 ;; them from the buffer.
10924 (if (or (and (stringp gnus-visible-headers)
10925 (looking-at gnus-visible-headers))
10926 (and (not (stringp gnus-visible-headers))
10927 (stringp gnus-ignored-headers)
10928 (not (looking-at gnus-ignored-headers))))
10932 ;; Be sure to get multi-line headers...
10933 (re-search-forward "^[^ \t]*:" nil t)
10934 (beginning-of-line)
10936 (cons (buffer-substring beg (point)) want-list))
10937 (delete-region beg (point))
10940 ;; Next we perform the sorting by looking at
10941 ;; `gnus-sorted-header-list'.
10942 (goto-char (point-min))
10943 (while (and sorted want-list)
10944 (setq want-l want-list)
10946 (not (string-match (car sorted) (car want-l))))
10947 (setq want-l (cdr want-l)))
10950 (insert (car want-l))
10951 (setq want-list (delq (car want-l) want-list))))
10952 (setq sorted (cdr sorted)))
10953 ;; Any headers that were not matched by the sorted list we
10954 ;; just tack on the end of the visible header list.
10956 (insert (car want-list))
10957 (setq want-list (cdr want-list)))
10958 ;; And finally we make the unwanted headers invisible.
10960 (delete-region (point) (point-max))
10961 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
10962 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
10964 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
10965 (defun gnus-article-treat-overstrike ()
10966 "Translate overstrikes into bold text."
10969 (set-buffer gnus-article-buffer)
10970 (let ((buffer-read-only nil))
10971 (while (search-forward "\b" nil t)
10972 (let ((next (following-char))
10973 (previous (char-after (- (point) 2))))
10974 (cond ((eq next previous)
10975 (put-text-property (- (point) 2) (point)
10977 (put-text-property (point) (1+ (point))
10980 (put-text-property (1- (point)) (1+ (point))
10982 (put-text-property (1- (point)) (point)
10985 (put-text-property (- (point) 2) (point)
10987 (put-text-property (point) (1+ (point))
10988 'face 'underline))))))))
10990 (defun gnus-article-word-wrap ()
10991 "Format too long lines."
10994 (set-buffer gnus-article-buffer)
10995 (let ((buffer-read-only nil))
10996 (goto-char (point-min))
10997 (search-forward "\n\n" nil t)
10999 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
11000 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
11001 (adaptive-fill-mode t))
11002 (while (not (eobp))
11003 (and (>= (current-column) (min fill-column (window-width)))
11004 (/= (preceding-char) ?:)
11005 (fill-paragraph nil))
11006 (end-of-line 2))))))
11008 (defun gnus-article-remove-cr ()
11009 "Remove carriage returns from an article."
11012 (set-buffer gnus-article-buffer)
11013 (let ((buffer-read-only nil))
11014 (goto-char (point-min))
11015 (while (search-forward "\r" nil t)
11016 (replace-match "" t t)))))
11018 (defun gnus-article-display-x-face (&optional force)
11019 "Look for an X-Face header and display it if present."
11020 (interactive (list 'force))
11022 (set-buffer gnus-article-buffer)
11023 (let ((inhibit-point-motion-hooks t)
11024 (case-fold-search nil))
11026 (goto-char (point-min))
11027 (search-forward "\n\n")
11028 (narrow-to-region (point-min) (point))
11029 (goto-char (point-min))
11030 (if (or (not gnus-article-x-face-command)
11032 (or (not gnus-article-x-face-too-ugly)
11033 (string-match gnus-article-x-face-too-ugly
11034 (mail-fetch-field "from"))))
11036 (goto-char (point-min))
11037 (not (re-search-forward "^X-Face: " nil t))))
11039 (let ((beg (point))
11040 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
11041 (if (symbolp gnus-article-x-face-command)
11042 (and (or (fboundp gnus-article-x-face-command)
11043 (error "%s is not a function"
11044 gnus-article-x-face-command))
11045 (funcall gnus-article-x-face-command beg end))
11046 (call-process-region beg end "sh" nil 0 nil
11047 "-c" gnus-article-x-face-command))))))))
11049 (defun gnus-article-de-quoted-unreadable (&optional force)
11050 "Do a naïve translation of a quoted-printable-encoded article.
11051 This is in no way, shape or form meant as a replacement for real MIME
11052 processing, but is simply a stop-gap measure until MIME support is
11054 If FORCE, decode the article whether it is marked as quoted-printable
11056 (interactive (list 'force))
11058 (set-buffer gnus-article-buffer)
11059 (let ((case-fold-search t)
11060 (buffer-read-only nil)
11061 (type (gnus-fetch-field "content-transfer-encoding")))
11062 (if (or force (and type (string-match "quoted-printable" type)))
11064 (goto-char (point-min))
11065 (search-forward "\n\n" nil 'move)
11066 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
11068 (defun gnus-mime-decode-quoted-printable (from to)
11069 ;; Decode quoted-printable from region between FROM and TO.
11072 (while (search-forward "=" to t)
11073 (cond ((eq (following-char) ?\n)
11076 ((looking-at "[0-9A-F][0-9A-F]")
11078 (insert (hexl-hex-string-to-integer
11079 (buffer-substring (point) (+ 2 (point)))))
11083 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
11085 (defvar gnus-article-time-units
11086 (list (cons 'year (* 365.25 24 60 60))
11087 (cons 'week (* 7 24 60 60))
11088 (cons 'day (* 24 60 60))
11089 (cons 'hour (* 60 60))
11093 (defun gnus-article-date-ut (&optional type)
11094 "Convert DATE date to universal time in the current article.
11095 If TYPE is `local', convert to local time; if it is `lapsed', output
11096 how much time has lapsed since DATE."
11097 (interactive (list 'ut))
11098 (let ((date (header-date (or gnus-current-headers
11099 (gnus-get-header-by-number
11100 (gnus-summary-article-number))"")))
11101 (date-regexp "^Date: \\|^X-Sent: "))
11106 (set-buffer gnus-article-buffer)
11107 (let ((buffer-read-only nil))
11108 (goto-char (point-min))
11109 (if (and (re-search-forward date-regexp nil t)
11111 (beginning-of-line)
11112 (looking-at date-regexp)))
11113 (delete-region (gnus-point-at-bol)
11114 (progn (end-of-line) (1+ (point))))
11115 (goto-char (point-min))
11116 (goto-char (- (search-forward "\n\n") 2)))
11120 (concat "Date: " (condition-case ()
11121 (timezone-make-date-arpa-standard date)
11127 (timezone-make-date-arpa-standard date nil "UT")
11131 ;; If the date is seriously mangled, the timezone
11132 ;; functions are liable to bug out, so we condition-case
11133 ;; the entire thing.
11134 (let* ((real-sec (condition-case ()
11135 (- (gnus-seconds-since-epoch
11136 (timezone-make-date-arpa-standard
11137 (current-time-string)
11138 (current-time-zone) "UT"))
11139 (gnus-seconds-since-epoch
11140 (timezone-make-date-arpa-standard
11143 (sec (abs real-sec))
11151 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
11153 (setq sec (- sec (* num (cdr unit))))
11155 (concat (if prev ", " "") (int-to-string
11157 " " (symbol-name (car unit))
11158 (if (> num 1) "s" ""))
11160 gnus-article-time-units "")
11163 " in the future\n")))))
11165 (error "Unknown conversion type: %s" type)))))))))
11167 (defun gnus-article-date-local ()
11168 "Convert the current article date to the local timezone."
11170 (gnus-article-date-ut 'local))
11172 (defun gnus-article-date-lapsed ()
11173 "Convert the current article date to time lapsed since it was sent."
11175 (gnus-article-date-ut 'lapsed))
11177 (defun gnus-article-maybe-highlight ()
11178 "Do some article highlighting if `gnus-visual' is non-nil."
11179 (if gnus-visual (gnus-article-highlight-some)))
11183 (defun gnus-output-to-rmail (file-name)
11184 "Append the current article to an Rmail file named FILE-NAME."
11186 ;; Most of these codes are borrowed from rmailout.el.
11187 (setq file-name (expand-file-name file-name))
11188 (setq rmail-default-rmail-file file-name)
11189 (let ((artbuf (current-buffer))
11190 (tmpbuf (get-buffer-create " *Gnus-output*")))
11192 (or (get-file-buffer file-name)
11193 (file-exists-p file-name)
11194 (if (gnus-yes-or-no-p
11195 (concat "\"" file-name "\" does not exist, create it? "))
11196 (let ((file-buffer (create-file-buffer file-name)))
11198 (set-buffer file-buffer)
11199 (rmail-insert-rmail-file-header)
11200 (let ((require-final-newline nil))
11201 (write-region (point-min) (point-max) file-name t 1)))
11202 (kill-buffer file-buffer))
11203 (error "Output file does not exist")))
11204 (set-buffer tmpbuf)
11205 (buffer-disable-undo (current-buffer))
11207 (insert-buffer-substring artbuf)
11208 (gnus-convert-article-to-rmail)
11209 ;; Decide whether to append to a file or to an Emacs buffer.
11210 (let ((outbuf (get-file-buffer file-name)))
11212 (append-to-file (point-min) (point-max) file-name)
11213 ;; File has been visited, in buffer OUTBUF.
11214 (set-buffer outbuf)
11215 (let ((buffer-read-only nil)
11216 (msg (and (boundp 'rmail-current-message)
11217 (symbol-value 'rmail-current-message))))
11218 ;; If MSG is non-nil, buffer is in RMAIL mode.
11221 (narrow-to-region (point-max) (point-max))))
11222 (insert-buffer-substring tmpbuf)
11225 (goto-char (point-min))
11227 (search-backward "\^_")
11228 (narrow-to-region (point) (point-max))
11229 (goto-char (1+ (point-min)))
11230 (rmail-count-new-messages t)
11231 (rmail-show-message msg)))))))
11232 (kill-buffer tmpbuf)))
11234 (defun gnus-output-to-file (file-name)
11235 "Append the current article to a file named FILE-NAME."
11236 (setq file-name (expand-file-name file-name))
11237 (let ((artbuf (current-buffer))
11238 (tmpbuf (get-buffer-create " *Gnus-output*")))
11240 (set-buffer tmpbuf)
11241 (buffer-disable-undo (current-buffer))
11243 (insert-buffer-substring artbuf)
11244 ;; Append newline at end of the buffer as separator, and then
11245 ;; save it to file.
11246 (goto-char (point-max))
11248 (append-to-file (point-min) (point-max) file-name))
11249 (kill-buffer tmpbuf)))
11251 (defun gnus-convert-article-to-rmail ()
11252 "Convert article in current buffer to Rmail message format."
11253 (let ((buffer-read-only nil))
11254 ;; Convert article directly into Babyl format.
11255 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11256 (goto-char (point-min))
11257 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11258 (while (search-forward "\n\^_" nil t) ;single char
11259 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
11260 (goto-char (point-max))
11263 (defun gnus-narrow-to-page (&optional arg)
11264 "Make text outside current page invisible except for page delimiter.
11265 A numeric arg specifies to move forward or backward by that many pages,
11266 thus showing a page other than the one point was originally in."
11268 (setq arg (if arg (prefix-numeric-value arg) 0))
11270 (forward-page -1) ;Beginning of current page.
11275 (forward-page (1- arg))))
11276 ;; Find the end of the page.
11278 ;; If we stopped due to end of buffer, stay there.
11279 ;; If we stopped after a page delimiter, put end of restriction
11280 ;; at the beginning of that line.
11281 ;; These are commented out.
11282 ;; (if (save-excursion (beginning-of-line)
11283 ;; (looking-at page-delimiter))
11284 ;; (beginning-of-line))
11285 (narrow-to-region (point)
11287 ;; Find the top of the page.
11289 ;; If we found beginning of buffer, stay there.
11290 ;; If extra text follows page delimiter on same line,
11292 ;; Otherwise, show text starting with following line.
11293 (if (and (eolp) (not (bobp)))
11297 (defun gnus-gmt-to-local ()
11298 "Rewrite Date header described in GMT to local in current buffer.
11299 Intended to be used with gnus-article-prepare-hook."
11303 (goto-char (point-min))
11304 (narrow-to-region (point-min)
11305 (progn (search-forward "\n\n" nil 'move) (point)))
11306 (goto-char (point-min))
11307 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
11308 (let ((buffer-read-only nil)
11309 (date (buffer-substring-no-properties
11310 (match-beginning 1) (match-end 1))))
11311 (delete-region (match-beginning 1) (match-end 1))
11313 (timezone-make-date-arpa-standard
11314 date nil (current-time-zone))))))))
11317 ;; Article mode commands
11319 (defun gnus-article-next-page (&optional lines)
11320 "Show next page of current article.
11321 If end of article, return non-nil. Otherwise return nil.
11322 Argument LINES specifies lines to be scrolled up."
11324 (move-to-window-line -1)
11325 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11326 (if (save-excursion
11328 (and (pos-visible-in-window-p) ;Not continuation line.
11330 ;; Nothing in this page.
11331 (if (or (not gnus-break-pages)
11334 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11336 (gnus-narrow-to-page 1) ;Go to next page.
11338 ;; More in this page.
11342 ;; Long lines may cause an end-of-buffer error.
11343 (goto-char (point-max))))
11346 (defun gnus-article-prev-page (&optional lines)
11347 "Show previous page of current article.
11348 Argument LINES specifies lines to be scrolled down."
11350 (move-to-window-line 0)
11351 (if (and gnus-break-pages
11353 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11355 (gnus-narrow-to-page -1) ;Go to previous page.
11356 (goto-char (point-max))
11358 (scroll-down lines)))
11360 (defun gnus-article-refer-article ()
11361 "Read article specified by message-id around point."
11363 (search-forward ">" nil t) ;Move point to end of "<....>".
11364 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11366 (buffer-substring (match-beginning 1) (match-end 1))))
11367 (set-buffer gnus-summary-buffer)
11368 (gnus-summary-refer-article message-id))
11369 (error "No references around point")))
11371 (defun gnus-article-show-summary ()
11372 "Reconfigure windows to show summary buffer."
11374 (gnus-configure-windows 'article)
11375 (gnus-summary-goto-subject gnus-current-article))
11377 (defun gnus-article-describe-briefly ()
11378 "Describe article mode commands briefly."
11381 (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")))
11383 (defun gnus-article-summary-command ()
11384 "Execute the last keystroke in the summary buffer."
11386 (let ((obuf (current-buffer))
11387 (owin (current-window-configuration))
11389 (switch-to-buffer gnus-summary-buffer 'norecord)
11390 (setq func (lookup-key (current-local-map) (this-command-keys)))
11391 (call-interactively func)
11393 (set-window-configuration owin)
11394 (set-window-point (get-buffer-window (current-buffer)) (point))))
11396 (defun gnus-article-summary-command-nosave ()
11397 "Execute the last keystroke in the summary buffer."
11400 (pop-to-buffer gnus-summary-buffer 'norecord)
11401 (setq func (lookup-key (current-local-map) (this-command-keys)))
11402 (call-interactively func)))
11405 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11408 (defalias 'gnus-batch-kill 'gnus-batch-score)
11410 (defun gnus-batch-score ()
11411 "Run batched scoring.
11412 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
11413 Newsgroups is a list of strings in Bnews format. If you want to score
11414 the comp hierarchy, you'd say \"comp.all\". If you would not like to
11415 score the alt hierarchy, you'd say \"!alt.all\"."
11418 (gnus-newsrc-parse-options
11419 (apply (function concat)
11420 (mapcar (lambda (g) (concat g " "))
11421 command-line-args-left))))
11422 (gnus-expert-user t)
11423 (nnmail-spool-file nil)
11424 (gnus-use-dribble-file nil)
11425 (yes (car yes-and-no))
11426 (no (cdr yes-and-no))
11428 ;; Disable verbose message.
11429 gnus-novice-user gnus-large-newsgroup)
11430 ;; Eat all arguments.
11431 (setq command-line-args-left nil)
11434 ;; Apply kills to specified newsgroups in command line arguments.
11435 (setq newsrc (cdr gnus-newsrc-alist))
11437 (setq group (car (car newsrc)))
11438 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
11439 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
11441 (or (eq (car entry) t)
11442 (not (zerop (car entry)))))
11443 (if yes (string-match yes group) t)
11444 (or (null no) (not (string-match no group))))
11446 (gnus-summary-read-group group nil t)
11447 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
11448 (gnus-summary-exit))))
11449 (setq newsrc (cdr newsrc)))
11451 (switch-to-buffer gnus-group-buffer)
11452 (gnus-group-save-newsrc)))
11454 (defun gnus-apply-kill-file ()
11455 "Apply a kill file to the current newsgroup.
11456 Returns the number of articles marked as read."
11457 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
11458 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11459 (gnus-apply-kill-file-internal)
11462 (defun gnus-kill-save-kill-buffer ()
11464 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11465 (if (get-file-buffer file)
11467 (set-buffer (get-file-buffer file))
11468 (and (buffer-modified-p) (save-buffer))
11469 (kill-buffer (current-buffer)))))))
11471 (defvar gnus-kill-file-name "KILL"
11472 "Suffix of the kill files.")
11474 (defun gnus-newsgroup-kill-file (newsgroup)
11475 "Return the name of a kill file name for NEWSGROUP.
11476 If NEWSGROUP is nil, return the global kill file name instead."
11477 (cond ((or (null newsgroup)
11478 (string-equal newsgroup ""))
11479 ;; The global KILL file is placed at top of the directory.
11480 (expand-file-name gnus-kill-file-name
11481 (or gnus-kill-files-directory "~/News")))
11482 ((gnus-use-long-file-name 'not-kill)
11483 ;; Append ".KILL" to newsgroup name.
11484 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
11485 "." gnus-kill-file-name)
11486 (or gnus-kill-files-directory "~/News")))
11488 ;; Place "KILL" under the hierarchical directory.
11489 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
11490 "/" gnus-kill-file-name)
11491 (or gnus-kill-files-directory "~/News")))))
11498 (defvar gnus-dribble-ignore nil)
11499 (defvar gnus-dribble-eval-file nil)
11501 (defun gnus-dribble-file-name ()
11502 (concat gnus-current-startup-file "-dribble"))
11504 (defun gnus-dribble-enter (string)
11505 (if (and (not gnus-dribble-ignore)
11506 gnus-dribble-buffer
11507 (buffer-name gnus-dribble-buffer))
11508 (let ((obuf (current-buffer)))
11509 (set-buffer gnus-dribble-buffer)
11510 (insert string "\n")
11511 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11512 (set-buffer obuf))))
11514 (defun gnus-dribble-read-file ()
11515 (let ((dribble-file (gnus-dribble-file-name)))
11517 (set-buffer (setq gnus-dribble-buffer
11519 (file-name-nondirectory dribble-file))))
11520 (gnus-add-current-to-buffer-list)
11522 (set-visited-file-name dribble-file)
11523 (buffer-disable-undo (current-buffer))
11524 (bury-buffer (current-buffer))
11525 (set-buffer-modified-p nil)
11526 (let ((auto (make-auto-save-file-name))
11527 (gnus-dribble-ignore t))
11528 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11530 (if (file-newer-than-file-p auto dribble-file)
11531 (setq dribble-file auto))
11532 (insert-file-contents dribble-file)
11533 (if (not (zerop (buffer-size)))
11534 (set-buffer-modified-p t))
11536 "Auto-save file exists. Do you want to read it? ")
11537 (setq gnus-dribble-eval-file t))))))))
11539 (defun gnus-dribble-eval-file ()
11540 (if (not gnus-dribble-eval-file)
11542 (setq gnus-dribble-eval-file nil)
11544 (let ((gnus-dribble-ignore t))
11545 (set-buffer gnus-dribble-buffer)
11546 (eval-buffer (current-buffer))))))
11548 (defun gnus-dribble-delete-file ()
11549 (if (file-exists-p (gnus-dribble-file-name))
11550 (delete-file (gnus-dribble-file-name)))
11551 (if gnus-dribble-buffer
11553 (set-buffer gnus-dribble-buffer)
11554 (let ((auto (make-auto-save-file-name)))
11555 (if (file-exists-p auto)
11556 (delete-file auto))
11558 (set-buffer-modified-p nil)))))
11560 (defun gnus-dribble-save ()
11561 (if (and gnus-dribble-buffer
11562 (buffer-name gnus-dribble-buffer))
11564 (set-buffer gnus-dribble-buffer)
11567 (defun gnus-dribble-clear ()
11569 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11571 (set-buffer gnus-dribble-buffer)
11573 (set-buffer-modified-p nil)
11574 (setq buffer-saved-size (buffer-size))))))
11577 ;;; Server Communication
11580 ;; All the Gnus backends have the same interface, and should return
11581 ;; data in a similar format. Below is an overview of what functions
11582 ;; these packages must supply and what results they should return.
11586 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
11589 ;; Functions for the imaginary backend `choke':
11591 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
11592 ;; Should return all headers for all ARTICLES, or return NOV lines for
11595 ;; `choke-request-group GROUP &optional SERVER DISCARD'
11596 ;; Switch to GROUP. If DISCARD is nil, active information on the group
11597 ;; must be returned.
11599 ;; `choke-close-group GROUP &optional SERVER'
11600 ;; Close group. Most backends won't have to do anything with this
11601 ;; call, but it is an opportunity to clean up, if that is needed. It
11602 ;; is called when Gnus exits a group.
11604 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
11605 ;; Return ARTICLE, which is either an article number or
11606 ;; message-id. Note that not all backends can return articles based on
11609 ;; `choke-request-list SERVER'
11610 ;; Return a list of all newsgroups on SERVER.
11612 ;; `choke-request-list-newsgroups SERVER'
11613 ;; Return a list of descriptions of all newsgroups on SERVER.
11615 ;; `choke-request-newgroups DATE &optional SERVER'
11616 ;; Return a list of all groups that have arrived after DATE on
11617 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
11618 ;; always check whether the groups are old or not. Backends that do
11619 ;; not store date information may just return the entire list of
11620 ;; groups, although this might not be a good idea in general.
11622 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
11623 ;; Should return a buffer that is suitable for "posting". nnspool and
11624 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
11625 ;; buffer. This function should fill out the appropriate headers.
11627 ;; `choke-request-post &optional SERVER'
11628 ;; Function that will be called from a buffer to be posted.
11630 ;; `choke-open-server SERVER &optional ARGUMENT'
11631 ;; Open a connection to SERVER.
11633 ;; `choke-close-server &optional SERVER'
11634 ;; Close the connection to SERVER.
11636 ;; `choke-server-opened &optional SERVER'
11637 ;; Whether the conenction to SERVER is opened or not.
11639 ;; `choke-server-status &optional SERVER'
11640 ;; Should return a status string (not in the nntp buffer, but as the
11641 ;; result of the function).
11643 ;; `choke-retrieve-groups GROUPS &optional SERVER'
11644 ;; Optional function for retrieving active file info on all groups in
11645 ;; GROUPS. Two return formats are supported: The normal active file
11646 ;; format, and a list of GROUP lines. This function should return (as
11647 ;; a function value) either `active' or `group', depending on what
11648 ;; format it returns.
11650 ;; The following functions are optional and apply only to backends
11651 ;; that are able to control the contents of their groups totally
11652 ;; (ie. mail backends.) Backends that aren't able to do that
11653 ;; shouldn't define these functions at all. Gnus will check for their
11654 ;; presence before attempting to call them.
11656 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
11657 ;; Should expire (according to some aging scheme) all ARTICLES. Most
11658 ;; backends will not be able to expire articles. Should return a list
11659 ;; of all articles that were not expired.
11661 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
11662 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
11663 ;; Removes any information it has added to the article (extra headers,
11664 ;; whatever - make it as clean as possible), and then passes the
11665 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
11666 ;; function described below. If the ACCEPT-FORM returns a non-nil
11667 ;; value, the article should then be deleted. If LAST is nil, that
11668 ;; means that there will be further calls to this function. This might
11669 ;; be taken as an advice not to save buffers/internal variables just
11670 ;; yet, but wait until the last call to speed things up.
11672 ;; `choke-request-accept-article GROUP &optional LAST'
11673 ;; The contents of the current buffer will be put into GROUP. There
11674 ;; should, of course, be an article in the current buffer. This
11675 ;; function is normally only called by the function described above,
11676 ;; and LAST works the same way as in that function.
11678 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
11679 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
11680 ;; This provides an easy interface for allowing editing of
11681 ;; articles. Note that even headers may be edited, so the backend has
11682 ;; to update any tables (nov buffers, etc) that it maintains after
11683 ;; replacing the article.
11685 ;; `choke-request-create-group GROUP &optional SERVER'
11686 ;; Create GROUP on SERVER. This might be a new, empty group, or it
11687 ;; might be a group that already exists, but hasn't been registered
11690 ;; All these functions must return nil if they couldn't service the
11691 ;; request. If the optional arguments are not supplied, some "current"
11692 ;; or "default" values should be used. In short, one should emulate an
11693 ;; NNTP server, in a way.
11695 ;; If you want to write a new backend, you just have to supply the
11696 ;; functions listed above. In addition, you must enter the new backend
11697 ;; into the list of valid select methods:
11698 ;; (setq gnus-valid-select-methods
11699 ;; (cons '("choke" mail) gnus-valid-select-methods))
11700 ;; The first element in this list is the name of the backend. Other
11701 ;; elemnets may be `mail' (for mail groups), `post' (for news
11702 ;; groups), `none' (neither), `respool' (for groups that can control
11703 ;; their contents).
11705 (defun gnus-start-news-server (&optional confirm)
11706 "Open a method for getting news.
11707 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11709 (if gnus-current-select-method
11710 ;; Stream is already opened.
11712 ;; Open NNTP server.
11713 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11716 ;; Read server name with completion.
11717 (setq gnus-nntp-server
11718 (completing-read "NNTP server: "
11719 (mapcar (lambda (server) (list server))
11720 (cons (list gnus-nntp-server)
11721 gnus-secondary-servers))
11722 nil nil gnus-nntp-server))))
11724 (if (and gnus-nntp-server
11725 (stringp gnus-nntp-server)
11726 (not (string= gnus-nntp-server "")))
11727 (setq gnus-select-method
11728 (cond ((or (string= gnus-nntp-server "")
11729 (string= gnus-nntp-server "::"))
11730 (list 'nnspool (system-name)))
11731 ((string-match "^:" gnus-nntp-server)
11732 (list 'nnmh gnus-nntp-server
11733 (list 'nnmh-directory
11734 (file-name-as-directory
11736 (concat "~/" (substring
11737 gnus-nntp-server 1)))))
11738 (list 'nnmh-get-new-mail nil)))
11740 (list 'nntp gnus-nntp-server)))))
11742 (setq how (car gnus-select-method))
11743 (cond ((eq how 'nnspool)
11745 (gnus-message 5 "Looking up local news spool..."))
11748 (gnus-message 5 "Looking up mh spool..."))
11751 (setq gnus-current-select-method gnus-select-method)
11752 (run-hooks 'gnus-open-server-hook)
11754 ;; gnus-open-server-hook might have opened it
11755 (gnus-server-opened gnus-select-method)
11756 (gnus-open-server gnus-select-method)
11759 "%s server on %s can't be opened. Continue? "
11760 (car gnus-select-method) (nth 1 gnus-select-method)))
11762 (gnus-message 1 "Couldn't open server on %s"
11763 (nth 1 gnus-select-method))
11767 (defun gnus-check-server (&optional method)
11768 "If the news server is down, start it up again."
11769 (let ((method (if method method gnus-select-method)))
11770 (and (stringp method)
11771 (setq method (gnus-server-to-method method)))
11772 (if (gnus-server-opened method)
11773 ;; Stream is already opened.
11776 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11777 (run-hooks 'gnus-open-server-hook)
11779 (gnus-open-server method)
11782 (defun gnus-nntp-message (&optional message)
11783 "Check the status of the NNTP server.
11784 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11785 is returned insted of the status string."
11786 (let ((status (gnus-status-message (gnus-find-method-for-group
11787 gnus-newsgroup-name)))
11788 (message (or message "")))
11789 (if (and (stringp status) (> (length status) 0))
11792 (defun gnus-get-function (method function)
11793 (and (stringp method)
11794 (setq method (gnus-server-to-method method)))
11795 (let ((func (intern (format "%s-%s" (car method) function))))
11796 (if (not (fboundp func))
11798 (require (car method))
11799 (if (not (fboundp func))
11800 (error "No such function: %s" func))))
11803 ;;; Interface functions to the backends.
11805 (defun gnus-open-server (method)
11806 (funcall (gnus-get-function method 'open-server)
11807 (nth 1 method) (nthcdr 2 method)))
11809 (defun gnus-close-server (method)
11810 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11812 (defun gnus-request-list (method)
11813 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11815 (defun gnus-request-list-newsgroups (method)
11816 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11818 (defun gnus-request-newgroups (date method)
11819 (funcall (gnus-get-function method 'request-newgroups)
11820 date (nth 1 method)))
11822 (defun gnus-server-opened (method)
11823 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11825 (defun gnus-status-message (method)
11826 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11828 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11830 (defun gnus-request-group (group &optional dont-check)
11831 (let ((method (gnus-find-method-for-group group)))
11832 ; (and t (message "%s GROUP %s" (car method) group))
11833 (funcall (gnus-get-function method 'request-group)
11834 (gnus-group-real-name group) (nth 1 method) dont-check)))
11836 (defun gnus-request-asynchronous (group &optional articles)
11837 (let ((method (gnus-find-method-for-group group)))
11838 (funcall (gnus-get-function method 'request-asynchronous)
11839 (gnus-group-real-name group) (nth 1 method) articles)))
11841 (defun gnus-list-active-group (group)
11842 (let ((method (gnus-find-method-for-group group))
11843 (func 'list-active-group))
11844 (and (gnus-check-backend-function func group)
11845 (funcall (gnus-get-function method func)
11846 (gnus-group-real-name group) (nth 1 method)))))
11848 (defun gnus-request-group-description (group)
11849 (let ((method (gnus-find-method-for-group group))
11850 (func 'request-group-description))
11851 (and (gnus-check-backend-function func group)
11852 (funcall (gnus-get-function method func)
11853 (gnus-group-real-name group) (nth 1 method)))))
11855 (defun gnus-close-group (group)
11856 (let ((method (gnus-find-method-for-group group)))
11857 (funcall (gnus-get-function method 'close-group)
11858 (gnus-group-real-name group) (nth 1 method))))
11860 (defun gnus-retrieve-headers (articles group)
11861 (let ((method (gnus-find-method-for-group group)))
11862 (if (and gnus-use-cache (numberp (car articles)))
11863 (gnus-cache-retrieve-headers articles group)
11864 (funcall (gnus-get-function method 'retrieve-headers)
11865 articles (gnus-group-real-name group) (nth 1 method)))))
11867 (defun gnus-retrieve-groups (groups method)
11868 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11870 (defun gnus-request-article (article group &optional buffer)
11871 (let ((method (gnus-find-method-for-group group)))
11872 (funcall (gnus-get-function method 'request-article)
11873 article (gnus-group-real-name group) (nth 1 method) buffer)))
11875 (defun gnus-request-head (article group)
11876 (let ((method (gnus-find-method-for-group group)))
11877 (funcall (gnus-get-function method 'request-head)
11878 article (gnus-group-real-name group) (nth 1 method))))
11880 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11881 (defun gnus-request-post-buffer (post group subject header artbuf
11882 info follow-to respect-poster)
11883 (let* ((info (or info (and group (nth 2 (gnus-gethash
11884 group gnus-newsrc-hashtb)))))
11886 (if (and gnus-post-method
11887 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11889 (format "%s" (car (gnus-find-method-for-group
11890 gnus-newsgroup-name)))
11891 gnus-valid-select-methods)))
11893 (gnus-find-method-for-group gnus-newsgroup-name))))
11894 (or (gnus-check-server method)
11895 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11896 (let ((mail-self-blind nil)
11897 (mail-archive-file-name nil))
11898 (funcall (gnus-get-function method 'request-post-buffer)
11899 post group subject header artbuf info follow-to
11902 (defun gnus-request-post (method &optional force)
11903 (and (stringp method)
11904 (setq method (gnus-server-to-method method)))
11905 (and (not force) gnus-post-method
11906 (memq 'post (assoc (format "%s" (car method))
11907 gnus-valid-select-methods))
11908 (setq method gnus-post-method))
11909 (funcall (gnus-get-function method 'request-post)
11912 (defun gnus-request-expire-articles (articles group &optional force)
11913 (let ((method (gnus-find-method-for-group group)))
11914 (funcall (gnus-get-function method 'request-expire-articles)
11915 articles (gnus-group-real-name group) (nth 1 method)
11918 (defun gnus-request-move-article
11919 (article group server accept-function &optional last)
11920 (let ((method (gnus-find-method-for-group group)))
11921 (funcall (gnus-get-function method 'request-move-article)
11922 article (gnus-group-real-name group)
11923 (nth 1 method) accept-function last)))
11925 (defun gnus-request-accept-article (group &optional last)
11926 (let ((func (if (symbolp group) group
11927 (car (gnus-find-method-for-group group)))))
11928 (funcall (intern (format "%s-request-accept-article" func))
11929 (if (stringp group) (gnus-group-real-name group) group)
11932 (defun gnus-request-replace-article (article group buffer)
11933 (let ((func (car (gnus-find-method-for-group group))))
11934 (funcall (intern (format "%s-request-replace-article" func))
11935 article (gnus-group-real-name group) buffer)))
11937 (defun gnus-request-create-group (group)
11938 (let ((method (gnus-find-method-for-group group)))
11939 (funcall (gnus-get-function method 'request-create-group)
11940 (gnus-group-real-name group) (nth 1 method))))
11942 (defun gnus-member-of-valid (symbol group)
11943 (memq symbol (assoc
11944 (format "%s" (car (gnus-find-method-for-group group)))
11945 gnus-valid-select-methods)))
11947 (defun gnus-secondary-method-p (method)
11948 (let ((methods gnus-secondary-select-methods)
11949 (gmethod (gnus-server-get-method nil method)))
11950 (while (and methods
11951 (not (equal (gnus-server-get-method nil (car methods))
11953 (setq methods (cdr methods)))
11956 (defun gnus-find-method-for-group (group &optional info)
11957 (or gnus-override-method
11959 gnus-select-method)
11960 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11963 (not (setq method (nth 4 info))))
11964 (setq method gnus-select-method)
11966 (cond ((stringp method)
11967 (gnus-server-to-method method))
11968 ((stringp (car method))
11969 (gnus-server-extend-method group method))
11972 (gnus-server-add-address method))))
11974 (defun gnus-check-backend-function (func group)
11975 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11977 (fboundp (intern (format "%s-%s" method func)))))
11979 (defun gnus-methods-using (method)
11980 (let ((valids gnus-valid-select-methods)
11983 (if (memq method (car valids))
11984 (setq outs (cons (car valids) outs)))
11985 (setq valids (cdr valids)))
11989 ;;; Active & Newsrc File Handling
11992 ;; Newsrc related functions.
11993 ;; Gnus internal format of gnus-newsrc-alist:
11994 ;; (("alt.general" 3 (1 . 1))
11995 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11996 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11997 ;; The first item is the group name; the second is the subscription
11998 ;; level; the third is either a range of a list of ranges of read
11999 ;; articles, the optional fourth element is a list of marked articles,
12000 ;; the optional fifth element is the select method.
12002 ;; Gnus internal format of gnus-newsrc-hashtb:
12003 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12004 ;; This is the entry for "alt.misc". The first element is the number
12005 ;; of unread articles in "alt.misc". The cdr of this entry is the
12006 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
12007 ;; trivial to remove or add new elements into gnus-newsrc-alist
12008 ;; without scanning the entire list. So, to get the actual information
12009 ;; of "alt.misc", you'd say something like
12010 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12012 ;; Gnus internal format of gnus-active-hashtb:
12016 ;; The only element in each entry in this hash table is a range of
12017 ;; (possibly) available articles. (Articles in this range may have
12018 ;; been expired or canceled.)
12020 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12021 ;; ("alt.misc" "alt.test" "alt.general" ...)
12023 (defun gnus-setup-news (&optional rawfile level)
12024 "Setup news information.
12025 If RAWFILE is non-nil, the .newsrc file will also be read.
12026 If LEVEL is non-nil, the news will be set up at level LEVEL."
12027 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
12028 ;; Clear some variables to re-initialize news information.
12029 (if init (setq gnus-newsrc-alist nil
12030 gnus-active-hashtb nil))
12032 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12033 (if init (gnus-read-newsrc-file rawfile))
12035 ;; If we don't read the complete active file, we fill in the
12037 (if (or (null gnus-read-active-file)
12038 (eq gnus-read-active-file 'some))
12039 (gnus-update-active-hashtb-from-killed))
12041 ;; Read the active file and create `gnus-active-hashtb'.
12042 ;; If `gnus-read-active-file' is nil, then we just create an empty
12043 ;; hash table. The partial filling out of the hash table will be
12044 ;; done in `gnus-get-unread-articles'.
12045 (and gnus-read-active-file
12047 (gnus-read-active-file))
12049 ;; Possibly eval the dribble file.
12050 (and init gnus-use-dribble-file (gnus-dribble-eval-file))
12052 (gnus-update-format-specifications)
12054 ;; Find the number of unread articles in each non-dead group.
12055 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
12056 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
12057 ;; Find new newsgroups and treat them.
12058 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12059 (gnus-server-opened gnus-select-method))
12060 (gnus-find-new-newsgroups))
12061 (if (and init gnus-check-bogus-newsgroups
12062 gnus-read-active-file (not level)
12063 (gnus-server-opened gnus-select-method))
12064 (gnus-check-bogus-newsgroups))))
12066 (defun gnus-find-new-newsgroups ()
12067 "Search for new newsgroups and add them.
12068 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12069 The `-n' option line from .newsrc is respected."
12071 (or (gnus-check-first-time-used)
12072 (if (or (consp gnus-check-new-newsgroups)
12073 (eq gnus-check-new-newsgroups 'ask-server))
12074 (gnus-ask-server-for-new-groups)
12076 group new-newsgroups)
12077 (gnus-message 5 "Checking for new newsgroups...")
12078 (or gnus-have-read-active-file (gnus-read-active-file))
12079 (setq gnus-newsrc-last-checked-date (current-time-string))
12080 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12081 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12082 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12085 (if (or (null (setq group (symbol-name sym)))
12086 (null (symbol-value sym))
12087 (gnus-gethash group gnus-killed-hashtb)
12088 (gnus-gethash group gnus-newsrc-hashtb))
12090 (let ((do-sub (gnus-matches-options-n group)))
12092 ((eq do-sub 'subscribe)
12093 (setq groups (1+ groups))
12094 (gnus-sethash group group gnus-killed-hashtb)
12095 (funcall gnus-subscribe-options-newsgroup-method group))
12096 ((eq do-sub 'ignore)
12099 (setq groups (1+ groups))
12100 (gnus-sethash group group gnus-killed-hashtb)
12101 (if gnus-subscribe-hierarchical-interactive
12102 (setq new-newsgroups (cons group new-newsgroups))
12103 (funcall gnus-subscribe-newsgroup-method group)))))))
12104 gnus-active-hashtb)
12106 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12107 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12109 (gnus-message 6 "%d new newsgroup%s arrived."
12110 groups (if (> groups 1) "s have" " has"))
12111 (gnus-message 6 "No new newsgroups."))))))
12113 (defun gnus-matches-options-n (group)
12114 ;; Returns `subscribe' if the group is to be uncoditionally
12115 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12116 ;; no match for the group.
12118 ;; First we check the two user variables.
12120 ((and gnus-options-subscribe
12121 (string-match gnus-options-subscribe group))
12123 ((and gnus-options-not-subscribe
12124 (string-match gnus-options-not-subscribe group))
12126 ;; Then we go through the list that was retrieved from the .newsrc
12127 ;; file. This list has elements on the form
12128 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12129 ;; is in the reverse order of the options line) is returned.
12131 (let ((regs gnus-newsrc-options-n))
12133 (not (string-match (car (car regs)) group)))
12134 (setq regs (cdr regs)))
12135 (and regs (cdr (car regs)))))))
12137 (defun gnus-ask-server-for-new-groups ()
12138 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12139 (methods (cons gnus-select-method
12141 (and (consp gnus-check-new-newsgroups)
12142 gnus-check-new-newsgroups)
12143 gnus-secondary-select-methods)))
12145 (new-date (current-time-string))
12146 hashtb group new-newsgroups got-new method)
12147 ;; Go thorugh both primary and secondary select methods and
12148 ;; request new newsgroups.
12150 (setq method (gnus-server-get-method nil (car methods)))
12151 (and (gnus-check-server method)
12152 (gnus-request-newgroups date method)
12155 (set-buffer nntp-server-buffer)
12156 (or hashtb (setq hashtb (gnus-make-hashtable
12157 (count-lines (point-min) (point-max)))))
12158 ;; Enter all the new groups in a hashtable.
12159 (gnus-active-to-gnus-format method hashtb 'ignore)))
12160 (setq methods (cdr methods)))
12161 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12162 ;; Now all new groups from all select methods are in `hashtb'.
12164 (lambda (group-sym)
12165 (setq group (symbol-name group-sym))
12166 (if (or (gnus-gethash group gnus-newsrc-hashtb)
12167 (member group gnus-zombie-list)
12168 (member group gnus-killed-list))
12169 ;; The group is already known.
12171 (and (symbol-value group-sym)
12172 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
12173 (let ((do-sub (gnus-matches-options-n group)))
12174 (cond ((eq do-sub 'subscribe)
12175 (setq groups (1+ groups))
12176 (gnus-sethash group group gnus-killed-hashtb)
12178 gnus-subscribe-options-newsgroup-method group))
12179 ((eq do-sub 'ignore)
12182 (setq groups (1+ groups))
12183 (gnus-sethash group group gnus-killed-hashtb)
12184 (if gnus-subscribe-hierarchical-interactive
12185 (setq new-newsgroups (cons group new-newsgroups))
12186 (funcall gnus-subscribe-newsgroup-method group)))))))
12189 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12190 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12192 (gnus-message 6 "%d new newsgroup%s arrived."
12193 groups (if (> groups 1) "s have" " has")))
12196 (defun gnus-check-first-time-used ()
12197 (if (or (> (length gnus-newsrc-alist) 1)
12198 (file-exists-p gnus-startup-file)
12199 (file-exists-p (concat gnus-startup-file ".el"))
12200 (file-exists-p (concat gnus-startup-file ".eld")))
12202 (gnus-message 6 "First time user; subscribing you to default groups")
12203 (or gnus-have-read-active-file (gnus-read-active-file))
12204 (setq gnus-newsrc-last-checked-date (current-time-string))
12205 (let ((groups gnus-default-subscribed-newsgroups)
12209 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12212 (if (null (setq group (symbol-name sym)))
12214 (let ((do-sub (gnus-matches-options-n group)))
12216 ((eq do-sub 'subscribe)
12217 (gnus-sethash group group gnus-killed-hashtb)
12218 (funcall gnus-subscribe-options-newsgroup-method group))
12219 ((eq do-sub 'ignore)
12222 (setq gnus-killed-list (cons group gnus-killed-list)))))))
12223 gnus-active-hashtb)
12225 (if (gnus-gethash (car groups) gnus-active-hashtb)
12226 (gnus-group-change-level
12227 (car groups) gnus-level-default-subscribed gnus-level-killed))
12228 (setq groups (cdr groups)))
12229 (gnus-group-make-help-group)
12230 (and gnus-novice-user
12231 (gnus-message 7 "`A k' to list killed groups"))))))
12233 (defun gnus-subscribe-group (group previous &optional method)
12234 (gnus-group-change-level
12236 (list t group gnus-level-default-subscribed nil nil method)
12238 gnus-level-default-subscribed gnus-level-killed previous t))
12240 ;; `gnus-group-change-level' is the fundamental function for changing
12241 ;; subscription levels of newsgroups. This might mean just changing
12242 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12243 ;; again, which subscribes/unsubscribes a group, which is equally
12244 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12245 ;; from 8-9 to 1-7 means that you remove the group from the list of
12246 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12247 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12248 ;; which is trivial.
12249 ;; ENTRY can either be a string (newsgroup name) or a list (if
12250 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12251 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12253 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12254 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12256 (defun gnus-group-change-level (entry level &optional oldlevel
12257 previous fromkilled)
12258 (let (group info active num)
12259 ;; Glean what info we can from the arguments
12261 (if fromkilled (setq group (nth 1 entry))
12262 (setq group (car (nth 2 entry))))
12263 (setq group entry))
12264 (if (and (stringp entry)
12266 (< oldlevel gnus-level-zombie))
12267 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12268 (if (and (not oldlevel)
12270 (setq oldlevel (car (cdr (nth 2 entry)))))
12271 (if (stringp previous)
12272 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12274 (if (and (>= oldlevel gnus-level-zombie)
12275 (gnus-gethash group gnus-newsrc-hashtb))
12276 ;; We are trying to subscribe a group that is already
12280 (gnus-dribble-enter
12281 (format "(gnus-group-change-level %S %S %S %S %S)"
12282 group level oldlevel (car (nth 2 previous)) fromkilled))
12284 ;; Then we remove the newgroup from any old structures, if needed.
12285 ;; If the group was killed, we remove it from the killed or zombie
12286 ;; list. If not, and it is in fact going to be killed, we remove
12287 ;; it from the newsrc hash table and assoc.
12288 (cond ((>= oldlevel gnus-level-zombie)
12289 (if (= oldlevel gnus-level-zombie)
12290 (setq gnus-zombie-list (delete group gnus-zombie-list))
12291 (setq gnus-killed-list (delete group gnus-killed-list))))
12293 (if (and (>= level gnus-level-zombie)
12296 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
12298 (setcdr (gnus-gethash (car (nth 3 entry))
12299 gnus-newsrc-hashtb)
12301 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12303 ;; Finally we enter (if needed) the list where it is supposed to
12304 ;; go, and change the subscription level. If it is to be killed,
12305 ;; we enter it into the killed or zombie list.
12306 (cond ((>= level gnus-level-zombie)
12307 ;; Remove from the hash table.
12308 (gnus-sethash group nil gnus-newsrc-hashtb)
12309 (or (gnus-group-foreign-p group)
12310 ;; We do not enter foreign groups into the list of dead
12312 (if (= level gnus-level-zombie)
12313 (setq gnus-zombie-list (cons group gnus-zombie-list))
12314 (setq gnus-killed-list (cons group gnus-killed-list)))))
12316 ;; If the list is to be entered into the newsrc assoc, and
12317 ;; it was killed, we have to create an entry in the newsrc
12318 ;; hashtb format and fix the pointers in the newsrc assoc.
12319 (if (>= oldlevel gnus-level-zombie)
12323 (setq info (cdr entry))
12324 (setq num (car entry)))
12325 (setq active (gnus-gethash group gnus-active-hashtb))
12326 (setq num (if active (- (1+ (cdr active)) (car active)) t))
12327 ;; Check whether the group is foreign. If so, the
12328 ;; foreign select method has to be entered into the
12330 (let ((method (gnus-group-method-name group)))
12331 (if (eq method gnus-select-method)
12332 (setq info (list group level nil))
12333 (setq info (list group level nil nil method)))))
12336 (let ((p gnus-newsrc-alist))
12337 (while (cdr (cdr p))
12340 (setq entry (cons info (cdr (cdr previous))))
12343 (setcdr (cdr previous) entry)
12344 (gnus-sethash group (cons num (cdr previous))
12345 gnus-newsrc-hashtb))
12346 (setcdr previous entry)
12347 (gnus-sethash group (cons num previous)
12348 gnus-newsrc-hashtb))
12350 (setcdr (gnus-gethash (car (car (cdr entry)))
12351 gnus-newsrc-hashtb)
12353 ;; It was alive, and it is going to stay alive, so we
12354 ;; just change the level and don't change any pointers or
12355 ;; hash table entries.
12356 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
12358 (defun gnus-kill-newsgroup (newsgroup)
12359 "Obsolete function. Kills a newsgroup."
12360 (gnus-group-change-level
12361 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
12363 (defun gnus-check-bogus-newsgroups (&optional confirm)
12364 "Remove bogus newsgroups.
12365 If CONFIRM is non-nil, the user has to confirm the deletion of every
12367 (let ((newsrc (cdr gnus-newsrc-alist))
12369 (gnus-message 5 "Checking bogus newsgroups...")
12370 (or gnus-have-read-active-file (gnus-read-active-file))
12371 ;; Find all bogus newsgroup that are subscribed.
12373 (setq group (car (car newsrc)))
12374 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
12375 (nth 4 (car newsrc)) ; Foreign
12377 (not (gnus-y-or-n-p
12378 (format "Remove bogus newsgroup: %s " group)))))
12381 ;; Found a bogus newsgroup.
12382 (setq bogus (cons group bogus)))
12383 (setq newsrc (cdr newsrc)))
12384 ;; Remove all bogus subscribed groups by first killing them, and
12385 ;; then removing them from the list of killed groups.
12387 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12389 (gnus-group-change-level entry gnus-level-killed)
12390 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12391 (setq bogus (cdr bogus)))
12392 ;; Then we remove all bogus groups from the list of killed and
12393 ;; zombie groups. They are are removed without confirmation.
12394 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12397 (setq killed (symbol-value (car dead-lists)))
12399 (setq group (car killed))
12400 (or (gnus-gethash group gnus-active-hashtb)
12401 ;; The group is bogus.
12402 (set (car dead-lists)
12403 (delete group (symbol-value (car dead-lists)))))
12404 (setq killed (cdr killed)))
12405 (setq dead-lists (cdr dead-lists))))
12406 (gnus-message 5 "Checking bogus newsgroups...done")))
12408 (defun gnus-check-duplicate-killed-groups ()
12409 "Remove duplicates from the list of killed groups."
12411 (let ((killed gnus-killed-list))
12413 (gnus-message 9 "%d" (length killed))
12414 (setcdr killed (delete (car killed) (cdr killed)))
12415 (setq killed (cdr killed)))))
12417 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12418 ;; and compute how many unread articles there are in each group.
12419 (defun gnus-get-unread-articles (&optional level)
12420 (let* ((newsrc (cdr gnus-newsrc-alist))
12421 (level (or level (1+ gnus-level-subscribed)))
12424 (cond ((and gnus-activate-foreign-newsgroups
12425 (not (numberp gnus-activate-foreign-newsgroups)))
12426 (1+ gnus-level-subscribed))
12427 ((numberp gnus-activate-foreign-newsgroups)
12428 gnus-activate-foreign-newsgroups)
12431 info group active virtuals method)
12432 (gnus-message 5 "Checking new news...")
12435 (setq info (car newsrc)
12437 active (gnus-gethash group gnus-active-hashtb))
12439 ;; Check newsgroups. If the user doesn't want to check them, or
12440 ;; they can't be checked (for instance, if the news server can't
12441 ;; be reached) we just set the number of unread articles in this
12442 ;; newsgroup to t. This means that Gnus thinks that there are
12443 ;; unread articles, but it has no idea how many.
12444 (if (and (setq method (nth 4 info))
12445 (not (gnus-server-equal gnus-select-method
12446 (gnus-server-get-method nil method)))
12447 (not (gnus-secondary-method-p method)))
12448 ;; These groups are foreign. Check the level.
12449 (if (<= (nth 1 info) foreign-level)
12450 (if (eq (car (if (stringp method)
12451 (gnus-server-to-method method)
12452 (nth 4 info))) 'nnvirtual)
12453 ;; We have to activate the virtual groups after all
12454 ;; the others, so we just pop them on a list for
12456 (setq virtuals (cons info virtuals))
12457 (and (setq active (gnus-activate-group (car info)))
12458 ;; Close the groups as we look at them!
12459 (gnus-close-group group))))
12461 (or gnus-read-active-file (gnus-check-server method))
12462 ;; These groups are native or secondary.
12463 (if (and (not gnus-read-active-file)
12464 (<= (nth 1 info) level))
12465 (setq active (gnus-activate-group (car info)))))
12468 (gnus-get-unread-articles-in-group info active)
12469 ;; The group couldn't be reached, so we nix out the number of
12470 ;; unread articles and stuff.
12471 (gnus-sethash group nil gnus-active-hashtb)
12472 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
12474 (setq newsrc (cdr newsrc)))
12476 ;; Activate the virtual groups. This has to be done after all the
12478 ;; !!! If one virtual group contains another virtual group, even
12479 ;; doing it this way might cause problems.
12481 (and (setq active (gnus-activate-group (car (car virtuals))))
12482 (gnus-get-unread-articles-in-group (car virtuals) active))
12483 (setq virtuals (cdr virtuals)))
12485 (gnus-message 5 "Checking new news...done")))
12487 ;; Create a hash table out of the newsrc alist. The `car's of the
12488 ;; alist elements are used as keys.
12489 (defun gnus-make-hashtable-from-newsrc-alist ()
12490 (let ((alist gnus-newsrc-alist)
12491 (ohashtb gnus-newsrc-hashtb)
12493 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12495 (setq prev (setq gnus-newsrc-alist
12496 (if (equal (car (car gnus-newsrc-alist))
12499 (cons (list "dummy.group" 0 nil) alist)))))
12501 (gnus-sethash (car (car alist))
12502 (cons (and ohashtb (car (gnus-gethash
12503 (car (car alist)) ohashtb)))
12504 prev) gnus-newsrc-hashtb)
12506 alist (cdr alist)))))
12508 (defun gnus-make-hashtable-from-killed ()
12509 "Create a hash table from the killed and zombie lists."
12510 (let ((lists '(gnus-killed-list gnus-zombie-list))
12512 (setq gnus-killed-hashtb
12513 (gnus-make-hashtable
12514 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12516 (setq list (symbol-value (car lists)))
12517 (setq lists (cdr lists))
12519 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12520 (setq list (cdr list))))))
12522 (defun gnus-get-unread-articles-in-group (info active)
12523 (let* ((range (nth 2 info))
12525 (marked (nth 3 info)))
12526 ;; If a cache is present, we may have to alter the active info.
12527 (and gnus-use-cache
12528 (gnus-cache-possibly-alter-active (car info) active))
12529 ;; Modify the list of read articles according to what articles
12530 ;; are available; then tally the unread articles and add the
12531 ;; number to the group hash table entry.
12533 ((zerop (cdr active))
12536 (setq num (- (1+ (cdr active)) (car active))))
12537 ((not (listp (cdr range)))
12538 ;; Fix a single (num . num) range according to the
12539 ;; active hash table.
12540 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12541 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12542 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12543 ;; Compute number of unread articles.
12544 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
12546 ;; The read list is a list of ranges. Fix them according to
12547 ;; the active hash table.
12548 ;; First peel off any elements that are below the lower
12550 (while (and (cdr range)
12552 (or (and (atom (car (cdr range))) (car (cdr range)))
12553 (car (car (cdr range))))))
12554 (if (numberp (car range))
12557 (or (and (numberp (car (cdr range)))
12559 (cdr (car (cdr range))))))
12560 (setcdr (car range)
12561 (or (and (numberp (nth 1 range)) (nth 1 range))
12562 (cdr (car (cdr range))))))
12563 (setcdr range (cdr (cdr range))))
12564 ;; Adjust the first element to be the same as the lower limit.
12565 (if (and (not (atom (car range)))
12566 (< (cdr (car range)) (car active)))
12567 (setcdr (car range) (1- (car active))))
12568 ;; Then we want to peel off any elements that are higher
12569 ;; than the upper active limit.
12570 (let ((srange range))
12571 ;; Go past all legal elements.
12572 (while (and (cdr srange)
12573 (<= (or (and (atom (car (cdr srange)))
12574 (car (cdr srange)))
12575 (car (car (cdr srange)))) (cdr active)))
12576 (setq srange (cdr srange)))
12578 ;; Nuke all remaining illegal elements.
12579 (setcdr srange nil))
12581 ;; Adjust the final element.
12582 (if (and (not (atom (car srange)))
12583 (> (cdr (car srange)) (cdr active)))
12584 (setcdr (car srange) (cdr active))))
12585 ;; Compute the number of unread articles.
12587 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12588 (cdr (car range))))
12589 (or (and (atom (car range)) (car range))
12590 (car (car range))))))
12591 (setq range (cdr range)))
12592 (setq num (max 0 (- (cdr active) num)))))
12595 (and (assq 'tick marked)
12596 (inline (gnus-remove-illegal-marked-articles
12597 (assq 'tick marked) (nth 2 info))))
12598 (and (assq 'dormant marked)
12599 (inline (gnus-remove-illegal-marked-articles
12600 (assq 'dormant marked) (nth 2 info))))
12602 (gnus-gethash (car info) gnus-newsrc-hashtb)
12603 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12604 (length (cdr (assq 'dormant marked)))))))))
12607 (defun gnus-remove-illegal-marked-articles (marked ranges)
12608 (let ((m (cdr marked)))
12609 ;; Make sure that all ticked articles are a subset of the unread
12612 (if (gnus-member-of-range (car m) ranges)
12613 (setcdr marked (cdr m))
12615 (setq m (cdr m)))))
12617 (defun gnus-activate-group (group)
12618 ;; Check whether a group has been activated or not.
12619 (let ((method (gnus-find-method-for-group group))
12621 (and (gnus-check-server method)
12622 ;; We escape all bugs and quits here to make it possible to
12623 ;; continue if a group is so out-there that it reports bugs
12626 (gnus-request-group group)
12630 (set-buffer nntp-server-buffer)
12631 (goto-char (point-min))
12632 ;; Parse the result we got from `gnus-request-group'.
12633 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12635 (goto-char (match-beginning 1))
12637 group (setq active (cons (read (current-buffer))
12638 (read (current-buffer))))
12639 gnus-active-hashtb))
12640 ;; Return the new active info.
12643 (defun gnus-update-read-articles
12644 (group unread unselected ticked &optional domarks replied expirable killed
12645 dormant bookmark score)
12646 "Update the list of read and ticked articles in GROUP using the
12647 UNREAD and TICKED lists.
12648 Note: UNSELECTED has to be sorted over `<'.
12649 Returns whether the updating was successful."
12650 (let* ((active (or gnus-newsgroup-active
12651 (gnus-gethash group gnus-active-hashtb)))
12652 (entry (gnus-gethash group gnus-newsrc-hashtb))
12653 (info (nth 2 entry))
12654 (marked (nth 3 info))
12656 (unread (sort (copy-sequence unread) (function <)))
12658 (if (or (not info) (not active))
12659 ;; There is no info on this group if it was, in fact,
12660 ;; killed. Gnus stores no information on killed groups, so
12661 ;; there's nothing to be done.
12662 ;; One could store the information somewhere temporarily,
12663 ;; perhaps... Hmmm...
12665 ;; Remove any negative articles numbers.
12666 (while (and unread (< (car unread) 0))
12667 (setq unread (cdr unread)))
12668 ;; Remove any expired article numbers
12669 (while (and unread (< (car unread) (car active)))
12670 (setq unread (cdr unread)))
12671 (while (and ticked (< (car ticked) (car active)))
12672 (setq ticked (cdr ticked)))
12673 (while (and dormant (< (car dormant) (car active)))
12674 (setq dormant (cdr dormant)))
12675 (setq unread (sort (append unselected unread) '<))
12676 ;; Compute the ranges of read articles by looking at the list of
12677 ;; unread articles.
12679 (if (/= (car unread) prev)
12680 (setq read (cons (if (= prev (1- (car unread))) prev
12681 (cons prev (1- (car unread)))) read)))
12682 (setq prev (1+ (car unread)))
12683 (setq unread (cdr unread)))
12684 (if (<= prev (cdr active))
12685 (setq read (cons (cons prev (cdr active)) read)))
12686 ;; Enter this list into the group info.
12687 (setcar (cdr (cdr info))
12688 (if (> (length read) 1) (nreverse read) read))
12689 ;; Enter the list of ticked articles.
12690 (gnus-set-marked-articles
12692 (if domarks replied (cdr (assq 'reply marked)))
12693 (if domarks expirable (cdr (assq 'expire marked)))
12694 (if domarks killed (cdr (assq 'killed marked)))
12695 (if domarks dormant (cdr (assq 'dormant marked)))
12696 (if domarks bookmark (cdr (assq 'bookmark marked)))
12697 (if domarks score (cdr (assq 'score marked))))
12698 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12699 (gnus-get-unread-articles-in-group
12700 info (gnus-gethash group gnus-active-hashtb))
12703 (defun gnus-make-articles-unread (group articles)
12704 "Mark ARTICLES in GROUP as unread."
12705 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12706 (gnus-gethash (gnus-group-real-name group)
12707 gnus-newsrc-hashtb))))
12708 (ranges (nth 2 info))
12711 (and (gnus-member-of-range (car articles) ranges)
12712 (setq news (cons (car articles) news)))
12713 (setq articles (cdr articles)))
12716 (setcar (nthcdr 2 info)
12717 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12718 (gnus-group-update-group group t))))
12720 ;; Enter all dead groups into the hashtb.
12721 (defun gnus-update-active-hashtb-from-killed ()
12722 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
12723 (lists (list gnus-killed-list gnus-zombie-list))
12726 (setq killed (car lists))
12728 (gnus-sethash (car killed) nil hashtb)
12729 (setq killed (cdr killed)))
12730 (setq lists (cdr lists)))))
12732 ;; Get the active file(s) from the backend(s).
12733 (defun gnus-read-active-file ()
12734 (gnus-group-set-mode-line)
12735 (let ((methods (if (gnus-check-server gnus-select-method)
12736 ;; The native server is available.
12737 (cons gnus-select-method gnus-secondary-select-methods)
12738 ;; The native server is down, so we just do the
12740 gnus-secondary-select-methods))
12742 (setq gnus-have-read-active-file nil)
12744 (set-buffer nntp-server-buffer)
12746 (let* ((method (gnus-server-get-method nil (car methods)))
12747 (where (nth 1 method))
12748 (mesg (format "Reading active file%s via %s..."
12749 (if (and where (not (zerop (length where))))
12750 (concat " from " where) "")
12752 (gnus-message 5 mesg)
12753 (gnus-check-server method)
12755 ((and (eq gnus-read-active-file 'some)
12756 (gnus-check-backend-function 'retrieve-groups (car method)))
12757 (let ((newsrc (cdr gnus-newsrc-alist))
12758 (gmethod (gnus-server-get-method nil method))
12761 (and (gnus-server-equal
12762 (gnus-find-method-for-group
12763 (car (car newsrc)) (car newsrc))
12765 (setq groups (cons (gnus-group-real-name
12766 (car (car newsrc))) groups)))
12767 (setq newsrc (cdr newsrc)))
12768 (gnus-check-server method)
12769 (setq list-type (gnus-retrieve-groups groups method))
12770 (cond ((not list-type)
12772 1 "Cannot read partial active file from %s server."
12776 ((eq list-type 'active)
12777 (gnus-active-to-gnus-format method gnus-active-hashtb))
12779 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
12781 (if (not (gnus-request-list method))
12783 (gnus-message 1 "Cannot read active file from %s server."
12786 (gnus-active-to-gnus-format method)
12787 ;; We mark this active file as read.
12788 (setq gnus-have-read-active-file
12789 (cons method gnus-have-read-active-file))
12790 (gnus-message 5 "%sdone" mesg)))))
12791 (setq methods (cdr methods))))))
12793 ;; Read an active file and place the results in `gnus-active-hashtb'.
12794 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12795 (let ((cur (current-buffer))
12797 (if (and gnus-active-hashtb
12798 (not (equal method gnus-select-method)))
12800 (setq gnus-active-hashtb
12801 (if (equal method gnus-select-method)
12802 (gnus-make-hashtable
12803 (count-lines (point-min) (point-max)))
12804 (gnus-make-hashtable 4096))))))
12805 (flag-hashtb (gnus-make-hashtable 60)))
12806 ;; Delete unnecessary lines.
12807 (goto-char (point-min))
12808 (while (search-forward "\nto." nil t)
12809 (delete-region (1+ (match-beginning 0))
12810 (progn (forward-line 1) (point))))
12811 (or (string= gnus-ignored-newsgroups "")
12813 (goto-char (point-min))
12814 (delete-matching-lines gnus-ignored-newsgroups)))
12815 ;; Make the group names readable as a lisp expression even if they
12816 ;; contain special characters.
12817 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
12818 (goto-char (point-max))
12819 (while (re-search-backward "[][';?()#]" nil t)
12821 ;; If these are groups from a foreign select method, we insert the
12822 ;; group prefix in front of the group names.
12823 (and method (not (gnus-server-equal
12824 (gnus-server-get-method nil method)
12825 (gnus-server-get-method nil gnus-select-method)))
12826 (let ((prefix (gnus-group-prefixed-name "" method)))
12827 (goto-char (point-min))
12828 (while (and (not (eobp))
12829 (progn (insert prefix)
12830 (zerop (forward-line 1)))))))
12831 ;; Store the active file in a hash table.
12832 (goto-char (point-min))
12833 (if (string-match "%[oO]" gnus-group-line-format)
12834 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12835 ;; If we want information on moderated groups, we use this
12837 (let* ((mod-hashtb (make-vector 7 0))
12838 (m (intern "m" mod-hashtb))
12840 (while (not (eobp))
12841 (condition-case nil
12843 (narrow-to-region (point) (gnus-point-at-eol))
12844 (setq group (let ((obarray hashtb)) (read cur)))
12845 (if (and (numberp (setq max (read cur)))
12846 (numberp (setq min (read cur)))
12848 (skip-chars-forward " \t")
12850 (or (= (following-char) ?=)
12851 (= (following-char) ?x)
12852 (= (following-char) ?j)))))
12853 (set group (cons min max))
12855 ;; Enter moderated groups into a list.
12856 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12857 (setq gnus-moderated-list
12858 (cons (symbol-name group) gnus-moderated-list))))
12860 (and (symbolp group)
12864 ;; And if we do not care about moderation, we use this loop,
12865 ;; which is faster.
12866 (let (group max min)
12867 (while (not (eobp))
12870 (narrow-to-region (point) (gnus-point-at-eol))
12871 ;; group gets set to a symbol interned in the hash table
12872 ;; (what a hack!!) - jwz
12873 (setq group (let ((obarray hashtb)) (read cur)))
12874 (if (and (numberp (setq max (read cur)))
12875 (numberp (setq min (read cur)))
12877 (skip-chars-forward " \t")
12879 (or (= (following-char) ?=)
12880 (= (following-char) ?x)
12881 (= (following-char) ?j)))))
12882 (set group (cons min max))
12886 (and (symbolp group)
12890 (gnus-message 3 "Warning - illegal active: %s"
12892 (gnus-point-at-bol) (gnus-point-at-eol)))
12895 (forward-line 1))))))
12897 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12898 ;; Parse a "groups" active file.
12899 (let ((cur (current-buffer))
12901 (if (and method gnus-active-hashtb)
12903 (setq gnus-active-hashtb
12904 (gnus-make-hashtable
12905 (count-lines (point-min) (point-max)))))))
12906 (prefix (and method (not (eq method gnus-select-method))
12907 (gnus-group-prefixed-name "" method))))
12909 (goto-char (point-min))
12910 ;; We split this into to separate loops, one with the prefix
12911 ;; and one without to speed the reading up somewhat.
12913 (let (min max opoint group)
12914 (while (not (eobp))
12917 (read cur) (read cur)
12918 (setq min (read cur)
12921 (skip-chars-forward " \t")
12924 (set (let ((obarray hashtb)) (read cur))
12926 (error (if group (set group nil))))
12928 (let (min max group)
12929 (while (not (eobp))
12931 (if (= (following-char) ?2)
12933 (read cur) (read cur)
12934 (setq min (read cur)
12936 (set (setq group (let ((obarray hashtb)) (read cur)))
12938 (error (if group (set group nil))))
12939 (forward-line 1))))))
12941 (defun gnus-read-newsrc-file (&optional force)
12942 "Read startup file.
12943 If FORCE is non-nil, the .newsrc file is read."
12944 ;; Reset variables that might be defined in the .newsrc.eld file.
12945 (let ((variables gnus-variable-list))
12947 (set (car variables) nil)
12948 (setq variables (cdr variables))))
12949 (let* ((newsrc-file gnus-current-startup-file)
12950 (quick-file (concat newsrc-file ".el")))
12952 ;; We always load the .newsrc.eld file. If always contains
12953 ;; much information that can not be gotten from the .newsrc
12954 ;; file (ticked articles, killed groups, foreign methods, etc.)
12955 (gnus-read-newsrc-el-file quick-file)
12958 (and (file-newer-than-file-p newsrc-file quick-file)
12959 (file-newer-than-file-p newsrc-file
12960 (concat quick-file "d")))
12961 (not gnus-newsrc-alist))
12962 ;; We read the .newsrc file. Note that if there if a
12963 ;; .newsrc.eld file exists, it has already been read, and
12964 ;; the `gnus-newsrc-hashtb' has been created. While reading
12965 ;; the .newsrc file, Gnus will only use the information it
12966 ;; can find there for changing the data already read -
12967 ;; ie. reading the .newsrc file will not trash the data
12968 ;; already read (except for read articles).
12970 (gnus-message 5 "Reading %s..." newsrc-file)
12971 (set-buffer (find-file-noselect newsrc-file))
12972 (buffer-disable-undo (current-buffer))
12973 (gnus-newsrc-to-gnus-format)
12974 (kill-buffer (current-buffer))
12975 (gnus-message 5 "Reading %s...done" newsrc-file))))))
12977 (defun gnus-read-newsrc-el-file (file)
12978 (let ((ding-file (concat file "d")))
12979 ;; We always, always read the .eld file.
12980 (gnus-message 5 "Reading %s..." ding-file)
12981 (let (gnus-newsrc-assoc)
12982 (condition-case nil
12983 (load ding-file t t t)
12985 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
12986 (let ((inhibit-quit t))
12987 (gnus-uncompress-newsrc-alist))
12988 (gnus-make-hashtable-from-newsrc-alist)
12989 (if (not (file-newer-than-file-p file ding-file))
12991 ;; Old format quick file
12992 (gnus-message 5 "Reading %s..." file)
12993 ;; The .el file is newer than the .eld file, so we read that one
12995 (gnus-read-old-newsrc-el-file file))))
12997 ;; Parse the old-style quick startup file
12998 (defun gnus-read-old-newsrc-el-file (file)
12999 (let (newsrc killed marked group m)
13001 (let ((gnus-killed-assoc nil)
13002 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
13004 (condition-case nil
13007 (setq newsrc gnus-newsrc-assoc
13008 killed gnus-killed-assoc
13009 marked gnus-marked-assoc)))
13010 (setq gnus-newsrc-alist nil)
13012 (setq group (car newsrc))
13013 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13016 (setcar (nthcdr 2 info) (cdr (cdr group)))
13018 (if (nth 1 group) gnus-level-default-subscribed
13019 gnus-level-default-unsubscribed))
13020 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
13021 (setq gnus-newsrc-alist
13025 (if (nth 1 group) gnus-level-default-subscribed
13026 gnus-level-default-unsubscribed)
13027 (cdr (cdr group))))
13028 gnus-newsrc-alist)))
13029 (if (setq m (assoc (car group) marked))
13030 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
13031 (setq newsrc (cdr newsrc)))
13032 (setq newsrc killed)
13034 (setcar newsrc (car (car newsrc)))
13035 (setq newsrc (cdr newsrc)))
13036 (setq gnus-killed-list killed))
13037 ;; The .el file version of this variable does not begin with
13038 ;; "options", while the .eld version does, so we just add it if it
13041 gnus-newsrc-options
13043 (and (not (string-match "^ *options" gnus-newsrc-options))
13044 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
13045 (and (not (string-match "\n$" gnus-newsrc-options))
13046 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))))
13047 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
13048 (gnus-make-hashtable-from-newsrc-alist)))
13050 (defun gnus-make-newsrc-file (file)
13051 "Make server dependent file name by catenating FILE and server host name."
13052 (let* ((file (expand-file-name file nil))
13053 (real-file (concat file "-" (nth 1 gnus-select-method))))
13054 (if (or (file-exists-p real-file)
13055 (file-exists-p (concat real-file ".el"))
13056 (file-exists-p (concat real-file ".eld")))
13059 (defun gnus-uncompress-newsrc-alist ()
13060 ;; Uncompress all lists of marked articles in the newsrc assoc.
13061 (let ((newsrc gnus-newsrc-alist)
13064 (if (not (setq marked (nth 3 (car newsrc))))
13067 (or (eq 'score (car (car marked)))
13068 (eq 'bookmark (car (car marked)))
13069 (eq 'killed (car (car marked)))
13070 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13071 (setq marked (cdr marked))))
13072 (setq newsrc (cdr newsrc)))))
13074 (defun gnus-compress-newsrc-alist ()
13075 ;; Compress all lists of marked articles in the newsrc assoc.
13076 (let ((newsrc gnus-newsrc-alist)
13079 (if (not (setq marked (nth 3 (car newsrc))))
13082 (or (eq 'score (car (car marked)))
13083 (eq 'bookmark (car (car marked)))
13084 (eq 'killed (car (car marked)))
13085 (setcdr (car marked)
13087 (gnus-compress-sequence
13088 (sort (cdr (car marked)) '<) t)
13089 (error (cdr (car marked))))))
13090 (setq marked (cdr marked))))
13091 (setq newsrc (cdr newsrc)))))
13093 (defun gnus-newsrc-to-gnus-format ()
13094 (setq gnus-newsrc-options "")
13095 (setq gnus-newsrc-options-n nil)
13097 (or gnus-active-hashtb
13098 (setq gnus-active-hashtb (make-vector 4095 0)))
13099 (let ((buf (current-buffer))
13100 (already-read (> (length gnus-newsrc-alist) 1))
13101 group subscribed options-symbol newsrc Options-symbol
13103 (goto-char (point-min))
13104 ;; We intern the symbol `options' in the active hashtb so that we
13105 ;; can `eq' against it later.
13106 (setq options-symbol (intern "options" gnus-active-hashtb))
13107 (setq Options-symbol (intern "Options" gnus-active-hashtb))
13109 (while (not (eobp))
13110 ;; We first read the first word on the line by narrowing and
13111 ;; then reading into `gnus-active-hashtb'. Most groups will
13112 ;; already exist in that hashtb, so this will save some string
13116 (progn (skip-chars-forward "^ \t!:\n") (point)))
13117 (goto-char (point-min))
13119 (and (/= (point-min) (point-max))
13120 (let ((obarray gnus-active-hashtb)) (read buf))))
13122 ;; Now, the symbol we have read is either `options' or a group
13123 ;; name. If it is an options line, we just add it to a string.
13125 ((or (eq symbol options-symbol)
13126 (eq symbol Options-symbol))
13127 (setq gnus-newsrc-options
13128 ;; This concatting is quite inefficient, but since our
13129 ;; thorough studies show that approx 99.37% of all
13130 ;; .newsrc files only contain a single options line, we
13131 ;; don't give a damn, frankly, my dear.
13132 (concat gnus-newsrc-options
13134 (gnus-point-at-bol)
13135 ;; Options may continue on the next line.
13136 (or (and (re-search-forward "^[^ \t]" nil 'move)
13137 (progn (beginning-of-line) (point)))
13140 ;; It was a group name.
13141 (setq subscribed (= (following-char) ?:)
13142 group (symbol-name symbol)
13145 ;; If the line ends here, this is clearly a buggy line, so
13146 ;; we put point a the beginning of line and let the cond
13147 ;; below do the error handling.
13148 (beginning-of-line)
13149 ;; We skip to the beginning of the ranges.
13150 (skip-chars-forward "!: \t"))
13151 ;; We are now at the beginning of the list of read articles.
13152 ;; We read them range by range.
13155 ((looking-at "[0-9]+")
13156 ;; We narrow and read a number instead of buffer-substring/
13157 ;; string-to-int because it's faster. narrow/widen is
13158 ;; faster than save-restriction/narrow, and save-restriction
13159 ;; produces a garbage object.
13161 (narrow-to-region (match-beginning 0) (match-end 0))
13164 ;; If the next character is a dash, then this is a range.
13165 (if (= (following-char) ?-)
13167 ;; We read the upper bound of the range.
13169 (if (not (looking-at "[0-9]+"))
13170 ;; This is a buggy line, by we pretend that
13171 ;; it's kinda OK. Perhaps the user should be
13173 (setq reads (cons num1 reads))
13177 (narrow-to-region (match-beginning 0)
13182 ;; It was just a simple number, so we add it to the
13184 (setq reads (cons num1 reads)))
13185 ;; If the next char in ?\n, then we have reached the end
13186 ;; of the line and return nil.
13187 (/= (following-char) ?\n))
13188 ((= (following-char) ?\n)
13189 ;; End of line, so we end.
13192 ;; Not numbers and not eol, so this might be a buggy
13194 (or (eobp) ; If it was eob instead of ?\n, we allow it.
13196 ;; The line was buggy.
13198 (gnus-message 3 "Mangled line: %s"
13199 (buffer-substring (gnus-point-at-bol)
13200 (gnus-point-at-eol)))
13204 ;; Skip past ", ". Spaces are illegal in these ranges, but
13205 ;; we allow them, because it's a common mistake to put a
13206 ;; space after the comma.
13207 (skip-chars-forward ", "))
13209 ;; We have already read .newsrc.eld, so we gently update the
13210 ;; data in the hash table with the information we have just
13214 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
13217 ;; There is an entry for this file in the alist.
13219 (setcar (nthcdr 2 info) (nreverse reads))
13220 ;; We update the level very gently. In fact, we
13221 ;; only change it if there's been a status change
13222 ;; from subscribed to unsubscribed, or vice versa.
13223 (setq level (nth 1 info))
13224 (cond ((and (<= level gnus-level-subscribed)
13226 (setq level (if reads
13227 gnus-level-default-unsubscribed
13228 (1+ gnus-level-default-unsubscribed))))
13229 ((and (> level gnus-level-subscribed) subscribed)
13230 (setq level gnus-level-default-subscribed)))
13231 (setcar (cdr info) level))
13232 ;; This is a new group.
13233 (setq info (list group
13235 gnus-level-default-subscribed
13237 (1+ gnus-level-subscribed)
13238 gnus-level-default-unsubscribed))
13239 (nreverse reads))))
13240 (setq newsrc (cons info newsrc))))))
13243 (setq newsrc (nreverse newsrc))
13245 (if (not already-read)
13247 ;; We now have two newsrc lists - `newsrc', which is what we
13248 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13249 ;; what we've read from .newsrc.eld. We have to merge these
13250 ;; lists. We do this by "attaching" any (foreign) groups in the
13251 ;; gnus-newsrc-alist to the (native) group that precedes them.
13252 (let ((rc (cdr gnus-newsrc-alist))
13253 (prev gnus-newsrc-alist)
13256 (or (null (nth 4 (car rc))) ; It's a native group.
13257 (assoc (car (car rc)) newsrc) ; It's already in the alist.
13258 (if (setq entry (assoc (car (car prev)) newsrc))
13259 (setcdr (setq mentry (memq entry newsrc))
13260 (cons (car rc) (cdr mentry)))
13261 (setq newsrc (cons (car rc) newsrc))))
13265 (setq gnus-newsrc-alist newsrc)
13266 ;; We make the newsrc hashtb.
13267 (gnus-make-hashtable-from-newsrc-alist)
13269 ;; Finally, if we read some options lines, we parse them.
13270 (or (string= gnus-newsrc-options "")
13271 (gnus-newsrc-parse-options gnus-newsrc-options))))
13273 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13274 ;; The return value will be a list on the form
13275 ;; ((regexp1 . ignore)
13276 ;; (regexp2 . subscribe)...)
13277 ;; When handling new newsgroups, groups that match a `ignore' regexp
13278 ;; will be ignored, and groups that match a `subscribe' regexp will be
13279 ;; subscribed. A line like
13280 ;; options -n !all rec.all
13281 ;; will lead to a list that looks like
13282 ;; (("^rec\\..+" . subscribe)
13283 ;; ("^.+" . ignore))
13284 ;; So all "rec.*" groups will be subscribed, while all the other
13285 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13286 ;; different from "options -n rec.all !all".
13287 (defun gnus-newsrc-parse-options (options)
13290 (gnus-set-work-buffer)
13291 (insert (regexp-quote options))
13292 ;; First we treat all continuation lines.
13293 (goto-char (point-min))
13294 (while (re-search-forward "\n[ \t]+" nil t)
13295 (replace-match " " t t))
13296 ;; Then we transform all "all"s into ".+"s.
13297 (goto-char (point-min))
13298 (while (re-search-forward "\\ball\\b" nil t)
13299 (replace-match ".+" t t))
13300 (goto-char (point-min))
13301 ;; We remove all other options than the "-n" ones.
13302 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
13303 (replace-match " ")
13305 (goto-char (point-min))
13307 ;; We are only interested in "options -n" lines - we
13308 ;; ignore the other option lines.
13309 (while (re-search-forward "[ \t]-n" nil t)
13311 (or (save-excursion
13312 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
13314 (gnus-point-at-eol)))
13315 ;; Search for all "words"...
13316 (while (re-search-forward "[^ \t,\n]+" eol t)
13317 (if (= (char-after (match-beginning 0)) ?!)
13318 ;; If the word begins with a bang (!), this is a "not"
13319 ;; spec. We put this spec (minus the bang) and the
13320 ;; symbol `ignore' into the list.
13321 (setq out (cons (cons (concat
13322 "^" (buffer-substring
13323 (1+ (match-beginning 0))
13326 ;; There was no bang, so this is a "yes" spec.
13327 (setq out (cons (cons (concat
13328 "^" (buffer-substring (match-beginning 0)
13330 'subscribe) out)))))
13332 (setq gnus-newsrc-options-n out))))
13335 (defun gnus-save-newsrc-file ()
13336 "Save .newsrc file."
13337 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13338 ;; from the variable gnus-newsrc-alist.
13339 (and (or gnus-newsrc-alist gnus-killed-list)
13340 gnus-current-startup-file
13342 (run-hooks 'gnus-save-newsrc-hook)
13344 (if (and gnus-use-dribble-file
13345 (or (not gnus-dribble-buffer)
13346 (not (buffer-name gnus-dribble-buffer))
13347 (zerop (save-excursion
13348 (set-buffer gnus-dribble-buffer)
13350 (gnus-message 4 "(No changes need to be saved)")
13351 (if gnus-save-newsrc-file
13353 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
13354 ;; Make backup file of master newsrc.
13355 (gnus-gnus-to-newsrc-format)
13356 (gnus-message 5 "Saving %s...done"
13357 gnus-current-startup-file)))
13358 ;; Quickly loadable .newsrc.
13359 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13360 (set-visited-file-name (concat gnus-current-startup-file ".eld"))
13361 (gnus-add-current-to-buffer-list)
13362 (buffer-disable-undo (current-buffer))
13364 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
13365 (gnus-gnus-to-quick-newsrc-format)
13367 (kill-buffer (current-buffer))
13368 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
13369 (gnus-dribble-delete-file))))))
13371 (defun gnus-gnus-to-quick-newsrc-format ()
13372 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13373 (insert ";; (ding) Gnus startup file.\n")
13374 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13375 (insert ";; to read .newsrc.\n")
13376 (insert "(setq gnus-newsrc-file-version "
13377 (prin1-to-string gnus-version) ")\n")
13378 (let ((variables gnus-variable-list)
13380 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
13382 ;; insert lisp expressions.
13383 (gnus-compress-newsrc-alist)
13385 (setq variable (car variables))
13386 (and (boundp variable)
13387 (symbol-value variable)
13388 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13389 (insert "(setq " (symbol-name variable) " '"
13390 (prin1-to-string (symbol-value variable))
13392 (setq variables (cdr variables)))
13393 (gnus-uncompress-newsrc-alist)))
13396 (defun gnus-gnus-to-newsrc-format ()
13397 ;; Generate and save the .newsrc file.
13398 (let ((newsrc (cdr gnus-newsrc-alist))
13401 (set-buffer (create-file-buffer gnus-current-startup-file))
13402 (set-visited-file-name gnus-current-startup-file)
13403 (buffer-disable-undo (current-buffer))
13406 (if gnus-newsrc-options (insert gnus-newsrc-options))
13407 ;; Write subscribed and unsubscribed.
13409 (setq info (car newsrc))
13410 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13412 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13414 (if (setq ranges (nth 2 info))
13417 (if (not (listp (cdr ranges)))
13418 (if (= (car ranges) (cdr ranges))
13419 (insert (int-to-string (car ranges)))
13420 (insert (int-to-string (car ranges)) "-"
13421 (int-to-string (cdr ranges))))
13423 (setq range (car ranges)
13424 ranges (cdr ranges))
13425 (if (or (atom range) (= (car range) (cdr range)))
13426 (insert (int-to-string
13427 (or (and (atom range) range)
13429 (insert (int-to-string (car range)) "-"
13430 (int-to-string (cdr range))))
13431 (if ranges (insert ","))))))
13433 (setq newsrc (cdr newsrc)))
13435 (kill-buffer (current-buffer)))))
13437 (defun gnus-read-all-descriptions-files ()
13438 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13440 (gnus-read-descriptions-file (car methods))
13441 (setq methods (cdr methods)))
13444 (defun gnus-read-descriptions-file (&optional method)
13445 (let ((method (or method gnus-select-method)))
13446 ;; We create the hashtable whether we manage to read the desc file
13447 ;; to avoid trying to re-read after a failed read.
13448 (or gnus-description-hashtb
13449 (setq gnus-description-hashtb
13450 (gnus-make-hashtable (length gnus-active-hashtb))))
13451 ;; Mark this method's desc file as read.
13452 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
13453 gnus-description-hashtb)
13455 (gnus-message 5 "Reading descriptions file via %s..." (car method))
13457 ((not (gnus-check-server method))
13458 (gnus-message 1 "Couldn't open server")
13460 ((not (gnus-request-list-newsgroups method))
13461 (gnus-message 1 "Couldn't read newsgroups descriptions")
13467 (set-buffer nntp-server-buffer)
13468 (goto-char (point-min))
13469 (if (or (search-forward "\n.\n" nil t)
13470 (goto-char (point-max)))
13472 (beginning-of-line)
13473 (narrow-to-region (point-min) (point))))
13474 (goto-char (point-min))
13475 (while (not (eobp))
13476 ;; If we get an error, we set group to 0, which is not a
13480 (let ((obarray gnus-description-hashtb))
13481 ;; Group is set to a symbol interned in this
13483 (read nntp-server-buffer))
13485 (skip-chars-forward " \t")
13486 ;; ... which leads to this line being effectively ignored.
13487 (and (symbolp group)
13488 (set group (buffer-substring
13489 (point) (progn (end-of-line) (point)))))
13490 (forward-line 1))))
13491 (gnus-message 5 "Reading descriptions file...done")
13494 (defun gnus-group-get-description (group)
13495 ;; Get the description of a group by sending XGTITLE to the server.
13496 (and (gnus-request-group-description group)
13498 (set-buffer nntp-server-buffer)
13499 (goto-char (point-min))
13500 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13501 (buffer-substring (match-beginning 1) (match-end 1))))))
13507 (defvar gnus-server-mode-hook nil
13508 "Hook run in `gnus-server-mode' buffers.")
13510 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13511 "Format of server lines.
13512 It works along the same lines as a normal formatting string,
13513 with some simple extensions.")
13515 (defvar gnus-server-mode-line-format "(ding) List of servers"
13516 "The format specification for the server mode line.")
13518 (defconst gnus-server-line-format-alist
13519 (list (list ?h 'how ?s)
13521 (list ?w 'where ?s)
13524 (defconst gnus-server-mode-line-format-alist
13525 (list (list ?S 'news-server ?s)
13526 (list ?M 'news-method ?s)
13527 (list ?u 'user-defined ?s)))
13529 (defvar gnus-server-line-format-spec nil)
13530 (defvar gnus-server-mode-line-format-spec nil)
13531 (defvar gnus-server-killed-servers nil)
13533 (defvar gnus-server-mode-map nil)
13534 (put 'gnus-server-mode 'mode-class 'special)
13536 (if gnus-server-mode-map
13538 (setq gnus-server-mode-map (make-sparse-keymap))
13539 (suppress-keymap gnus-server-mode-map)
13540 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13541 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
13542 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
13543 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13544 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13545 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13546 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13547 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13548 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13549 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13551 (defun gnus-server-mode ()
13552 "Major mode for listing and editing servers.
13554 All normal editing commands are switched off.
13555 \\<gnus-server-mode-map>
13557 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13559 The following commands are available:
13561 \\{gnus-server-mode-map}"
13563 (if gnus-visual (gnus-server-make-menu-bar))
13564 (kill-all-local-variables)
13565 (setq mode-line-modified "-- ")
13566 (make-local-variable 'mode-line-format)
13567 (setq mode-line-format (copy-sequence mode-line-format))
13568 (and (equal (nth 3 mode-line-format) " ")
13569 (setcar (nthcdr 3 mode-line-format) ""))
13570 (setq major-mode 'gnus-server-mode)
13571 (setq mode-name "Server")
13572 ; (gnus-group-set-mode-line)
13573 (setq mode-line-process nil)
13574 (use-local-map gnus-server-mode-map)
13575 (buffer-disable-undo (current-buffer))
13576 (setq truncate-lines t)
13577 (setq buffer-read-only t)
13578 (run-hooks 'gnus-server-mode-hook))
13580 (defun gnus-server-insert-server-line (sformat name method)
13581 (let* ((sformat (or sformat gnus-server-line-format-spec))
13583 (where (nth 1 method))
13585 (beginning-of-line)
13587 ;; Insert the text.
13588 (insert (eval sformat))
13589 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
13591 (defun gnus-server-setup-buffer ()
13592 (if (get-buffer gnus-server-buffer)
13595 (set-buffer (get-buffer-create gnus-server-buffer))
13597 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
13599 (defun gnus-server-prepare ()
13600 (setq gnus-server-mode-line-format-spec
13601 (gnus-parse-format gnus-server-mode-line-format
13602 gnus-server-mode-line-format-alist))
13603 (setq gnus-server-line-format-spec
13604 (gnus-parse-format gnus-server-line-format
13605 gnus-server-line-format-alist))
13606 (let ((alist gnus-server-alist)
13607 (buffer-read-only nil))
13610 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13611 (setq alist (cdr alist))))
13612 (goto-char (point-min))
13613 (gnus-server-position-cursor))
13615 (defun gnus-server-server-name ()
13616 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
13617 (and server (symbol-name server))))
13619 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13621 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13623 (defun gnus-server-update-server (server)
13625 (set-buffer gnus-server-buffer)
13626 (let ((buffer-read-only nil)
13627 (info (cdr (assoc server gnus-server-alist))))
13628 (gnus-dribble-enter
13629 (concat "(gnus-server-set-info \"" server "\" '"
13630 (prin1-to-string info) ")"))
13631 ;; Buffer may be narrowed.
13634 (if (gnus-server-goto-server server)
13635 (delete-region (progn (beginning-of-line) (point))
13636 (progn (forward-line 1) (point))))
13637 (let ((entry (assoc server gnus-server-alist)))
13638 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13639 (gnus-server-position-cursor))))))
13641 (defun gnus-server-set-info (server info)
13642 ;; Enter a select method into the virtual server alist.
13643 (gnus-dribble-enter
13644 (concat "(gnus-server-set-info \"" server "\" '"
13645 (prin1-to-string info) ")"))
13646 (let* ((server (nth 1 info))
13647 (entry (assoc server gnus-server-alist)))
13648 (if entry (setcdr entry info)
13649 (setq gnus-server-alist
13650 (nconc gnus-server-alist (list (cons server info)))))))
13652 (defun gnus-server-to-method (server)
13653 ;; Map virtual server names to select methods.
13654 (or (and (equal server "native") gnus-select-method)
13655 (cdr (assoc server gnus-server-alist))))
13657 (defun gnus-server-extend-method (group method)
13658 ;; This function "extends" a virtual server. If the server is
13659 ;; "hello", and the select method is ("hello" (my-var "something"))
13660 ;; in the group "alt.alt", this will result in a new virtual server
13661 ;; called "helly+alt.alt".
13663 (gnus-copy-sequence
13664 (if (equal (car method) "native") gnus-select-method
13665 (cdr (assoc (car method) gnus-server-alist))))))
13666 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13667 (nconc entry (cdr method))))
13669 (defun gnus-server-get-method (group method)
13670 ;; Input either a server name, and extended server name, or a
13671 ;; select method, and return a select method.
13672 (cond ((stringp method)
13673 (gnus-server-to-method method))
13674 ((and (stringp (car method)) group)
13675 (gnus-server-extend-method group method))
13677 (gnus-server-add-address method))))
13679 (defun gnus-server-add-address (method)
13680 (let ((method-name (symbol-name (car method))))
13681 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13682 (not (assq (intern (concat method-name "-address")) method)))
13683 (append method (list (list (intern (concat method-name "-address"))
13687 (defun gnus-server-equal (s1 s2)
13689 (and (= (length s1) (length s2))
13691 (while (and s1 (member (car s1) s2))
13692 (setq s1 (cdr s1)))
13695 ;;; Interactive server functions.
13697 (defun gnus-server-kill-server (server)
13698 "Kill the server on the current line."
13699 (interactive (list (gnus-server-server-name)))
13700 (or (gnus-server-goto-server server)
13701 (if server (error "No such server: %s" server)
13702 (error "No server on the current line")))
13703 (let ((buffer-read-only nil))
13704 (delete-region (progn (beginning-of-line) (point))
13705 (progn (forward-line 1) (point))))
13706 (setq gnus-server-killed-servers
13707 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13708 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13709 gnus-server-alist))
13710 (gnus-server-position-cursor))
13712 (defun gnus-server-yank-server ()
13713 "Yank the previously killed server."
13715 (or gnus-server-killed-servers
13716 (error "No killed servers to be yanked"))
13717 (let ((alist gnus-server-alist)
13718 (server (gnus-server-server-name))
13719 (killed (car gnus-server-killed-servers)))
13721 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13722 (if (string= server (car (car gnus-server-alist)))
13723 (setq gnus-server-alist (cons killed gnus-server-alist))
13724 (while (and (cdr alist)
13725 (not (string= server (car (car (cdr alist))))))
13726 (setq alist (cdr alist)))
13727 (setcdr alist (cons killed (cdr alist)))))
13728 (gnus-server-update-server (car killed))
13729 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13730 (gnus-server-position-cursor)))
13732 (defun gnus-server-exit ()
13733 "Return to the group buffer."
13735 (kill-buffer (current-buffer))
13736 (switch-to-buffer gnus-group-buffer))
13738 (defun gnus-server-list-servers ()
13739 "List all available servers."
13741 (let ((cur (gnus-server-server-name)))
13742 (gnus-server-prepare)
13743 (if cur (gnus-server-goto-server cur)
13744 (goto-char (point-max))
13746 (gnus-server-position-cursor)))
13748 (defun gnus-server-copy-server (from to)
13751 (or (gnus-server-server-name)
13752 (error "No server on the current line"))
13753 (read-string "Copy to: ")))
13754 (or from (error "No server on current line"))
13755 (or (and to (not (string= to ""))) (error "No name to copy to"))
13756 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13757 (or (assoc from gnus-server-alist)
13758 (error "%s: no such server" from))
13759 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13760 (setcar to-entry to)
13761 (setcar (nthcdr 2 to-entry) to)
13762 (setq gnus-server-killed-servers
13763 (cons to-entry gnus-server-killed-servers))
13764 (gnus-server-yank-server)))
13766 (defun gnus-server-add-server (how where)
13768 (list (intern (completing-read "Server method: "
13769 gnus-valid-select-methods nil t))
13770 (read-string "Server name: ")))
13771 (setq gnus-server-killed-servers
13772 (cons (list where how where) gnus-server-killed-servers))
13773 (gnus-server-yank-server))
13775 (defun gnus-server-goto-server (server)
13776 "Jump to a server line."
13778 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13779 (let ((to (text-property-any (point-min) (point-max)
13780 'gnus-server (intern server))))
13784 (gnus-server-position-cursor)))))
13786 (defun gnus-server-edit-server (server)
13787 "Edit the server on the current line."
13788 (interactive (list (gnus-server-server-name)))
13790 (error "No server on current line"))
13791 (let ((winconf (current-window-configuration)))
13792 (get-buffer-create gnus-server-edit-buffer)
13793 (gnus-configure-windows 'edit-server)
13794 (gnus-add-current-to-buffer-list)
13796 (make-local-variable 'gnus-prev-winconf)
13797 (setq gnus-prev-winconf winconf)
13798 (use-local-map (copy-keymap (current-local-map)))
13799 (let ((done-func '(lambda ()
13800 "Exit editing mode and update the information."
13802 (gnus-server-edit-server-done 'group))))
13803 (setcar (cdr (nth 4 done-func)) server)
13804 (local-set-key "\C-c\C-c" done-func))
13806 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13807 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13809 (defun gnus-server-edit-server-done (server)
13811 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13812 (goto-char (point-min))
13813 (let ((form (read (current-buffer)))
13814 (winconf gnus-prev-winconf))
13815 (gnus-server-set-info server form)
13816 (kill-buffer (current-buffer))
13817 (and winconf (set-window-configuration winconf))
13818 (set-buffer gnus-server-buffer)
13819 (gnus-server-update-server (gnus-server-server-name))
13820 (gnus-server-position-cursor)))
13822 (defun gnus-server-read-server (server)
13824 (interactive (list (gnus-server-server-name)))
13825 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13827 (defun gnus-mouse-pick-server (e)
13829 (mouse-set-point e)
13830 (gnus-server-read-server (gnus-server-server-name)))
13833 ;;; entry points into gnus-score.el
13836 ;;; Finding score files.
13838 (defvar gnus-global-score-files nil
13839 "*List of global score files and directories.
13840 Set this variable if you want to use people's score files. One entry
13841 for each score file or each score file directory. Gnus will decide
13842 by itself what score files are applicable to which group.
13844 Say you want to use the single score file
13845 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13846 score files in the \"/ftp.some-where:/pub/score\" directory.
13848 (setq gnus-global-score-files
13849 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13850 \"/ftp.some-where:/pub/score\"))")
13852 (defun gnus-score-score-files (group)
13853 "Return a list of all possible score files."
13854 ;; Search and set any global score files.
13855 (and gnus-global-score-files
13856 (or gnus-internal-global-score-files
13857 (gnus-score-search-global-directories gnus-global-score-files)))
13858 ;; Fix the kill-file dir variable.
13859 (setq gnus-kill-files-directory
13860 (file-name-as-directory
13861 (or gnus-kill-files-directory "~/News/")))
13862 ;; If we can't read it, there are no score files.
13863 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13864 (setq gnus-score-file-list nil)
13865 (if (gnus-use-long-file-name 'not-score)
13866 ;; We want long file names.
13867 (if (or (not gnus-score-file-list)
13868 (not (car gnus-score-file-list))
13869 (gnus-file-newer-than gnus-kill-files-directory
13870 (car gnus-score-file-list)))
13871 (setq gnus-score-file-list
13872 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13875 gnus-kill-files-directory t
13876 (gnus-score-file-regexp))))))
13877 ;; We do not use long file names, so we have to do some
13878 ;; directory traversing.
13879 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13880 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13883 (setq dir (expand-file-name
13884 (concat gnus-kill-files-directory
13885 (gnus-replace-chars-in-string group ?. ?/))))
13886 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13887 (setq suffix (car suffixes)
13888 suffixes (cdr suffixes))
13889 (if (file-exists-p (concat dir "/" suffix))
13890 (setq files (cons (concat dir "/" suffix) files)))
13891 (while (>= (1+ (length dir)) mdir)
13892 (and (file-exists-p (concat dir "/all/" suffix))
13893 (setq files (cons (concat dir "/all/" suffix) files)))
13894 (string-match "/[^/]*$" dir)
13895 (setq dir (substring dir 0 (match-beginning 0)))))
13896 (setq gnus-score-file-list
13897 (cons nil (nreverse files)))))
13898 (cdr gnus-score-file-list)))
13900 (defun gnus-score-file-regexp ()
13901 (concat "\\(" gnus-score-file-suffix
13902 "\\|" gnus-adaptive-file-suffix "\\)$"))
13904 (defun gnus-score-find-bnews (group)
13905 "Return a list of score files for GROUP.
13906 The score files are those files in the ~/News directory which matches
13907 GROUP using BNews sys file syntax."
13908 (let* ((sfiles (append (gnus-score-score-files group)
13909 gnus-internal-global-score-files))
13910 (kill-dir (file-name-as-directory
13911 (expand-file-name gnus-kill-files-directory)))
13912 (klen (length kill-dir))
13913 ofiles not-match regexp)
13915 (set-buffer (get-buffer-create "*gnus score files*"))
13916 (buffer-disable-undo (current-buffer))
13917 ;; Go through all score file names and create regexp with them
13921 (insert (car sfiles))
13922 (goto-char (point-min))
13923 ;; First remove the suffix itself.
13924 (re-search-forward (concat "." (gnus-score-file-regexp)))
13925 (replace-match "" t t)
13926 (goto-char (point-min))
13927 (if (looking-at (regexp-quote kill-dir))
13928 ;; If the file name was just "SCORE", `klen' is one character
13930 (delete-char (min (1- (point-max)) klen))
13931 (goto-char (point-max))
13932 (search-backward "/")
13933 (delete-region (1+ (point)) (point-min)))
13934 ;; If short file names were used, we have to translate slashes.
13935 (goto-char (point-min))
13936 (while (re-search-forward "[/:]" nil t)
13937 (replace-match "." t t))
13938 ;; Translate "all" to ".*".
13939 (while (search-forward "all" nil t)
13940 (replace-match ".*" t t))
13941 (goto-char (point-min))
13942 ;; Deal with "not."s.
13943 (if (looking-at "not.")
13946 (setq regexp (buffer-substring 5 (point-max))))
13947 (setq regexp (buffer-substring 1 (point-max)))
13948 (setq not-match nil))
13949 ;; Finally - if this resulting regexp matches the group name,
13950 ;; we add this score file to the list of score files
13951 ;; applicable to this group.
13952 (if (or (and not-match
13953 (not (string-match regexp group)))
13954 (and (not not-match)
13955 (string-match regexp group)))
13956 (setq ofiles (cons (car sfiles) ofiles)))
13957 (setq sfiles (cdr sfiles)))
13958 (kill-buffer (current-buffer))
13959 ;; Slight kludge here - the last score file returned should be
13960 ;; the local score file, whether it exists or not. This is so
13961 ;; that any score commands the user enters will go to the right
13962 ;; file, and not end up in some global score file.
13965 (if (gnus-use-long-file-name 'not-score)
13966 (concat gnus-kill-files-directory group "."
13967 gnus-score-file-suffix)
13968 (concat gnus-kill-files-directory
13969 (gnus-replace-chars-in-string group ?. ?/)
13970 "/" gnus-score-file-suffix)))))
13971 (and (member localscore ofiles)
13972 (delete localscore ofiles))
13973 (setq ofiles (cons localscore ofiles)))
13974 (nreverse ofiles))))
13976 (defun gnus-score-find-single (group)
13977 "Return list containing the score file for GROUP."
13978 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
13979 (gnus-score-file-name group)))
13981 (defun gnus-score-find-hierarchical (group)
13982 "Return list of score files for GROUP.
13983 This includes the score file for the group and all its parents."
13984 (let ((all (copy-sequence '(nil)))
13986 (while (string-match "\\." group (1+ start))
13987 (setq start (match-beginning 0))
13988 (setq all (cons (substring group 0 start) all)))
13989 (setq all (cons group all))
13991 (mapcar (lambda (newsgroup)
13992 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
13993 (setq all (nreverse all)))
13994 (mapcar 'gnus-score-file-name all))))
13996 (defvar gnus-score-file-alist-cache nil)
13998 (defun gnus-score-find-alist (group)
13999 "Return list of score files for GROUP.
14000 The list is determined from the variable gnus-score-file-alist."
14001 (let ((alist gnus-score-file-multiple-match-alist)
14003 ;; if this group has been seen before, return the cached entry
14004 (if (setq score-files (assoc group gnus-score-file-alist-cache))
14005 (cdr score-files) ; ensures caching of groups with no matches
14006 ;; handle the multiple match alist
14008 (and (string-match (car (car alist)) group)
14010 (nconc score-files (copy-sequence (cdr (car alist))))))
14011 (setq alist (cdr alist)))
14012 (setq alist gnus-score-file-single-match-alist)
14013 ;; handle the single match alist
14015 (and (string-match (car (car alist)) group)
14016 ;; progn used just in case ("regexp") has no files
14017 ;; and score-files is still nil. -sj
14018 ;; this can be construed as a "stop searching here" feature :>
14019 ;; and used to simplify regexps in the single-alist
14022 (nconc score-files (copy-sequence (cdr (car alist)))))
14024 (setq alist (cdr alist)))
14025 ;; cache the score files
14026 (setq gnus-score-file-alist-cache
14027 (cons (cons group score-files) gnus-score-file-alist-cache))
14031 (defun gnus-possibly-score-headers (&optional trace)
14032 (let ((func gnus-score-find-score-files-function)
14034 (and func (not (listp func))
14035 (setq func (list func)))
14036 ;; Go through all the functions for finding score files (or actual
14037 ;; scores) and add them to a list.
14038 (setq score-files (gnus-score-find-alist gnus-newsgroup-name))
14040 (and (symbolp (car func))
14041 (fboundp (car func))
14043 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
14044 (setq func (cdr func)))
14045 (if score-files (gnus-score-headers score-files trace))))
14047 (defun gnus-score-file-name (newsgroup &optional suffix)
14048 "Return the name of a score file for NEWSGROUP."
14049 (let ((suffix (or suffix gnus-score-file-suffix)))
14051 ((or (null newsgroup)
14052 (string-equal newsgroup ""))
14053 ;; The global score file is placed at top of the directory.
14055 suffix (or gnus-kill-files-directory "~/News")))
14056 ((gnus-use-long-file-name 'not-score)
14057 ;; Append ".SCORE" to newsgroup name.
14058 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
14060 (or gnus-kill-files-directory "~/News")))
14062 ;; Place "SCORE" under the hierarchical directory.
14063 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14065 (or gnus-kill-files-directory "~/News"))))))
14067 (defun gnus-score-search-global-directories (files)
14068 "Scan all global score directories for score files."
14069 ;; Set the variable `gnus-internal-global-score-files' to all
14070 ;; available global score files.
14071 (interactive (list gnus-global-score-files))
14074 (if (string-match "/$" (car files))
14075 (setq out (nconc (directory-files
14077 (concat (gnus-score-file-regexp) "$"))))
14078 (setq out (cons (car files) out)))
14079 (setq files (cdr files)))
14080 (setq gnus-internal-global-score-files out)))
14082 ;; Allow redefinition of Gnus functions.
14084 (gnus-ems-redefine)
14088 ;;; gnus.el ends here