1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
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 the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval '(run-hooks 'gnus-load-hook))
37 (eval-when-compile (require 'cl))
39 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/")
40 "*Directory variable from which all other Gnus file variables are derived.")
42 ;; Site dependent variables. These variables should be defined in
45 (defvar gnus-default-nntp-server nil
46 "Specify a default NNTP server.
47 This variable should be defined in paths.el, and should never be set
49 If you want to change servers, you should use `gnus-select-method'.
50 See the documentation to that variable.")
52 (defvar gnus-backup-default-subscribed-newsgroups
53 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
54 "Default default new newsgroups the first time Gnus is run.
55 Should be set in paths.el, and shouldn't be touched by the user.")
57 (defvar gnus-local-domain nil
58 "Local domain name without a host name.
59 The DOMAINNAME environment variable is used instead if it is defined.
60 If the `system-name' function returns the full Internet name, there is
61 no need to set this variable.")
63 (defvar gnus-local-organization nil
64 "String with a description of what organization (if any) the user belongs to.
65 The ORGANIZATION environment variable is used instead if it is defined.
66 If this variable contains a function, this function will be called
67 with the current newsgroup name as the argument. The function should
70 In any case, if the string (either in the variable, in the environment
71 variable, or returned by the function) is a file name, the contents of
72 this file will be used as the organization.")
74 ;; Customization variables
76 ;; Don't touch this variable.
77 (defvar gnus-nntp-service "nntp"
78 "*NNTP service name (\"nntp\" or 119).
79 This is an obsolete variable, which is scarcely used. If you use an
80 nntp server for your newsgroup and want to change the port number
81 used to 899, you would say something along these lines:
83 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
85 (defvar gnus-nntpserver-file "/etc/nntpserver"
86 "*A file with only the name of the nntp server in it.")
88 ;; This function is used to check both the environment variable
89 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
90 ;; an nntp server name default.
91 (defun gnus-getenv-nntpserver ()
92 (or (getenv "NNTPSERVER")
93 (and (file-readable-p gnus-nntpserver-file)
95 (set-buffer (get-buffer-create " *gnus nntp*"))
96 (buffer-disable-undo (current-buffer))
97 (insert-file-contents gnus-nntpserver-file)
98 (let ((name (buffer-string)))
100 (if (string-match "^[ \t\n]*$" name)
103 (kill-buffer (current-buffer))))))))
105 (defvar gnus-select-method
107 (list 'nntp (or (condition-case ()
108 (gnus-getenv-nntpserver)
110 (if (and gnus-default-nntp-server
111 (not (string= gnus-default-nntp-server "")))
112 gnus-default-nntp-server)
114 (if (or (null gnus-nntp-service)
115 (equal gnus-nntp-service "nntp"))
117 (list gnus-nntp-service)))
118 "*Default method for selecting a newsgroup.
119 This variable should be a list, where the first element is how the
120 news is to be fetched, the second is the address.
122 For instance, if you want to get your news via NNTP from
123 \"flab.flab.edu\", you could say:
125 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
127 If you want to use your local spool, say:
129 (setq gnus-select-method (list 'nnspool (system-name)))
131 If you use this variable, you must set `gnus-nntp-server' to nil.
133 There is a lot more to know about select methods and virtual servers -
134 see the manual for details.")
136 (defvar gnus-message-archive-method
139 (nnfolder-directory ,(nnheader-concat message-directory "archive"))
140 (nnfolder-active-file
141 ,(nnheader-concat message-directory "archive/active"))
142 (nnfolder-get-new-mail nil)
143 (nnfolder-inhibit-expiry t))
144 "*Method used for archiving messages you've sent.
145 This should be a mail method.")
147 (defvar gnus-refer-article-method nil
148 "*Preferred method for fetching an article by Message-ID.
149 If you are reading news from the local spool (with nnspool), fetching
150 articles by Message-ID is painfully slow. By setting this method to an
151 nntp method, you might get acceptable results.
153 The value of this variable must be a valid select method as discussed
154 in the documentation of `gnus-select-method'.")
156 (defvar gnus-secondary-select-methods nil
157 "*A list of secondary methods that will be used for reading news.
158 This is a list where each element is a complete select method (see
159 `gnus-select-method').
161 If, for instance, you want to read your mail with the nnml backend,
162 you could set this variable:
164 (setq gnus-secondary-select-methods '((nnml \"\")))")
166 (defvar gnus-secondary-servers nil
167 "*List of NNTP servers that the user can choose between interactively.
168 To make Gnus query you for a server, you have to give `gnus' a
169 non-numeric prefix - `C-u M-x gnus', in short.")
171 (defvar gnus-nntp-server nil
172 "*The name of the host running the NNTP server.
173 This variable is semi-obsolete. Use the `gnus-select-method'
176 (defvar gnus-startup-file "~/.newsrc"
177 "*Your `.newsrc' file.
178 `.newsrc-SERVER' will be used instead if that exists.")
180 (defvar gnus-init-file "~/.gnus"
181 "*Your Gnus elisp startup file.
182 If a file with the .el or .elc suffixes exist, it will be read
185 (defvar gnus-group-faq-directory
186 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
187 "/ftp@sunsite.auc.dk:/pub/usenet/"
188 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
189 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
190 "/ftp@rtfm.mit.edu:/pub/usenet/"
191 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
192 "/ftp@ftp.sunet.se:/pub/usenet/"
193 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
194 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
195 "/ftp@ftp.hk.super.net:/mirror/faqs/")
196 "*Directory where the group FAQs are stored.
197 This will most commonly be on a remote machine, and the file will be
200 This variable can also be a list of directories. In that case, the
201 first element in the list will be used by default, and the others will
202 be used as backup sites.
204 Note that Gnus uses an aol machine as the default directory. If this
205 feels fundamentally unclean, just think of it as a way to finally get
206 something of value back from them.
208 If the default site is too slow, try one of these:
210 North America: mirrors.aol.com /pub/rtfm/usenet
211 ftp.seas.gwu.edu /pub/rtfm
212 rtfm.mit.edu /pub/usenet
213 Europe: ftp.uni-paderborn.de /pub/FAQ
214 src.doc.ic.ac.uk /usenet/news-FAQS
215 ftp.sunet.se /pub/usenet
216 sunsite.auc.dk /pub/usenet
217 Asia: nctuccca.edu.tw /USENET/FAQ
218 hwarang.postech.ac.kr /pub/usenet
219 ftp.hk.super.net /mirror/faqs")
221 (defvar gnus-group-archive-directory
222 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
223 "*The address of the (ding) archives.")
225 (defvar gnus-group-recent-archive-directory
226 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
227 "*The address of the most recent (ding) articles.")
229 (defvar gnus-default-subscribed-newsgroups nil
230 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
231 It should be a list of strings.
232 If it is `t', Gnus will not do anything special the first time it is
233 started; it'll just use the normal newsgroups subscription methods.")
235 (defvar gnus-use-cross-reference t
236 "*Non-nil means that cross referenced articles will be marked as read.
237 If nil, ignore cross references. If t, mark articles as read in
238 subscribed newsgroups. If neither t nor nil, mark as read in all
241 (defvar gnus-single-article-buffer t
242 "*If non-nil, display all articles in the same buffer.
243 If nil, each group will get its own article buffer.")
245 (defvar gnus-use-dribble-file t
246 "*Non-nil means that Gnus will use a dribble file to store user updates.
247 If Emacs should crash without saving the .newsrc files, complete
248 information can be restored from the dribble file.")
250 (defvar gnus-dribble-directory nil
251 "*The directory where dribble files will be saved.
252 If this variable is nil, the directory where the .newsrc files are
253 saved will be used.")
255 (defvar gnus-asynchronous nil
256 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
258 (defvar gnus-kill-summary-on-exit t
259 "*If non-nil, kill the summary buffer when you exit from it.
260 If nil, the summary will become a \"*Dead Summary*\" buffer, and
261 it will be killed sometime later.")
263 (defvar gnus-large-newsgroup 200
264 "*The number of articles which indicates a large newsgroup.
265 If the number of articles in a newsgroup is greater than this value,
266 confirmation is required for selecting the newsgroup.")
268 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
269 (defvar gnus-no-groups-message "No news is horrible news"
270 "*Message displayed by Gnus when no groups are available.")
272 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
273 "*Non-nil means that the default name of a file to save articles in is the group name.
274 If it's nil, the directory form of the group name is used instead.
276 If this variable is a list, and the list contains the element
277 `not-score', long file names will not be used for score files; if it
278 contains the element `not-save', long file names will not be used for
279 saving; and if it contains the element `not-kill', long file names
280 will not be used for kill files.")
282 (defvar gnus-article-save-directory gnus-directory
283 "*Name of the directory articles will be saved in (default \"~/News\").")
285 (defvar gnus-kill-files-directory gnus-directory
286 "*Name of the directory where kill files will be stored (default \"~/News\").")
288 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
289 "*A function to save articles in your favorite format.
290 The function must be interactively callable (in other words, it must
291 be an Emacs command).
293 Gnus provides the following functions:
295 * gnus-summary-save-in-rmail (Rmail format)
296 * gnus-summary-save-in-mail (Unix mail format)
297 * gnus-summary-save-in-folder (MH folder)
298 * gnus-summary-save-in-file (article format).
299 * gnus-summary-save-in-vm (use VM's folder format).")
301 (defvar gnus-prompt-before-saving 'always
302 "*This variable says how much prompting is to be done when saving articles.
303 If it is nil, no prompting will be done, and the articles will be
304 saved to the default files. If this variable is `always', each and
305 every article that is saved will be preceded by a prompt, even when
306 saving large batches of articles. If this variable is neither nil not
307 `always', there the user will be prompted once for a file name for
308 each invocation of the saving commands.")
310 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
311 "*A function generating a file name to save articles in Rmail format.
312 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
314 (defvar gnus-mail-save-name (function gnus-plain-save-name)
315 "*A function generating a file name to save articles in Unix mail format.
316 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
318 (defvar gnus-folder-save-name (function gnus-folder-save-name)
319 "*A function generating a file name to save articles in MH folder.
320 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
322 (defvar gnus-file-save-name (function gnus-numeric-save-name)
323 "*A function generating a file name to save articles in article format.
324 The function is called with NEWSGROUP, HEADERS, and optional
327 (defvar gnus-split-methods
328 '((gnus-article-archive-name))
329 "*Variable used to suggest where articles are to be saved.
330 For instance, if you would like to save articles related to Gnus in
331 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
332 you could set this variable to something like:
334 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
335 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
337 This variable is an alist where the where the key is the match and the
338 value is a list of possible files to save in if the match is non-nil.
340 If the match is a string, it is used as a regexp match on the
341 article. If the match is a symbol, that symbol will be funcalled
342 from the buffer of the article to be saved with the newsgroup as the
343 parameter. If it is a list, it will be evaled in the same buffer.
345 If this form or function returns a string, this string will be used as
346 a possible file name; and if it returns a non-nil list, that list will
347 be used as possible file names.")
349 (defvar gnus-move-split-methods nil
350 "*Variable used to suggest where articles are to be moved to.
351 It uses the same syntax as the `gnus-split-methods' variable.")
353 (defvar gnus-save-score nil
354 "*If non-nil, save group scoring info.")
356 (defvar gnus-use-adaptive-scoring nil
357 "*If non-nil, use some adaptive scoring scheme.")
359 (defvar gnus-use-cache 'passive
360 "*If nil, Gnus will ignore the article cache.
361 If `passive', it will allow entering (and reading) articles
362 explicitly entered into the cache. If anything else, use the
363 cache to the full extent of the law.")
365 (defvar gnus-use-trees nil
366 "*If non-nil, display a thread tree buffer.")
368 (defvar gnus-use-grouplens nil
369 "*If non-nil, use GroupLens ratings.")
371 (defvar gnus-keep-backlog nil
372 "*If non-nil, Gnus will keep read articles for later re-retrieval.
373 If it is a number N, then Gnus will only keep the last N articles
374 read. If it is neither nil nor a number, Gnus will keep all read
375 articles. This is not a good idea.")
377 (defvar gnus-use-nocem nil
378 "*If non-nil, Gnus will read NoCeM cancel messages.")
380 (defvar gnus-use-demon nil
381 "If non-nil, Gnus might use some demons.")
383 (defvar gnus-use-scoring t
384 "*If non-nil, enable scoring.")
386 (defvar gnus-use-picons nil
387 "*If non-nil, display picons.")
389 (defvar gnus-fetch-old-headers nil
390 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
391 If an unread article in the group refers to an older, already read (or
392 just marked as read) article, the old article will not normally be
393 displayed in the Summary buffer. If this variable is non-nil, Gnus
394 will attempt to grab the headers to the old articles, and thereby
395 build complete threads. If it has the value `some', only enough
396 headers to connect otherwise loose threads will be displayed.
397 This variable can also be a number. In that case, no more than that
398 number of old headers will be fetched.
400 The server has to support NOV for any of this to work.")
403 ;(defvar gnus-visual t
404 ; "*If non-nil, will do various highlighting.
405 ;If nil, no mouse highlights (or any other highlights) will be
406 ;performed. This might speed up Gnus some when generating large group
407 ;and summary buffers.")
409 (defvar gnus-novice-user t
410 "*Non-nil means that you are a usenet novice.
411 If non-nil, verbose messages may be displayed and confirmations may be
414 (defvar gnus-expert-user nil
415 "*Non-nil means that you will never be asked for confirmation about anything.
416 And that means *anything*.")
418 (defvar gnus-verbose 7
419 "*Integer that says how verbose Gnus should be.
420 The higher the number, the more messages Gnus will flash to say what
421 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
422 display most important messages; and at ten, Gnus will keep on
423 jabbering all the time.")
425 (defvar gnus-keep-same-level nil
426 "*Non-nil means that the next newsgroup after the current will be on the same level.
427 When you type, for instance, `n' after reading the last article in the
428 current newsgroup, you will go to the next newsgroup. If this variable
429 is nil, the next newsgroup will be the next from the group
431 If this variable is non-nil, Gnus will either put you in the
432 next newsgroup with the same level, or, if no such newsgroup is
433 available, the next newsgroup with the lowest possible level higher
434 than the current level.
435 If this variable is `best', Gnus will make the next newsgroup the one
436 with the best level.")
438 (defvar gnus-summary-make-false-root 'adopt
439 "*nil means that Gnus won't gather loose threads.
440 If the root of a thread has expired or been read in a previous
441 session, the information necessary to build a complete thread has been
442 lost. Instead of having many small sub-threads from this original thread
443 scattered all over the summary buffer, Gnus can gather them.
445 If non-nil, Gnus will try to gather all loose sub-threads from an
446 original thread into one large thread.
448 If this variable is non-nil, it should be one of `none', `adopt',
451 If this variable is `none', Gnus will not make a false root, but just
452 present the sub-threads after another.
453 If this variable is `dummy', Gnus will create a dummy root that will
454 have all the sub-threads as children.
455 If this variable is `adopt', Gnus will make one of the \"children\"
456 the parent and mark all the step-children as such.
457 If this variable is `empty', the \"children\" are printed with empty
458 subject fields. (Or rather, they will be printed with a string
459 given by the `gnus-summary-same-subject' variable.)")
461 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
462 "*A regexp to match subjects to be excluded from loose thread gathering.
463 As loose thread gathering is done on subjects only, that means that
464 there can be many false gatherings performed. By rooting out certain
465 common subjects, gathering might become saner.")
467 (defvar gnus-summary-gather-subject-limit nil
468 "*Maximum length of subject comparisons when gathering loose threads.
469 Use nil to compare full subjects. Setting this variable to a low
470 number will help gather threads that have been corrupted by
471 newsreaders chopping off subject lines, but it might also mean that
472 unrelated articles that have subject that happen to begin with the
473 same few characters will be incorrectly gathered.
475 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
476 comparing subjects.")
478 (defvar gnus-simplify-ignored-prefixes nil
479 "*Regexp, matches for which are removed from subject lines when simplifying.")
481 (defvar gnus-build-sparse-threads nil
482 "*If non-nil, fill in the gaps in threads.
483 If `some', only fill in the gaps that are needed to tie loose threads
484 together. If `more', fill in all leaf nodes that Gnus can find. If
485 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
487 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
488 "Function used for gathering loose threads.
489 There are two pre-defined functions: `gnus-gather-threads-by-subject',
490 which only takes Subjects into consideration; and
491 `gnus-gather-threads-by-references', which compared the References
492 headers of the articles to find matches.")
494 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
495 (defvar gnus-summary-same-subject ""
496 "*String indicating that the current article has the same subject as the previous.
497 This variable will only be used if the value of
498 `gnus-summary-make-false-root' is `empty'.")
500 (defvar gnus-summary-goto-unread t
501 "*If non-nil, marking commands will go to the next unread article.
502 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
503 whether it is read or not.")
505 (defvar gnus-group-goto-unread t
506 "*If non-nil, movement commands will go to the next unread and subscribed group.")
508 (defvar gnus-goto-next-group-when-activating t
509 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
511 (defvar gnus-check-new-newsgroups t
512 "*Non-nil means that Gnus will add new newsgroups at startup.
513 If this variable is `ask-server', Gnus will ask the server for new
514 groups since the last time it checked. This means that the killed list
515 is no longer necessary, so you could set `gnus-save-killed-list' to
518 A variant is to have this variable be a list of select methods. Gnus
519 will then use the `ask-server' method on all these select methods to
520 query for new groups from all those servers.
523 (setq gnus-check-new-newsgroups
524 '((nntp \"some.server\") (nntp \"other.server\")))
526 If this variable is nil, then you have to tell Gnus explicitly to
527 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
529 (defvar gnus-check-bogus-newsgroups nil
530 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
531 If this variable is nil, then you have to tell Gnus explicitly to
532 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
534 (defvar gnus-read-active-file t
535 "*Non-nil means that Gnus will read the entire active file at startup.
536 If this variable is nil, Gnus will only know about the groups in your
539 If this variable is `some', Gnus will try to only read the relevant
540 parts of the active file from the server. Not all servers support
541 this, and it might be quite slow with other servers, but this should
542 generally be faster than both the t and nil value.
544 If you set this variable to nil or `some', you probably still want to
545 be told about new newsgroups that arrive. To do that, set
546 `gnus-check-new-newsgroups' to `ask-server'. This may not work
547 properly with all servers.")
549 (defvar gnus-level-subscribed 5
550 "*Groups with levels less than or equal to this variable are subscribed.")
552 (defvar gnus-level-unsubscribed 7
553 "*Groups with levels less than or equal to this variable are unsubscribed.
554 Groups with levels less than `gnus-level-subscribed', which should be
555 less than this variable, are subscribed.")
557 (defvar gnus-level-zombie 8
558 "*Groups with this level are zombie groups.")
560 (defvar gnus-level-killed 9
561 "*Groups with this level are killed.")
563 (defvar gnus-level-default-subscribed 3
564 "*New subscribed groups will be subscribed at this level.")
566 (defvar gnus-level-default-unsubscribed 6
567 "*New unsubscribed groups will be unsubscribed at this level.")
569 (defvar gnus-activate-level (1+ gnus-level-subscribed)
570 "*Groups higher than this level won't be activated on startup.
571 Setting this variable to something log might save lots of time when
572 you have many groups that you aren't interested in.")
574 (defvar gnus-activate-foreign-newsgroups 4
575 "*If nil, Gnus will not check foreign newsgroups at startup.
576 If it is non-nil, it should be a number between one and nine. Foreign
577 newsgroups that have a level lower or equal to this number will be
578 activated on startup. For instance, if you want to active all
579 subscribed newsgroups, but not the rest, you'd set this variable to
580 `gnus-level-subscribed'.
582 If you subscribe to lots of newsgroups from different servers, startup
583 might take a while. By setting this variable to nil, you'll save time,
584 but you won't be told how many unread articles there are in the
587 (defvar gnus-save-newsrc-file t
588 "*Non-nil means that Gnus will save the `.newsrc' file.
589 Gnus always saves its own startup file, which is called
590 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
591 be readily understood by other newsreaders. If you don't plan on
592 using other newsreaders, set this variable to nil to save some time on
595 (defvar gnus-save-killed-list t
596 "*If non-nil, save the list of killed groups to the startup file.
597 If you set this variable to nil, you'll save both time (when starting
598 and quitting) and space (both memory and disk), but it will also mean
599 that Gnus has no record of which groups are new and which are old, so
600 the automatic new newsgroups subscription methods become meaningless.
602 You should always set `gnus-check-new-newsgroups' to `ask-server' or
603 nil if you set this variable to nil.")
605 (defvar gnus-interactive-catchup t
606 "*If non-nil, require your confirmation when catching up a group.")
608 (defvar gnus-interactive-exit t
609 "*If non-nil, require your confirmation when exiting Gnus.")
611 (defvar gnus-kill-killed t
612 "*If non-nil, Gnus will apply kill files to already killed articles.
613 If it is nil, Gnus will never apply kill files to articles that have
614 already been through the scoring process, which might very well save lots
617 (defvar gnus-extract-address-components 'gnus-extract-address-components
618 "*Function for extracting address components from a From header.
619 Two pre-defined function exist: `gnus-extract-address-components',
620 which is the default, quite fast, and too simplistic solution, and
621 `mail-extract-address-components', which works much better, but is
624 (defvar gnus-summary-default-score 0
625 "*Default article score level.
626 If this variable is nil, scoring will be disabled.")
628 (defvar gnus-summary-zcore-fuzz 0
629 "*Fuzziness factor for the zcore in the summary buffer.
630 Articles with scores closer than this to `gnus-summary-default-score'
631 will not be marked.")
633 (defvar gnus-simplify-subject-fuzzy-regexp nil
634 "*Strings to be removed when doing fuzzy matches.
635 This can either be a regular expression or list of regular expressions
636 that will be removed from subject strings if fuzzy subject
637 simplification is selected.")
639 (defvar gnus-permanently-visible-groups nil
640 "*Regexp to match groups that should always be listed in the group buffer.
641 This means that they will still be listed when there are no unread
642 articles in the groups.")
644 (defvar gnus-list-groups-with-ticked-articles t
645 "*If non-nil, list groups that have only ticked articles.
646 If nil, only list groups that have unread articles.")
648 (defvar gnus-group-default-list-level gnus-level-subscribed
649 "*Default listing level.
650 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
652 (defvar gnus-group-use-permanent-levels nil
653 "*If non-nil, once you set a level, Gnus will use this level.")
655 (defvar gnus-group-list-inactive-groups t
656 "*If non-nil, inactive groups will be listed.")
658 (defvar gnus-show-mime nil
659 "*If non-nil, do mime processing of articles.
660 The articles will simply be fed to the function given by
661 `gnus-show-mime-method'.")
663 (defvar gnus-strict-mime t
664 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
666 (defvar gnus-show-mime-method 'metamail-buffer
667 "*Function to process a MIME message.
668 The function is called from the article buffer.")
670 (defvar gnus-decode-encoded-word-method (lambda ())
671 "*Function to decode a MIME encoded-words.
672 The function is called from the article buffer.")
674 (defvar gnus-show-threads t
675 "*If non-nil, display threads in summary mode.")
677 (defvar gnus-thread-hide-subtree nil
678 "*If non-nil, hide all threads initially.
679 If threads are hidden, you have to run the command
680 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
681 to expose hidden threads.")
683 (defvar gnus-thread-hide-killed t
684 "*If non-nil, hide killed threads automatically.")
686 (defvar gnus-thread-ignore-subject nil
687 "*If non-nil, ignore subjects and do all threading based on the Reference header.
688 If nil, which is the default, articles that have different subjects
689 from their parents will start separate threads.")
691 (defvar gnus-thread-operation-ignore-subject t
692 "*If non-nil, subjects will be ignored when doing thread commands.
693 This affects commands like `gnus-summary-kill-thread' and
694 `gnus-summary-lower-thread'.
696 If this variable is nil, articles in the same thread with different
697 subjects will not be included in the operation in question. If this
698 variable is `fuzzy', only articles that have subjects that are fuzzily
699 equal will be included.")
701 (defvar gnus-thread-indent-level 4
702 "*Number that says how much each sub-thread should be indented.")
704 (defvar gnus-ignored-newsgroups
705 (purecopy (mapconcat 'identity
706 '("^to\\." ; not "real" groups
707 "^[0-9. \t]+ " ; all digits in name
708 "[][\"#'()]" ; bogus characters
711 "*A regexp to match uninteresting newsgroups in the active file.
712 Any lines in the active file matching this regular expression are
713 removed from the newsgroup list before anything else is done to it,
714 thus making them effectively non-existent.")
716 (defvar gnus-ignored-headers
717 "^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:"
718 "*All headers that match this regexp will be hidden.
719 This variable can also be a list of regexps of headers to be ignored.
720 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
722 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-"
723 "*All headers that do not match this regexp will be hidden.
724 This variable can also be a list of regexp of headers to remain visible.
725 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
727 (defvar gnus-sorted-header-list
728 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
729 "^Cc:" "^Date:" "^Organization:")
730 "*This variable is a list of regular expressions.
731 If it is non-nil, headers that match the regular expressions will
732 be placed first in the article buffer in the sequence specified by
735 (defvar gnus-boring-article-headers
736 '(empty followup-to reply-to)
737 "*Headers that are only to be displayed if they have interesting data.
738 Possible values in this list are `empty', `newsgroups', `followup-to',
739 `reply-to', and `date'.")
741 (defvar gnus-show-all-headers nil
742 "*If non-nil, don't hide any headers.")
744 (defvar gnus-save-all-headers t
745 "*If non-nil, don't remove any headers before saving.")
747 (defvar gnus-saved-headers gnus-visible-headers
748 "*Headers to keep if `gnus-save-all-headers' is nil.
749 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
750 If that variable is nil, however, all headers that match this regexp
751 will be kept while the rest will be deleted before saving.")
753 (defvar gnus-inhibit-startup-message nil
754 "*If non-nil, the startup message will not be displayed.")
756 (defvar gnus-signature-separator "^-- *$"
757 "Regexp matching signature separator.")
759 (defvar gnus-signature-limit nil
760 "Provide a limit to what is considered a signature.
761 If it is a number, no signature may not be longer (in characters) than
762 that number. If it is a function, the function will be called without
763 any parameters, and if it returns nil, there is no signature in the
764 buffer. If it is a string, it will be used as a regexp. If it
765 matches, the text in question is not a signature.")
767 (defvar gnus-auto-extend-newsgroup t
768 "*If non-nil, extend newsgroup forward and backward when requested.")
770 (defvar gnus-auto-select-first t
771 "*If nil, don't select the first unread article when entering a group.
772 If this variable is `best', select the highest-scored unread article
773 in the group. If neither nil nor `best', select the first unread
776 If you want to prevent automatic selection of the first unread article
777 in some newsgroups, set the variable to nil in
778 `gnus-select-group-hook'.")
780 (defvar gnus-auto-select-next t
781 "*If non-nil, offer to go to the next group from the end of the previous.
782 If the value is t and the next newsgroup is empty, Gnus will exit
783 summary mode and go back to group mode. If the value is neither nil
784 nor t, Gnus will select the following unread newsgroup. In
785 particular, if the value is the symbol `quietly', the next unread
786 newsgroup will be selected without any confirmation, and if it is
787 `almost-quietly', the next group will be selected without any
788 confirmation if you are located on the last article in the group.
789 Finally, if this variable is `slightly-quietly', the `Z n' command
790 will go to the next group without confirmation.")
792 (defvar gnus-auto-select-same nil
793 "*If non-nil, select the next article with the same subject.")
795 (defvar gnus-summary-check-current nil
796 "*If non-nil, consider the current article when moving.
797 The \"unread\" movement commands will stay on the same line if the
798 current article is unread.")
800 (defvar gnus-auto-center-summary t
801 "*If non-nil, always center the current summary buffer.
802 In particular, if `vertical' do only vertical recentering. If non-nil
803 and non-`vertical', do both horizontal and vertical recentering.")
805 (defvar gnus-break-pages t
806 "*If non-nil, do page breaking on articles.
807 The page delimiter is specified by the `gnus-page-delimiter'
810 (defvar gnus-page-delimiter "^\^L"
811 "*Regexp describing what to use as article page delimiters.
812 The default value is \"^\^L\", which is a form linefeed at the
813 beginning of a line.")
815 (defvar gnus-use-full-window t
816 "*If non-nil, use the entire Emacs screen.")
818 (defvar gnus-window-configuration nil
819 "Obsolete variable. See `gnus-buffer-configuration'.")
821 (defvar gnus-window-min-width 2
822 "*Minimum width of Gnus buffers.")
824 (defvar gnus-window-min-height 1
825 "*Minimum height of Gnus buffers.")
827 (defvar gnus-buffer-configuration
831 (if gnus-carpal '(group-carpal 4))))
835 (if gnus-carpal '(summary-carpal 4))))
842 (if gnus-carpal '(summary-carpal 4))
844 (vertical ((height . 5) (width . 15)
846 (left . -1) (top . 1))
856 (if gnus-carpal '(summary-carpal 4))
857 (if gnus-use-trees '(tree 0.25))
862 (if gnus-carpal '(server-carpal 2))))
866 (if gnus-carpal '(browse-carpal 2))))
869 (message 1.0 point)))
872 (article 1.0 point)))
883 (edit-group 1.0 point)))
887 (edit-server 1.0 point)))
891 (edit-score 1.0 point)))
898 (message 1.0 point)))
901 (message 1.0 point)))
904 (message 1.0 point)))
908 (message 1.0 point)))
915 (if gnus-carpal '(summary-carpal 4))
916 ("*Shell Command Output*" 1.0)))
919 ("*Gnus Help Bug*" 0.5)
920 ("*Gnus Bug*" 1.0 point)))
924 (message 1.0 point))))
925 "Window configuration for all possible Gnus buffers.
926 This variable is a list of lists. Each of these lists has a NAME and
927 a RULE. The NAMEs are commonsense names like `group', which names a
928 rule used when displaying the group buffer; `summary', which names a
929 rule for what happens when you enter a group and do not display an
930 article buffer; and so on. See the value of this variable for a
931 complete list of NAMEs.
933 Each RULE is a list of vectors. The first element in this vector is
934 the name of the buffer to be displayed; the second element is the
935 percentage of the screen this buffer is to occupy (a number in the
936 0.0-0.99 range); the optional third element is `point', which should
937 be present to denote which buffer point is to go to after making this
938 buffer configuration.")
940 (defvar gnus-window-to-buffer
941 '((group . gnus-group-buffer)
942 (summary . gnus-summary-buffer)
943 (article . gnus-article-buffer)
944 (server . gnus-server-buffer)
945 (browse . "*Gnus Browse Server*")
946 (edit-group . gnus-group-edit-buffer)
947 (edit-server . gnus-server-edit-buffer)
948 (group-carpal . gnus-carpal-group-buffer)
949 (summary-carpal . gnus-carpal-summary-buffer)
950 (server-carpal . gnus-carpal-server-buffer)
951 (browse-carpal . gnus-carpal-browse-buffer)
952 (edit-score . gnus-score-edit-buffer)
953 (message . gnus-message-buffer)
954 (mail . gnus-message-buffer)
955 (post-news . gnus-message-buffer)
956 (faq . gnus-faq-buffer)
957 (picons . "*Picons*")
958 (tree . gnus-tree-buffer)
959 (info . gnus-info-buffer)
960 (article-copy . gnus-article-copy)
961 (draft . gnus-draft-buffer))
962 "Mapping from short symbols to buffer names or buffer variables.")
964 (defvar gnus-carpal nil
965 "*If non-nil, display clickable icons.")
967 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
968 "*Function called with a group name when new group is detected.
969 A few pre-made functions are supplied: `gnus-subscribe-randomly'
970 inserts new groups at the beginning of the list of groups;
971 `gnus-subscribe-alphabetically' inserts new groups in strict
972 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
973 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
974 for your decision; `gnus-subscribe-killed' kills all new groups;
975 `gnus-subscribe-zombies' will make all new groups into zombies.")
977 ;; Suggested by a bug report by Hallvard B Furuseth.
978 ;; <h.b.furuseth@usit.uio.no>.
979 (defvar gnus-subscribe-options-newsgroup-method
980 (function gnus-subscribe-alphabetically)
981 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
982 If, for instance, you want to subscribe to all newsgroups in the
983 \"no\" and \"alt\" hierarchies, you'd put the following in your
986 options -n no.all alt.all
988 Gnus will the subscribe all new newsgroups in these hierarchies with
989 the subscription method in this variable.")
991 (defvar gnus-subscribe-hierarchical-interactive nil
992 "*If non-nil, Gnus will offer to subscribe hierarchically.
993 When a new hierarchy appears, Gnus will ask the user:
995 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
997 If the user pressed `d', Gnus will descend the hierarchy, `y' will
998 subscribe to all newsgroups in the hierarchy and `s' will skip this
999 hierarchy in its entirety.")
1001 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1002 "*Function used for sorting the group buffer.
1003 This function will be called with group info entries as the arguments
1004 for the groups to be sorted. Pre-made functions include
1005 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1006 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1007 `gnus-group-sort-by-rank'.
1009 This variable can also be a list of sorting functions. In that case,
1010 the most significant sort function should be the last function in the
1013 ;; Mark variables suggested by Thomas Michanek
1014 ;; <Thomas.Michanek@telelogic.se>.
1015 (defvar gnus-unread-mark ?
1016 "*Mark used for unread articles.")
1017 (defvar gnus-ticked-mark ?!
1018 "*Mark used for ticked articles.")
1019 (defvar gnus-dormant-mark ??
1020 "*Mark used for dormant articles.")
1021 (defvar gnus-del-mark ?r
1022 "*Mark used for del'd articles.")
1023 (defvar gnus-read-mark ?R
1024 "*Mark used for read articles.")
1025 (defvar gnus-expirable-mark ?E
1026 "*Mark used for expirable articles.")
1027 (defvar gnus-killed-mark ?K
1028 "*Mark used for killed articles.")
1029 (defvar gnus-souped-mark ?F
1030 "*Mark used for killed articles.")
1031 (defvar gnus-kill-file-mark ?X
1032 "*Mark used for articles killed by kill files.")
1033 (defvar gnus-low-score-mark ?Y
1034 "*Mark used for articles with a low score.")
1035 (defvar gnus-catchup-mark ?C
1036 "*Mark used for articles that are caught up.")
1037 (defvar gnus-replied-mark ?A
1038 "*Mark used for articles that have been replied to.")
1039 (defvar gnus-cached-mark ?*
1040 "*Mark used for articles that are in the cache.")
1041 (defvar gnus-saved-mark ?S
1042 "*Mark used for articles that have been saved to.")
1043 (defvar gnus-process-mark ?#
1045 (defvar gnus-ancient-mark ?O
1046 "*Mark used for ancient articles.")
1047 (defvar gnus-sparse-mark ?Q
1048 "*Mark used for sparsely reffed articles.")
1049 (defvar gnus-canceled-mark ?G
1050 "*Mark used for canceled articles.")
1051 (defvar gnus-score-over-mark ?+
1052 "*Score mark used for articles with high scores.")
1053 (defvar gnus-score-below-mark ?-
1054 "*Score mark used for articles with low scores.")
1055 (defvar gnus-empty-thread-mark ?
1056 "*There is no thread under the article.")
1057 (defvar gnus-not-empty-thread-mark ?=
1058 "*There is a thread under the article.")
1060 (defvar gnus-view-pseudo-asynchronously nil
1061 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1063 (defvar gnus-view-pseudos nil
1064 "*If `automatic', pseudo-articles will be viewed automatically.
1065 If `not-confirm', pseudos will be viewed automatically, and the user
1066 will not be asked to confirm the command.")
1068 (defvar gnus-view-pseudos-separately t
1069 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1070 If nil, all files that use the same viewing command will be given as a
1071 list of parameters to that command.")
1073 (defvar gnus-insert-pseudo-articles t
1074 "*If non-nil, insert pseudo-articles when decoding articles.")
1076 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1077 "*Format of group lines.
1078 It works along the same lines as a normal formatting string,
1079 with some simple extensions.
1081 %M Only marked articles (character, \"*\" or \" \")
1082 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1083 %L Level of subscribedness (integer)
1084 %N Number of unread articles (integer)
1085 %I Number of dormant articles (integer)
1086 %i Number of ticked and dormant (integer)
1087 %T Number of ticked articles (integer)
1088 %R Number of read articles (integer)
1089 %t Total number of articles (integer)
1090 %y Number of unread, unticked articles (integer)
1091 %G Group name (string)
1092 %g Qualified group name (string)
1093 %D Group description (string)
1094 %s Select method (string)
1095 %o Moderated group (char, \"m\")
1096 %p Process mark (char)
1097 %O Moderated group (string, \"(m)\" or \"\")
1098 %P Topic indentation (string)
1099 %l Whether there are GroupLens predictions for this group (string)
1100 %n Select from where (string)
1101 %z A string that look like `<%s:%n>' if a foreign select method is used
1102 %u User defined specifier. The next character in the format string should
1103 be a letter. Gnus will call the function gnus-user-format-function-X,
1104 where X is the letter following %u. The function will be passed the
1105 current header as argument. The function should return a string, which
1106 will be inserted into the buffer just like information from any other
1109 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1110 the mouse point move inside the area. There can only be one such area.
1112 Note that this format specification is not always respected. For
1113 reasons of efficiency, when listing killed groups, this specification
1114 is ignored altogether. If the spec is changed considerably, your
1115 output may end up looking strange when listing both alive and killed
1118 If you use %o or %O, reading the active file will be slower and quite
1119 a bit of extra memory will be used. %D will also worsen performance.
1120 Also note that if you change the format specification to include any
1121 of these specs, you must probably re-start Gnus to see them go into
1124 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1125 "*The format specification of the lines in the summary buffer.
1127 It works along the same lines as a normal formatting string,
1128 with some simple extensions.
1130 %N Article number, left padded with spaces (string)
1132 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1133 %n Name of the poster (string)
1134 %a Extracted name of the poster (string)
1135 %A Extracted address of the poster (string)
1136 %F Contents of the From: header (string)
1137 %x Contents of the Xref: header (string)
1138 %D Date of the article (string)
1139 %d Date of the article (string) in DD-MMM format
1140 %M Message-id of the article (string)
1141 %r References of the article (string)
1142 %c Number of characters in the article (integer)
1143 %L Number of lines in the article (integer)
1144 %I Indentation based on thread level (a string of spaces)
1145 %T A string with two possible values: 80 spaces if the article
1146 is on thread level two or larger and 0 spaces on level one
1147 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1148 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1149 %[ Opening bracket (character, \"[\" or \"<\")
1150 %] Closing bracket (character, \"]\" or \">\")
1151 %> Spaces of length thread-level (string)
1152 %< Spaces of length (- 20 thread-level) (string)
1153 %i Article score (number)
1154 %z Article zcore (character)
1155 %t Number of articles under the current thread (number).
1156 %e Whether the thread is empty or not (character).
1157 %l GroupLens score (string).
1158 %u User defined specifier. The next character in the format string should
1159 be a letter. Gnus will call the function gnus-user-format-function-X,
1160 where X is the letter following %u. The function will be passed the
1161 current header as argument. The function should return a string, which
1162 will be inserted into the summary just like information from any other
1165 Text between %( and %) will be highlighted with `gnus-mouse-face'
1166 when the mouse point is placed inside the area. There can only be one
1169 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1170 with care. For reasons of efficiency, Gnus will compute what column
1171 these characters will end up in, and \"hard-code\" that. This means that
1172 it is illegal to have these specs after a variable-length spec. Well,
1173 you might not be arrested, but your summary buffer will look strange,
1174 which is bad enough.
1176 The smart choice is to have these specs as for to the left as
1179 This restriction may disappear in later versions of Gnus.")
1181 (defvar gnus-summary-dummy-line-format
1183 "*The format specification for the dummy roots in the summary buffer.
1184 It works along the same lines as a normal formatting string,
1185 with some simple extensions.
1189 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1190 "*The format specification for the summary mode line.
1191 It works along the same lines as a normal formatting string,
1192 with some simple extensions:
1195 %p Unprefixed group name
1196 %A Current article number
1198 %U Number of unread articles in the group
1199 %e Number of unselected articles in the group
1200 %Z A string with unread/unselected article counts
1201 %g Shortish group name
1202 %S Subject of the current article
1203 %u User-defined spec
1204 %s Current score file name
1205 %d Number of dormant articles
1206 %r Number of articles that have been marked as read in this session
1207 %E Number of articles expunged by the score files")
1209 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1210 "*The format specification for the article mode line.
1211 See `gnus-summary-mode-line-format' for a closer description.")
1213 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1214 "*The format specification for the group mode line.
1215 It works along the same lines as a normal formatting string,
1216 with some simple extensions:
1218 %S The native news server.
1219 %M The native select method.
1220 %: \":\" if %S isn't \"\".")
1222 (defvar gnus-valid-select-methods
1223 '(("nntp" post address prompt-address)
1224 ("nnspool" post address)
1225 ("nnvirtual" post-mail virtual prompt-address)
1226 ("nnmbox" mail respool address)
1227 ("nnml" mail respool address)
1228 ("nnmh" mail respool address)
1229 ("nndir" post-mail prompt-address address)
1230 ("nneething" none address prompt-address)
1231 ("nndoc" none address prompt-address)
1232 ("nnbabyl" mail address respool)
1233 ("nnkiboze" post address virtual)
1234 ("nnsoup" post-mail address)
1235 ("nndraft" post-mail)
1236 ("nnfolder" mail respool address))
1237 "An alist of valid select methods.
1238 The first element of each list lists should be a string with the name
1239 of the select method. The other elements may be be the category of
1240 this method (ie. `post', `mail', `none' or whatever) or other
1241 properties that this method has (like being respoolable).
1242 If you implement a new select method, all you should have to change is
1243 this variable. I think.")
1245 (defvar gnus-updated-mode-lines '(group article summary tree)
1246 "*List of buffers that should update their mode lines.
1247 The list may contain the symbols `group', `article' and `summary'. If
1248 the corresponding symbol is present, Gnus will keep that mode line
1249 updated with information that may be pertinent.
1250 If this variable is nil, screen refresh may be quicker.")
1252 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1253 (defvar gnus-mode-non-string-length nil
1254 "*Max length of mode-line non-string contents.
1255 If this is nil, Gnus will take space as is needed, leaving the rest
1256 of the modeline intact.")
1259 ;(defvar gnus-mouse-face 'highlight
1260 ; "*Face used for mouse highlighting in Gnus.
1261 ;No mouse highlights will be done if `gnus-visual' is nil.")
1263 (defvar gnus-summary-mark-below 0
1264 "*Mark all articles with a score below this variable as read.
1265 This variable is local to each summary buffer and usually set by the
1268 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1269 "*List of functions used for sorting articles in the summary buffer.
1270 This variable is only used when not using a threaded display.")
1272 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1273 "*List of functions used for sorting threads in the summary buffer.
1274 By default, threads are sorted by article number.
1276 Each function takes two threads and return non-nil if the first thread
1277 should be sorted before the other. If you use more than one function,
1278 the primary sort function should be the last. You should probably
1279 always include `gnus-thread-sort-by-number' in the list of sorting
1280 functions -- preferably first.
1282 Ready-mady functions include `gnus-thread-sort-by-number',
1283 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1284 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1285 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1287 (defvar gnus-thread-score-function '+
1288 "*Function used for calculating the total score of a thread.
1290 The function is called with the scores of the article and each
1291 subthread and should then return the score of the thread.
1293 Some functions you can use are `+', `max', or `min'.")
1295 (defvar gnus-summary-expunge-below nil
1296 "All articles that have a score less than this variable will be expunged.")
1298 (defvar gnus-thread-expunge-below nil
1299 "All threads that have a total score less than this variable will be expunged.
1300 See `gnus-thread-score-function' for en explanation of what a
1301 \"thread score\" is.")
1303 (defvar gnus-auto-subscribed-groups
1304 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1305 "*All new groups that match this regexp will be subscribed automatically.
1306 Note that this variable only deals with new groups. It has no effect
1307 whatsoever on old groups.")
1309 (defvar gnus-options-subscribe nil
1310 "*All new groups matching this regexp will be subscribed unconditionally.
1311 Note that this variable deals only with new newsgroups. This variable
1312 does not affect old newsgroups.")
1314 (defvar gnus-options-not-subscribe nil
1315 "*All new groups matching this regexp will be ignored.
1316 Note that this variable deals only with new newsgroups. This variable
1317 does not affect old (already subscribed) newsgroups.")
1319 (defvar gnus-auto-expirable-newsgroups nil
1320 "*Groups in which to automatically mark read articles as expirable.
1321 If non-nil, this should be a regexp that should match all groups in
1322 which to perform auto-expiry. This only makes sense for mail groups.")
1324 (defvar gnus-total-expirable-newsgroups nil
1325 "*Groups in which to perform expiry of all read articles.
1326 Use with extreme caution. All groups that match this regexp will be
1327 expiring - which means that all read articles will be deleted after
1328 (say) one week. (This only goes for mail groups and the like, of
1331 (defvar gnus-group-uncollapsed-levels 1
1332 "Number of group name elements to leave alone when making a short group name.")
1334 (defvar gnus-hidden-properties '(invisible t intangible t)
1335 "Property list to use for hiding text.")
1337 (defvar gnus-modtime-botch nil
1338 "*Non-nil means .newsrc should be deleted prior to save.
1339 Its use is due to the bogus appearance that .newsrc was modified on
1344 (defvar gnus-group-mode-hook nil
1345 "*A hook for Gnus group mode.")
1347 (defvar gnus-summary-mode-hook nil
1348 "*A hook for Gnus summary mode.
1349 This hook is run before any variables are set in the summary buffer.")
1351 (defvar gnus-article-mode-hook nil
1352 "*A hook for Gnus article mode.")
1354 (defvar gnus-summary-prepare-exit-hook nil
1355 "*A hook called when preparing to exit from the summary buffer.
1356 It calls `gnus-summary-expire-articles' by default.")
1357 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1359 (defvar gnus-summary-exit-hook nil
1360 "*A hook called on exit from the summary buffer.")
1362 (defvar gnus-group-catchup-group-hook nil
1363 "*A hook run when catching up a group from the group buffer.")
1365 (defvar gnus-open-server-hook nil
1366 "*A hook called just before opening connection to the news server.")
1368 (defvar gnus-load-hook nil
1369 "*A hook run while Gnus is loaded.")
1371 (defvar gnus-startup-hook nil
1372 "*A hook called at startup.
1373 This hook is called after Gnus is connected to the NNTP server.")
1375 (defvar gnus-get-new-news-hook nil
1376 "*A hook run just before Gnus checks for new news.")
1378 (defvar gnus-after-getting-new-news-hook nil
1379 "*A hook run after Gnus checks for new news.")
1381 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1382 "*A function that is called to generate the group buffer.
1383 The function is called with three arguments: The first is a number;
1384 all group with a level less or equal to that number should be listed,
1385 if the second is non-nil, empty groups should also be displayed. If
1386 the third is non-nil, it is a number. No groups with a level lower
1387 than this number should be displayed.
1389 The only current function implemented is `gnus-group-prepare-flat'.")
1391 (defvar gnus-group-prepare-hook nil
1392 "*A hook called after the group buffer has been generated.
1393 If you want to modify the group buffer, you can use this hook.")
1395 (defvar gnus-summary-prepare-hook nil
1396 "*A hook called after the summary buffer has been generated.
1397 If you want to modify the summary buffer, you can use this hook.")
1399 (defvar gnus-summary-generate-hook nil
1400 "*A hook run just before generating the summary buffer.
1401 This hook is commonly used to customize threading variables and the
1404 (defvar gnus-article-prepare-hook nil
1405 "*A hook called after an article has been prepared in the article buffer.
1406 If you want to run a special decoding program like nkf, use this hook.")
1408 ;(defvar gnus-article-display-hook nil
1409 ; "*A hook called after the article is displayed in the article buffer.
1410 ;The hook is designed to change the contents of the article
1411 ;buffer. Typical functions that this hook may contain are
1412 ;`gnus-article-hide-headers' (hide selected headers),
1413 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1414 ;`gnus-article-hide-signature' (hide signature) and
1415 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1416 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1417 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1418 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1420 (defvar gnus-article-x-face-command
1421 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1422 "String or function to be executed to display an X-Face header.
1423 If it is a string, the command will be executed in a sub-shell
1424 asynchronously. The compressed face will be piped to this command.")
1426 (defvar gnus-article-x-face-too-ugly nil
1427 "Regexp matching posters whose face shouldn't be shown automatically.")
1429 (defvar gnus-select-group-hook nil
1430 "*A hook called when a newsgroup is selected.
1432 If you'd like to simplify subjects like the
1433 `gnus-summary-next-same-subject' command does, you can use the
1436 (setq gnus-select-group-hook
1439 (mapcar (lambda (header)
1440 (mail-header-set-subject
1442 (gnus-simplify-subject
1443 (mail-header-subject header) 're-only)))
1444 gnus-newsgroup-headers))))")
1446 (defvar gnus-select-article-hook nil
1447 "*A hook called when an article is selected.")
1449 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1450 "*A hook called to apply kill files to a group.
1451 This hook is intended to apply a kill file to the selected newsgroup.
1452 The function `gnus-apply-kill-file' is called by default.
1454 Since a general kill file is too heavy to use only for a few
1455 newsgroups, I recommend you to use a lighter hook function. For
1456 example, if you'd like to apply a kill file to articles which contains
1457 a string `rmgroup' in subject in newsgroup `control', you can use the
1460 (setq gnus-apply-kill-hook
1463 (cond ((string-match \"control\" gnus-newsgroup-name)
1464 (gnus-kill \"Subject\" \"rmgroup\")
1465 (gnus-expunge \"X\"))))))")
1467 (defvar gnus-visual-mark-article-hook
1468 (list 'gnus-highlight-selected-summary)
1469 "*Hook run after selecting an article in the summary buffer.
1470 It is meant to be used for highlighting the article in some way. It
1471 is not run if `gnus-visual' is nil.")
1473 (defvar gnus-parse-headers-hook nil
1474 "*A hook called before parsing the headers.")
1475 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1477 (defvar gnus-exit-group-hook nil
1478 "*A hook called when exiting (not quitting) summary mode.")
1480 (defvar gnus-suspend-gnus-hook nil
1481 "*A hook called when suspending (not exiting) Gnus.")
1483 (defvar gnus-exit-gnus-hook nil
1484 "*A hook called when exiting Gnus.")
1486 (defvar gnus-after-exiting-gnus-hook nil
1487 "*A hook called after exiting Gnus.")
1489 (defvar gnus-save-newsrc-hook nil
1490 "*A hook called before saving any of the newsrc files.")
1492 (defvar gnus-save-quick-newsrc-hook nil
1493 "*A hook called just before saving the quick newsrc file.
1494 Can be used to turn version control on or off.")
1496 (defvar gnus-save-standard-newsrc-hook nil
1497 "*A hook called just before saving the standard newsrc file.
1498 Can be used to turn version control on or off.")
1500 (defvar gnus-summary-update-hook
1501 (list 'gnus-summary-highlight-line)
1502 "*A hook called when a summary line is changed.
1503 The hook will not be called if `gnus-visual' is nil.
1505 The default function `gnus-summary-highlight-line' will
1506 highlight the line according to the `gnus-summary-highlight'
1509 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1510 "*A hook called when a group line is changed.
1511 The hook will not be called if `gnus-visual' is nil.
1513 The default function `gnus-group-highlight-line' will
1514 highlight the line according to the `gnus-group-highlight'
1517 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1518 "*A hook called when an article is selected for the first time.
1519 The hook is intended to mark an article as read (or unread)
1520 automatically when it is selected.")
1522 (defvar gnus-group-change-level-function nil
1523 "Function run when a group level is changed.
1524 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1526 ;; Remove any hilit infestation.
1527 (add-hook 'gnus-startup-hook
1529 (remove-hook 'gnus-summary-prepare-hook
1530 'hilit-rehighlight-buffer-quietly)
1531 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1532 (setq gnus-mark-article-hook
1533 '(gnus-summary-mark-read-and-unread-as-read))
1534 (remove-hook 'gnus-article-prepare-hook
1535 'hilit-rehighlight-buffer-quietly)))
1538 ;; Internal variables
1540 (defvar gnus-tree-buffer "*Tree*"
1541 "Buffer where Gnus thread trees are displayed.")
1544 (defvar gnus-use-generic-from nil)
1546 (defvar gnus-thread-indent-array nil)
1547 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1549 (defvar gnus-newsrc-file-version nil)
1551 (defvar gnus-method-history nil)
1552 ;; Variable holding the user answers to all method prompts.
1554 (defvar gnus-group-history nil)
1555 ;; Variable holding the user answers to all group prompts.
1557 (defvar gnus-server-alist nil
1558 "List of available servers.")
1560 (defvar gnus-group-indentation-function nil)
1562 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1564 (defvar gnus-goto-missing-group-function nil)
1566 (defvar gnus-override-subscribe-method nil)
1568 (defvar gnus-group-goto-next-group-function nil
1569 "Function to override finding the next group after listing groups.")
1571 (defconst gnus-article-mark-lists
1572 '((marked . tick) (replied . reply)
1573 (expirable . expire) (killed . killed)
1574 (bookmarks . bookmark) (dormant . dormant)
1575 (scored . score) (saved . save)
1579 ;; Avoid highlighting in kill files.
1580 (defvar gnus-summary-inhibit-highlight nil)
1581 (defvar gnus-newsgroup-selected-overlay nil)
1583 (defvar gnus-inhibit-hiding nil)
1584 (defvar gnus-group-indentation "")
1585 (defvar gnus-inhibit-limiting nil)
1586 (defvar gnus-created-frames nil)
1588 (defvar gnus-article-mode-map nil)
1589 (defvar gnus-dribble-buffer nil)
1590 (defvar gnus-headers-retrieved-by nil)
1591 (defvar gnus-article-reply nil)
1592 (defvar gnus-override-method nil)
1593 (defvar gnus-article-check-size nil)
1595 (defvar gnus-current-score-file nil)
1596 (defvar gnus-newsgroup-adaptive-score-file nil)
1597 (defvar gnus-scores-exclude-files nil)
1599 (defvar gnus-opened-servers nil)
1601 (defvar gnus-current-move-group nil)
1602 (defvar gnus-current-copy-group nil)
1603 (defvar gnus-current-crosspost-group nil)
1605 (defvar gnus-newsgroup-dependencies nil)
1606 (defvar gnus-newsgroup-async nil)
1607 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1609 (defvar gnus-newsgroup-adaptive nil)
1611 (defvar gnus-summary-display-table nil)
1612 (defvar gnus-summary-display-article-function nil)
1614 (defvar gnus-summary-highlight-line-function nil
1615 "Function called after highlighting a summary line.")
1617 (defvar gnus-group-line-format-alist
1618 `((?M gnus-tmp-marked-mark ?c)
1619 (?S gnus-tmp-subscribed ?c)
1620 (?L gnus-tmp-level ?d)
1621 (?N (cond ((eq number t) "*" )
1625 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1626 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1628 (?R gnus-tmp-number-of-read ?s)
1629 (?t gnus-tmp-number-total ?d)
1630 (?y gnus-tmp-number-of-unread ?s)
1631 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1632 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1633 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1634 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1635 (?g gnus-tmp-group ?s)
1636 (?G gnus-tmp-qualified-group ?s)
1637 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1638 (?D gnus-tmp-newsgroup-description ?s)
1639 (?o gnus-tmp-moderated ?c)
1640 (?O gnus-tmp-moderated-string ?s)
1641 (?p gnus-tmp-process-marked ?c)
1642 (?s gnus-tmp-news-server ?s)
1643 (?n gnus-tmp-news-method ?s)
1644 (?P gnus-group-indentation ?s)
1645 (?l gnus-tmp-grouplens ?s)
1646 (?z gnus-tmp-news-method-string ?s)
1647 (?u gnus-tmp-user-defined ?s)))
1649 (defvar gnus-summary-line-format-alist
1650 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1651 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1652 (?s gnus-tmp-subject-or-nil ?s)
1653 (?n gnus-tmp-name ?s)
1654 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1656 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1658 (?F gnus-tmp-from ?s)
1659 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1660 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1661 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1662 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1663 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1664 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1665 (?L gnus-tmp-lines ?d)
1666 (?I gnus-tmp-indentation ?s)
1667 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1668 (?R gnus-tmp-replied ?c)
1669 (?\[ gnus-tmp-opening-bracket ?c)
1670 (?\] gnus-tmp-closing-bracket ?c)
1671 (?\> (make-string gnus-tmp-level ? ) ?s)
1672 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1673 (?i gnus-tmp-score ?d)
1674 (?z gnus-tmp-score-char ?c)
1675 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1676 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1677 (?U gnus-tmp-unread ?c)
1678 (?t (gnus-summary-number-of-articles-in-thread
1679 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1681 (?e (gnus-summary-number-of-articles-in-thread
1682 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1684 (?u gnus-tmp-user-defined ?s))
1685 "An alist of format specifications that can appear in summary lines,
1686 and what variables they correspond with, along with the type of the
1687 variable (string, integer, character, etc).")
1689 (defvar gnus-summary-dummy-line-format-alist
1690 `((?S gnus-tmp-subject ?s)
1691 (?N gnus-tmp-number ?d)
1692 (?u gnus-tmp-user-defined ?s)))
1694 (defvar gnus-summary-mode-line-format-alist
1695 `((?G gnus-tmp-group-name ?s)
1696 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1697 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1698 (?A gnus-tmp-article-number ?d)
1699 (?Z gnus-tmp-unread-and-unselected ?s)
1700 (?V gnus-version ?s)
1701 (?U gnus-tmp-unread ?d)
1702 (?S gnus-tmp-subject ?s)
1703 (?e gnus-tmp-unselected ?d)
1704 (?u gnus-tmp-user-defined ?s)
1705 (?d (length gnus-newsgroup-dormant) ?d)
1706 (?t (length gnus-newsgroup-marked) ?d)
1707 (?r (length gnus-newsgroup-reads) ?d)
1708 (?E gnus-newsgroup-expunged-tally ?d)
1709 (?s (gnus-current-score-file-nondirectory) ?s)))
1711 (defvar gnus-article-mode-line-format-alist
1712 gnus-summary-mode-line-format-alist)
1714 (defvar gnus-group-mode-line-format-alist
1715 `((?S gnus-tmp-news-server ?s)
1716 (?M gnus-tmp-news-method ?s)
1717 (?u gnus-tmp-user-defined ?s)
1718 (?: gnus-tmp-colon ?s)))
1720 (defvar gnus-have-read-active-file nil)
1722 (defconst gnus-maintainer
1723 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1724 "The mail address of the Gnus maintainers.")
1726 (defconst gnus-version-number "5.2.3"
1727 "Version number for this version of Gnus.")
1729 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1730 "Version string for this version of Gnus.")
1732 (defvar gnus-info-nodes
1733 '((gnus-group-mode "(gnus)The Group Buffer")
1734 (gnus-summary-mode "(gnus)The Summary Buffer")
1735 (gnus-article-mode "(gnus)The Article Buffer"))
1736 "Assoc list of major modes and related Info nodes.")
1738 (defvar gnus-group-buffer "*Group*")
1739 (defvar gnus-summary-buffer "*Summary*")
1740 (defvar gnus-article-buffer "*Article*")
1741 (defvar gnus-server-buffer "*Server*")
1743 (defvar gnus-work-buffer " *gnus work*")
1745 (defvar gnus-original-article-buffer " *Original Article*")
1746 (defvar gnus-original-article nil)
1748 (defvar gnus-buffer-list nil
1749 "Gnus buffers that should be killed on exit.")
1751 (defvar gnus-slave nil
1752 "Whether this Gnus is a slave or not.")
1754 (defvar gnus-variable-list
1755 '(gnus-newsrc-options gnus-newsrc-options-n
1756 gnus-newsrc-last-checked-date
1757 gnus-newsrc-alist gnus-server-alist
1758 gnus-killed-list gnus-zombie-list
1759 gnus-topic-topology gnus-topic-alist
1761 "Gnus variables saved in the quick startup file.")
1763 (defvar gnus-newsrc-options nil
1764 "Options line in the .newsrc file.")
1766 (defvar gnus-newsrc-options-n nil
1767 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1769 (defvar gnus-newsrc-last-checked-date nil
1770 "Date Gnus last asked server for new newsgroups.")
1772 (defvar gnus-topic-topology nil
1773 "The complete topic hierarchy.")
1775 (defvar gnus-topic-alist nil
1776 "The complete topic-group alist.")
1778 (defvar gnus-newsrc-alist nil
1779 "Assoc list of read articles.
1780 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1782 (defvar gnus-newsrc-hashtb nil
1783 "Hashtable of gnus-newsrc-alist.")
1785 (defvar gnus-killed-list nil
1786 "List of killed newsgroups.")
1788 (defvar gnus-killed-hashtb nil
1789 "Hash table equivalent of gnus-killed-list.")
1791 (defvar gnus-zombie-list nil
1792 "List of almost dead newsgroups.")
1794 (defvar gnus-description-hashtb nil
1795 "Descriptions of newsgroups.")
1797 (defvar gnus-list-of-killed-groups nil
1798 "List of newsgroups that have recently been killed by the user.")
1800 (defvar gnus-active-hashtb nil
1801 "Hashtable of active articles.")
1803 (defvar gnus-moderated-list nil
1804 "List of moderated newsgroups.")
1806 (defvar gnus-group-marked nil)
1808 (defvar gnus-current-startup-file nil
1809 "Startup file for the current host.")
1811 (defvar gnus-last-search-regexp nil
1812 "Default regexp for article search command.")
1814 (defvar gnus-last-shell-command nil
1815 "Default shell command on article.")
1817 (defvar gnus-current-select-method nil
1818 "The current method for selecting a newsgroup.")
1820 (defvar gnus-group-list-mode nil)
1822 (defvar gnus-article-internal-prepare-hook nil)
1824 (defvar gnus-newsgroup-name nil)
1825 (defvar gnus-newsgroup-begin nil)
1826 (defvar gnus-newsgroup-end nil)
1827 (defvar gnus-newsgroup-last-rmail nil)
1828 (defvar gnus-newsgroup-last-mail nil)
1829 (defvar gnus-newsgroup-last-folder nil)
1830 (defvar gnus-newsgroup-last-file nil)
1831 (defvar gnus-newsgroup-auto-expire nil)
1832 (defvar gnus-newsgroup-active nil)
1834 (defvar gnus-newsgroup-data nil)
1835 (defvar gnus-newsgroup-data-reverse nil)
1836 (defvar gnus-newsgroup-limit nil)
1837 (defvar gnus-newsgroup-limits nil)
1839 (defvar gnus-newsgroup-unreads nil
1840 "List of unread articles in the current newsgroup.")
1842 (defvar gnus-newsgroup-unselected nil
1843 "List of unselected unread articles in the current newsgroup.")
1845 (defvar gnus-newsgroup-reads nil
1846 "Alist of read articles and article marks in the current newsgroup.")
1848 (defvar gnus-newsgroup-expunged-tally nil)
1850 (defvar gnus-newsgroup-marked nil
1851 "List of ticked articles in the current newsgroup (a subset of unread art).")
1853 (defvar gnus-newsgroup-killed nil
1854 "List of ranges of articles that have been through the scoring process.")
1856 (defvar gnus-newsgroup-cached nil
1857 "List of articles that come from the article cache.")
1859 (defvar gnus-newsgroup-saved nil
1860 "List of articles that have been saved.")
1862 (defvar gnus-newsgroup-kill-headers nil)
1864 (defvar gnus-newsgroup-replied nil
1865 "List of articles that have been replied to in the current newsgroup.")
1867 (defvar gnus-newsgroup-expirable nil
1868 "List of articles in the current newsgroup that can be expired.")
1870 (defvar gnus-newsgroup-processable nil
1871 "List of articles in the current newsgroup that can be processed.")
1873 (defvar gnus-newsgroup-bookmarks nil
1874 "List of articles in the current newsgroup that have bookmarks.")
1876 (defvar gnus-newsgroup-dormant nil
1877 "List of dormant articles in the current newsgroup.")
1879 (defvar gnus-newsgroup-scored nil
1880 "List of scored articles in the current newsgroup.")
1882 (defvar gnus-newsgroup-headers nil
1883 "List of article headers in the current newsgroup.")
1885 (defvar gnus-newsgroup-threads nil)
1887 (defvar gnus-newsgroup-prepared nil
1888 "Whether the current group has been prepared properly.")
1890 (defvar gnus-newsgroup-ancient nil
1891 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1893 (defvar gnus-newsgroup-sparse nil)
1895 (defvar gnus-current-article nil)
1896 (defvar gnus-article-current nil)
1897 (defvar gnus-current-headers nil)
1898 (defvar gnus-have-all-headers nil)
1899 (defvar gnus-last-article nil)
1900 (defvar gnus-newsgroup-history nil)
1901 (defvar gnus-current-kill-article nil)
1903 ;; Save window configuration.
1904 (defvar gnus-prev-winconf nil)
1906 (defvar gnus-summary-mark-positions nil)
1907 (defvar gnus-group-mark-positions nil)
1909 (defvar gnus-reffed-article-number nil)
1911 ;;; Let the byte-compiler know that we know about this variable.
1912 (defvar rmail-default-rmail-file)
1914 (defvar gnus-cache-removable-articles nil)
1916 (defvar gnus-dead-summary nil)
1918 (defconst gnus-summary-local-variables
1919 '(gnus-newsgroup-name
1920 gnus-newsgroup-begin gnus-newsgroup-end
1921 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1922 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1923 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1924 gnus-newsgroup-unselected gnus-newsgroup-marked
1925 gnus-newsgroup-reads gnus-newsgroup-saved
1926 gnus-newsgroup-replied gnus-newsgroup-expirable
1927 gnus-newsgroup-processable gnus-newsgroup-killed
1928 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1929 gnus-newsgroup-headers gnus-newsgroup-threads
1930 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1931 gnus-current-article gnus-current-headers gnus-have-all-headers
1932 gnus-last-article gnus-article-internal-prepare-hook
1933 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1934 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1935 gnus-newsgroup-async gnus-thread-expunge-below
1936 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1937 (gnus-summary-mark-below . 0)
1938 gnus-newsgroup-active gnus-scores-exclude-files
1939 gnus-newsgroup-history gnus-newsgroup-ancient
1940 gnus-newsgroup-sparse
1941 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1942 gnus-newsgroup-adaptive-score-file
1943 (gnus-newsgroup-expunged-tally . 0)
1944 gnus-cache-removable-articles gnus-newsgroup-cached
1945 gnus-newsgroup-data gnus-newsgroup-data-reverse
1946 gnus-newsgroup-limit gnus-newsgroup-limits)
1947 "Variables that are buffer-local to the summary buffers.")
1949 (defconst gnus-bug-message
1950 "Sending a bug report to the Gnus Towers.
1951 ========================================
1953 The buffer below is a mail buffer. When you press `C-c C-c', it will
1954 be sent to the Gnus Bug Exterminators.
1956 At the bottom of the buffer you'll see lots of variable settings.
1957 Please do not delete those. They will tell the Bug People what your
1958 environment is, so that it will be easier to locate the bugs.
1960 If you have found a bug that makes Emacs go \"beep\", set
1961 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1962 and include the backtrace in your bug report.
1964 Please describe the bug in annoying, painstaking detail.
1966 Thank you for your help in stamping out bugs.
1969 ;;; End of variables.
1971 ;; Define some autoload functions Gnus might use.
1974 ;; This little mapcar goes through the list below and marks the
1975 ;; symbols in question as autoloaded functions.
1978 (let ((interactive (nth 1 (memq ':interactive package))))
1982 (when (consp function)
1983 (setq keymap (car (memq 'keymap function)))
1984 (setq function (car function)))
1985 (autoload function (car package) nil interactive keymap)))
1986 (if (eq (nth 1 package) ':interactive)
1989 '(("metamail" metamail-buffer)
1990 ("info" Info-goto-node)
1991 ("hexl" hexl-hex-string-to-integer)
1992 ("pp" pp pp-to-string pp-eval-expression)
1993 ("mail-extr" mail-extract-address-components)
1994 ("nnmail" nnmail-split-fancy nnmail-article-group)
1995 ("nnvirtual" nnvirtual-catchup-group)
1996 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1997 timezone-make-sortable-date timezone-make-time-string)
1998 ("sendmail" mail-position-on-field mail-setup)
1999 ("rmailout" rmail-output)
2000 ("rnewspost" news-mail-other-window news-reply-yank-original
2001 news-caesar-buffer-body)
2002 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2004 ("gnus-soup" :interactive t
2005 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2006 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2007 ("nnsoup" nnsoup-pack-replies)
2008 ("gnus-scomo" :interactive t gnus-score-mode)
2009 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2010 gnus-Folder-save-name gnus-folder-save-name)
2011 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2012 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2013 gnus-server-make-menu-bar gnus-article-make-menu-bar
2014 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2015 gnus-summary-highlight-line gnus-carpal-setup-buffer
2016 gnus-group-highlight-line
2017 gnus-article-add-button gnus-insert-next-page-button
2018 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2019 ("gnus-vis" :interactive t
2020 gnus-article-push-button gnus-article-press-button
2021 gnus-article-highlight gnus-article-highlight-some
2022 gnus-article-highlight-headers gnus-article-highlight-signature
2023 gnus-article-add-buttons gnus-article-add-buttons-to-head
2024 gnus-article-next-button gnus-article-prev-button)
2025 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2026 gnus-demon-add-disconnection gnus-demon-add-handler
2027 gnus-demon-remove-handler)
2028 ("gnus-demon" :interactive t
2029 gnus-demon-init gnus-demon-cancel)
2030 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2031 gnus-tree-open gnus-tree-close)
2032 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2033 gnus-nocem-unwanted-article-p)
2034 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2035 ("gnus-srvr" gnus-browse-foreign-server)
2036 ("gnus-cite" :interactive t
2037 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2038 gnus-article-hide-citation gnus-article-fill-cited-article
2039 gnus-article-hide-citation-in-followups)
2040 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2041 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2042 gnus-execute gnus-expunge)
2043 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2044 gnus-cache-possibly-remove-articles gnus-cache-request-article
2045 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2046 gnus-cache-enter-remove-article gnus-cached-article-p
2047 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2048 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2049 gnus-cache-remove-article)
2050 ("gnus-score" :interactive t
2051 gnus-summary-increase-score gnus-summary-lower-score
2052 gnus-score-flush-cache gnus-score-close
2053 gnus-score-raise-same-subject-and-select
2054 gnus-score-raise-same-subject gnus-score-default
2055 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2056 gnus-score-lower-same-subject gnus-score-lower-thread
2057 gnus-possibly-score-headers gnus-summary-raise-score
2058 gnus-summary-set-score gnus-summary-current-score)
2060 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2061 gnus-current-score-file-nondirectory gnus-score-adaptive
2062 gnus-score-find-trace gnus-score-file-name)
2063 ("gnus-edit" :interactive t gnus-score-customize)
2064 ("gnus-topic" :interactive t gnus-topic-mode)
2065 ("gnus-topic" gnus-topic-remove-group)
2066 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2067 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2068 ("gnus-uu" :interactive t
2069 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2070 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2071 gnus-uu-mark-by-regexp gnus-uu-mark-all
2072 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2073 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2074 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2075 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2076 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2077 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2078 gnus-uu-decode-binhex-view)
2079 ("gnus-msg" (gnus-summary-send-map keymap)
2080 gnus-mail-yank-original gnus-mail-send-and-exit
2081 gnus-sendmail-setup-mail gnus-article-mail
2082 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2083 ("gnus-msg" :interactive t
2084 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2085 gnus-summary-followup gnus-summary-followup-with-original
2086 gnus-summary-followup-and-reply
2087 gnus-summary-followup-and-reply-with-original
2088 gnus-summary-cancel-article gnus-summary-supersede-article
2089 gnus-post-news gnus-inews-news gnus-cancel-news
2090 gnus-summary-reply gnus-summary-reply-with-original
2091 gnus-summary-mail-forward gnus-summary-mail-other-window
2093 ("gnus-picon" :interactive t gnus-article-display-picons
2094 gnus-group-display-picons gnus-picons-article-display-x-face)
2095 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2096 gnus-grouplens-mode)
2097 ("gnus-vm" gnus-vm-mail-setup)
2098 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2099 gnus-summary-save-article-vm gnus-yank-article))))
2103 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2104 ;; If you want the cursor to go somewhere else, set these two
2105 ;; functions in some startup hook to whatever you want.
2106 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2107 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2109 ;;; Various macros and substs.
2111 (defun gnus-header-from (header)
2112 (mail-header-from header))
2114 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2115 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2116 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2117 (w (make-symbol "w"))
2118 (buf (make-symbol "buf")))
2119 `(let* ((,tempvar (selected-window))
2121 (,w (get-buffer-window ,buf 'visible)))
2126 (pop-to-buffer ,buf))
2128 (select-window ,tempvar)))))
2130 (defmacro gnus-gethash (string hashtable)
2131 "Get hash value of STRING in HASHTABLE."
2132 `(symbol-value (intern-soft ,string ,hashtable)))
2134 (defmacro gnus-sethash (string value hashtable)
2135 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2136 `(set (intern ,string ,hashtable) ,value))
2138 (defmacro gnus-intern-safe (string hashtable)
2139 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2140 `(let ((symbol (intern ,string ,hashtable)))
2145 (defmacro gnus-group-unread (group)
2146 "Get the currently computed number of unread articles in GROUP."
2147 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2149 (defmacro gnus-group-entry (group)
2150 "Get the newsrc entry for GROUP."
2151 `(gnus-gethash ,group gnus-newsrc-hashtb))
2153 (defmacro gnus-active (group)
2154 "Get active info on GROUP."
2155 `(gnus-gethash ,group gnus-active-hashtb))
2157 (defmacro gnus-set-active (group active)
2158 "Set GROUP's active info."
2159 `(gnus-sethash ,group ,active gnus-active-hashtb))
2161 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2162 ;; function `substring' might cut on a middle of multi-octet
2164 (defun gnus-truncate-string (str width)
2165 (substring str 0 width))
2167 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2168 ;; to limit the length of a string. This function is necessary since
2169 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2170 (defsubst gnus-limit-string (str width)
2171 (if (> (length str) width)
2172 (substring str 0 width)
2175 (defsubst gnus-simplify-subject-re (subject)
2176 "Remove \"Re:\" from subject lines."
2177 (if (string-match "^[Rr][Ee]: *" subject)
2178 (substring subject (match-end 0))
2181 (defsubst gnus-functionp (form)
2182 "Return non-nil if FORM is funcallable."
2183 (or (and (symbolp form) (fboundp form))
2184 (and (listp form) (eq (car form) 'lambda))))
2186 (defsubst gnus-goto-char (point)
2187 (and point (goto-char point)))
2189 (defmacro gnus-buffer-exists-p (buffer)
2190 `(let ((buffer ,buffer))
2192 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2195 (defmacro gnus-kill-buffer (buffer)
2196 `(let ((buf ,buffer))
2197 (if (gnus-buffer-exists-p buf)
2198 (kill-buffer buf))))
2200 (defsubst gnus-point-at-bol ()
2201 "Return point at the beginning of the line."
2208 (defsubst gnus-point-at-eol ()
2209 "Return point at the end of the line."
2216 (defun gnus-alive-p ()
2217 "Say whether Gnus is running or not."
2218 (and gnus-group-buffer
2219 (get-buffer gnus-group-buffer)))
2221 ;; Delete the current line (and the next N lines.);
2222 (defmacro gnus-delete-line (&optional n)
2223 `(delete-region (progn (beginning-of-line) (point))
2224 (progn (forward-line ,(or n 1)) (point))))
2226 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2227 (defvar gnus-init-inhibit nil)
2228 (defun gnus-read-init-file (&optional inhibit-next)
2229 (if gnus-init-inhibit
2230 (setq gnus-init-inhibit nil)
2231 (setq gnus-init-inhibit inhibit-next)
2233 (or (and (file-exists-p gnus-init-file)
2234 ;; Don't try to load a directory.
2235 (not (file-directory-p gnus-init-file)))
2236 (file-exists-p (concat gnus-init-file ".el"))
2237 (file-exists-p (concat gnus-init-file ".elc")))
2239 (load gnus-init-file nil t)
2241 (error "Error in %s: %s" gnus-init-file var))))))
2243 ;; Info access macros.
2245 (defmacro gnus-info-group (info)
2247 (defmacro gnus-info-rank (info)
2249 (defmacro gnus-info-read (info)
2251 (defmacro gnus-info-marks (info)
2253 (defmacro gnus-info-method (info)
2255 (defmacro gnus-info-params (info)
2258 (defmacro gnus-info-level (info)
2259 `(let ((rank (gnus-info-rank ,info)))
2263 (defmacro gnus-info-score (info)
2264 `(let ((rank (gnus-info-rank ,info)))
2265 (or (and (consp rank) (cdr rank)) 0)))
2267 (defmacro gnus-info-set-group (info group)
2268 `(setcar ,info ,group))
2269 (defmacro gnus-info-set-rank (info rank)
2270 `(setcar (nthcdr 1 ,info) ,rank))
2271 (defmacro gnus-info-set-read (info read)
2272 `(setcar (nthcdr 2 ,info) ,read))
2273 (defmacro gnus-info-set-marks (info marks)
2274 `(setcar (nthcdr 3 ,info) ,marks))
2275 (defmacro gnus-info-set-method (info method)
2276 `(setcar (nthcdr 4 ,info) ,method))
2277 (defmacro gnus-info-set-params (info params)
2278 `(setcar (nthcdr 5 ,info) ,params))
2280 (defmacro gnus-info-set-level (info level)
2281 `(let ((rank (cdr ,info)))
2282 (if (consp (car rank))
2283 (setcar (car rank) ,level)
2284 (setcar rank ,level))))
2285 (defmacro gnus-info-set-score (info score)
2286 `(let ((rank (cdr ,info)))
2287 (if (consp (car rank))
2288 (setcdr (car rank) ,score)
2289 (setcar rank (cons (car rank) ,score)))))
2291 (defmacro gnus-get-info (group)
2292 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2294 (defun gnus-byte-code (func)
2295 "Return a form that can be `eval'ed based on FUNC."
2296 (let ((fval (symbol-function func)))
2297 (if (byte-code-function-p fval)
2298 (let ((flist (append fval nil)))
2299 (setcar flist 'byte-code)
2301 (cons 'progn (cddr fval)))))
2303 ;;; Load the compatability functions.
2313 (defvar gnus-shutdown-alist nil)
2315 (defun gnus-add-shutdown (function &rest symbols)
2316 "Run FUNCTION whenever one of SYMBOLS is shut down."
2317 (push (cons function symbols) gnus-shutdown-alist))
2319 (defun gnus-shutdown (symbol)
2320 "Shut down everything that waits for SYMBOL."
2321 (let ((alist gnus-shutdown-alist)
2323 (while (setq entry (pop alist))
2324 (when (memq symbol (cdr entry))
2325 (funcall (car entry))))))
2329 ;; Format specs. The chunks below are the machine-generated forms
2330 ;; that are to be evaled as the result of the default format strings.
2331 ;; We write them in here to get them byte-compiled. That way the
2332 ;; default actions will be quite fast, while still retaining the full
2333 ;; flexibility of the user-defined format specs.
2335 ;; First we have lots of dummy defvars to let the compiler know these
2336 ;; are really dynamic variables.
2338 (defvar gnus-tmp-unread)
2339 (defvar gnus-tmp-replied)
2340 (defvar gnus-tmp-score-char)
2341 (defvar gnus-tmp-indentation)
2342 (defvar gnus-tmp-opening-bracket)
2343 (defvar gnus-tmp-lines)
2344 (defvar gnus-tmp-name)
2345 (defvar gnus-tmp-closing-bracket)
2346 (defvar gnus-tmp-subject-or-nil)
2347 (defvar gnus-tmp-subject)
2348 (defvar gnus-tmp-marked)
2349 (defvar gnus-tmp-marked-mark)
2350 (defvar gnus-tmp-subscribed)
2351 (defvar gnus-tmp-process-marked)
2352 (defvar gnus-tmp-number-of-unread)
2353 (defvar gnus-tmp-group-name)
2354 (defvar gnus-tmp-group)
2355 (defvar gnus-tmp-article-number)
2356 (defvar gnus-tmp-unread-and-unselected)
2357 (defvar gnus-tmp-news-method)
2358 (defvar gnus-tmp-news-server)
2359 (defvar gnus-tmp-article-number)
2360 (defvar gnus-mouse-face)
2361 (defvar gnus-mouse-face-prop)
2363 (defun gnus-summary-line-format-spec ()
2364 (insert gnus-tmp-unread gnus-tmp-replied
2365 gnus-tmp-score-char gnus-tmp-indentation)
2366 (gnus-put-text-property
2370 gnus-tmp-opening-bracket
2371 (format "%4d: %-20s"
2373 (if (> (length gnus-tmp-name) 20)
2374 (substring gnus-tmp-name 0 20)
2376 gnus-tmp-closing-bracket)
2378 gnus-mouse-face-prop gnus-mouse-face)
2379 (insert " " gnus-tmp-subject-or-nil "\n"))
2381 (defvar gnus-summary-line-format-spec
2382 (gnus-byte-code 'gnus-summary-line-format-spec))
2384 (defun gnus-summary-dummy-line-format-spec ()
2386 (gnus-put-text-property
2391 gnus-mouse-face-prop gnus-mouse-face)
2392 (insert " " gnus-tmp-subject "\n"))
2394 (defvar gnus-summary-dummy-line-format-spec
2395 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2397 (defun gnus-group-line-format-spec ()
2398 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2399 gnus-tmp-process-marked
2400 gnus-group-indentation
2401 (format "%5s: " gnus-tmp-number-of-unread))
2402 (gnus-put-text-property
2405 (insert gnus-tmp-group "\n")
2407 gnus-mouse-face-prop gnus-mouse-face))
2408 (defvar gnus-group-line-format-spec
2409 (gnus-byte-code 'gnus-group-line-format-spec))
2411 (defvar gnus-format-specs
2412 `((version . ,emacs-version)
2413 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2414 (summary-dummy ,gnus-summary-dummy-line-format
2415 ,gnus-summary-dummy-line-format-spec)
2416 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2418 (defvar gnus-article-mode-line-format-spec nil)
2419 (defvar gnus-summary-mode-line-format-spec nil)
2420 (defvar gnus-group-mode-line-format-spec nil)
2422 ;;; Phew. All that gruft is over, fortunately.
2426 ;;; Gnus Utility Functions
2429 (defun gnus-extract-address-components (from)
2431 ;; First find the address - the thing with the @ in it. This may
2432 ;; not be accurate in mail addresses, but does the trick most of
2433 ;; the time in news messages.
2434 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2435 (setq address (substring from (match-beginning 0) (match-end 0))))
2436 ;; Then we check whether the "name <address>" format is used.
2438 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2439 ;; Linear white space is not required.
2440 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2441 (and (setq name (substring from 0 (match-beginning 0)))
2442 ;; Strip any quotes from the name.
2443 (string-match "\".*\"" name)
2444 (setq name (substring name 1 (1- (match-end 0))))))
2445 ;; If not, then "address (name)" is used.
2447 (and (string-match "(.+)" from)
2448 (setq name (substring from (1+ (match-beginning 0))
2449 (1- (match-end 0)))))
2450 (and (string-match "()" from)
2451 (setq name address))
2452 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2453 ;; XOVER might not support folded From headers.
2454 (and (string-match "(.*" from)
2455 (setq name (substring from (1+ (match-beginning 0))
2457 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2458 (list (or name from) (or address from))))
2460 (defun gnus-fetch-field (field)
2461 "Return the value of the header FIELD of current article."
2464 (let ((case-fold-search t)
2465 (inhibit-point-motion-hooks t))
2466 (nnheader-narrow-to-headers)
2467 (message-fetch-field field)))))
2469 (defun gnus-goto-colon ()
2471 (search-forward ":" (gnus-point-at-eol) t))
2474 (defun gnus-update-format (var)
2475 "Update the format specification near point."
2480 ;; Find the end of the current word.
2481 (re-search-forward "[ \t\n]" nil t)
2483 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2484 (match-string 1)))))
2485 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2486 (match-string 1 var))))
2487 (entry (assq type gnus-format-specs))
2490 (setq gnus-format-specs (delq entry gnus-format-specs)))
2492 (intern (format "%s-spec" var))
2493 (gnus-parse-format (setq value (symbol-value (intern var)))
2494 (symbol-value (intern (format "%s-alist" var)))
2495 (not (string-match "mode" var))))
2496 (setq spec (symbol-value (intern (format "%s-spec" var))))
2497 (push (list type value spec) gnus-format-specs)
2499 (pop-to-buffer "*Gnus Format*")
2501 (lisp-interaction-mode)
2502 (insert (pp-to-string spec))))
2504 (defun gnus-update-format-specifications (&optional force)
2505 "Update all (necessary) format specifications."
2506 ;; Make the indentation array.
2507 (gnus-make-thread-indent-array)
2509 ;; See whether all the stored info needs to be flushed.
2511 (not (equal emacs-version
2512 (cdr (assq 'version gnus-format-specs)))))
2513 (setq gnus-format-specs nil))
2515 ;; Go through all the formats and see whether they need updating.
2516 (let ((types '(summary summary-dummy group
2517 summary-mode group-mode article-mode))
2518 new-format entry type val)
2519 (while (setq type (pop types))
2520 ;; Jump to the proper buffer to find out the value of
2521 ;; the variable, if possible. (It may be buffer-local.)
2523 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2525 (when (and (boundp buffer)
2526 (setq val (symbol-value buffer))
2528 (buffer-name (get-buffer val)))
2529 (set-buffer (get-buffer val)))
2530 (setq new-format (symbol-value
2531 (intern (format "gnus-%s-line-format" type))))))
2532 (setq entry (cdr (assq type gnus-format-specs)))
2534 (equal (car entry) new-format))
2535 ;; Use the old format.
2536 (set (intern (format "gnus-%s-line-format-spec" type))
2538 ;; This is a new format.
2540 (if (not (stringp new-format))
2541 ;; This is a function call or something.
2543 ;; This is a "real" format.
2547 (intern (format "gnus-%s-line-format-alist"
2548 (if (eq type 'article-mode)
2549 'summary-mode type))))
2550 (not (string-match "mode$" (symbol-name type))))))
2551 ;; Enter the new format spec into the list.
2554 (setcar (cdr entry) val)
2555 (setcar entry new-format))
2556 (push (list type new-format val) gnus-format-specs))
2557 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2559 (unless (assq 'version gnus-format-specs)
2560 (push (cons 'version emacs-version) gnus-format-specs))
2562 (gnus-update-group-mark-positions)
2563 (gnus-update-summary-mark-positions))
2565 (defun gnus-update-summary-mark-positions ()
2566 "Compute where the summary marks are to go."
2568 (when (and gnus-summary-buffer
2569 (get-buffer gnus-summary-buffer)
2570 (buffer-name (get-buffer gnus-summary-buffer)))
2571 (set-buffer gnus-summary-buffer))
2572 (let ((gnus-replied-mark 129)
2573 (gnus-score-below-mark 130)
2574 (gnus-score-over-mark 130)
2577 (spec gnus-summary-line-format-spec)
2580 (gnus-set-work-buffer)
2581 (let ((gnus-summary-line-format-spec spec))
2582 (gnus-summary-insert-line
2583 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2584 (goto-char (point-min))
2585 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2587 (goto-char (point-min))
2588 (push (cons 'replied (and (search-forward "\201" nil t)
2591 (goto-char (point-min))
2592 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2594 (setq gnus-summary-mark-positions pos))))
2596 (defun gnus-update-group-mark-positions ()
2598 (let ((gnus-process-mark 128)
2599 (gnus-group-marked '("dummy.group"))
2600 (gnus-active-hashtb (make-vector 10 0)))
2601 (gnus-set-active "dummy.group" '(0 . 0))
2602 (gnus-set-work-buffer)
2603 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2604 (goto-char (point-min))
2605 (setq gnus-group-mark-positions
2606 (list (cons 'process (and (search-forward "\200" nil t)
2607 (- (point) 2))))))))
2609 (defvar gnus-mouse-face-0 'highlight)
2610 (defvar gnus-mouse-face-1 'highlight)
2611 (defvar gnus-mouse-face-2 'highlight)
2612 (defvar gnus-mouse-face-3 'highlight)
2613 (defvar gnus-mouse-face-4 'highlight)
2615 (defun gnus-mouse-face-function (form type)
2616 `(gnus-put-text-property
2617 (point) (progn ,@form (point))
2618 gnus-mouse-face-prop
2621 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2623 (defvar gnus-face-0 'bold)
2624 (defvar gnus-face-1 'italic)
2625 (defvar gnus-face-2 'bold-italic)
2626 (defvar gnus-face-3 'bold)
2627 (defvar gnus-face-4 'bold)
2629 (defun gnus-face-face-function (form type)
2630 `(gnus-put-text-property
2631 (point) (progn ,@form (point))
2632 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2634 (defun gnus-max-width-function (el max-width)
2635 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2637 `(if (> (length ,el) ,max-width)
2638 (substring ,el 0 ,max-width)
2640 `(let ((val (eval ,el)))
2642 (setq val (int-to-string val)))
2643 (if (> (length val) ,max-width)
2644 (substring val 0 ,max-width)
2647 (defun gnus-parse-format (format spec-alist &optional insert)
2648 ;; This function parses the FORMAT string with the help of the
2649 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2650 ;; string. If the FORMAT string contains the specifiers %( and %)
2651 ;; the text between them will have the mouse-face text property.
2653 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2655 (gnus-parse-complex-format format spec-alist)
2656 ;; This is a simple format.
2657 (gnus-parse-simple-format format spec-alist insert)))
2659 (defun gnus-parse-complex-format (format spec-alist)
2661 (gnus-set-work-buffer)
2663 (goto-char (point-min))
2664 (while (re-search-forward "\"" nil t)
2665 (replace-match "\\\"" nil t))
2666 (goto-char (point-min))
2668 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2669 (let ((number (if (match-beginning 1)
2670 (match-string 1) "0"))
2671 (delim (aref (match-string 2) 0)))
2672 (if (or (= delim ?\() (= delim ?\{))
2673 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2675 (replace-match "\")\""))))
2676 (goto-char (point-max))
2678 (goto-char (point-min))
2679 (let ((form (read (current-buffer))))
2680 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2682 (defun gnus-complex-form-to-spec (form spec-alist)
2687 (gnus-parse-simple-format sform spec-alist t)
2688 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2689 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2693 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2694 ;; This function parses the FORMAT string with the help of the
2695 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2698 spec flist fstring newspec elem beg result dontinsert)
2700 (gnus-set-work-buffer)
2702 (goto-char (point-min))
2703 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2705 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2707 beg (1+ (match-beginning 0)))
2708 ;; First check if there are any specs that look anything like
2709 ;; "%12,12A", ie. with a "max width specification". These have
2710 ;; to be treated specially.
2711 (if (setq beg (match-beginning 1))
2715 (1+ (match-beginning 1)) (match-end 1))))
2717 (setq beg (match-beginning 2)))
2718 ;; Find the specification from `spec-alist'.
2719 (unless (setq elem (cdr (assq spec spec-alist)))
2720 (setq elem '("*" ?s)))
2721 ;; Treat user defined format specifiers specially.
2722 (when (eq (car elem) 'gnus-tmp-user-defined)
2725 (list (intern (concat "gnus-user-format-function-"
2727 'gnus-tmp-header) ?s))
2728 (delete-region (match-beginning 3) (match-end 3)))
2729 (if (not (zerop max-width))
2730 (let ((el (car elem)))
2731 (cond ((= (cadr elem) ?c)
2732 (setq el (list 'char-to-string el)))
2734 (setq el (list 'int-to-string el))))
2735 (setq flist (cons (gnus-max-width-function el max-width)
2739 (setq flist (cons (car elem) flist))
2740 (setq newspec (cadr elem)))))
2741 ;; Remove the old specification (and possibly a ",12" string).
2742 (delete-region beg (match-end 2))
2743 ;; Insert the new specification.
2746 (setq fstring (buffer-substring 1 (point-max))))
2747 ;; Do some postprocessing to increase efficiency.
2752 ((string= fstring "")
2754 ;; Not a format string.
2755 ((not (string-match "%" fstring))
2757 ;; A format string with just a single string spec.
2758 ((string= fstring "%s")
2760 ;; A single character.
2761 ((string= fstring "%c")
2764 ((string= fstring "%d")
2767 (list `(princ ,(car flist)))
2768 (list `(int-to-string ,(car flist)))))
2769 ;; Just lots of chars and strings.
2770 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2772 ;; A single string spec at the beginning of the spec.
2773 ((string-match "\\`%[sc][^%]+\\'" fstring)
2774 (list (car flist) (substring fstring 2)))
2775 ;; A single string spec in the middle of the spec.
2776 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2777 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2778 ;; A single string spec in the end of the spec.
2779 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2780 (list (match-string 1 fstring) (car flist)))
2781 ;; A more complex spec.
2783 (list (cons 'format (cons fstring (nreverse flist)))))))
2789 (cons 'insert result)))
2790 (cond ((stringp result)
2793 (cons 'concat result))
2796 (defun gnus-eval-format (format &optional alist props)
2797 "Eval the format variable FORMAT, using ALIST.
2798 If PROPS, insert the result."
2799 (let ((form (gnus-parse-format format alist props)))
2801 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2804 (defun gnus-remove-text-with-property (prop)
2805 "Delete all text in the current buffer with text property PROP."
2807 (goto-char (point-min))
2809 (while (get-text-property (point) prop)
2811 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2813 (defun gnus-set-work-buffer ()
2814 (if (get-buffer gnus-work-buffer)
2816 (set-buffer gnus-work-buffer)
2818 (set-buffer (get-buffer-create gnus-work-buffer))
2819 (kill-all-local-variables)
2820 (buffer-disable-undo (current-buffer))
2821 (gnus-add-current-to-buffer-list)))
2823 ;; Article file names when saving.
2825 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2826 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2827 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2828 Otherwise, it is like ~/News/news/group/num."
2831 (concat (if (gnus-use-long-file-name 'not-save)
2832 (gnus-capitalize-newsgroup newsgroup)
2833 (gnus-newsgroup-directory-form newsgroup))
2834 "/" (int-to-string (mail-header-number headers)))
2835 gnus-article-save-directory)))
2837 (string-equal (file-name-directory default)
2838 (file-name-directory last-file))
2839 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2841 (or last-file default))))
2843 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2844 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2845 If variable `gnus-use-long-file-name' is non-nil, it is
2846 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2849 (concat (if (gnus-use-long-file-name 'not-save)
2851 (gnus-newsgroup-directory-form newsgroup))
2852 "/" (int-to-string (mail-header-number headers)))
2853 gnus-article-save-directory)))
2855 (string-equal (file-name-directory default)
2856 (file-name-directory last-file))
2857 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2859 (or last-file default))))
2861 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2862 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2863 If variable `gnus-use-long-file-name' is non-nil, it is
2864 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2867 (if (gnus-use-long-file-name 'not-save)
2868 (gnus-capitalize-newsgroup newsgroup)
2869 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2870 gnus-article-save-directory)))
2872 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2873 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2874 If variable `gnus-use-long-file-name' is non-nil, it is
2875 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2878 (if (gnus-use-long-file-name 'not-save)
2880 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2881 gnus-article-save-directory)))
2883 ;; For subscribing new newsgroup
2885 (defun gnus-subscribe-hierarchical-interactive (groups)
2886 (let ((groups (sort groups 'string<))
2887 prefixes prefix start ans group starts)
2889 (setq prefixes (list "^"))
2890 (while (and groups prefixes)
2891 (while (not (string-match (car prefixes) (car groups)))
2892 (setq prefixes (cdr prefixes)))
2893 (setq prefix (car prefixes))
2894 (setq start (1- (length prefix)))
2895 (if (and (string-match "[^\\.]\\." (car groups) start)
2898 (concat "^" (substring (car groups) 0 (match-end 0))))
2899 (string-match prefix (cadr groups)))
2901 (setq prefixes (cons prefix prefixes))
2902 (message "Descend hierarchy %s? ([y]nsq): "
2903 (substring prefix 1 (1- (length prefix))))
2904 (setq ans (read-char))
2907 (string-match prefix
2908 (setq group (car groups))))
2909 (setq gnus-killed-list
2910 (cons group gnus-killed-list))
2911 (gnus-sethash group group gnus-killed-hashtb)
2912 (setq groups (cdr groups)))
2913 (setq starts (cdr starts)))
2916 (string-match prefix
2917 (setq group (car groups))))
2918 (gnus-sethash group group gnus-killed-hashtb)
2919 (gnus-subscribe-alphabetically (car groups))
2920 (setq groups (cdr groups)))
2921 (setq starts (cdr starts)))
2924 (setq group (car groups))
2925 (setq gnus-killed-list (cons group gnus-killed-list))
2926 (gnus-sethash group group gnus-killed-hashtb)
2927 (setq groups (cdr groups))))
2929 (message "Subscribe %s? ([n]yq)" (car groups))
2930 (setq ans (read-char))
2931 (setq group (car groups))
2933 (gnus-subscribe-alphabetically (car groups))
2934 (gnus-sethash group group gnus-killed-hashtb))
2937 (setq group (car groups))
2938 (setq gnus-killed-list (cons group gnus-killed-list))
2939 (gnus-sethash group group gnus-killed-hashtb)
2940 (setq groups (cdr groups))))
2942 (setq gnus-killed-list (cons group gnus-killed-list))
2943 (gnus-sethash group group gnus-killed-hashtb)))
2944 (setq groups (cdr groups)))))))
2946 (defun gnus-subscribe-randomly (newsgroup)
2947 "Subscribe new NEWSGROUP by making it the first newsgroup."
2948 (gnus-subscribe-newsgroup newsgroup))
2950 (defun gnus-subscribe-alphabetically (newgroup)
2951 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2952 (let ((groups (cdr gnus-newsrc-alist))
2954 (while (and (not before) groups)
2955 (if (string< newgroup (caar groups))
2956 (setq before (caar groups))
2957 (setq groups (cdr groups))))
2958 (gnus-subscribe-newsgroup newgroup before)))
2960 (defun gnus-subscribe-hierarchically (newgroup)
2961 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2962 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2964 (set-buffer (find-file-noselect gnus-current-startup-file))
2965 (let ((groupkey newgroup)
2967 (while (and (not before) groupkey)
2968 (goto-char (point-min))
2970 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2971 (while (and (re-search-forward groupkey-re nil t)
2973 (setq before (match-string 1))
2974 (string< before newgroup)))))
2975 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2977 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2978 (substring groupkey (match-beginning 1) (match-end 1)))))
2979 (gnus-subscribe-newsgroup newgroup before))))
2981 (defun gnus-subscribe-interactively (group)
2982 "Subscribe the new GROUP interactively.
2983 It is inserted in hierarchical newsgroup order if subscribed. If not,
2985 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2986 (gnus-subscribe-hierarchically group)
2987 (push group gnus-killed-list)))
2989 (defun gnus-subscribe-zombies (group)
2990 "Make the new GROUP into a zombie group."
2991 (push group gnus-zombie-list))
2993 (defun gnus-subscribe-killed (group)
2994 "Make the new GROUP a killed group."
2995 (push group gnus-killed-list))
2997 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2998 "Subscribe new NEWSGROUP.
2999 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3000 the first newsgroup."
3001 ;; We subscribe the group by changing its level to `subscribed'.
3002 (gnus-group-change-level
3003 newsgroup gnus-level-default-subscribed
3004 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3005 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3009 (defun gnus-newsgroup-directory-form (newsgroup)
3010 "Make hierarchical directory name from NEWSGROUP name."
3011 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3012 (len (length newsgroup))
3014 ;; If this is a foreign group, we don't want to translate the
3016 (if (setq idx (string-match ":" newsgroup))
3017 (aset newsgroup idx ?/)
3019 ;; Replace all occurrences of `.' with `/'.
3021 (if (= (aref newsgroup idx) ?.)
3022 (aset newsgroup idx ?/))
3023 (setq idx (1+ idx)))
3026 (defun gnus-newsgroup-savable-name (group)
3027 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3029 (nnheader-replace-chars-in-string group ?/ ?.))
3031 (defun gnus-make-directory (dir)
3032 "Make DIRECTORY recursively."
3033 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3034 ;; of the many mysteries of the universe.
3035 (let* ((dir (expand-file-name dir default-directory))
3037 (if (string-match "/$" dir)
3038 (setq dir (substring dir 0 (match-beginning 0))))
3039 ;; First go down the path until we find a directory that exists.
3040 (while (not (file-exists-p dir))
3041 (setq dirs (cons dir dirs))
3042 (string-match "/[^/]+$" dir)
3043 (setq dir (substring dir 0 (match-beginning 0))))
3044 ;; Then create all the subdirs.
3045 (while (and dirs (not err))
3047 (make-directory (car dirs))
3048 (error (setq err t)))
3049 (setq dirs (cdr dirs)))
3050 ;; We return whether we were successful or not.
3053 (defun gnus-capitalize-newsgroup (newsgroup)
3054 "Capitalize NEWSGROUP name."
3055 (and (not (zerop (length newsgroup)))
3056 (concat (char-to-string (upcase (aref newsgroup 0)))
3057 (substring newsgroup 1))))
3059 ;; Various... things.
3061 (defun gnus-simplify-subject (subject &optional re-only)
3062 "Remove `Re:' and words in parentheses.
3063 If RE-ONLY is non-nil, strip leading `Re:'s only."
3064 (let ((case-fold-search t)) ;Ignore case.
3065 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3066 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3067 (setq subject (substring subject (match-end 0))))
3068 ;; Remove uninteresting prefixes.
3069 (if (and (not re-only)
3070 gnus-simplify-ignored-prefixes
3071 (string-match gnus-simplify-ignored-prefixes subject))
3072 (setq subject (substring subject (match-end 0))))
3073 ;; Remove words in parentheses from end.
3075 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3076 (setq subject (substring subject 0 (match-beginning 0)))))
3077 ;; Return subject string.
3080 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3082 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3083 (defun gnus-simplify-buffer-fuzzy ()
3084 (goto-char (point-min))
3085 (while (search-forward "\t" nil t)
3086 (replace-match " " t t))
3087 (goto-char (point-min))
3088 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3089 (goto-char (match-beginning 0))
3091 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3092 (looking-at "^[[].*: .*[]]$"))
3093 (goto-char (point-min))
3094 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3096 (replace-match "" t t))
3097 (goto-char (point-min))
3098 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3099 (goto-char (match-end 0))
3102 (progn (goto-char (match-beginning 0)))
3103 (re-search-forward ":"))))
3104 (goto-char (point-min))
3105 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3106 (replace-match "" t t))
3107 (goto-char (point-min))
3108 (while (re-search-forward " +" nil t)
3109 (replace-match " " t t))
3110 (goto-char (point-min))
3111 (while (re-search-forward " $" nil t)
3112 (replace-match "" t t))
3113 (goto-char (point-min))
3114 (while (re-search-forward "^ +" nil t)
3115 (replace-match "" t t))
3116 (goto-char (point-min))
3117 (when gnus-simplify-subject-fuzzy-regexp
3118 (if (listp gnus-simplify-subject-fuzzy-regexp)
3119 (let ((list gnus-simplify-subject-fuzzy-regexp))
3121 (goto-char (point-min))
3122 (while (re-search-forward (car list) nil t)
3123 (replace-match "" t t))
3124 (setq list (cdr list))))
3125 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3126 (replace-match "" t t)))))
3128 (defun gnus-simplify-subject-fuzzy (subject)
3129 "Siplify a subject string fuzzily."
3131 (gnus-set-work-buffer)
3132 (let ((case-fold-search t))
3134 (inline (gnus-simplify-buffer-fuzzy))
3137 ;; Add the current buffer to the list of buffers to be killed on exit.
3138 (defun gnus-add-current-to-buffer-list ()
3139 (or (memq (current-buffer) gnus-buffer-list)
3140 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3142 (defun gnus-string> (s1 s2)
3143 (not (or (string< s1 s2)
3146 (defun gnus-read-active-file-p ()
3147 "Say whether the active file has been read from `gnus-select-method'."
3148 (memq gnus-select-method gnus-have-read-active-file))
3150 ;;; General various misc type functions.
3152 (defun gnus-clear-system ()
3153 "Clear all variables and buffers."
3154 ;; Clear Gnus variables.
3155 (let ((variables gnus-variable-list))
3157 (set (car variables) nil)
3158 (setq variables (cdr variables))))
3159 ;; Clear other internal variables.
3160 (setq gnus-list-of-killed-groups nil
3161 gnus-have-read-active-file nil
3162 gnus-newsrc-alist nil
3163 gnus-newsrc-hashtb nil
3164 gnus-killed-list nil
3165 gnus-zombie-list nil
3166 gnus-killed-hashtb nil
3167 gnus-active-hashtb nil
3168 gnus-moderated-list nil
3169 gnus-description-hashtb nil
3170 gnus-current-headers nil
3171 gnus-thread-indent-array nil
3172 gnus-newsgroup-headers nil
3173 gnus-newsgroup-name nil
3174 gnus-server-alist nil
3175 gnus-group-list-mode nil
3176 gnus-opened-servers nil
3177 gnus-current-select-method nil)
3178 (gnus-shutdown 'gnus)
3179 ;; Kill the startup file.
3180 (and gnus-current-startup-file
3181 (get-file-buffer gnus-current-startup-file)
3182 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3183 ;; Clear the dribble buffer.
3184 (gnus-dribble-clear)
3185 ;; Kill global KILL file buffer.
3186 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3187 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3188 (gnus-kill-buffer nntp-server-buffer)
3189 ;; Kill Gnus buffers.
3190 (while gnus-buffer-list
3191 (gnus-kill-buffer (pop gnus-buffer-list)))
3192 ;; Remove Gnus frames.
3193 (while gnus-created-frames
3194 (when (frame-live-p (car gnus-created-frames))
3195 ;; We slap a condition-case around this `delete-frame' to ensure
3196 ;; agains errors if we try do delete the single frame that's left.
3198 (delete-frame (car gnus-created-frames))
3200 (pop gnus-created-frames)))
3202 (defun gnus-windows-old-to-new (setting)
3203 ;; First we take care of the really, really old Gnus 3 actions.
3204 (when (symbolp setting)
3206 ;; Take care of ooold GNUS 3.x values.
3207 (cond ((eq setting 'SelectArticle) 'article)
3208 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3209 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3211 (if (or (listp setting)
3212 (not (and gnus-window-configuration
3213 (memq setting '(group summary article)))))
3215 (let* ((setting (if (eq setting 'group)
3216 (if (assq 'newsgroup gnus-window-configuration)
3218 'newsgroups) setting))
3219 (elem (cadr (assq setting gnus-window-configuration)))
3220 (total (apply '+ elem))
3221 (types '(group summary article))
3222 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3227 (or (not (numberp (nth i elem)))
3228 (zerop (nth i elem))
3230 (setq perc (/ (float (nth 0 elem)) total))
3231 (setq out (cons (if (eq pbuf (nth i types))
3232 (vector (nth i types) perc 'point)
3233 (vector (nth i types) perc))
3236 (list (nreverse out)))))
3239 (defun gnus-add-configuration (conf)
3240 "Add the window configuration CONF to `gnus-buffer-configuration'."
3241 (setq gnus-buffer-configuration
3242 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3243 gnus-buffer-configuration))))
3245 (defvar gnus-frame-list nil)
3247 (defun gnus-configure-frame (split &optional window)
3248 "Split WINDOW according to SPLIT."
3250 (setq window (get-buffer-window (current-buffer))))
3251 (select-window window)
3252 ;; This might be an old-stylee buffer config.
3253 (when (vectorp split)
3254 (setq split (append split nil)))
3255 (when (or (consp (car split))
3256 (vectorp (car split)))
3258 (push 'vertical split))
3259 ;; The SPLIT might be something that is to be evaled to
3260 ;; return a new SPLIT.
3261 (while (and (not (assq (car split) gnus-window-to-buffer))
3262 (gnus-functionp (car split)))
3263 (setq split (eval split)))
3264 (let* ((type (car split))
3266 (len (if (eq type 'horizontal) (window-width) (window-height)))
3268 (window-min-width (or gnus-window-min-width window-min-width))
3269 (window-min-height (or gnus-window-min-height window-min-height))
3270 s result new-win rest comp-subs size sub)
3272 ;; Nothing to do here.
3274 ;; Don't switch buffers.
3276 (and (memq 'point split) window))
3277 ;; This is a buffer to be selected.
3278 ((not (memq type '(frame horizontal vertical)))
3279 (let ((buffer (cond ((stringp type) type)
3280 (t (cdr (assq type gnus-window-to-buffer)))))
3283 (error "Illegal buffer type: %s" type))
3284 (unless (setq buf (get-buffer (if (symbolp buffer)
3285 (symbol-value buffer) buffer)))
3286 (setq buf (get-buffer-create (if (symbolp buffer)
3287 (symbol-value buffer) buffer))))
3288 (switch-to-buffer buf)
3289 ;; We return the window if it has the `point' spec.
3290 (and (memq 'point split) window)))
3291 ;; This is a frame split.
3293 (unless gnus-frame-list
3294 (setq gnus-frame-list (list (window-frame
3295 (get-buffer-window (current-buffer))))))
3297 params frame fresult)
3298 (while (< i (length subs))
3299 ;; Frame parameter is gotten from the sub-split.
3300 (setq params (cadr (elt subs i)))
3301 ;; It should be a list.
3302 (unless (listp params)
3304 ;; Create a new frame?
3305 (unless (setq frame (elt gnus-frame-list i))
3306 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3307 (push frame gnus-created-frames))
3308 ;; Is the old frame still alive?
3309 (unless (frame-live-p frame)
3310 (setcar (nthcdr i gnus-frame-list)
3311 (setq frame (make-frame params))))
3312 ;; Select the frame in question and do more splits there.
3313 (select-frame frame)
3314 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3316 ;; Select the frame that has the selected buffer.
3318 (select-frame (window-frame fresult)))))
3319 ;; This is a normal split.
3321 (when (> (length subs) 0)
3322 ;; First we have to compute the sizes of all new windows.
3324 (setq sub (append (pop subs) nil))
3325 (while (and (not (assq (car sub) gnus-window-to-buffer))
3326 (gnus-functionp (car sub)))
3327 (setq sub (eval sub)))
3329 (push sub comp-subs)
3330 (setq size (cadar comp-subs))
3331 (cond ((equal size 1.0)
3332 (setq rest (car comp-subs))
3335 (setq s (floor (* size len))))
3339 (error "Illegal size: %s" size)))
3340 ;; Try to make sure that we are inside the safe limits.
3342 ((eq type 'horizontal)
3343 (setq s (max s window-min-width)))
3344 ((eq type 'vertical)
3345 (setq s (max s window-min-height))))
3346 (setcar (cdar comp-subs) s)
3348 ;; Take care of the "1.0" spec.
3350 (setcar (cdr rest) (- len total))
3351 (error "No 1.0 specs in %s" split))
3352 ;; The we do the actual splitting in a nice recursive
3354 (setq comp-subs (nreverse comp-subs))
3356 (if (null (cdr comp-subs))
3357 (setq new-win window)
3359 (split-window window (cadar comp-subs)
3360 (eq type 'horizontal))))
3361 (setq result (or (gnus-configure-frame
3362 (car comp-subs) window) result))
3363 (select-window new-win)
3364 (setq window new-win)
3365 (setq comp-subs (cdr comp-subs))))
3366 ;; Return the proper window, if any.
3368 (select-window result))))))
3370 (defvar gnus-frame-split-p nil)
3372 (defun gnus-configure-windows (setting &optional force)
3373 (setq setting (gnus-windows-old-to-new setting))
3374 (let ((split (if (symbolp setting)
3375 (cadr (assq setting gnus-buffer-configuration))
3379 (setq gnus-frame-split-p nil)
3382 (error "No such setting: %s" setting))
3384 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3386 ;; All the windows mentioned are already visible, so we just
3387 ;; put point in the assigned buffer, and do not touch the
3389 (select-window all-visible)
3391 ;; Either remove all windows or just remove all Gnus windows.
3392 (let ((frame (selected-frame)))
3394 (if gnus-use-full-window
3395 ;; We want to remove all other windows.
3396 (if (not gnus-frame-split-p)
3397 ;; This is not a `frame' split, so we ignore the
3399 (delete-other-windows)
3400 ;; This is a `frame' split, so we delete all windows
3404 (unless (eq (cdr (assq 'minibuffer
3405 (frame-parameters frame)))
3407 (select-frame frame)
3408 (delete-other-windows)))
3410 ;; Just remove some windows.
3411 (gnus-remove-some-windows)
3412 (switch-to-buffer nntp-server-buffer))
3413 (select-frame frame)))
3415 (switch-to-buffer nntp-server-buffer)
3416 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3418 (defun gnus-all-windows-visible-p (split)
3419 "Say whether all buffers in SPLIT are currently visible.
3420 In particular, the value returned will be the window that
3422 (let ((stack (list split))
3424 type buffer win buf)
3425 (while (and (setq split (pop stack))
3427 ;; Be backwards compatible.
3428 (when (vectorp split)
3429 (setq split (append split nil)))
3430 (when (or (consp (car split))
3431 (vectorp (car split)))
3433 (push 'vertical split))
3434 ;; The SPLIT might be something that is to be evaled to
3435 ;; return a new SPLIT.
3436 (while (and (not (assq (car split) gnus-window-to-buffer))
3437 (gnus-functionp (car split)))
3438 (setq split (eval split)))
3440 (setq type (elt split 0))
3445 ((not (memq type '(horizontal vertical frame)))
3446 (setq buffer (cond ((stringp type) type)
3447 (t (cdr (assq type gnus-window-to-buffer)))))
3449 (error "Illegal buffer type: %s" type))
3450 (when (setq buf (get-buffer (if (symbolp buffer)
3451 (symbol-value buffer)
3453 (setq win (get-buffer-window buf t)))
3455 (when (memq 'point split)
3456 (setq all-visible win))
3457 (setq all-visible nil)))
3459 (when (eq type 'frame)
3460 (setq gnus-frame-split-p t))
3461 (setq stack (append (cddr split) stack)))))
3462 (unless (eq all-visible t)
3465 (defun gnus-window-top-edge (&optional window)
3466 (nth 1 (window-edges window)))
3468 (defun gnus-remove-some-windows ()
3469 (let ((buffers gnus-window-to-buffer)
3470 buf bufs lowest-buf lowest)
3472 ;; Remove windows on all known Gnus buffers.
3474 (setq buf (cdar buffers))
3476 (setq buf (and (boundp buf) (symbol-value buf))))
3478 (get-buffer-window buf)
3480 (setq bufs (cons buf bufs))
3482 (if (or (not lowest)
3483 (< (gnus-window-top-edge) lowest))
3485 (setq lowest (gnus-window-top-edge))
3486 (setq lowest-buf buf)))))
3487 (setq buffers (cdr buffers)))
3488 ;; Remove windows on *all* summary buffers.
3491 (let ((buf (window-buffer win)))
3492 (if (string-match "^\\*Summary" (buffer-name buf))
3494 (setq bufs (cons buf bufs))
3496 (if (or (not lowest)
3497 (< (gnus-window-top-edge) lowest))
3499 (setq lowest-buf buf)
3500 (setq lowest (gnus-window-top-edge)))))))))
3503 (pop-to-buffer lowest-buf)
3504 (switch-to-buffer nntp-server-buffer)))
3506 (and (not (eq (car bufs) lowest-buf))
3507 (delete-windows-on (car bufs)))
3508 (setq bufs (cdr bufs))))))
3510 (defun gnus-version ()
3511 "Version numbers of this version of Gnus."
3513 (let ((methods gnus-valid-select-methods)
3516 ;; Go through all the legal select methods and add their version
3517 ;; numbers to the total version string. Only the backends that are
3518 ;; currently in use will have their message numbers taken into
3521 (setq meth (intern (concat (caar methods) "-version")))
3523 (stringp (symbol-value meth))
3524 (setq mess (concat mess "; " (symbol-value meth))))
3525 (setq methods (cdr methods)))
3526 (gnus-message 2 mess)))
3528 (defun gnus-info-find-node ()
3529 "Find Info documentation of Gnus."
3531 ;; Enlarge info window if needed.
3532 (let ((mode major-mode)
3534 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3535 (setq gnus-info-buffer (current-buffer))
3536 (gnus-configure-windows 'info)))
3538 (defun gnus-days-between (date1 date2)
3539 ;; Return the number of days between date1 and date2.
3540 (- (gnus-day-number date1) (gnus-day-number date2)))
3542 (defun gnus-day-number (date)
3543 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3544 (timezone-parse-date date))))
3545 (timezone-absolute-from-gregorian
3546 (nth 1 dat) (nth 2 dat) (car dat))))
3548 (defun gnus-encode-date (date)
3549 "Convert DATE to internal time."
3550 (let* ((parse (timezone-parse-date date))
3551 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3552 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3553 (encode-time (caddr time) (cadr time) (car time)
3554 (caddr date) (cadr date) (car date) (nth 4 date))))
3556 (defun gnus-time-minus (t1 t2)
3557 "Subtract two internal times."
3558 (let ((borrow (< (cadr t1) (cadr t2))))
3559 (list (- (car t1) (car t2) (if borrow 1 0))
3560 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3562 (defun gnus-file-newer-than (file date)
3563 (let ((fdate (nth 5 (file-attributes file))))
3564 (or (> (car fdate) (car date))
3565 (and (= (car fdate) (car date))
3566 (> (nth 1 fdate) (nth 1 date))))))
3568 (defmacro gnus-local-set-keys (&rest plist)
3569 "Set the keys in PLIST in the current keymap."
3570 `(gnus-define-keys-1 (current-local-map) ',plist))
3572 (defmacro gnus-define-keys (keymap &rest plist)
3573 "Define all keys in PLIST in KEYMAP."
3574 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3576 (put 'gnus-define-keys 'lisp-indent-function 1)
3577 (put 'gnus-define-keys 'lisp-indent-hook 1)
3578 (put 'gnus-define-keymap 'lisp-indent-function 1)
3579 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3581 (defmacro gnus-define-keymap (keymap &rest plist)
3582 "Define all keys in PLIST in KEYMAP."
3583 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3585 (defun gnus-define-keys-1 (keymap plist)
3587 (error "Can't set keys in a null keymap"))
3588 (cond ((symbolp keymap)
3589 (setq keymap (symbol-value keymap)))
3592 (set (car keymap) nil)
3593 (define-prefix-command (car keymap))
3594 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3595 (setq keymap (symbol-value (car keymap)))))
3598 (when (symbolp (setq key (pop plist)))
3599 (setq key (symbol-value key)))
3600 (define-key keymap key (pop plist)))))
3602 (defun gnus-group-read-only-p (&optional group)
3603 "Check whether GROUP supports editing or not.
3604 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3605 that that variable is buffer-local to the summary buffers."
3606 (let ((group (or group gnus-newsgroup-name)))
3607 (not (gnus-check-backend-function 'request-replace-article group))))
3609 (defun gnus-group-total-expirable-p (group)
3610 "Check whether GROUP is total-expirable or not."
3611 (let ((params (gnus-info-params (gnus-get-info group))))
3612 (or (memq 'total-expire params)
3613 (cdr (assq 'total-expire params)) ; (total-expire . t)
3614 (and gnus-total-expirable-newsgroups ; Check var.
3615 (string-match gnus-total-expirable-newsgroups group)))))
3617 (defun gnus-group-auto-expirable-p (group)
3618 "Check whether GROUP is total-expirable or not."
3619 (let ((params (gnus-info-params (gnus-get-info group))))
3620 (or (memq 'auto-expire params)
3621 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3622 (and gnus-auto-expirable-newsgroups ; Check var.
3623 (string-match gnus-auto-expirable-newsgroups group)))))
3625 (defun gnus-virtual-group-p (group)
3626 "Say whether GROUP is virtual or not."
3627 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3628 gnus-valid-select-methods)))
3630 (defun gnus-news-group-p (group &optional article)
3631 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3632 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3633 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3634 (eq (gnus-request-type group article) 'news))))
3636 (defsubst gnus-simplify-subject-fully (subject)
3637 "Simplify a subject string according to the user's wishes."
3639 ((null gnus-summary-gather-subject-limit)
3640 (gnus-simplify-subject-re subject))
3641 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3642 (gnus-simplify-subject-fuzzy subject))
3643 ((numberp gnus-summary-gather-subject-limit)
3644 (gnus-limit-string (gnus-simplify-subject-re subject)
3645 gnus-summary-gather-subject-limit))
3649 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3650 "Check whether two subjects are equal. If optional argument
3651 simple-first is t, first argument is already simplified."
3653 ((null simple-first)
3654 (equal (gnus-simplify-subject-fully s1)
3655 (gnus-simplify-subject-fully s2)))
3658 (gnus-simplify-subject-fully s2)))))
3660 ;; Returns a list of writable groups.
3661 (defun gnus-writable-groups ()
3662 (let ((alist gnus-newsrc-alist)
3664 (while (setq group (car (pop alist)))
3665 (unless (gnus-group-read-only-p group)
3666 (push group groups)))
3669 (defun gnus-completing-read (default prompt &rest args)
3670 ;; Like `completing-read', except that DEFAULT is the default argument.
3671 (let* ((prompt (if default
3672 (concat prompt " (default " default ") ")
3673 (concat prompt " ")))
3674 (answer (apply 'completing-read prompt args)))
3675 (if (or (null answer) (zerop (length answer)))
3679 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3681 (defun gnus-y-or-n-p (prompt)
3686 (defun gnus-yes-or-no-p (prompt)
3688 (yes-or-no-p prompt)
3691 ;; Check whether to use long file names.
3692 (defun gnus-use-long-file-name (symbol)
3693 ;; The variable has to be set...
3694 (and gnus-use-long-file-name
3695 ;; If it isn't a list, then we return t.
3696 (or (not (listp gnus-use-long-file-name))
3697 ;; If it is a list, and the list contains `symbol', we
3699 (not (memq symbol gnus-use-long-file-name)))))
3701 ;; I suspect there's a better way, but I haven't taken the time to do
3702 ;; it yet. -erik selberg@cs.washington.edu
3703 (defun gnus-dd-mmm (messy-date)
3704 "Return a string like DD-MMM from a big messy string"
3705 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3711 ;; Make sure leading zeroes are stripped.
3712 (number-to-string (string-to-number (aref datevec 2)))
3716 (nth (1- (string-to-number (aref datevec 1)))
3717 timezone-months-assoc))
3720 (defun gnus-mode-string-quote (string)
3721 "Quote all \"%\" in STRING."
3723 (gnus-set-work-buffer)
3725 (goto-char (point-min))
3726 (while (search-forward "%" nil t)
3730 ;; Make a hash table (default and minimum size is 255).
3731 ;; Optional argument HASHSIZE specifies the table size.
3732 (defun gnus-make-hashtable (&optional hashsize)
3733 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3735 ;; Make a number that is suitable for hashing; bigger than MIN and one
3737 (defun gnus-create-hash-size (min)
3743 ;; Show message if message has a lower level than `gnus-verbose'.
3744 ;; Guideline for numbers:
3745 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3746 ;; for things that take a long time, 7 - not very important messages
3747 ;; on stuff, 9 - messages inside loops.
3748 (defun gnus-message (level &rest args)
3749 (if (<= level gnus-verbose)
3750 (apply 'message args)
3751 ;; We have to do this format thingy here even if the result isn't
3752 ;; shown - the return value has to be the same as the return value
3754 (apply 'format args)))
3756 (defun gnus-error (level &rest args)
3757 "Beep an error if `gnus-verbose' is on LEVEL or less."
3758 (when (<= (floor level) gnus-verbose)
3759 (apply 'message args)
3762 (when (and (floatp level)
3763 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3764 (sit-for duration))))
3767 ;; Generate a unique new group name.
3768 (defun gnus-generate-new-group-name (leaf)
3771 (while (gnus-gethash name gnus-newsrc-hashtb)
3772 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3775 (defsubst gnus-hide-text (b e props)
3776 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3777 (gnus-add-text-properties b e props)
3778 (when (memq 'intangible props)
3779 (gnus-put-text-property (max (1- b) (point-min))
3780 b 'intangible (cddr (memq 'intangible props)))))
3782 (defsubst gnus-unhide-text (b e)
3783 "Remove hidden text properties from region between B and E."
3784 (remove-text-properties b e gnus-hidden-properties)
3785 (when (memq 'intangible gnus-hidden-properties)
3786 (gnus-put-text-property (max (1- b) (point-min))
3787 b 'intangible nil)))
3789 (defun gnus-hide-text-type (b e type)
3790 "Hide text of TYPE between B and E."
3791 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3793 ;; Find out whether the gnus-visual TYPE is wanted.
3794 (defun gnus-visual-p (&optional type class)
3795 (and gnus-visual ; Has to be non-nil, at least.
3796 (if (not type) ; We don't care about type.
3798 (if (listp gnus-visual) ; It's a list, so we check it.
3799 (or (memq type gnus-visual)
3800 (memq class gnus-visual))
3803 (defun gnus-parent-headers (headers &optional generation)
3804 "Return the headers of the GENERATIONeth parent of HEADERS."
3806 (setq generation 1))
3807 (let (references parent)
3808 (while (and headers (not (zerop generation)))
3809 (setq references (mail-header-references headers))
3810 (when (and references
3811 (setq parent (gnus-parent-id references))
3812 (setq headers (car (gnus-id-to-thread parent))))
3816 (defun gnus-parent-id (references)
3817 "Return the last Message-ID in REFERENCES."
3818 (when (and references
3819 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3820 (substring references (match-beginning 1) (match-end 1))))
3822 (defun gnus-split-references (references)
3823 "Return a list of Message-IDs in REFERENCES."
3826 (while (string-match "<[^>]+>" references beg)
3827 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3831 (defun gnus-buffer-live-p (buffer)
3832 "Say whether BUFFER is alive or not."
3835 (buffer-name (get-buffer buffer))))
3837 (defun gnus-ephemeral-group-p (group)
3838 "Say whether GROUP is ephemeral or not."
3839 (gnus-group-get-parameter group 'quit-config))
3841 (defun gnus-group-quit-config (group)
3842 "Return the quit-config of GROUP."
3843 (gnus-group-get-parameter group 'quit-config))
3845 (defun gnus-simplify-mode-line ()
3846 "Make mode lines a bit simpler."
3847 (setq mode-line-modified "-- ")
3848 (when (listp mode-line-format)
3849 (make-local-variable 'mode-line-format)
3850 (setq mode-line-format (copy-sequence mode-line-format))
3851 (when (equal (nth 3 mode-line-format) " ")
3852 (setcar (nthcdr 3 mode-line-format) " "))))
3854 ;;; List and range functions
3856 (defun gnus-last-element (list)
3857 "Return last element of LIST."
3859 (setq list (cdr list)))
3862 (defun gnus-copy-sequence (list)
3863 "Do a complete, total copy of a list."
3864 (if (and (consp list) (not (consp (cdr list))))
3865 (cons (car list) (cdr list))
3866 (mapcar (lambda (elem) (if (consp elem)
3867 (if (consp (cdr elem))
3868 (gnus-copy-sequence elem)
3869 (cons (car elem) (cdr elem)))
3873 (defun gnus-set-difference (list1 list2)
3874 "Return a list of elements of LIST1 that do not appear in LIST2."
3875 (let ((list1 (copy-sequence list1)))
3877 (setq list1 (delq (car list2) list1))
3878 (setq list2 (cdr list2)))
3881 (defun gnus-sorted-complement (list1 list2)
3882 "Return a list of elements of LIST1 that do not appear in LIST2.
3883 Both lists have to be sorted over <."
3885 (if (or (null list1) (null list2))
3887 (while (and list1 list2)
3888 (cond ((= (car list1) (car list2))
3889 (setq list1 (cdr list1)
3891 ((< (car list1) (car list2))
3892 (setq out (cons (car list1) out))
3893 (setq list1 (cdr list1)))
3895 (setq out (cons (car list2) out))
3896 (setq list2 (cdr list2)))))
3897 (nconc (nreverse out) (or list1 list2)))))
3899 (defun gnus-intersection (list1 list2)
3902 (if (memq (car list2) list1)
3903 (setq result (cons (car list2) result)))
3904 (setq list2 (cdr list2)))
3907 (defun gnus-sorted-intersection (list1 list2)
3908 ;; LIST1 and LIST2 have to be sorted over <.
3910 (while (and list1 list2)
3911 (cond ((= (car list1) (car list2))
3912 (setq out (cons (car list1) out)
3915 ((< (car list1) (car list2))
3916 (setq list1 (cdr list1)))
3918 (setq list2 (cdr list2)))))
3921 (defun gnus-set-sorted-intersection (list1 list2)
3922 ;; LIST1 and LIST2 have to be sorted over <.
3923 ;; This function modifies LIST1.
3924 (let* ((top (cons nil list1))
3926 (while (and list1 list2)
3927 (cond ((= (car list1) (car list2))
3931 ((< (car list1) (car list2))
3932 (setcdr prev (cdr list1))
3933 (setq list1 (cdr list1)))
3935 (setq list2 (cdr list2)))))
3939 (defun gnus-compress-sequence (numbers &optional always-list)
3940 "Convert list of numbers to a list of ranges or a single range.
3941 If ALWAYS-LIST is non-nil, this function will always release a list of
3943 (let* ((first (car numbers))
3944 (last (car numbers))
3948 (if (not (listp (cdr numbers)))
3951 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3952 ((= (1+ last) (car numbers)) ;Still in sequence
3953 (setq last (car numbers)))
3954 (t ;End of one sequence
3956 (cons (if (= first last) first
3957 (cons first last)) result))
3958 (setq first (car numbers))
3959 (setq last (car numbers))))
3960 (setq numbers (cdr numbers)))
3961 (if (and (not always-list) (null result))
3962 (if (= first last) (list first) (cons first last))
3963 (nreverse (cons (if (= first last) first (cons first last))
3966 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3967 (defun gnus-uncompress-range (ranges)
3968 "Expand a list of ranges into a list of numbers.
3969 RANGES is either a single range on the form `(num . num)' or a list of
3971 (let (first last result)
3975 ((not (listp (cdr ranges)))
3976 (setq first (car ranges))
3977 (setq last (cdr ranges))
3978 (while (<= first last)
3979 (setq result (cons first result))
3980 (setq first (1+ first)))
3984 (if (atom (car ranges))
3985 (if (numberp (car ranges))
3986 (setq result (cons (car ranges) result)))
3987 (setq first (caar ranges))
3988 (setq last (cdar ranges))
3989 (while (<= first last)
3990 (setq result (cons first result))
3991 (setq first (1+ first))))
3992 (setq ranges (cdr ranges)))
3993 (nreverse result)))))
3995 (defun gnus-add-to-range (ranges list)
3996 "Return a list of ranges that has all articles from both RANGES and LIST.
3997 Note: LIST has to be sorted over `<'."
3999 (gnus-compress-sequence list t)
4000 (setq list (copy-sequence list))
4001 (or (listp (cdr ranges))
4002 (setq ranges (list ranges)))
4004 ilist lowest highest temp)
4005 (while (and ranges list)
4007 (setq lowest (or (and (atom (car ranges)) (car ranges))
4009 (while (and list (cdr list) (< (cadr list) lowest))
4010 (setq list (cdr list)))
4011 (if (< (car ilist) lowest)
4014 (setq list (cdr list))
4016 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4017 (setq highest (or (and (atom (car ranges)) (car ranges))
4019 (while (and list (<= (car list) highest))
4020 (setq list (cdr list)))
4021 (setq ranges (cdr ranges)))
4023 (setq out (nconc (gnus-compress-sequence list t) out)))
4024 (setq out (sort out (lambda (r1 r2)
4025 (< (or (and (atom r1) r1) (car r1))
4026 (or (and (atom r2) r2) (car r2))))))
4029 (if (atom (car ranges))
4031 (if (atom (cadr ranges))
4032 (if (= (1+ (car ranges)) (cadr ranges))
4034 (setcar ranges (cons (car ranges)
4036 (setcdr ranges (cddr ranges))))
4037 (if (= (1+ (car ranges)) (caadr ranges))
4039 (setcar (cadr ranges) (car ranges))
4040 (setcar ranges (cadr ranges))
4041 (setcdr ranges (cddr ranges))))))
4043 (if (atom (cadr ranges))
4044 (if (= (1+ (cdar ranges)) (cadr ranges))
4046 (setcdr (car ranges) (cadr ranges))
4047 (setcdr ranges (cddr ranges))))
4048 (if (= (1+ (cdar ranges)) (caadr ranges))
4050 (setcdr (car ranges) (cdadr ranges))
4051 (setcdr ranges (cddr ranges)))))))
4052 (setq ranges (cdr ranges)))
4055 (defun gnus-remove-from-range (ranges list)
4056 "Return a list of ranges that has all articles from LIST removed from RANGES.
4057 Note: LIST has to be sorted over `<'."
4058 ;; !!! This function shouldn't look like this, but I've got a headache.
4059 (gnus-compress-sequence
4060 (gnus-sorted-complement
4061 (gnus-uncompress-range ranges) list)))
4063 (defun gnus-member-of-range (number ranges)
4064 (if (not (listp (cdr ranges)))
4065 (and (>= number (car ranges))
4066 (<= number (cdr ranges)))
4069 (if (numberp (car ranges))
4070 (>= number (car ranges))
4071 (>= number (caar ranges)))
4073 (if (if (numberp (car ranges))
4074 (= number (car ranges))
4075 (and (>= number (caar ranges))
4076 (<= number (cdar ranges))))
4077 (setq not-stop nil))
4078 (setq ranges (cdr ranges)))
4081 (defun gnus-range-length (range)
4082 "Return the length RANGE would have if uncompressed."
4083 (length (gnus-uncompress-range range)))
4085 (defun gnus-sublist-p (list sublist)
4086 "Test whether all elements in SUBLIST are members of LIST."
4089 (unless (memq (pop sublist) list)
4099 (defvar gnus-group-mode-map nil)
4100 (put 'gnus-group-mode 'mode-class 'special)
4102 (unless gnus-group-mode-map
4103 (setq gnus-group-mode-map (make-keymap))
4104 (suppress-keymap gnus-group-mode-map)
4106 (gnus-define-keys gnus-group-mode-map
4107 " " gnus-group-read-group
4108 "=" gnus-group-select-group
4109 "\r" gnus-group-select-group
4110 "\M-\r" gnus-group-quick-select-group
4111 "j" gnus-group-jump-to-group
4112 "n" gnus-group-next-unread-group
4113 "p" gnus-group-prev-unread-group
4114 "\177" gnus-group-prev-unread-group
4115 [delete] gnus-group-prev-unread-group
4116 "N" gnus-group-next-group
4117 "P" gnus-group-prev-group
4118 "\M-n" gnus-group-next-unread-group-same-level
4119 "\M-p" gnus-group-prev-unread-group-same-level
4120 "," gnus-group-best-unread-group
4121 "." gnus-group-first-unread-group
4122 "u" gnus-group-unsubscribe-current-group
4123 "U" gnus-group-unsubscribe-group
4124 "c" gnus-group-catchup-current
4125 "C" gnus-group-catchup-current-all
4126 "l" gnus-group-list-groups
4127 "L" gnus-group-list-all-groups
4129 "g" gnus-group-get-new-news
4130 "\M-g" gnus-group-get-new-news-this-group
4131 "R" gnus-group-restart
4132 "r" gnus-group-read-init-file
4133 "B" gnus-group-browse-foreign-server
4134 "b" gnus-group-check-bogus-groups
4135 "F" gnus-find-new-newsgroups
4136 "\C-c\C-d" gnus-group-describe-group
4137 "\M-d" gnus-group-describe-all-groups
4138 "\C-c\C-a" gnus-group-apropos
4139 "\C-c\M-\C-a" gnus-group-description-apropos
4140 "a" gnus-group-post-news
4141 "\ek" gnus-group-edit-local-kill
4142 "\eK" gnus-group-edit-global-kill
4143 "\C-k" gnus-group-kill-group
4144 "\C-y" gnus-group-yank-group
4145 "\C-w" gnus-group-kill-region
4146 "\C-x\C-t" gnus-group-transpose-groups
4147 "\C-c\C-l" gnus-group-list-killed
4148 "\C-c\C-x" gnus-group-expire-articles
4149 "\C-c\M-\C-x" gnus-group-expire-all-groups
4151 "s" gnus-group-save-newsrc
4152 "z" gnus-group-suspend
4153 "Z" gnus-group-clear-dribble
4156 "?" gnus-group-describe-briefly
4157 "\C-c\C-i" gnus-info-find-node
4158 "\M-e" gnus-group-edit-group-method
4159 "^" gnus-group-enter-server-mode
4160 gnus-mouse-2 gnus-mouse-pick-group
4161 "<" beginning-of-buffer
4164 "\C-c\C-s" gnus-group-sort-groups
4166 "\C-c\M-g" gnus-activate-all-groups
4167 "\M-&" gnus-group-universal-argument
4168 "#" gnus-group-mark-group
4169 "\M-#" gnus-group-unmark-group)
4171 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4172 "m" gnus-group-mark-group
4173 "u" gnus-group-unmark-group
4174 "w" gnus-group-mark-region
4175 "m" gnus-group-mark-buffer
4176 "r" gnus-group-mark-regexp
4177 "U" gnus-group-unmark-all-groups)
4179 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4180 "d" gnus-group-make-directory-group
4181 "h" gnus-group-make-help-group
4182 "a" gnus-group-make-archive-group
4183 "k" gnus-group-make-kiboze-group
4184 "m" gnus-group-make-group
4185 "E" gnus-group-edit-group
4186 "e" gnus-group-edit-group-method
4187 "p" gnus-group-edit-group-parameters
4188 "v" gnus-group-add-to-virtual
4189 "V" gnus-group-make-empty-virtual
4190 "D" gnus-group-enter-directory
4191 "f" gnus-group-make-doc-group
4192 "r" gnus-group-rename-group
4193 "\177" gnus-group-delete-group
4194 [delete] gnus-group-delete-group)
4196 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4197 "b" gnus-group-brew-soup
4198 "w" gnus-soup-save-areas
4199 "s" gnus-soup-send-replies
4200 "p" gnus-soup-pack-packet
4201 "r" nnsoup-pack-replies)
4203 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4204 "s" gnus-group-sort-groups
4205 "a" gnus-group-sort-groups-by-alphabet
4206 "u" gnus-group-sort-groups-by-unread
4207 "l" gnus-group-sort-groups-by-level
4208 "v" gnus-group-sort-groups-by-score
4209 "r" gnus-group-sort-groups-by-rank
4210 "m" gnus-group-sort-groups-by-method)
4212 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4213 "k" gnus-group-list-killed
4214 "z" gnus-group-list-zombies
4215 "s" gnus-group-list-groups
4216 "u" gnus-group-list-all-groups
4217 "A" gnus-group-list-active
4218 "a" gnus-group-apropos
4219 "d" gnus-group-description-apropos
4220 "m" gnus-group-list-matching
4221 "M" gnus-group-list-all-matching
4222 "l" gnus-group-list-level)
4224 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4225 "f" gnus-score-flush-cache)
4227 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4228 "f" gnus-group-fetch-faq)
4230 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4231 "l" gnus-group-set-current-level
4232 "t" gnus-group-unsubscribe-current-group
4233 "s" gnus-group-unsubscribe-group
4234 "k" gnus-group-kill-group
4235 "y" gnus-group-yank-group
4236 "w" gnus-group-kill-region
4237 "\C-k" gnus-group-kill-level
4238 "z" gnus-group-kill-all-zombies))
4240 (defun gnus-group-mode ()
4241 "Major mode for reading news.
4243 All normal editing commands are switched off.
4244 \\<gnus-group-mode-map>
4245 The group buffer lists (some of) the groups available. For instance,
4246 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4247 lists all zombie groups.
4249 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4250 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4252 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4254 The following commands are available:
4256 \\{gnus-group-mode-map}"
4258 (when (and menu-bar-mode
4259 (gnus-visual-p 'group-menu 'menu))
4260 (gnus-group-make-menu-bar))
4261 (kill-all-local-variables)
4262 (gnus-simplify-mode-line)
4263 (setq major-mode 'gnus-group-mode)
4264 (setq mode-name "Group")
4265 (gnus-group-set-mode-line)
4266 (setq mode-line-process nil)
4267 (use-local-map gnus-group-mode-map)
4268 (buffer-disable-undo (current-buffer))
4269 (setq truncate-lines t)
4270 (setq buffer-read-only t)
4271 (gnus-make-local-hook 'post-command-hook)
4272 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4273 (run-hooks 'gnus-group-mode-hook))
4275 (defun gnus-clear-inboxes-moved ()
4276 (setq nnmail-moved-inboxes nil))
4278 (defun gnus-mouse-pick-group (e)
4279 "Enter the group under the mouse pointer."
4282 (gnus-group-read-group nil))
4284 ;; Look at LEVEL and find out what the level is really supposed to be.
4285 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4286 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4287 (defun gnus-group-default-level (&optional level number-or-nil)
4289 (gnus-group-use-permanent-levels
4290 (or (setq gnus-group-use-permanent-levels
4291 (or level (if (numberp gnus-group-use-permanent-levels)
4292 gnus-group-use-permanent-levels
4293 (or gnus-group-default-list-level
4294 gnus-level-subscribed))))
4295 gnus-group-default-list-level gnus-level-subscribed))
4299 (or level gnus-group-default-list-level gnus-level-subscribed))))
4302 (defun gnus-slave-no-server (&optional arg)
4303 "Read network news as a slave, without connecting to local server"
4305 (gnus-no-server arg t))
4308 (defun gnus-no-server (&optional arg slave)
4310 If ARG is a positive number, Gnus will use that as the
4311 startup level. If ARG is nil, Gnus will be started at level 2.
4312 If ARG is non-nil and not a positive number, Gnus will
4313 prompt the user for the name of an NNTP server to use.
4314 As opposed to `gnus', this command will not connect to the local server."
4316 (let ((val (or arg (1- gnus-level-default-subscribed))))
4318 (make-local-variable 'gnus-group-use-permanent-levels)
4319 (setq gnus-group-use-permanent-levels val)))
4322 (defun gnus-slave (&optional arg)
4323 "Read news as a slave."
4325 (gnus arg nil 'slave))
4328 (defun gnus-other-frame (&optional arg)
4329 "Pop up a frame to read news."
4331 (if (get-buffer gnus-group-buffer)
4332 (let ((pop-up-frames t))
4334 (select-frame (make-frame))
4338 (defun gnus (&optional arg dont-connect slave)
4340 If ARG is non-nil and a positive number, Gnus will use that as the
4341 startup level. If ARG is non-nil and not a positive number, Gnus will
4342 prompt the user for the name of an NNTP server to use."
4345 (if (get-buffer gnus-group-buffer)
4347 (switch-to-buffer gnus-group-buffer)
4348 (gnus-group-get-new-news))
4351 (nnheader-init-server-buffer)
4352 (gnus-read-init-file)
4353 (setq gnus-slave slave)
4355 (gnus-group-setup-buffer)
4356 (let ((buffer-read-only nil))
4358 (if (not gnus-inhibit-startup-message)
4360 (gnus-group-startup-message)
4363 (let ((level (and (numberp arg) (> arg 0) arg))
4369 (gnus-start-news-server (and arg (not level))))))
4370 (if (and (not dont-connect)
4373 (run-hooks 'gnus-startup-hook)
4374 ;; NNTP server is successfully open.
4376 ;; Find the current startup file name.
4377 (setq gnus-current-startup-file
4378 (gnus-make-newsrc-file gnus-startup-file))
4380 ;; Read the dribble file.
4381 (when (or gnus-slave gnus-use-dribble-file)
4382 (gnus-dribble-read-file))
4384 ;; Allow using GroupLens predictions.
4385 (when gnus-use-grouplens
4387 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4389 (gnus-summary-make-display-table)
4390 ;; Do the actual startup.
4391 (gnus-setup-news nil level dont-connect)
4392 ;; Generate the group buffer.
4393 (gnus-group-list-groups level)
4394 (gnus-group-first-unread-group)
4395 (gnus-configure-windows 'group)
4396 (gnus-group-set-mode-line))))))
4398 (defun gnus-unload ()
4399 "Unload all Gnus features."
4401 (or (boundp 'load-history)
4402 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4403 (let ((history load-history)
4406 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4407 (setq feature (cdr (assq 'provide (car history))))
4408 (unload-feature feature 'force))
4409 (setq history (cdr history)))))
4411 (defun gnus-compile ()
4412 "Byte-compile the user-defined format specs."
4414 (let ((entries gnus-format-specs)
4415 entry gnus-tmp-func)
4417 (gnus-message 7 "Compiling format specs...")
4420 (setq entry (pop entries))
4421 (if (eq (car entry) 'version)
4422 (setq gnus-format-specs (delq entry gnus-format-specs))
4423 (when (and (listp (caddr entry))
4424 (not (eq 'byte-code (caaddr entry))))
4425 (fset 'gnus-tmp-func
4426 `(lambda () ,(caddr entry)))
4427 (byte-compile 'gnus-tmp-func)
4428 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4430 (push (cons 'version emacs-version) gnus-format-specs)
4432 (gnus-message 7 "Compiling user specs...done"))))
4434 (defun gnus-indent-rigidly (start end arg)
4435 "Indent rigidly using only spaces and no tabs."
4438 (narrow-to-region start end)
4439 (indent-rigidly start end arg)
4440 (goto-char (point-min))
4441 (while (search-forward "\t" nil t)
4442 (replace-match " " t t)))))
4444 (defun gnus-group-startup-message (&optional x y)
4445 "Insert startup message in current buffer."
4446 ;; Insert the message.
4451 _ ___ __ ___ __ _ ___
4470 ;; And then hack it.
4471 (gnus-indent-rigidly (point-min) (point-max)
4472 (/ (max (- (window-width) (or x 46)) 0) 2))
4473 (goto-char (point-min))
4475 (let* ((pheight (count-lines (point-min) (point-max)))
4476 (wheight (window-height))
4477 (rest (- wheight pheight)))
4478 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4480 (goto-char (point-min))
4481 (and (search-forward "Praxis" nil t)
4482 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4483 (goto-char (point-min))
4484 (let* ((mode-string (gnus-group-set-mode-line)))
4485 (setq mode-line-buffer-identification
4486 (list (concat gnus-version (substring (car mode-string) 4))))
4487 (set-buffer-modified-p t)))
4489 (defun gnus-group-setup-buffer ()
4490 (or (get-buffer gnus-group-buffer)
4492 (switch-to-buffer gnus-group-buffer)
4493 (gnus-add-current-to-buffer-list)
4495 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4497 (defun gnus-group-list-groups (&optional level unread lowest)
4498 "List newsgroups with level LEVEL or lower that have unread articles.
4499 Default is all subscribed groups.
4500 If argument UNREAD is non-nil, groups with no unread articles are also
4502 (interactive (list (if current-prefix-arg
4503 (prefix-numeric-value current-prefix-arg)
4505 (gnus-group-default-level nil t)
4506 gnus-group-default-list-level
4507 gnus-level-subscribed))))
4509 (setq level (car gnus-group-list-mode)
4510 unread (cdr gnus-group-list-mode)))
4511 (setq level (gnus-group-default-level level))
4512 (gnus-group-setup-buffer) ;May call from out of group buffer
4513 (gnus-update-format-specifications)
4514 (let ((case-fold-search nil)
4515 (props (text-properties-at (gnus-point-at-bol)))
4516 (group (gnus-group-group-name)))
4517 (set-buffer gnus-group-buffer)
4518 (funcall gnus-group-prepare-function level unread lowest)
4519 (if (zerop (buffer-size))
4520 (gnus-message 5 gnus-no-groups-message)
4521 (goto-char (point-max))
4522 (when (or (not gnus-group-goto-next-group-function)
4523 (not (funcall gnus-group-goto-next-group-function
4526 ;; Go to the first group with unread articles.
4527 (gnus-group-search-forward t)
4528 ;; Find the right group to put point on. If the current group
4529 ;; has disappeared in the new listing, try to find the next
4530 ;; one. If no next one can be found, just leave point at the
4531 ;; first newsgroup in the buffer.
4532 (if (not (gnus-goto-char
4534 (point-min) (point-max)
4535 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4536 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4538 (not (gnus-goto-char
4540 (point-min) (point-max) 'gnus-group
4542 (caar newsrc) gnus-active-hashtb)))))
4543 (setq newsrc (cdr newsrc)))
4544 (or newsrc (progn (goto-char (point-max))
4545 (forward-line -1)))))))
4546 ;; Adjust cursor point.
4547 (gnus-group-position-point))))
4549 (defun gnus-group-list-level (level &optional all)
4550 "List groups on LEVEL.
4551 If ALL (the prefix), also list groups that have no unread articles."
4552 (interactive "nList groups on level: \nP")
4553 (gnus-group-list-groups level all level))
4555 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4556 "List all newsgroups with unread articles of level LEVEL or lower.
4557 If ALL is non-nil, list groups that have no unread articles.
4558 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4559 If REGEXP, only list groups matching REGEXP."
4560 (set-buffer gnus-group-buffer)
4561 (let ((buffer-read-only nil)
4562 (newsrc (cdr gnus-newsrc-alist))
4563 (lowest (or lowest 1))
4564 info clevel unread group params)
4566 (if (< lowest gnus-level-zombie)
4567 ;; List living groups.
4569 (setq info (car newsrc)
4570 group (gnus-info-group info)
4571 params (gnus-info-params info)
4573 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4574 (and unread ; This group might be bogus
4576 (string-match regexp group))
4577 (<= (setq clevel (gnus-info-level info)) level)
4579 (or all ; We list all groups?
4580 (if (eq unread t) ; Unactivated?
4581 gnus-group-list-inactive-groups ; We list unactivated
4582 (> unread 0)) ; We list groups with unread articles
4583 (and gnus-list-groups-with-ticked-articles
4584 (cdr (assq 'tick (gnus-info-marks info))))
4585 ; And groups with tickeds
4586 ;; Check for permanent visibility.
4587 (and gnus-permanently-visible-groups
4588 (string-match gnus-permanently-visible-groups
4590 (memq 'visible params)
4591 (cdr (assq 'visible params)))
4592 (gnus-group-insert-group-line
4593 group (gnus-info-level info)
4594 (gnus-info-marks info) unread (gnus-info-method info)))))
4596 ;; List dead groups.
4597 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4598 (gnus-group-prepare-flat-list-dead
4599 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4600 gnus-level-zombie ?Z
4602 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4603 (gnus-group-prepare-flat-list-dead
4604 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4605 gnus-level-killed ?K regexp))
4607 (gnus-group-set-mode-line)
4608 (setq gnus-group-list-mode (cons level all))
4609 (run-hooks 'gnus-group-prepare-hook)))
4611 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4612 ;; List zombies and killed lists somewhat faster, which was
4613 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4614 ;; this by ignoring the group format specification altogether.
4617 ;; This loop is used when listing groups that match some
4620 (setq group (pop groups))
4621 (when (string-match regexp group)
4622 (gnus-add-text-properties
4623 (point) (prog1 (1+ (point))
4624 (insert " " mark " *: " group "\n"))
4625 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4627 'gnus-level level))))
4628 ;; This loop is used when listing all groups.
4630 (gnus-add-text-properties
4631 (point) (prog1 (1+ (point))
4632 (insert " " mark " *: "
4633 (setq group (pop groups)) "\n"))
4634 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4636 'gnus-level level))))))
4638 (defmacro gnus-group-real-name (group)
4639 "Find the real name of a foreign newsgroup."
4640 `(let ((gname ,group))
4641 (if (string-match ":[^:]+$" gname)
4642 (substring gname (1+ (match-beginning 0)))
4645 (defsubst gnus-server-add-address (method)
4646 (let ((method-name (symbol-name (car method))))
4647 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4648 (not (assq (intern (concat method-name "-address")) method)))
4649 (append method (list (list (intern (concat method-name "-address"))
4653 (defsubst gnus-server-get-method (group method)
4654 ;; Input either a server name, and extended server name, or a
4655 ;; select method, and return a select method.
4656 (cond ((stringp method)
4657 (gnus-server-to-method method))
4658 ((equal method gnus-select-method)
4660 ((and (stringp (car method)) group)
4661 (gnus-server-extend-method group method))
4662 ((and method (not group)
4663 (equal (cadr method) ""))
4666 (gnus-server-add-address method))))
4668 (defun gnus-server-to-method (server)
4669 "Map virtual server names to select methods."
4671 ;; Is this a method, perhaps?
4672 (and server (listp server) server)
4673 ;; Perhaps this is the native server?
4674 (and (equal server "native") gnus-select-method)
4675 ;; It should be in the server alist.
4676 (cdr (assoc server gnus-server-alist))
4677 ;; If not, we look through all the opened server
4678 ;; to see whether we can find it there.
4679 (let ((opened gnus-opened-servers))
4681 (not (equal server (format "%s:%s" (caaar opened)
4686 (defmacro gnus-method-equal (ss1 ss2)
4687 "Say whether two servers are equal."
4691 (and (= (length s1) (length s2))
4693 (while (and s1 (member (car s1) s2))
4697 (defun gnus-server-equal (m1 m2)
4698 "Say whether two methods are equal."
4699 (let ((m1 (cond ((null m1) gnus-select-method)
4700 ((stringp m1) (gnus-server-to-method m1))
4702 (m2 (cond ((null m2) gnus-select-method)
4703 ((stringp m2) (gnus-server-to-method m2))
4705 (gnus-method-equal m1 m2)))
4707 (defun gnus-servers-using-backend (backend)
4708 "Return a list of known servers using BACKEND."
4709 (let ((opened gnus-opened-servers)
4712 (when (eq backend (caaar opened))
4713 (push (caar opened) out))
4717 (defun gnus-group-prefixed-name (group method)
4718 "Return the whole name from GROUP and METHOD."
4719 (and (stringp method) (setq method (gnus-server-to-method method)))
4720 (concat (format "%s" (car method))
4722 (or (assoc (format "%s" (car method))
4723 (gnus-methods-using 'address))
4724 (gnus-server-equal method gnus-message-archive-method))
4726 (not (string= (nth 1 method) "")))
4727 (concat "+" (nth 1 method)))
4730 (defun gnus-group-real-prefix (group)
4731 "Return the prefix of the current group name."
4732 (if (string-match "^[^:]+:" group)
4733 (substring group 0 (match-end 0))
4736 (defun gnus-group-method (group)
4737 "Return the server or method used for selecting GROUP."
4738 (let ((prefix (gnus-group-real-prefix group)))
4739 (if (equal prefix "")
4741 (let ((servers gnus-opened-servers)
4743 backend possible found)
4744 (if (string-match "^[^\\+]+\\+" prefix)
4745 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4746 server (substring prefix (match-end 0) (1- (length prefix))))
4747 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4749 (when (eq (caaar servers) backend)
4750 (setq possible (caar servers))
4751 (when (equal (cadaar servers) server)
4752 (setq found (caar servers))))
4754 (or (car (rassoc found gnus-server-alist))
4756 (car (rassoc possible gnus-server-alist))
4758 (list backend server))))))
4760 (defsubst gnus-secondary-method-p (method)
4761 "Return whether METHOD is a secondary select method."
4762 (let ((methods gnus-secondary-select-methods)
4763 (gmethod (gnus-server-get-method nil method)))
4765 (not (equal (gnus-server-get-method nil (car methods))
4767 (setq methods (cdr methods)))
4770 (defun gnus-group-foreign-p (group)
4771 "Say whether a group is foreign or not."
4772 (and (not (gnus-group-native-p group))
4773 (not (gnus-group-secondary-p group))))
4775 (defun gnus-group-native-p (group)
4776 "Say whether the group is native or not."
4777 (not (string-match ":" group)))
4779 (defun gnus-group-secondary-p (group)
4780 "Say whether the group is secondary or not."
4781 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4783 (defun gnus-group-get-parameter (group &optional symbol)
4784 "Returns the group parameters for GROUP.
4785 If SYMBOL, return the value of that symbol in the group parameters."
4786 (let ((params (gnus-info-params (gnus-get-info group))))
4788 (gnus-group-parameter-value params symbol)
4791 (defun gnus-group-parameter-value (params symbol)
4792 "Return the value of SYMBOL in group PARAMS."
4793 (or (car (memq symbol params)) ; It's either a simple symbol
4794 (cdr (assq symbol params)))) ; or a cons.
4796 (defun gnus-group-add-parameter (group param)
4797 "Add parameter PARAM to GROUP."
4798 (let ((info (gnus-get-info group)))
4800 () ; This is a dead group. We just ignore it.
4801 ;; Cons the new param to the old one and update.
4802 (gnus-group-set-info (cons param (gnus-info-params info))
4805 (defun gnus-group-set-parameter (group name value)
4806 "Set parameter NAME to VALUE in GROUP."
4807 (let ((info (gnus-get-info group)))
4809 () ; This is a dead group. We just ignore it.
4810 (let ((old-params (gnus-info-params info))
4811 (new-params (list (cons name value))))
4813 (if (or (not (listp (car old-params)))
4814 (not (eq (caar old-params) name)))
4815 (setq new-params (append new-params (list (car old-params)))))
4816 (setq old-params (cdr old-params)))
4817 (gnus-group-set-info new-params group 'params)))))
4819 (defun gnus-group-add-score (group &optional score)
4820 "Add SCORE to the GROUP score.
4821 If SCORE is nil, add 1 to the score of GROUP."
4822 (let ((info (gnus-get-info group)))
4824 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4826 (defun gnus-summary-bubble-group ()
4827 "Increase the score of the current group.
4828 This is a handy function to add to `gnus-summary-exit-hook' to
4829 increase the score of each group you read."
4830 (gnus-group-add-score gnus-newsgroup-name))
4832 (defun gnus-group-set-info (info &optional method-only-group part)
4833 (let* ((entry (gnus-gethash
4834 (or method-only-group (gnus-info-group info))
4835 gnus-newsrc-hashtb))
4837 (info (if method-only-group (nth 2 entry) info))
4839 (when method-only-group
4841 (error "Trying to change non-existent group %s" method-only-group))
4842 ;; We have received parts of the actual group info - either the
4843 ;; select method or the group parameters. We first check
4844 ;; whether we have to extend the info, and if so, do that.
4845 (let ((len (length info))
4846 (total (if (eq part 'method) 5 6)))
4848 (setcdr (nthcdr (1- len) info)
4849 (make-list (- total len) nil)))
4850 ;; Then we enter the new info.
4851 (setcar (nthcdr (1- total) info) part-info)))
4853 ;; This is a new group, so we just create it.
4855 (set-buffer gnus-group-buffer)
4856 (setq method (gnus-info-method info))
4857 (when (gnus-server-equal method "native")
4860 (set-buffer gnus-group-buffer)
4862 ;; It's a foreign group...
4863 (gnus-group-make-group
4864 (gnus-group-real-name (gnus-info-group info))
4865 (if (stringp method) method
4866 (prin1-to-string (car method)))
4868 (nth 1 (gnus-info-method info))))
4869 ;; It's a native group.
4870 (gnus-group-make-group (gnus-info-group info))))
4871 (gnus-message 6 "Note: New group created")
4873 (gnus-gethash (gnus-group-prefixed-name
4874 (gnus-group-real-name (gnus-info-group info))
4875 (or (gnus-info-method info) gnus-select-method))
4876 gnus-newsrc-hashtb))))
4877 ;; Whether it was a new group or not, we now have the entry, so we
4878 ;; can do the update.
4881 (setcar (nthcdr 2 entry) info)
4882 (when (and (not (eq (car entry) t))
4883 (gnus-active (gnus-info-group info)))
4884 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4885 (error "No such group: %s" (gnus-info-group info)))))
4887 (defun gnus-group-set-method-info (group select-method)
4888 (gnus-group-set-info select-method group 'method))
4890 (defun gnus-group-set-params-info (group params)
4891 (gnus-group-set-info params group 'params))
4893 (defun gnus-group-update-group-line ()
4894 "Update the current line in the group buffer."
4895 (let* ((buffer-read-only nil)
4896 (group (gnus-group-group-name))
4897 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4898 gnus-group-indentation)
4900 (not (gnus-ephemeral-group-p group))
4902 (concat "(gnus-group-set-info '"
4903 (prin1-to-string (nth 2 entry)) ")")))
4904 (setq gnus-group-indentation (gnus-group-group-indentation))
4906 (gnus-group-insert-group-line-info group)
4908 (gnus-group-position-point)))
4910 (defun gnus-group-insert-group-line-info (group)
4911 "Insert GROUP on the current line."
4912 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4916 ;; (Un)subscribed group.
4917 (setq info (nth 2 entry))
4918 (gnus-group-insert-group-line
4919 group (gnus-info-level info) (gnus-info-marks info)
4920 (or (car entry) t) (gnus-info-method info)))
4921 ;; This group is dead.
4922 (gnus-group-insert-group-line
4924 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4926 (if (setq active (gnus-active group))
4927 (- (1+ (cdr active)) (car active)) 0)
4930 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4931 gnus-tmp-marked number
4933 "Insert a group line in the group buffer."
4934 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4935 (gnus-tmp-number-total
4937 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4939 (gnus-tmp-number-of-unread
4940 (if (numberp number) (int-to-string (max 0 number))
4942 (gnus-tmp-number-of-read
4943 (if (numberp number)
4944 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4946 (gnus-tmp-subscribed
4947 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4948 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4949 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4951 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4952 (gnus-tmp-newsgroup-description
4953 (if gnus-description-hashtb
4954 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4957 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4958 (gnus-tmp-moderated-string
4959 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4961 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4962 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4963 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4964 (gnus-tmp-news-method-string
4966 (format "(%s:%s)" (car gnus-tmp-method)
4967 (cadr gnus-tmp-method)) ""))
4968 (gnus-tmp-marked-mark
4969 (if (and (numberp number)
4971 (cdr (assq 'tick gnus-tmp-marked)))
4973 (gnus-tmp-process-marked
4974 (if (member gnus-tmp-group gnus-group-marked)
4975 gnus-process-mark ? ))
4977 (or (and gnus-use-grouplens
4978 (bbb-grouplens-group-p gnus-tmp-group))
4980 (buffer-read-only nil)
4981 header gnus-tmp-header) ; passed as parameter to user-funcs.
4983 (gnus-add-text-properties
4987 (eval gnus-group-line-format-spec))
4988 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4989 gnus-unread ,(if (numberp number)
4990 (string-to-int gnus-tmp-number-of-unread)
4992 gnus-marked ,gnus-tmp-marked-mark
4993 gnus-indentation ,gnus-group-indentation
4994 gnus-level ,gnus-tmp-level))
4995 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4997 (run-hooks 'gnus-group-update-hook)
4999 ;; Allow XEmacs to remove front-sticky text properties.
5000 (gnus-group-remove-excess-properties)))
5002 (defun gnus-group-update-group (group &optional visible-only)
5003 "Update all lines where GROUP appear.
5004 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5007 (set-buffer gnus-group-buffer)
5008 ;; The buffer may be narrowed.
5011 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5013 found buffer-read-only)
5014 ;; Enter the current status into the dribble buffer.
5015 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5016 (if (and entry (not (gnus-ephemeral-group-p group)))
5018 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5020 ;; Find all group instances. If topics are in use, each group
5021 ;; may be listed in more than once.
5022 (while (setq loc (text-property-any
5023 loc (point-max) 'gnus-group ident))
5026 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5028 (gnus-group-insert-group-line-info group))
5029 (setq loc (1+ loc)))
5030 (unless (or found visible-only)
5031 ;; No such line in the buffer, find out where it's supposed to
5032 ;; go, and insert it there (or at the end of the buffer).
5033 (if gnus-goto-missing-group-function
5034 (funcall gnus-goto-missing-group-function group)
5035 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5036 (while (and entry (car entry)
5040 (point-min) (point-max)
5041 'gnus-group (gnus-intern-safe
5042 (caar entry) gnus-active-hashtb)))))
5043 (setq entry (cdr entry)))
5044 (or entry (goto-char (point-max)))))
5045 ;; Finally insert the line.
5046 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5047 (gnus-group-insert-group-line-info group)))
5048 (gnus-group-set-mode-line)))))
5050 (defun gnus-group-set-mode-line ()
5051 "Update the mode line in the group buffer."
5052 (when (memq 'group gnus-updated-mode-lines)
5053 ;; Yes, we want to keep this mode line updated.
5055 (set-buffer gnus-group-buffer)
5056 (let* ((gformat (or gnus-group-mode-line-format-spec
5057 (setq gnus-group-mode-line-format-spec
5059 gnus-group-mode-line-format
5060 gnus-group-mode-line-format-alist))))
5061 (gnus-tmp-news-server (cadr gnus-select-method))
5062 (gnus-tmp-news-method (car gnus-select-method))
5063 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5065 gnus-tmp-header ;Dummy binding for user-defined formats
5066 ;; Get the resulting string.
5067 (mode-string (eval gformat)))
5068 ;; Say whether the dribble buffer has been modified.
5069 (setq mode-line-modified
5070 (if (and gnus-dribble-buffer
5071 (buffer-name gnus-dribble-buffer)
5072 (buffer-modified-p gnus-dribble-buffer)
5074 (set-buffer gnus-dribble-buffer)
5075 (not (zerop (buffer-size)))))
5077 ;; If the line is too long, we chop it off.
5078 (when (> (length mode-string) max-len)
5079 (setq mode-string (substring mode-string 0 (- max-len 4))))
5081 (setq mode-line-buffer-identification
5083 (set-buffer-modified-p t))))))
5085 (defun gnus-group-group-name ()
5086 "Get the name of the newsgroup on the current line."
5087 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5088 (and group (symbol-name group))))
5090 (defun gnus-group-group-level ()
5091 "Get the level of the newsgroup on the current line."
5092 (get-text-property (gnus-point-at-bol) 'gnus-level))
5094 (defun gnus-group-group-indentation ()
5095 "Get the indentation of the newsgroup on the current line."
5096 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5097 (and gnus-group-indentation-function
5098 (funcall gnus-group-indentation-function))
5101 (defun gnus-group-group-unread ()
5102 "Get the number of unread articles of the newsgroup on the current line."
5103 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5105 (defun gnus-group-search-forward (&optional backward all level first-too)
5106 "Find the next newsgroup with unread articles.
5107 If BACKWARD is non-nil, find the previous newsgroup instead.
5108 If ALL is non-nil, just find any newsgroup.
5109 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5111 If FIRST-TOO, the current line is also eligible as a target."
5112 (let ((way (if backward -1 1))
5113 (low gnus-level-killed)
5116 (if (and backward (progn (beginning-of-line)) (bobp))
5118 (or first-too (forward-line way))
5126 (get-text-property (point) 'gnus-unread)))
5127 (and (numberp unread) (> unread 0)))
5128 (setq lev (get-text-property (point)
5130 (<= lev gnus-level-subscribed)))
5132 (and (setq lev (get-text-property (point)
5141 (zerop (forward-line way)))))
5143 (progn (gnus-group-position-point) t)
5144 (goto-char (or pos beg))
5147 ;;; Gnus group mode commands
5151 (defun gnus-group-mark-group (n &optional unmark no-advance)
5152 "Mark the current group."
5154 (let ((buffer-read-only nil)
5158 (when (setq group (gnus-group-group-name))
5162 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5167 (setq gnus-group-marked (delete group gnus-group-marked)))
5169 (setq gnus-group-marked
5170 (cons group (delete group gnus-group-marked)))))
5171 (or no-advance (gnus-group-next-group 1))
5173 (gnus-summary-position-point)
5176 (defun gnus-group-unmark-group (n)
5177 "Remove the mark from the current group."
5179 (gnus-group-mark-group n 'unmark)
5180 (gnus-group-position-point))
5182 (defun gnus-group-unmark-all-groups ()
5183 "Unmark all groups."
5185 (let ((groups gnus-group-marked))
5188 (gnus-group-remove-mark (pop groups)))))
5189 (gnus-group-position-point))
5191 (defun gnus-group-mark-region (unmark beg end)
5192 "Mark all groups between point and mark.
5193 If UNMARK, remove the mark instead."
5194 (interactive "P\nr")
5195 (let ((num (count-lines beg end)))
5198 (- num (gnus-group-mark-group num unmark)))))
5200 (defun gnus-group-mark-buffer (&optional unmark)
5201 "Mark all groups in the buffer.
5202 If UNMARK, remove the mark instead."
5204 (gnus-group-mark-region unmark (point-min) (point-max)))
5206 (defun gnus-group-mark-regexp (regexp)
5207 "Mark all groups that match some regexp."
5208 (interactive "sMark (regexp): ")
5209 (let ((alist (cdr gnus-newsrc-alist))
5212 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5213 (gnus-group-set-mark group))))
5214 (gnus-group-position-point))
5216 (defun gnus-group-remove-mark (group)
5217 "Remove the process mark from GROUP and move point there.
5218 Return nil if the group isn't displayed."
5219 (if (gnus-group-goto-group group)
5221 (gnus-group-mark-group 1 'unmark t)
5223 (setq gnus-group-marked
5224 (delete group gnus-group-marked))
5227 (defun gnus-group-set-mark (group)
5228 "Set the process mark on GROUP."
5229 (if (gnus-group-goto-group group)
5231 (gnus-group-mark-group 1 nil t))
5232 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5234 (defun gnus-group-universal-argument (arg &optional groups func)
5235 "Perform any command on all groups accoring to the process/prefix convention."
5237 (let ((groups (or groups (gnus-group-process-prefix arg)))
5239 (if (eq (setq func (or func
5242 (substitute-command-keys
5243 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5245 (gnus-error 1 "Undefined key")
5247 (gnus-group-remove-mark (setq group (pop groups)))
5248 (command-execute func))))
5249 (gnus-group-position-point))
5251 (defun gnus-group-process-prefix (n)
5252 "Return a list of groups to work on.
5253 Take into consideration N (the prefix) and the list of marked groups."
5256 (setq n (prefix-numeric-value n))
5257 ;; There is a prefix, so we return a list of the N next
5259 (let ((way (if (< n 0) -1 1))
5264 (setq group (gnus-group-group-name)))
5265 (setq groups (cons group groups))
5267 (gnus-group-next-group way)))
5269 ((and (boundp 'transient-mark-mode)
5271 (boundp 'mark-active)
5273 ;; Work on the region between point and mark.
5274 (let ((max (max (point) (mark)))
5277 (goto-char (min (point) (mark)))
5280 (push (gnus-group-group-name) groups)
5281 (zerop (gnus-group-next-group 1))
5283 (nreverse groups))))
5285 ;; No prefix, but a list of marked articles.
5286 (reverse gnus-group-marked))
5288 ;; Neither marked articles or a prefix, so we return the
5290 (let ((group (gnus-group-group-name)))
5291 (and group (list group))))))
5293 ;; Selecting groups.
5295 (defun gnus-group-read-group (&optional all no-article group)
5296 "Read news in this newsgroup.
5297 If the prefix argument ALL is non-nil, already read articles become
5298 readable. IF ALL is a number, fetch this number of articles. If the
5299 optional argument NO-ARTICLE is non-nil, no article will be
5300 auto-selected upon group entry. If GROUP is non-nil, fetch that
5303 (let ((group (or group (gnus-group-group-name)))
5304 number active marked entry)
5305 (or group (error "No group on current line"))
5306 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5307 group gnus-newsrc-hashtb)))))
5308 ;; This group might be a dead group. In that case we have to get
5309 ;; the number of unread articles from `gnus-active-hashtb'.
5311 (cond ((numberp all) all)
5313 ((setq active (gnus-active group))
5314 (- (1+ (cdr active)) (car active)))))
5315 (gnus-summary-read-group
5316 group (or all (and (numberp number)
5317 (zerop (+ number (length (cdr (assq 'tick marked)))
5318 (length (cdr (assq 'dormant marked)))))))
5321 (defun gnus-group-select-group (&optional all)
5322 "Select this newsgroup.
5323 No article is selected automatically.
5324 If ALL is non-nil, already read articles become readable.
5325 If ALL is a number, fetch this number of articles."
5327 (gnus-group-read-group all t))
5329 (defun gnus-group-quick-select-group (&optional all)
5330 "Select the current group \"quickly\".
5331 This means that no highlighting or scoring will be performed."
5334 gnus-score-find-score-files-function
5335 gnus-apply-kill-hook
5336 gnus-summary-expunge-below)
5337 (gnus-group-read-group all t)))
5339 (defun gnus-group-visible-select-group (&optional all)
5340 "Select the current group without hiding any articles."
5342 (let ((gnus-inhibit-limiting t))
5343 (gnus-group-read-group all t)))
5346 (defun gnus-fetch-group (group)
5347 "Start Gnus if necessary and enter GROUP.
5348 Returns whether the fetching was successful or not."
5349 (interactive "sGroup name: ")
5350 (or (get-buffer gnus-group-buffer)
5352 (gnus-group-read-group nil nil group))
5354 ;; Enter a group that is not in the group buffer. Non-nil is returned
5355 ;; if selection was successful.
5356 (defun gnus-group-read-ephemeral-group
5357 (group method &optional activate quit-config)
5358 (let ((group (if (gnus-group-foreign-p group) group
5359 (gnus-group-prefixed-name group method))))
5362 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5363 ((quit-config . ,(if quit-config quit-config
5364 (cons (current-buffer) 'summary))))))
5366 (set-buffer gnus-group-buffer)
5367 (or (gnus-check-server method)
5368 (error "Unable to contact server: %s" (gnus-status-message method)))
5369 (if activate (or (gnus-request-group group)
5370 (error "Couldn't request group")))
5372 (gnus-group-read-group t t group)
5376 (defun gnus-group-jump-to-group (group)
5377 "Jump to newsgroup GROUP."
5379 (list (completing-read
5380 "Group: " gnus-active-hashtb nil
5381 (gnus-read-active-file-p)
5383 'gnus-group-history)))
5385 (when (equal group "")
5386 (error "Empty group name"))
5388 (when (string-match "[\000-\032]" group)
5389 (error "Control characters in group: %s" group))
5391 (let ((b (text-property-any
5392 (point-min) (point-max)
5393 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5394 (unless (gnus-ephemeral-group-p group)
5396 ;; Either go to the line in the group buffer...
5398 ;; ... or insert the line.
5401 (gnus-activate-group group)
5402 (error "%s error: %s" group (gnus-status-message group)))
5404 (gnus-group-update-group group)
5405 (goto-char (text-property-any
5406 (point-min) (point-max)
5407 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5408 ;; Adjust cursor point.
5409 (gnus-group-position-point)))
5411 (defun gnus-group-goto-group (group)
5412 "Goto to newsgroup GROUP."
5414 (let ((b (text-property-any (point-min) (point-max)
5415 'gnus-group (gnus-intern-safe
5416 group gnus-active-hashtb))))
5417 (and b (goto-char b)))))
5419 (defun gnus-group-next-group (n)
5420 "Go to next N'th newsgroup.
5421 If N is negative, search backward instead.
5422 Returns the difference between N and the number of skips actually
5425 (gnus-group-next-unread-group n t))
5427 (defun gnus-group-next-unread-group (n &optional all level)
5428 "Go to next N'th unread newsgroup.
5429 If N is negative, search backward instead.
5430 If ALL is non-nil, choose any newsgroup, unread or not.
5431 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5432 such group can be found, the next group with a level higher than
5434 Returns the difference between N and the number of skips actually
5437 (let ((backward (< n 0))
5440 (gnus-group-search-forward
5441 backward (or (not gnus-group-goto-unread) all) level))
5443 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5444 (if level " on this level or higher" "")))
5447 (defun gnus-group-prev-group (n)
5448 "Go to previous N'th newsgroup.
5449 Returns the difference between N and the number of skips actually
5452 (gnus-group-next-unread-group (- n) t))
5454 (defun gnus-group-prev-unread-group (n)
5455 "Go to previous N'th unread newsgroup.
5456 Returns the difference between N and the number of skips actually
5459 (gnus-group-next-unread-group (- n)))
5461 (defun gnus-group-next-unread-group-same-level (n)
5462 "Go to next N'th unread newsgroup on the same level.
5463 If N is negative, search backward instead.
5464 Returns the difference between N and the number of skips actually
5467 (gnus-group-next-unread-group n t (gnus-group-group-level))
5468 (gnus-group-position-point))
5470 (defun gnus-group-prev-unread-group-same-level (n)
5471 "Go to next N'th unread newsgroup on the same level.
5472 Returns the difference between N and the number of skips actually
5475 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5476 (gnus-group-position-point))
5478 (defun gnus-group-best-unread-group (&optional exclude-group)
5479 "Go to the group with the highest level.
5480 If EXCLUDE-GROUP, do not go to that group."
5482 (goto-char (point-min))
5486 (setq unread (get-text-property (point) 'gnus-unread))
5487 (if (and (numberp unread) (> unread 0))
5489 (if (and (get-text-property (point) 'gnus-level)
5490 (< (get-text-property (point) 'gnus-level) best)
5491 (or (not exclude-group)
5492 (not (equal exclude-group (gnus-group-group-name)))))
5494 (setq best (get-text-property (point) 'gnus-level))
5495 (setq best-point (point))))))
5497 (if best-point (goto-char best-point))
5498 (gnus-summary-position-point)
5499 (and best-point (gnus-group-group-name))))
5501 (defun gnus-group-first-unread-group ()
5502 "Go to the first group with unread articles."
5505 (let ((opoint (point))
5507 (goto-char (point-min))
5508 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5509 (and (numberp unread) ; Not a topic.
5510 (not (zerop unread))) ; Has unread articles.
5511 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5514 nil)) ; Not success.
5515 (gnus-group-position-point)))
5517 (defun gnus-group-enter-server-mode ()
5518 "Jump to the server buffer."
5520 (gnus-enter-server-buffer))
5522 (defun gnus-group-make-group (name &optional method address)
5523 "Add a new newsgroup.
5524 The user will be prompted for a NAME, for a select METHOD, and an
5528 (read-string "Group name: ")
5531 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5532 nil t nil 'gnus-method-history)))
5533 (cond ((assoc method gnus-valid-select-methods)
5535 (if (memq 'prompt-address
5536 (assoc method gnus-valid-select-methods))
5537 (read-string "Address: ")
5539 ((assoc method gnus-server-alist)
5542 (list method ""))))))
5544 (let* ((meth (and method (if address (list (intern method) address)
5546 (nname (if method (gnus-group-prefixed-name name meth) name))
5548 (when (gnus-gethash nname gnus-newsrc-hashtb)
5549 (error "Group %s already exists" nname))
5550 ;; Subscribe to the new group.
5551 (gnus-group-change-level
5552 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5553 gnus-level-default-subscribed gnus-level-killed
5554 (and (gnus-group-group-name)
5555 (gnus-gethash (gnus-group-group-name)
5556 gnus-newsrc-hashtb))
5559 (gnus-set-active nname (cons 1 0))
5560 (or (gnus-ephemeral-group-p name)
5562 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5564 (gnus-group-insert-group-line-info nname)
5566 (gnus-group-position-point)
5568 ;; Load the backend and try to make the backend create
5569 ;; the group as well.
5570 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5572 gnus-valid-select-methods)
5574 (gnus-check-server meth)
5575 (and (gnus-check-backend-function 'request-create-group nname)
5576 (gnus-request-create-group nname))
5579 (defun gnus-group-delete-group (group &optional force)
5580 "Delete the current group.
5581 If FORCE (the prefix) is non-nil, all the articles in the group will
5582 be deleted. This is \"deleted\" as in \"removed forever from the face
5583 of the Earth\". There is no undo."
5585 (list (gnus-group-group-name)
5586 current-prefix-arg))
5587 (or group (error "No group to rename"))
5588 (or (gnus-check-backend-function 'request-delete-group group)
5589 (error "This backend does not support group deletion"))
5591 (if (not (gnus-yes-or-no-p
5593 "Do you really want to delete %s%s? "
5594 group (if force " and all its contents" ""))))
5596 (gnus-message 6 "Deleting group %s..." group)
5597 (if (not (gnus-request-delete-group group force))
5598 (gnus-error 3 "Couldn't delete group %s" group)
5599 (gnus-message 6 "Deleting group %s...done" group)
5600 (gnus-group-goto-group group)
5601 (gnus-group-kill-group 1 t)
5602 (gnus-sethash group nil gnus-active-hashtb)
5604 (gnus-group-position-point)))
5606 (defun gnus-group-rename-group (group new-name)
5609 (gnus-group-group-name)
5611 (or (gnus-check-backend-function
5612 'request-rename-group (gnus-group-group-name))
5613 (error "This backend does not support renaming groups"))
5614 (read-string "New group name: "))))
5616 (or (gnus-check-backend-function 'request-rename-group group)
5617 (error "This backend does not support renaming groups"))
5619 (or group (error "No group to rename"))
5620 (and (string-match "^[ \t]*$" new-name)
5621 (error "Not a valid group name"))
5623 ;; We find the proper prefixed name.
5625 (gnus-group-prefixed-name
5626 (gnus-group-real-name new-name)
5627 (gnus-info-method (gnus-get-info group))))
5629 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5631 (if (not (gnus-request-rename-group group new-name))
5632 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5633 ;; We rename the group internally by killing it...
5634 (gnus-group-goto-group group)
5635 (gnus-group-kill-group)
5636 ;; ... changing its name ...
5637 (setcar (cdar gnus-list-of-killed-groups) new-name)
5638 ;; ... and then yanking it. Magic!
5639 (gnus-group-yank-group)
5640 (gnus-set-active new-name (gnus-active group))
5641 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5643 (gnus-group-position-point)))
5645 (defun gnus-group-edit-group (group &optional part)
5646 "Edit the group on the current line."
5647 (interactive (list (gnus-group-group-name)))
5648 (let* ((part (or part 'info))
5649 (done-func `(lambda ()
5650 "Exit editing mode and update the information."
5652 (gnus-group-edit-group-done ',part ,group)))
5653 (winconf (current-window-configuration))
5655 (or group (error "No group on current line"))
5656 (or (setq info (gnus-get-info group))
5657 (error "Killed group; can't be edited"))
5658 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5659 (gnus-configure-windows 'edit-group)
5660 (gnus-add-current-to-buffer-list)
5662 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5663 (use-local-map (copy-keymap emacs-lisp-mode-map))
5664 (local-set-key "\C-c\C-c" done-func)
5665 (make-local-variable 'gnus-prev-winconf)
5666 (setq gnus-prev-winconf winconf)
5671 ";; Type `C-c C-c' after editing the select method.\n\n")
5673 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5675 ";; Type `C-c C-c' after editing the group info.\n\n")))
5678 (cond ((eq part 'method)
5679 (or (gnus-info-method info) "native"))
5681 (gnus-info-params info))
5685 (defun gnus-group-edit-group-method (group)
5686 "Edit the select method of GROUP."
5687 (interactive (list (gnus-group-group-name)))
5688 (gnus-group-edit-group group 'method))
5690 (defun gnus-group-edit-group-parameters (group)
5691 "Edit the group parameters of GROUP."
5692 (interactive (list (gnus-group-group-name)))
5693 (gnus-group-edit-group group 'params))
5695 (defun gnus-group-edit-group-done (part group)
5696 "Get info from buffer, update variables and jump to the group buffer."
5697 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5698 (goto-char (point-min))
5699 (let* ((form (read (current-buffer)))
5700 (winconf gnus-prev-winconf)
5701 (method (cond ((eq part 'info) (nth 4 form))
5702 ((eq part 'method) form)
5704 (info (cond ((eq part 'info) form)
5705 ((eq part 'method) (gnus-get-info group))
5708 (if (or (not method)
5710 gnus-select-method method))
5711 (gnus-group-real-name (car info))
5712 (gnus-group-prefixed-name
5713 (gnus-group-real-name (car info)) method))
5715 (when (and new-group
5716 (not (equal new-group group)))
5717 (when (gnus-group-goto-group group)
5718 (gnus-group-kill-group 1))
5719 (gnus-activate-group new-group))
5721 (if (and info new-group)
5723 (setq info (gnus-copy-sequence info))
5724 (setcar info new-group)
5725 (unless (gnus-server-equal method "native")
5726 (unless (nthcdr 3 info)
5727 (nconc info (list nil nil)))
5728 (unless (nthcdr 4 info)
5729 (nconc info (list nil)))
5730 (gnus-info-set-method info method))
5731 (gnus-group-set-info info))
5732 (gnus-group-set-info form (or new-group group) part))
5733 (kill-buffer (current-buffer))
5734 (and winconf (set-window-configuration winconf))
5735 (set-buffer gnus-group-buffer)
5736 (gnus-group-update-group (or new-group group))
5737 (gnus-group-position-point)))
5739 (defun gnus-group-make-help-group ()
5740 "Create the Gnus documentation group."
5742 (let ((path load-path)
5743 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5745 (and (gnus-gethash name gnus-newsrc-hashtb)
5746 (error "Documentation group already exists"))
5748 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5750 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5752 (setq file (concat (file-name-directory
5753 (directory-file-name dir))
5754 "etc/gnus-tut.txt"))))
5757 (gnus-message 1 "Couldn't find doc group")
5758 (gnus-group-make-group
5759 (gnus-group-real-name name)
5760 (list 'nndoc "gnus-help"
5761 (list 'nndoc-address file)
5762 (list 'nndoc-article-type 'mbox)))))
5763 (gnus-group-position-point))
5765 (defun gnus-group-make-doc-group (file type)
5766 "Create a group that uses a single file as the source."
5768 (list (read-file-name "File name: ")
5769 (and current-prefix-arg 'ask)))
5770 (when (eq type 'ask)
5775 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5777 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5778 ((= char ?b) 'babyl)
5779 ((= char ?d) 'digest)
5780 ((= char ?f) 'forward)
5782 (t (setq err (format "%c unknown. " char))
5785 (let* ((file (expand-file-name file))
5786 (name (gnus-generate-new-group-name
5787 (gnus-group-prefixed-name
5788 (file-name-nondirectory file) '(nndoc "")))))
5789 (gnus-group-make-group
5790 (gnus-group-real-name name)
5791 (list 'nndoc (file-name-nondirectory file)
5792 (list 'nndoc-address file)
5793 (list 'nndoc-article-type (or type 'guess))))))
5795 (defun gnus-group-make-archive-group (&optional all)
5796 "Create the (ding) Gnus archive group of the most recent articles.
5797 Given a prefix, create a full group."
5799 (let ((group (gnus-group-prefixed-name
5800 (if all "ding.archives" "ding.recent") '(nndir ""))))
5801 (and (gnus-gethash group gnus-newsrc-hashtb)
5802 (error "Archive group already exists"))
5803 (gnus-group-make-group
5804 (gnus-group-real-name group)
5805 (list 'nndir (if all "hpc" "edu")
5806 (list 'nndir-directory
5807 (if all gnus-group-archive-directory
5808 gnus-group-recent-archive-directory))))))
5810 (defun gnus-group-make-directory-group (dir)
5811 "Create an nndir group.
5812 The user will be prompted for a directory. The contents of this
5813 directory will be used as a newsgroup. The directory should contain
5814 mail messages or news articles in files that have numeric names."
5816 (list (read-file-name "Create group from directory: ")))
5817 (or (file-exists-p dir) (error "No such directory"))
5818 (or (file-directory-p dir) (error "Not a directory"))
5822 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5824 (gnus-group-prefixed-name
5825 (concat (file-name-as-directory (directory-file-name dir))
5828 (setq ext (format "<%d>" (setq i (1+ i)))))
5829 (gnus-group-make-group
5830 (gnus-group-real-name group)
5831 (list 'nndir group (list 'nndir-directory dir)))))
5833 (defun gnus-group-make-kiboze-group (group address scores)
5834 "Create an nnkiboze group.
5835 The user will be prompted for a name, a regexp to match groups, and
5836 score file entries for articles to include in the group."
5839 (read-string "nnkiboze group name: ")
5840 (read-string "Source groups (regexp): ")
5841 (let ((headers (mapcar (lambda (group) (list group))
5842 '("subject" "from" "number" "date" "message-id"
5843 "references" "chars" "lines" "xref"
5844 "followup" "all" "body" "head")))
5845 scores header regexp regexps)
5846 (while (not (equal "" (setq header (completing-read
5847 "Match on header: " headers nil t))))
5849 (while (not (equal "" (setq regexp (read-string
5850 (format "Match on %s (string): "
5852 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5853 (setq scores (cons (cons header regexps) scores)))
5855 (gnus-group-make-group group "nnkiboze" address)
5856 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5857 (let (emacs-lisp-mode-hook)
5858 (pp scores (current-buffer)))))
5860 (defun gnus-group-add-to-virtual (n vgroup)
5861 "Add the current group to a virtual group."
5863 (list current-prefix-arg
5864 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5866 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5867 (error "%s is not an nnvirtual group" vgroup))
5868 (let* ((groups (gnus-group-process-prefix n))
5869 (method (gnus-info-method (gnus-get-info vgroup))))
5870 (setcar (cdr method)
5872 (nth 1 method) "\\|"
5875 (gnus-group-remove-mark s)
5876 (concat "\\(^" (regexp-quote s) "$\\)"))
5878 (gnus-group-position-point))
5880 (defun gnus-group-make-empty-virtual (group)
5881 "Create a new, fresh, empty virtual group."
5882 (interactive "sCreate new, empty virtual group: ")
5883 (let* ((method (list 'nnvirtual "^$"))
5884 (pgroup (gnus-group-prefixed-name group method)))
5885 ;; Check whether it exists already.
5886 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5887 (error "Group %s already exists." pgroup))
5888 ;; Subscribe the new group after the group on the current line.
5889 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5890 (gnus-group-update-group pgroup)
5892 (gnus-group-position-point)))
5894 (defun gnus-group-enter-directory (dir)
5895 "Enter an ephemeral nneething group."
5896 (interactive "DDirectory to read: ")
5897 (let* ((method (list 'nneething dir))
5898 (leaf (gnus-group-prefixed-name
5899 (file-name-nondirectory (directory-file-name dir))
5901 (name (gnus-generate-new-group-name leaf)))
5902 (let ((nneething-read-only t))
5903 (or (gnus-group-read-ephemeral-group
5905 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5907 (error "Couldn't enter %s" dir)))))
5909 ;; Group sorting commands
5910 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5912 (defun gnus-group-sort-groups (func &optional reverse)
5913 "Sort the group buffer according to FUNC.
5914 If REVERSE, reverse the sorting order."
5915 (interactive (list gnus-group-sort-function
5916 current-prefix-arg))
5918 ((not (listp func)) func)
5920 ((= 1 (length func)) (car func))
5922 ,(gnus-make-sort-function
5923 (reverse func)))))))
5924 ;; We peel off the dummy group from the alist.
5926 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5927 (pop gnus-newsrc-alist))
5929 (setq gnus-newsrc-alist
5930 (sort gnus-newsrc-alist func))
5932 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5933 ;; Regenerate the hash table.
5934 (gnus-make-hashtable-from-newsrc-alist)
5935 (gnus-group-list-groups))))
5937 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5938 "Sort the group buffer alphabetically by group name.
5939 If REVERSE, sort in reverse order."
5941 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5943 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5944 "Sort the group buffer by number of unread articles.
5945 If REVERSE, sort in reverse order."
5947 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5949 (defun gnus-group-sort-groups-by-level (&optional reverse)
5950 "Sort the group buffer by group level.
5951 If REVERSE, sort in reverse order."
5953 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5955 (defun gnus-group-sort-groups-by-score (&optional reverse)
5956 "Sort the group buffer by group score.
5957 If REVERSE, sort in reverse order."
5959 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5961 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5962 "Sort the group buffer by group rank.
5963 If REVERSE, sort in reverse order."
5965 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5967 (defun gnus-group-sort-groups-by-method (&optional reverse)
5968 "Sort the group buffer alphabetically by backend name.
5969 If REVERSE, sort in reverse order."
5971 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5973 (defun gnus-group-sort-by-alphabet (info1 info2)
5974 "Sort alphabetically."
5975 (string< (gnus-info-group info1) (gnus-info-group info2)))
5977 (defun gnus-group-sort-by-unread (info1 info2)
5978 "Sort by number of unread articles."
5979 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5980 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5981 (< (or (and (numberp n1) n1) 0)
5982 (or (and (numberp n2) n2) 0))))
5984 (defun gnus-group-sort-by-level (info1 info2)
5986 (< (gnus-info-level info1) (gnus-info-level info2)))
5988 (defun gnus-group-sort-by-method (info1 info2)
5989 "Sort alphabetically by backend name."
5990 (string< (symbol-name (car (gnus-find-method-for-group
5991 (gnus-info-group info1) info1)))
5992 (symbol-name (car (gnus-find-method-for-group
5993 (gnus-info-group info2) info2)))))
5995 (defun gnus-group-sort-by-score (info1 info2)
5996 "Sort by group score."
5997 (< (gnus-info-score info1) (gnus-info-score info2)))
5999 (defun gnus-group-sort-by-rank (info1 info2)
6000 "Sort by level and score."
6001 (let ((level1 (gnus-info-level info1))
6002 (level2 (gnus-info-level info2)))
6003 (or (< level1 level2)
6004 (and (= level1 level2)
6005 (> (gnus-info-score info1) (gnus-info-score info2))))))
6007 ;; Group catching up.
6009 (defun gnus-group-clear-data (n)
6010 "Clear all marks and read ranges from the current group."
6012 (let ((groups (gnus-group-process-prefix n))
6014 (while (setq group (pop groups))
6015 (setq info (gnus-get-info group))
6016 (gnus-info-set-read info nil)
6017 (when (gnus-info-marks info)
6018 (gnus-info-set-marks info nil))
6019 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6020 (when (gnus-group-goto-group group)
6021 (gnus-group-remove-mark group)
6022 (gnus-group-update-group-line)))))
6024 (defun gnus-group-catchup-current (&optional n all)
6025 "Mark all articles not marked as unread in current newsgroup as read.
6026 If prefix argument N is numeric, the ARG next newsgroups will be
6027 caught up. If ALL is non-nil, marked articles will also be marked as
6028 read. Cross references (Xref: header) of articles are ignored.
6029 The difference between N and actual number of newsgroups that were
6030 caught up is returned."
6032 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6036 "Do you really want to mark all articles as read? "
6037 "Mark all unread articles as read? "))))
6039 (let ((groups (gnus-group-process-prefix n))
6042 ;; Virtual groups have to be given special treatment.
6043 (let ((method (gnus-find-method-for-group (car groups))))
6044 (if (eq 'nnvirtual (car method))
6045 (nnvirtual-catchup-group
6046 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6047 (gnus-group-remove-mark (car groups))
6048 (if (>= (gnus-group-group-level) gnus-level-zombie)
6049 (gnus-message 2 "Dead groups can't be caught up")
6051 (gnus-group-goto-group (car groups))
6052 (gnus-group-catchup (car groups) all))
6053 (gnus-group-update-group-line)
6054 (setq ret (1+ ret))))
6055 (setq groups (cdr groups)))
6056 (gnus-group-next-unread-group 1)
6059 (defun gnus-group-catchup-current-all (&optional n)
6060 "Mark all articles in current newsgroup as read.
6061 Cross references (Xref: header) of articles are ignored."
6063 (gnus-group-catchup-current n 'all))
6065 (defun gnus-group-catchup (group &optional all)
6066 "Mark all articles in GROUP as read.
6067 If ALL is non-nil, all articles are marked as read.
6068 The return value is the number of articles that were marked as read,
6069 or nil if no action could be taken."
6070 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6072 ;; Do the updating only if the newsgroup isn't killed.
6073 (if (not (numberp (car entry)))
6074 (gnus-message 1 "Can't catch up; non-active group")
6075 ;; Do auto-expirable marks if that's required.
6076 (when (gnus-group-auto-expirable-p group)
6077 (gnus-add-marked-articles
6078 group 'expire (gnus-list-of-unread-articles group))
6080 (let ((marks (nth 3 (nth 2 entry))))
6081 (gnus-add-marked-articles
6082 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6083 (gnus-add-marked-articles
6084 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6086 (gnus-update-read-articles group nil)
6087 ;; Also nix out the lists of marks and dormants.
6089 (gnus-add-marked-articles group 'tick nil nil 'force)
6090 (gnus-add-marked-articles group 'dormant nil nil 'force))
6091 (run-hooks 'gnus-group-catchup-group-hook)
6094 (defun gnus-group-expire-articles (&optional n)
6095 "Expire all expirable articles in the current newsgroup."
6097 (let ((groups (gnus-group-process-prefix n))
6100 (error "No groups to expire"))
6101 (while (setq group (pop groups))
6102 (gnus-group-remove-mark group)
6103 (when (gnus-check-backend-function 'request-expire-articles group)
6104 (gnus-message 6 "Expiring articles in %s..." group)
6105 (let* ((info (gnus-get-info group))
6106 (expirable (if (gnus-group-total-expirable-p group)
6107 (cons nil (gnus-list-of-read-articles group))
6108 (assq 'expire (gnus-info-marks info))))
6109 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6113 (gnus-compress-sequence
6115 ;; We set the expiry variables to the groupp
6117 (let ((nnmail-expiry-wait-function nil)
6118 (nnmail-expiry-wait expiry-wait))
6119 (gnus-request-expire-articles
6120 (gnus-uncompress-sequence (cdr expirable)) group))
6121 ;; Just expire using the normal expiry values.
6122 (gnus-request-expire-articles
6123 (gnus-uncompress-sequence (cdr expirable)) group)))))
6124 (gnus-message 6 "Expiring articles in %s...done" group)))
6125 (gnus-group-position-point))))
6127 (defun gnus-group-expire-all-groups ()
6128 "Expire all expirable articles in all newsgroups."
6131 (gnus-message 5 "Expiring...")
6132 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6133 (cdr gnus-newsrc-alist))))
6134 (gnus-group-expire-articles nil)))
6135 (gnus-group-position-point)
6136 (gnus-message 5 "Expiring...done"))
6138 (defun gnus-group-set-current-level (n level)
6139 "Set the level of the next N groups to LEVEL."
6144 (let ((s (read-string
6145 (format "Level (default %s): "
6146 (or (gnus-group-group-level)
6147 gnus-level-default-subscribed)))))
6148 (if (string-match "^\\s-*$" s)
6149 (int-to-string (or (gnus-group-group-level)
6150 gnus-level-default-subscribed))
6152 (or (and (>= level 1) (<= level gnus-level-killed))
6153 (error "Illegal level: %d" level))
6154 (let ((groups (gnus-group-process-prefix n))
6156 (while (setq group (pop groups))
6157 (gnus-group-remove-mark group)
6158 (gnus-message 6 "Changed level of %s from %d to %d"
6159 group (or (gnus-group-group-level) gnus-level-killed)
6161 (gnus-group-change-level
6162 group level (or (gnus-group-group-level) gnus-level-killed))
6163 (gnus-group-update-group-line)))
6164 (gnus-group-position-point))
6166 (defun gnus-group-unsubscribe-current-group (&optional n)
6167 "Toggle subscription of the current group.
6168 If given numerical prefix, toggle the N next groups."
6170 (let ((groups (gnus-group-process-prefix n))
6173 (setq group (car groups)
6174 groups (cdr groups))
6175 (gnus-group-remove-mark group)
6176 (gnus-group-unsubscribe-group
6177 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6178 gnus-level-default-unsubscribed
6179 gnus-level-default-subscribed) t)
6180 (gnus-group-update-group-line))
6181 (gnus-group-next-group 1)))
6183 (defun gnus-group-unsubscribe-group (group &optional level silent)
6184 "Toggle subscription to GROUP.
6185 Killed newsgroups are subscribed. If SILENT, don't try to update the
6188 (list (completing-read
6189 "Group: " gnus-active-hashtb nil
6190 (gnus-read-active-file-p)
6192 'gnus-group-history)))
6193 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6195 ((string-match "^[ \t]$" group)
6196 (error "Empty group name"))
6198 ;; Toggle subscription flag.
6199 (gnus-group-change-level
6200 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6201 gnus-level-subscribed)
6202 (1+ gnus-level-subscribed)
6203 gnus-level-default-subscribed)))
6205 (gnus-group-update-group group)))
6206 ((and (stringp group)
6207 (or (not (gnus-read-active-file-p))
6208 (gnus-active group)))
6209 ;; Add new newsgroup.
6210 (gnus-group-change-level
6212 (if level level gnus-level-default-subscribed)
6213 (or (and (member group gnus-zombie-list)
6216 (and (gnus-group-group-name)
6217 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6219 (gnus-group-update-group group)))
6220 (t (error "No such newsgroup: %s" group)))
6221 (gnus-group-position-point)))
6223 (defun gnus-group-transpose-groups (n)
6224 "Move the current newsgroup up N places.
6225 If given a negative prefix, move down instead. The difference between
6226 N and the number of steps taken is returned."
6228 (or (gnus-group-group-name)
6229 (error "No group on current line"))
6230 (gnus-group-kill-group 1)
6232 (forward-line (- n))
6233 (gnus-group-yank-group)
6234 (gnus-group-position-point)))
6236 (defun gnus-group-kill-all-zombies ()
6237 "Kill all zombie newsgroups."
6239 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6240 (setq gnus-zombie-list nil)
6241 (gnus-group-list-groups))
6243 (defun gnus-group-kill-region (begin end)
6244 "Kill newsgroups in current region (excluding current point).
6245 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6260 (beginning-of-line) ;Important when LINES < 1
6261 (gnus-group-kill-group lines)))
6263 (defun gnus-group-kill-group (&optional n discard)
6264 "Kill the next N groups.
6265 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6266 However, only groups that were alive can be yanked; already killed
6267 groups or zombie groups can't be yanked.
6268 The return value is the name of the group that was killed, or a list
6271 (let ((buffer-read-only nil)
6272 (groups (gnus-group-process-prefix n))
6273 group entry level out)
6274 (if (< (length groups) 10)
6275 ;; This is faster when there are few groups.
6277 (push (setq group (pop groups)) out)
6278 (gnus-group-remove-mark group)
6279 (setq level (gnus-group-group-level))
6281 (when (and (not discard)
6282 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6283 (push (cons (car entry) (nth 2 entry))
6284 gnus-list-of-killed-groups))
6285 (gnus-group-change-level
6286 (if entry entry group) gnus-level-killed (if entry nil level)))
6287 ;; If there are lots and lots of groups to be killed, we use
6288 ;; this thing instead.
6290 (setq groups (nreverse groups))
6292 (gnus-group-remove-mark (setq group (pop groups)))
6295 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6296 (push (cons (car entry) (nth 2 entry))
6297 gnus-list-of-killed-groups)
6298 (setcdr (cdr entry) (cdddr entry)))
6299 ((member group gnus-zombie-list)
6300 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6301 (gnus-make-hashtable-from-newsrc-alist)))
6303 (gnus-group-position-point)
6304 (if (< (length out) 2) (car out) (nreverse out))))
6306 (defun gnus-group-yank-group (&optional arg)
6307 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6308 inserting it before the current newsgroup. The numeric ARG specifies
6309 how many newsgroups are to be yanked. The name of the newsgroup yanked
6310 is returned, or (if several groups are yanked) a list of yanked groups
6313 (setq arg (or arg 1))
6314 (let (info group prev out)
6315 (while (>= (decf arg) 0)
6316 (if (not (setq info (pop gnus-list-of-killed-groups)))
6317 (error "No more newsgroups to yank"))
6318 (push (setq group (nth 1 info)) out)
6319 ;; Find which newsgroup to insert this one before - search
6320 ;; backward until something suitable is found. If there are no
6321 ;; other newsgroups in this buffer, just make this newsgroup the
6323 (setq prev (gnus-group-group-name))
6324 (gnus-group-change-level
6325 info (gnus-info-level (cdr info)) gnus-level-killed
6326 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6328 (gnus-group-insert-group-line-info group))
6330 (gnus-group-position-point)
6331 (if (< (length out) 2) (car out) (nreverse out))))
6333 (defun gnus-group-kill-level (level)
6334 "Kill all groups that is on a certain LEVEL."
6335 (interactive "nKill all groups on level: ")
6337 ((= level gnus-level-zombie)
6338 (setq gnus-killed-list
6339 (nconc gnus-zombie-list gnus-killed-list))
6340 (setq gnus-zombie-list nil))
6341 ((and (< level gnus-level-zombie)
6343 (or gnus-expert-user
6346 "Do you really want to kill all groups on level %d? "
6348 (let* ((prev gnus-newsrc-alist)
6351 (if (= (gnus-info-level level) level)
6352 (setcdr prev (cdr alist))
6354 (setq alist (cdr alist)))
6355 (gnus-make-hashtable-from-newsrc-alist)
6356 (gnus-group-list-groups)))
6358 (error "Can't kill; illegal level: %d" level))))
6360 (defun gnus-group-list-all-groups (&optional arg)
6361 "List all newsgroups with level ARG or lower.
6362 Default is gnus-level-unsubscribed, which lists all subscribed and most
6363 unsubscribed groups."
6365 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6367 ;; Redefine this to list ALL killed groups if prefix arg used.
6368 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6369 (defun gnus-group-list-killed (&optional arg)
6370 "List all killed newsgroups in the group buffer.
6371 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6372 entail asking the server for the groups."
6374 ;; Find all possible killed newsgroups if arg.
6376 (gnus-get-killed-groups))
6377 (if (not gnus-killed-list)
6378 (gnus-message 6 "No killed groups")
6379 (let (gnus-group-list-mode)
6380 (funcall gnus-group-prepare-function
6381 gnus-level-killed t gnus-level-killed))
6382 (goto-char (point-min)))
6383 (gnus-group-position-point))
6385 (defun gnus-group-list-zombies ()
6386 "List all zombie newsgroups in the group buffer."
6388 (if (not gnus-zombie-list)
6389 (gnus-message 6 "No zombie groups")
6390 (let (gnus-group-list-mode)
6391 (funcall gnus-group-prepare-function
6392 gnus-level-zombie t gnus-level-zombie))
6393 (goto-char (point-min)))
6394 (gnus-group-position-point))
6396 (defun gnus-group-list-active ()
6397 "List all groups that are available from the server(s)."
6399 ;; First we make sure that we have really read the active file.
6400 (unless (gnus-read-active-file-p)
6401 (let ((gnus-read-active-file t))
6402 (gnus-read-active-file)))
6403 ;; Find all groups and sort them.
6411 (setq list (cons (symbol-name sym) list))))
6415 (buffer-read-only nil))
6418 (gnus-group-insert-group-line-info (pop groups)))
6419 (goto-char (point-min))))
6421 (defun gnus-activate-all-groups (level)
6422 "Activate absolutely all groups."
6423 (interactive (list 7))
6424 (let ((gnus-activate-level level)
6425 (gnus-activate-foreign-newsgroups level))
6426 (gnus-group-get-new-news)))
6428 (defun gnus-group-get-new-news (&optional arg)
6429 "Get newly arrived articles.
6430 If ARG is a number, it specifies which levels you are interested in
6431 re-scanning. If ARG is non-nil and not a number, this will force
6432 \"hard\" re-reading of the active files from all servers."
6434 (run-hooks 'gnus-get-new-news-hook)
6435 ;; We might read in new NoCeM messages here.
6436 (when (and gnus-use-nocem
6438 (gnus-nocem-scan-groups))
6439 ;; If ARG is not a number, then we read the active file.
6440 (when (and arg (not (numberp arg)))
6441 (let ((gnus-read-active-file t))
6442 (gnus-read-active-file))
6445 (setq arg (gnus-group-default-level arg t))
6446 (if (and gnus-read-active-file (not arg))
6448 (gnus-read-active-file)
6449 (gnus-get-unread-articles arg))
6450 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6451 (gnus-get-unread-articles arg)))
6452 (run-hooks 'gnus-after-getting-new-news-hook)
6453 (gnus-group-list-groups))
6455 (defun gnus-group-get-new-news-this-group (&optional n)
6456 "Check for newly arrived news in the current group (and the N-1 next groups).
6457 The difference between N and the number of newsgroup checked is returned.
6458 If N is negative, this group and the N-1 previous groups will be checked."
6460 (let* ((groups (gnus-group-process-prefix n))
6461 (ret (if (numberp n) (- n (length groups)) 0))
6462 (beg (unless n (point)))
6464 (while (setq group (pop groups))
6465 (gnus-group-remove-mark group)
6466 (if (gnus-activate-group group 'scan)
6468 (gnus-get-unread-articles-in-group
6469 (gnus-get-info group) (gnus-active group) t)
6470 (unless (gnus-virtual-group-p group)
6471 (gnus-close-group group))
6472 (gnus-group-update-group group))
6473 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6474 (when beg (goto-char beg))
6475 (when gnus-goto-next-group-when-activating
6476 (gnus-group-next-unread-group 1 t))
6477 (gnus-summary-position-point)
6480 (defun gnus-group-fetch-faq (group &optional faq-dir)
6481 "Fetch the FAQ for the current group."
6484 (gnus-group-real-name (gnus-group-group-name))
6485 (cond (current-prefix-arg
6487 "Faq dir: " (and (listp gnus-group-faq-directory)
6488 gnus-group-faq-directory))))))
6490 (setq faq-dir (if (listp gnus-group-faq-directory)
6491 (car gnus-group-faq-directory)
6492 gnus-group-faq-directory)))
6493 (or group (error "No group name given"))
6494 (let ((file (concat (file-name-as-directory faq-dir)
6495 (gnus-group-real-name group))))
6496 (if (not (file-exists-p file))
6497 (error "No such file: %s" file)
6500 (defun gnus-group-describe-group (force &optional group)
6501 "Display a description of the current newsgroup."
6502 (interactive (list current-prefix-arg (gnus-group-group-name)))
6503 (and force (setq gnus-description-hashtb nil))
6504 (let ((method (gnus-find-method-for-group group))
6506 (or group (error "No group name given"))
6507 (and (or (and gnus-description-hashtb
6508 ;; We check whether this group's method has been
6509 ;; queried for a description file.
6511 (gnus-group-prefixed-name "" method)
6512 gnus-description-hashtb))
6513 (setq desc (gnus-group-get-description group))
6514 (gnus-read-descriptions-file method))
6516 (or desc (gnus-gethash group gnus-description-hashtb)
6517 "No description available")))))
6519 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6520 (defun gnus-group-describe-all-groups (&optional force)
6521 "Pop up a buffer with descriptions of all newsgroups."
6523 (and force (setq gnus-description-hashtb nil))
6524 (if (not (or gnus-description-hashtb
6525 (gnus-read-all-descriptions-files)))
6526 (error "Couldn't request descriptions file"))
6527 (let ((buffer-read-only nil)
6533 (insert (format " *: %-20s %s\n" (symbol-name group)
6534 (symbol-value group)))
6535 (gnus-add-text-properties
6536 b (1+ b) (list 'gnus-group group
6537 'gnus-unread t 'gnus-marked nil
6538 'gnus-level (1+ gnus-level-subscribed))))
6539 gnus-description-hashtb)
6540 (goto-char (point-min))
6541 (gnus-group-position-point)))
6543 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6544 (defun gnus-group-apropos (regexp &optional search-description)
6545 "List all newsgroups that have names that match a regexp."
6546 (interactive "sGnus apropos (regexp): ")
6548 (obuf (current-buffer))
6550 ;; Go through all newsgroups that are known to Gnus.
6553 (and (symbol-name group)
6554 (string-match regexp (symbol-name group))
6555 (setq groups (cons (symbol-name group) groups))))
6557 ;; Also go through all descriptions that are known to Gnus.
6558 (when search-description
6561 (and (string-match regexp (symbol-value group))
6562 (gnus-active (symbol-name group))
6563 (setq groups (cons (symbol-name group) groups))))
6564 gnus-description-hashtb))
6566 (gnus-message 3 "No groups matched \"%s\"." regexp)
6567 ;; Print out all the groups.
6569 (pop-to-buffer "*Gnus Help*")
6570 (buffer-disable-undo (current-buffer))
6572 (setq groups (sort groups 'string<))
6574 ;; Groups may be entered twice into the list of groups.
6575 (if (not (string= (car groups) prev))
6577 (insert (setq prev (car groups)) "\n")
6578 (if (and gnus-description-hashtb
6579 (setq des (gnus-gethash (car groups)
6580 gnus-description-hashtb)))
6581 (insert " " des "\n"))))
6582 (setq groups (cdr groups)))
6583 (goto-char (point-min))))
6584 (pop-to-buffer obuf)))
6586 (defun gnus-group-description-apropos (regexp)
6587 "List all newsgroups that have names or descriptions that match a regexp."
6588 (interactive "sGnus description apropos (regexp): ")
6589 (if (not (or gnus-description-hashtb
6590 (gnus-read-all-descriptions-files)))
6591 (error "Couldn't request descriptions file"))
6592 (gnus-group-apropos regexp t))
6594 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6595 (defun gnus-group-list-matching (level regexp &optional all lowest)
6596 "List all groups with unread articles that match REGEXP.
6597 If the prefix LEVEL is non-nil, it should be a number that says which
6598 level to cut off listing groups.
6599 If ALL, also list groups with no unread articles.
6600 If LOWEST, don't list groups with level lower than LOWEST.
6602 This command may read the active file."
6603 (interactive "P\nsList newsgroups matching: ")
6604 ;; First make sure active file has been read.
6606 (>= (prefix-numeric-value level) gnus-level-killed))
6607 (gnus-get-killed-groups))
6608 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6609 all (or lowest 1) regexp)
6610 (goto-char (point-min))
6611 (gnus-group-position-point))
6613 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6614 "List all groups that match REGEXP.
6615 If the prefix LEVEL is non-nil, it should be a number that says which
6616 level to cut off listing groups.
6617 If LOWEST, don't list groups with level lower than LOWEST."
6618 (interactive "P\nsList newsgroups matching: ")
6619 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6621 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6622 (defun gnus-group-save-newsrc (&optional force)
6623 "Save the Gnus startup files.
6624 If FORCE, force saving whether it is necessary or not."
6626 (gnus-save-newsrc-file force))
6628 (defun gnus-group-restart (&optional arg)
6629 "Force Gnus to read the .newsrc file."
6631 (when (gnus-yes-or-no-p
6632 (format "Are you sure you want to read %s? "
6633 gnus-current-startup-file))
6634 (gnus-save-newsrc-file)
6635 (gnus-setup-news 'force)
6636 (gnus-group-list-groups arg)))
6638 (defun gnus-group-read-init-file ()
6639 "Read the Gnus elisp init file."
6641 (gnus-read-init-file))
6643 (defun gnus-group-check-bogus-groups (&optional silent)
6644 "Check bogus newsgroups.
6645 If given a prefix, don't ask for confirmation before removing a bogus
6648 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6649 (gnus-group-list-groups))
6651 (defun gnus-group-edit-global-kill (&optional article group)
6652 "Edit the global kill file.
6653 If GROUP, edit that local kill file instead."
6655 (setq gnus-current-kill-article article)
6656 (gnus-kill-file-edit-file group)
6659 (substitute-command-keys
6660 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6661 (if group "local" "global")))))
6663 (defun gnus-group-edit-local-kill (article group)
6664 "Edit a local kill file."
6665 (interactive (list nil (gnus-group-group-name)))
6666 (gnus-group-edit-global-kill article group))
6668 (defun gnus-group-force-update ()
6669 "Update `.newsrc' file."
6671 (gnus-save-newsrc-file))
6673 (defun gnus-group-suspend ()
6674 "Suspend the current Gnus session.
6675 In fact, cleanup buffers except for group mode buffer.
6676 The hook gnus-suspend-gnus-hook is called before actually suspending."
6678 (run-hooks 'gnus-suspend-gnus-hook)
6679 ;; Kill Gnus buffers except for group mode buffer.
6680 (let ((group-buf (get-buffer gnus-group-buffer)))
6681 ;; Do this on a separate list in case the user does a ^G before we finish
6682 (let ((gnus-buffer-list
6683 (delq group-buf (delq gnus-dribble-buffer
6684 (append gnus-buffer-list nil)))))
6685 (while gnus-buffer-list
6686 (gnus-kill-buffer (car gnus-buffer-list))
6687 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6690 (setq gnus-buffer-list (list group-buf))
6691 (bury-buffer group-buf)
6692 (delete-windows-on group-buf t)))))
6694 (defun gnus-group-clear-dribble ()
6695 "Clear all information from the dribble buffer."
6697 (gnus-dribble-clear)
6698 (gnus-message 7 "Cleared dribble buffer"))
6700 (defun gnus-group-exit ()
6701 "Quit reading news after updating .newsrc.eld and .newsrc.
6702 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6705 (or noninteractive ;For gnus-batch-kill
6706 (not gnus-interactive-exit) ;Without confirmation
6708 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6709 (run-hooks 'gnus-exit-gnus-hook)
6710 ;; Offer to save data from non-quitted summary buffers.
6711 (gnus-offer-save-summaries)
6712 ;; Save the newsrc file(s).
6713 (gnus-save-newsrc-file)
6715 (gnus-close-backends)
6716 ;; Reset everything.
6718 ;; Allow the user to do things after cleaning up.
6719 (run-hooks 'gnus-after-exiting-gnus-hook)))
6721 (defun gnus-close-backends ()
6722 ;; Send a close request to all backends that support such a request.
6723 (let ((methods gnus-valid-select-methods)
6726 (if (fboundp (setq func (intern (concat (caar methods)
6727 "-request-close"))))
6729 (setq methods (cdr methods)))))
6731 (defun gnus-group-quit ()
6732 "Quit reading news without updating .newsrc.eld or .newsrc.
6733 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6735 (when (or noninteractive ;For gnus-batch-kill
6736 (zerop (buffer-size))
6737 (not (gnus-server-opened gnus-select-method))
6739 (not gnus-current-startup-file)
6741 (format "Quit reading news without saving %s? "
6742 (file-name-nondirectory gnus-current-startup-file))))
6743 (run-hooks 'gnus-exit-gnus-hook)
6744 (if gnus-use-full-window
6745 (delete-other-windows)
6746 (gnus-remove-some-windows))
6748 (gnus-close-backends)
6750 ;; Allow the user to do things after cleaning up.
6751 (run-hooks 'gnus-after-exiting-gnus-hook)))
6753 (defun gnus-offer-save-summaries ()
6754 "Offer to save all active summary buffers."
6756 (let ((buflist (buffer-list))
6758 ;; Go through all buffers and find all summaries.
6760 (and (setq bufname (buffer-name (car buflist)))
6761 (string-match "Summary" bufname)
6763 (set-buffer bufname)
6764 ;; We check that this is, indeed, a summary buffer.
6765 (and (eq major-mode 'gnus-summary-mode)
6766 ;; Also make sure this isn't bogus.
6767 gnus-newsgroup-prepared))
6768 (push bufname buffers))
6769 (setq buflist (cdr buflist)))
6770 ;; Go through all these summary buffers and offer to save them.
6773 "Update summary buffer %s? "
6774 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6777 (defun gnus-group-describe-briefly ()
6778 "Give a one line description of the group mode commands."
6780 (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")))
6782 (defun gnus-group-browse-foreign-server (method)
6783 "Browse a foreign news server.
6784 If called interactively, this function will ask for a select method
6785 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6786 If not, METHOD should be a list where the first element is the method
6787 and the second element is the address."
6789 (list (let ((how (completing-read
6791 (append gnus-valid-select-methods gnus-server-alist)
6792 nil t (cons "nntp" 0) 'gnus-method-history)))
6793 ;; We either got a backend name or a virtual server name.
6794 ;; If the first, we also need an address.
6795 (if (assoc how gnus-valid-select-methods)
6797 ;; Suggested by mapjph@bath.ac.uk.
6800 (mapcar (lambda (server) (list server))
6801 gnus-secondary-servers)))
6802 ;; We got a server name, so we find the method.
6803 (gnus-server-to-method how)))))
6804 (gnus-browse-foreign-server method))
6808 ;;; Gnus summary mode
6811 (defvar gnus-summary-mode-map nil)
6813 (put 'gnus-summary-mode 'mode-class 'special)
6815 (unless gnus-summary-mode-map
6816 (setq gnus-summary-mode-map (make-keymap))
6817 (suppress-keymap gnus-summary-mode-map)
6819 ;; Non-orthogonal keys
6821 (gnus-define-keys gnus-summary-mode-map
6822 " " gnus-summary-next-page
6823 "\177" gnus-summary-prev-page
6824 [delete] gnus-summary-prev-page
6825 "\r" gnus-summary-scroll-up
6826 "n" gnus-summary-next-unread-article
6827 "p" gnus-summary-prev-unread-article
6828 "N" gnus-summary-next-article
6829 "P" gnus-summary-prev-article
6830 "\M-\C-n" gnus-summary-next-same-subject
6831 "\M-\C-p" gnus-summary-prev-same-subject
6832 "\M-n" gnus-summary-next-unread-subject
6833 "\M-p" gnus-summary-prev-unread-subject
6834 "." gnus-summary-first-unread-article
6835 "," gnus-summary-best-unread-article
6836 "\M-s" gnus-summary-search-article-forward
6837 "\M-r" gnus-summary-search-article-backward
6838 "<" gnus-summary-beginning-of-article
6839 ">" gnus-summary-end-of-article
6840 "j" gnus-summary-goto-article
6841 "^" gnus-summary-refer-parent-article
6842 "\M-^" gnus-summary-refer-article
6843 "u" gnus-summary-tick-article-forward
6844 "!" gnus-summary-tick-article-forward
6845 "U" gnus-summary-tick-article-backward
6846 "d" gnus-summary-mark-as-read-forward
6847 "D" gnus-summary-mark-as-read-backward
6848 "E" gnus-summary-mark-as-expirable
6849 "\M-u" gnus-summary-clear-mark-forward
6850 "\M-U" gnus-summary-clear-mark-backward
6851 "k" gnus-summary-kill-same-subject-and-select
6852 "\C-k" gnus-summary-kill-same-subject
6853 "\M-\C-k" gnus-summary-kill-thread
6854 "\M-\C-l" gnus-summary-lower-thread
6855 "e" gnus-summary-edit-article
6856 "#" gnus-summary-mark-as-processable
6857 "\M-#" gnus-summary-unmark-as-processable
6858 "\M-\C-t" gnus-summary-toggle-threads
6859 "\M-\C-s" gnus-summary-show-thread
6860 "\M-\C-h" gnus-summary-hide-thread
6861 "\M-\C-f" gnus-summary-next-thread
6862 "\M-\C-b" gnus-summary-prev-thread
6863 "\M-\C-u" gnus-summary-up-thread
6864 "\M-\C-d" gnus-summary-down-thread
6865 "&" gnus-summary-execute-command
6866 "c" gnus-summary-catchup-and-exit
6867 "\C-w" gnus-summary-mark-region-as-read
6868 "\C-t" gnus-summary-toggle-truncation
6869 "?" gnus-summary-mark-as-dormant
6870 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6871 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6872 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6873 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6874 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6875 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6876 "=" gnus-summary-expand-window
6877 "\C-x\C-s" gnus-summary-reselect-current-group
6878 "\M-g" gnus-summary-rescan-group
6879 "w" gnus-summary-stop-page-breaking
6880 "\C-c\C-r" gnus-summary-caesar-message
6881 "\M-t" gnus-summary-toggle-mime
6882 "f" gnus-summary-followup
6883 "F" gnus-summary-followup-with-original
6884 "C" gnus-summary-cancel-article
6885 "r" gnus-summary-reply
6886 "R" gnus-summary-reply-with-original
6887 "\C-c\C-f" gnus-summary-mail-forward
6888 "o" gnus-summary-save-article
6889 "\C-o" gnus-summary-save-article-mail
6890 "|" gnus-summary-pipe-output
6891 "\M-k" gnus-summary-edit-local-kill
6892 "\M-K" gnus-summary-edit-global-kill
6894 "\C-c\C-d" gnus-summary-describe-group
6895 "q" gnus-summary-exit
6896 "Q" gnus-summary-exit-no-update
6897 "\C-c\C-i" gnus-info-find-node
6898 gnus-mouse-2 gnus-mouse-pick-article
6899 "m" gnus-summary-mail-other-window
6900 "a" gnus-summary-post-news
6901 "x" gnus-summary-limit-to-unread
6902 "s" gnus-summary-isearch-article
6903 "t" gnus-article-hide-headers
6904 "g" gnus-summary-show-article
6905 "l" gnus-summary-goto-last-article
6906 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6907 "\C-d" gnus-summary-enter-digest-group
6909 "*" gnus-cache-enter-article
6910 "\M-*" gnus-cache-remove-article
6911 "\M-&" gnus-summary-universal-argument
6912 "\C-l" gnus-recenter
6913 "I" gnus-summary-increase-score
6914 "L" gnus-summary-lower-score
6916 "V" gnus-summary-score-map
6917 "X" gnus-uu-extract-map
6918 "S" gnus-summary-send-map)
6920 ;; Sort of orthogonal keymap
6921 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6922 "t" gnus-summary-tick-article-forward
6923 "!" gnus-summary-tick-article-forward
6924 "d" gnus-summary-mark-as-read-forward
6925 "r" gnus-summary-mark-as-read-forward
6926 "c" gnus-summary-clear-mark-forward
6927 " " gnus-summary-clear-mark-forward
6928 "e" gnus-summary-mark-as-expirable
6929 "x" gnus-summary-mark-as-expirable
6930 "?" gnus-summary-mark-as-dormant
6931 "b" gnus-summary-set-bookmark
6932 "B" gnus-summary-remove-bookmark
6933 "#" gnus-summary-mark-as-processable
6934 "\M-#" gnus-summary-unmark-as-processable
6935 "S" gnus-summary-limit-include-expunged
6936 "C" gnus-summary-catchup
6937 "H" gnus-summary-catchup-to-here
6938 "\C-c" gnus-summary-catchup-all
6939 "k" gnus-summary-kill-same-subject-and-select
6940 "K" gnus-summary-kill-same-subject
6941 "P" gnus-uu-mark-map)
6943 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6944 "c" gnus-summary-clear-above
6945 "u" gnus-summary-tick-above
6946 "m" gnus-summary-mark-above
6947 "k" gnus-summary-kill-below)
6949 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6950 "/" gnus-summary-limit-to-subject
6951 "n" gnus-summary-limit-to-articles
6952 "w" gnus-summary-pop-limit
6953 "s" gnus-summary-limit-to-subject
6954 "a" gnus-summary-limit-to-author
6955 "u" gnus-summary-limit-to-unread
6956 "m" gnus-summary-limit-to-marks
6957 "v" gnus-summary-limit-to-score
6958 "D" gnus-summary-limit-include-dormant
6959 "d" gnus-summary-limit-exclude-dormant
6960 ;; "t" gnus-summary-limit-exclude-thread
6961 "E" gnus-summary-limit-include-expunged
6962 "c" gnus-summary-limit-exclude-childless-dormant
6963 "C" gnus-summary-limit-mark-excluded-as-read)
6965 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6966 "n" gnus-summary-next-unread-article
6967 "p" gnus-summary-prev-unread-article
6968 "N" gnus-summary-next-article
6969 "P" gnus-summary-prev-article
6970 "\C-n" gnus-summary-next-same-subject
6971 "\C-p" gnus-summary-prev-same-subject
6972 "\M-n" gnus-summary-next-unread-subject
6973 "\M-p" gnus-summary-prev-unread-subject
6974 "f" gnus-summary-first-unread-article
6975 "b" gnus-summary-best-unread-article
6976 "j" gnus-summary-goto-article
6977 "g" gnus-summary-goto-subject
6978 "l" gnus-summary-goto-last-article
6979 "p" gnus-summary-pop-article)
6981 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6982 "k" gnus-summary-kill-thread
6983 "l" gnus-summary-lower-thread
6984 "i" gnus-summary-raise-thread
6985 "T" gnus-summary-toggle-threads
6986 "t" gnus-summary-rethread-current
6987 "^" gnus-summary-reparent-thread
6988 "s" gnus-summary-show-thread
6989 "S" gnus-summary-show-all-threads
6990 "h" gnus-summary-hide-thread
6991 "H" gnus-summary-hide-all-threads
6992 "n" gnus-summary-next-thread
6993 "p" gnus-summary-prev-thread
6994 "u" gnus-summary-up-thread
6995 "o" gnus-summary-top-thread
6996 "d" gnus-summary-down-thread
6997 "#" gnus-uu-mark-thread
6998 "\M-#" gnus-uu-unmark-thread)
7000 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7001 "c" gnus-summary-catchup-and-exit
7002 "C" gnus-summary-catchup-all-and-exit
7003 "E" gnus-summary-exit-no-update
7004 "Q" gnus-summary-exit
7005 "Z" gnus-summary-exit
7006 "n" gnus-summary-catchup-and-goto-next-group
7007 "R" gnus-summary-reselect-current-group
7008 "G" gnus-summary-rescan-group
7009 "N" gnus-summary-next-group
7010 "P" gnus-summary-prev-group)
7012 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7013 " " gnus-summary-next-page
7014 "n" gnus-summary-next-page
7015 "\177" gnus-summary-prev-page
7016 [delete] gnus-summary-prev-page
7017 "p" gnus-summary-prev-page
7018 "\r" gnus-summary-scroll-up
7019 "<" gnus-summary-beginning-of-article
7020 ">" gnus-summary-end-of-article
7021 "b" gnus-summary-beginning-of-article
7022 "e" gnus-summary-end-of-article
7023 "^" gnus-summary-refer-parent-article
7024 "r" gnus-summary-refer-parent-article
7025 "R" gnus-summary-refer-references
7026 "g" gnus-summary-show-article
7027 "s" gnus-summary-isearch-article)
7029 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7030 "b" gnus-article-add-buttons
7031 "B" gnus-article-add-buttons-to-head
7032 "o" gnus-article-treat-overstrike
7033 ;; "w" gnus-article-word-wrap
7034 "w" gnus-article-fill-cited-article
7035 "c" gnus-article-remove-cr
7036 "L" gnus-article-remove-trailing-blank-lines
7037 "q" gnus-article-de-quoted-unreadable
7038 "f" gnus-article-display-x-face
7039 "l" gnus-summary-stop-page-breaking
7040 "r" gnus-summary-caesar-message
7041 "t" gnus-article-hide-headers
7042 "v" gnus-summary-verbose-headers
7043 "m" gnus-summary-toggle-mime)
7045 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7046 "a" gnus-article-hide
7047 "h" gnus-article-hide-headers
7048 "b" gnus-article-hide-boring-headers
7049 "s" gnus-article-hide-signature
7050 "c" gnus-article-hide-citation
7051 "p" gnus-article-hide-pgp
7052 "\C-c" gnus-article-hide-citation-maybe)
7054 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7055 "a" gnus-article-highlight
7056 "h" gnus-article-highlight-headers
7057 "c" gnus-article-highlight-citation
7058 "s" gnus-article-highlight-signature)
7060 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7061 "z" gnus-article-date-ut
7062 "u" gnus-article-date-ut
7063 "l" gnus-article-date-local
7064 "e" gnus-article-date-lapsed
7065 "o" gnus-article-date-original)
7067 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7069 "f" gnus-summary-fetch-faq
7070 "d" gnus-summary-describe-group
7071 "h" gnus-summary-describe-briefly
7072 "i" gnus-info-find-node)
7074 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7075 "e" gnus-summary-expire-articles
7076 "\M-\C-e" gnus-summary-expire-articles-now
7077 "\177" gnus-summary-delete-article
7078 [delete] gnus-summary-delete-article
7079 "m" gnus-summary-move-article
7080 "r" gnus-summary-respool-article
7081 "w" gnus-summary-edit-article
7082 "c" gnus-summary-copy-article
7083 "B" gnus-summary-crosspost-article
7084 "q" gnus-summary-respool-query
7085 "i" gnus-summary-import-article)
7087 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7088 "o" gnus-summary-save-article
7089 "m" gnus-summary-save-article-mail
7090 "r" gnus-summary-save-article-rmail
7091 "f" gnus-summary-save-article-file
7092 "b" gnus-summary-save-article-body-file
7093 "h" gnus-summary-save-article-folder
7094 "v" gnus-summary-save-article-vm
7095 "p" gnus-summary-pipe-output
7096 "s" gnus-soup-add-article)
7101 (defun gnus-summary-mode (&optional group)
7102 "Major mode for reading articles.
7104 All normal editing commands are switched off.
7105 \\<gnus-summary-mode-map>
7106 Each line in this buffer represents one article. To read an
7107 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7108 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7111 You can also post articles and send mail from this buffer. To
7112 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7113 of an article, type `\\[gnus-summary-reply]'.
7115 There are approx. one gazillion commands you can execute in this
7116 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7118 The following commands are available:
7120 \\{gnus-summary-mode-map}"
7122 (when (and menu-bar-mode
7123 (gnus-visual-p 'summary-menu 'menu))
7124 (gnus-summary-make-menu-bar))
7125 (kill-all-local-variables)
7126 (let ((locals gnus-summary-local-variables))
7128 (if (consp (car locals))
7130 (make-local-variable (caar locals))
7131 (set (caar locals) (eval (cdar locals))))
7132 (make-local-variable (car locals))
7133 (set (car locals) nil))
7134 (setq locals (cdr locals))))
7135 (gnus-make-thread-indent-array)
7136 (gnus-simplify-mode-line)
7137 (setq major-mode 'gnus-summary-mode)
7138 (setq mode-name "Summary")
7139 (make-local-variable 'minor-mode-alist)
7140 (use-local-map gnus-summary-mode-map)
7141 (buffer-disable-undo (current-buffer))
7142 (setq buffer-read-only t) ;Disable modification
7143 (setq truncate-lines t)
7144 (setq selective-display t)
7145 (setq selective-display-ellipses t) ;Display `...'
7146 (setq buffer-display-table gnus-summary-display-table)
7147 (setq gnus-newsgroup-name group)
7148 (make-local-variable 'gnus-summary-line-format)
7149 (make-local-variable 'gnus-summary-line-format-spec)
7150 (make-local-variable 'gnus-summary-mark-positions)
7151 (run-hooks 'gnus-summary-mode-hook))
7153 (defun gnus-summary-make-display-table ()
7154 ;; Change the display table. Odd characters have a tendency to mess
7155 ;; up nicely formatted displays - we make all possible glyphs
7156 ;; display only a single character.
7158 ;; We start from the standard display table, if any.
7159 (setq gnus-summary-display-table
7160 (or (copy-sequence standard-display-table)
7161 (make-display-table)))
7162 ;; Nix out all the control chars...
7164 (while (>= (setq i (1- i)) 0)
7165 (aset gnus-summary-display-table i [??])))
7166 ;; ... but not newline and cr, of course. (cr is necessary for the
7167 ;; selective display).
7168 (aset gnus-summary-display-table ?\n nil)
7169 (aset gnus-summary-display-table ?\r nil)
7170 ;; We nix out any glyphs over 126 that are not set already.
7172 (while (>= (setq i (1- i)) 127)
7173 ;; Only modify if the entry is nil.
7174 (or (aref gnus-summary-display-table i)
7175 (aset gnus-summary-display-table i [??])))))
7177 (defun gnus-summary-clear-local-variables ()
7178 (let ((locals gnus-summary-local-variables))
7180 (if (consp (car locals))
7181 (and (vectorp (caar locals))
7182 (set (caar locals) nil))
7183 (and (vectorp (car locals))
7184 (set (car locals) nil)))
7185 (setq locals (cdr locals)))))
7187 ;; Summary data functions.
7189 (defmacro gnus-data-number (data)
7192 (defmacro gnus-data-set-number (data number)
7193 `(setcar ,data ,number))
7195 (defmacro gnus-data-mark (data)
7198 (defmacro gnus-data-set-mark (data mark)
7199 `(setcar (nthcdr 1 ,data) ,mark))
7201 (defmacro gnus-data-pos (data)
7204 (defmacro gnus-data-set-pos (data pos)
7205 `(setcar (nthcdr 2 ,data) ,pos))
7207 (defmacro gnus-data-header (data)
7210 (defmacro gnus-data-level (data)
7213 (defmacro gnus-data-unread-p (data)
7214 `(= (nth 1 ,data) gnus-unread-mark))
7216 (defmacro gnus-data-pseudo-p (data)
7217 `(consp (nth 3 ,data)))
7219 (defmacro gnus-data-find (number)
7220 `(assq ,number gnus-newsgroup-data))
7222 (defmacro gnus-data-find-list (number &optional data)
7223 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7224 (memq (assq ,number bdata)
7227 (defmacro gnus-data-make (number mark pos header level)
7228 `(list ,number ,mark ,pos ,header ,level))
7230 (defun gnus-data-enter (after-article number mark pos header level offset)
7231 (let ((data (gnus-data-find-list after-article)))
7232 (or data (error "No such article: %d" after-article))
7233 (setcdr data (cons (gnus-data-make number mark pos header level)
7235 (setq gnus-newsgroup-data-reverse nil)
7236 (gnus-data-update-list (cddr data) offset)))
7238 (defun gnus-data-enter-list (after-article list &optional offset)
7240 (let ((data (and after-article (gnus-data-find-list after-article)))
7242 (or data (not after-article) (error "No such article: %d" after-article))
7243 ;; Find the last element in the list to be spliced into the main
7246 (setq list (cdr list)))
7249 (setcdr list gnus-newsgroup-data)
7250 (setq gnus-newsgroup-data ilist)
7251 (and offset (gnus-data-update-list (cdr list) offset)))
7252 (setcdr list (cdr data))
7254 (and offset (gnus-data-update-list (cdr data) offset)))
7255 (setq gnus-newsgroup-data-reverse nil))))
7257 (defun gnus-data-remove (article &optional offset)
7258 (let ((data gnus-newsgroup-data))
7259 (if (= (gnus-data-number (car data)) article)
7260 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7261 gnus-newsgroup-data-reverse nil)
7263 (and (= (gnus-data-number (cadr data)) article)
7265 (setcdr data (cddr data))
7266 (and offset (gnus-data-update-list (cdr data) offset))
7268 gnus-newsgroup-data-reverse nil)))
7269 (setq data (cdr data))))))
7271 (defmacro gnus-data-list (backward)
7273 (or gnus-newsgroup-data-reverse
7274 (setq gnus-newsgroup-data-reverse
7275 (reverse gnus-newsgroup-data)))
7276 gnus-newsgroup-data))
7278 (defun gnus-data-update-list (data offset)
7279 "Add OFFSET to the POS of all data entries in DATA."
7281 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7282 (setq data (cdr data))))
7284 (defun gnus-data-compute-positions ()
7285 "Compute the positions of all articles."
7286 (let ((data gnus-newsgroup-data)
7289 (when (setq pos (text-property-any
7290 (point-min) (point-max)
7291 'gnus-number (gnus-data-number (car data))))
7292 (gnus-data-set-pos (car data) (+ pos 3)))
7293 (setq data (cdr data)))))
7295 (defun gnus-summary-article-pseudo-p (article)
7296 "Say whether this article is a pseudo article or not."
7297 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7299 (defun gnus-article-parent-p (number)
7300 "Say whether this article is a parent or not."
7301 (let ((data (gnus-data-find-list number)))
7302 (and (cdr data) ; There has to be an article after...
7303 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7304 (gnus-data-level (nth 1 data))))))
7306 (defun gnus-article-children (number)
7307 "Return a list of all children to NUMBER."
7308 (let* ((data (gnus-data-find-list number))
7309 (level (gnus-data-level (car data)))
7311 (setq data (cdr data))
7313 (= (gnus-data-level (car data)) (1+ level)))
7314 (push (gnus-data-number (car data)) children)
7315 (setq data (cdr data)))
7318 (defmacro gnus-summary-skip-intangible ()
7319 "If the current article is intangible, then jump to a different article."
7320 '(let ((to (get-text-property (point) 'gnus-intangible)))
7321 (and to (gnus-summary-goto-subject to))))
7323 (defmacro gnus-summary-article-intangible-p ()
7324 "Say whether this article is intangible or not."
7325 '(get-text-property (point) 'gnus-intangible))
7327 ;; Some summary mode macros.
7329 (defmacro gnus-summary-article-number ()
7330 "The article number of the article on the current line.
7331 If there isn's an article number here, then we return the current
7334 (gnus-summary-skip-intangible)
7335 (or (get-text-property (point) 'gnus-number)
7336 (gnus-summary-last-subject))))
7338 (defmacro gnus-summary-article-header (&optional number)
7339 `(gnus-data-header (gnus-data-find
7340 ,(or number '(gnus-summary-article-number)))))
7342 (defmacro gnus-summary-thread-level (&optional number)
7343 `(if (and (eq gnus-summary-make-false-root 'dummy)
7344 (get-text-property (point) 'gnus-intangible))
7346 (gnus-data-level (gnus-data-find
7347 ,(or number '(gnus-summary-article-number))))))
7349 (defmacro gnus-summary-article-mark (&optional number)
7350 `(gnus-data-mark (gnus-data-find
7351 ,(or number '(gnus-summary-article-number)))))
7353 (defmacro gnus-summary-article-pos (&optional number)
7354 `(gnus-data-pos (gnus-data-find
7355 ,(or number '(gnus-summary-article-number)))))
7357 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7358 (defmacro gnus-summary-article-subject (&optional number)
7359 "Return current subject string or nil if nothing."
7362 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7363 '(gnus-data-header (assq (gnus-summary-article-number)
7364 gnus-newsgroup-data)))))
7367 (mail-header-subject headers))))
7369 (defmacro gnus-summary-article-score (&optional number)
7370 "Return current article score."
7371 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7372 gnus-newsgroup-scored))
7373 gnus-summary-default-score 0))
7375 (defun gnus-summary-article-children (&optional number)
7376 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7377 (level (gnus-data-level (car data)))
7379 (while (and (setq data (cdr data))
7380 (> (setq l (gnus-data-level (car data))) level))
7381 (and (= (1+ level) l)
7382 (setq children (cons (gnus-data-number (car data))
7384 (nreverse children)))
7386 (defun gnus-summary-article-parent (&optional number)
7387 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7388 (gnus-data-list t)))
7389 (level (gnus-data-level (car data))))
7391 () ; This is a root.
7392 ;; We search until we find an article with a level less than
7393 ;; this one. That function has to be the parent.
7394 (while (and (setq data (cdr data))
7395 (not (< (gnus-data-level (car data)) level))))
7396 (and data (gnus-data-number (car data))))))
7398 (defun gnus-unread-mark-p (mark)
7399 "Say whether MARK is the unread mark."
7400 (= mark gnus-unread-mark))
7402 (defun gnus-read-mark-p (mark)
7403 "Say whether MARK is one of the marks that mark as read.
7404 This is all marks except unread, ticked, dormant, and expirable."
7405 (not (or (= mark gnus-unread-mark)
7406 (= mark gnus-ticked-mark)
7407 (= mark gnus-dormant-mark)
7408 (= mark gnus-expirable-mark))))
7410 ;; Saving hidden threads.
7412 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7413 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7414 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7416 (defmacro gnus-save-hidden-threads (&rest forms)
7417 "Save hidden threads, eval FORMS, and restore the hidden threads."
7418 (let ((config (make-symbol "config")))
7419 `(let ((,config (gnus-hidden-threads-configuration)))
7423 (gnus-restore-hidden-threads-configuration ,config)))))
7425 (defun gnus-hidden-threads-configuration ()
7426 "Return the current hidden threads configuration."
7429 (goto-char (point-min))
7430 (while (search-forward "\r" nil t)
7431 (push (1- (point)) config))
7434 (defun gnus-restore-hidden-threads-configuration (config)
7435 "Restore hidden threads configuration from CONFIG."
7436 (let (point buffer-read-only)
7437 (while (setq point (pop config))
7438 (when (and (< point (point-max))
7440 (= (following-char) ?\n))
7441 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7443 ;; Various summary mode internalish functions.
7445 (defun gnus-mouse-pick-article (e)
7448 (gnus-summary-next-page nil t))
7450 (defun gnus-summary-setup-buffer (group)
7451 "Initialize summary buffer."
7452 (let ((buffer (concat "*Summary " group "*")))
7453 (if (get-buffer buffer)
7456 (setq gnus-summary-buffer (current-buffer))
7457 (not gnus-newsgroup-prepared))
7458 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7459 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7460 (gnus-add-current-to-buffer-list)
7461 (gnus-summary-mode group)
7463 (gnus-carpal-setup-buffer 'summary))
7464 (unless gnus-single-article-buffer
7465 (make-local-variable 'gnus-article-buffer)
7466 (make-local-variable 'gnus-article-current)
7467 (make-local-variable 'gnus-original-article-buffer))
7468 (setq gnus-newsgroup-name group)
7471 (defun gnus-set-global-variables ()
7472 ;; Set the global equivalents of the summary buffer-local variables
7473 ;; to the latest values they had. These reflect the summary buffer
7474 ;; that was in action when the last article was fetched.
7475 (when (eq major-mode 'gnus-summary-mode)
7476 (setq gnus-summary-buffer (current-buffer))
7477 (let ((name gnus-newsgroup-name)
7478 (marked gnus-newsgroup-marked)
7479 (unread gnus-newsgroup-unreads)
7480 (headers gnus-current-headers)
7481 (data gnus-newsgroup-data)
7482 (summary gnus-summary-buffer)
7483 (article-buffer gnus-article-buffer)
7484 (original gnus-original-article-buffer)
7485 (gac gnus-article-current)
7486 (score-file gnus-current-score-file))
7488 (set-buffer gnus-group-buffer)
7489 (setq gnus-newsgroup-name name)
7490 (setq gnus-newsgroup-marked marked)
7491 (setq gnus-newsgroup-unreads unread)
7492 (setq gnus-current-headers headers)
7493 (setq gnus-newsgroup-data data)
7494 (setq gnus-article-current gac)
7495 (setq gnus-summary-buffer summary)
7496 (setq gnus-article-buffer article-buffer)
7497 (setq gnus-original-article-buffer original)
7498 (setq gnus-current-score-file score-file)))))
7500 (defun gnus-summary-last-article-p (&optional article)
7501 "Return whether ARTICLE is the last article in the buffer."
7502 (if (not (setq article (or article (gnus-summary-article-number))))
7503 t ; All non-existant numbers are the last article. :-)
7504 (not (cdr (gnus-data-find-list article)))))
7506 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7507 "Insert a dummy root in the summary buffer."
7509 (gnus-add-text-properties
7510 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7511 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7513 (defun gnus-make-thread-indent-array ()
7515 (unless (and gnus-thread-indent-array
7516 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7517 (setq gnus-thread-indent-array (make-vector 201 "")
7518 gnus-thread-indent-array-level gnus-thread-indent-level)
7520 (aset gnus-thread-indent-array n
7521 (make-string (* n gnus-thread-indent-level) ? ))
7524 (defun gnus-summary-insert-line
7525 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7526 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7527 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7528 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7529 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7530 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7531 (gnus-tmp-score-char
7532 (if (or (null gnus-summary-default-score)
7533 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7534 gnus-summary-zcore-fuzz)) ?
7535 (if (< gnus-tmp-score gnus-summary-default-score)
7536 gnus-score-below-mark gnus-score-over-mark)))
7537 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7538 ((memq gnus-tmp-current gnus-newsgroup-cached)
7540 (gnus-tmp-replied gnus-replied-mark)
7541 ((memq gnus-tmp-current gnus-newsgroup-saved)
7543 (t gnus-unread-mark)))
7544 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7547 ((string-match "(.+)" gnus-tmp-from)
7548 (substring gnus-tmp-from
7549 (1+ (match-beginning 0)) (1- (match-end 0))))
7550 ((string-match "<[^>]+> *$" gnus-tmp-from)
7551 (let ((beg (match-beginning 0)))
7552 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7553 (substring gnus-tmp-from (1+ (match-beginning 0))
7554 (1- (match-end 0))))
7555 (substring gnus-tmp-from 0 beg))))
7557 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7558 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7559 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7560 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7561 (buffer-read-only nil))
7562 (when (string= gnus-tmp-name "")
7563 (setq gnus-tmp-name gnus-tmp-from))
7564 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7565 (gnus-put-text-property
7567 (progn (eval gnus-summary-line-format-spec) (point))
7568 'gnus-number gnus-tmp-number)
7569 (when (gnus-visual-p 'summary-highlight 'highlight)
7571 (run-hooks 'gnus-summary-update-hook)
7574 (defun gnus-summary-update-line (&optional dont-update)
7575 ;; Update summary line after change.
7576 (when (and gnus-summary-default-score
7577 (not gnus-summary-inhibit-highlight))
7578 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7579 (article (gnus-summary-article-number))
7580 (score (gnus-summary-article-score article)))
7582 (if (and gnus-summary-mark-below
7583 (< (gnus-summary-article-score)
7584 gnus-summary-mark-below))
7585 ;; This article has a low score, so we mark it as read.
7586 (when (memq article gnus-newsgroup-unreads)
7587 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7588 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7589 ;; This article was previously marked as read on account
7590 ;; of a low score, but now it has risen, so we mark it as
7592 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7593 (gnus-summary-update-mark
7594 (if (or (null gnus-summary-default-score)
7595 (<= (abs (- score gnus-summary-default-score))
7596 gnus-summary-zcore-fuzz)) ?
7597 (if (< score gnus-summary-default-score)
7598 gnus-score-below-mark gnus-score-over-mark)) 'score))
7599 ;; Do visual highlighting.
7600 (when (gnus-visual-p 'summary-highlight 'highlight)
7601 (run-hooks 'gnus-summary-update-hook)))))
7603 (defvar gnus-tmp-new-adopts nil)
7605 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7606 ;; Sum up all elements (and sub-elements) in a list.
7608 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7610 ((and (consp thread) (cdr thread))
7613 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7616 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7619 (when (and level (zerop level) gnus-tmp-new-adopts)
7622 'gnus-summary-number-of-articles-in-thread
7623 gnus-tmp-new-adopts))))
7625 (if (> number 1) gnus-not-empty-thread-mark
7626 gnus-empty-thread-mark)
7629 (defun gnus-summary-set-local-parameters (group)
7630 "Go through the local params of GROUP and set all variable specs in that list."
7631 (let ((params (gnus-info-params (gnus-get-info group)))
7634 (setq elem (car params)
7635 params (cdr params))
7636 (and (consp elem) ; Has to be a cons.
7637 (consp (cdr elem)) ; The cdr has to be a list.
7638 (symbolp (car elem)) ; Has to be a symbol in there.
7639 (not (memq (car elem)
7640 '(quit-config to-address to-list to-group)))
7641 (progn ; So we set it.
7642 (make-local-variable (car elem))
7643 (set (car elem) (eval (nth 1 elem))))))))
7645 (defun gnus-summary-read-group (group &optional show-all no-article
7646 kill-buffer no-display)
7647 "Start reading news in newsgroup GROUP.
7648 If SHOW-ALL is non-nil, already read articles are also listed.
7649 If NO-ARTICLE is non-nil, no article is selected initially.
7650 If NO-DISPLAY, don't generate a summary buffer."
7651 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7652 (let* ((new-group (gnus-summary-setup-buffer group))
7653 (quit-config (gnus-group-quit-config group))
7654 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7656 ;; This summary buffer exists already, so we just select it.
7658 (gnus-set-global-variables)
7660 (gnus-kill-or-deaden-summary kill-buffer))
7661 (gnus-configure-windows 'summary 'force)
7662 (gnus-set-mode-line 'summary)
7663 (gnus-summary-position-point)
7666 ;; We couldn't select this group.
7668 (when (and (eq major-mode 'gnus-summary-mode)
7669 (not (equal (current-buffer) kill-buffer)))
7670 (kill-buffer (current-buffer))
7671 (if (not quit-config)
7673 (set-buffer gnus-group-buffer)
7674 (gnus-group-jump-to-group group)
7675 (gnus-group-next-unread-group 1))
7676 (if (not (buffer-name (car quit-config)))
7677 (gnus-configure-windows 'group 'force)
7678 (set-buffer (car quit-config))
7679 (and (eq major-mode 'gnus-summary-mode)
7680 (gnus-set-global-variables))
7681 (gnus-configure-windows (cdr quit-config)))))
7682 (gnus-message 3 "Can't select group")
7684 ;; The user did a `C-g' while prompting for number of articles,
7685 ;; so we exit this group.
7686 ((eq did-select 'quit)
7687 (and (eq major-mode 'gnus-summary-mode)
7688 (not (equal (current-buffer) kill-buffer))
7689 (kill-buffer (current-buffer)))
7691 (gnus-kill-or-deaden-summary kill-buffer))
7692 (if (not quit-config)
7694 (set-buffer gnus-group-buffer)
7695 (gnus-group-jump-to-group group)
7696 (gnus-group-next-unread-group 1)
7697 (gnus-configure-windows 'group 'force))
7698 (if (not (buffer-name (car quit-config)))
7699 (gnus-configure-windows 'group 'force)
7700 (set-buffer (car quit-config))
7701 (and (eq major-mode 'gnus-summary-mode)
7702 (gnus-set-global-variables))
7703 (gnus-configure-windows (cdr quit-config))))
7704 ;; Finally signal the quit.
7706 ;; The group was successfully selected.
7708 (gnus-set-global-variables)
7709 ;; Save the active value in effect when the group was entered.
7710 (setq gnus-newsgroup-active
7712 (gnus-active gnus-newsgroup-name)))
7713 ;; You can change the summary buffer in some way with this hook.
7714 (run-hooks 'gnus-select-group-hook)
7715 ;; Set any local variables in the group parameters.
7716 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7717 (gnus-update-format-specifications)
7718 ;; Do score processing.
7719 (when gnus-use-scoring
7720 (gnus-possibly-score-headers))
7721 ;; Check whether to fill in the gaps in the threads.
7722 (when gnus-build-sparse-threads
7723 (gnus-build-sparse-threads))
7724 ;; Find the initial limit.
7725 (if gnus-show-threads
7727 (let ((gnus-newsgroup-dormant nil))
7728 (gnus-summary-initial-limit show-all))
7729 (gnus-summary-initial-limit show-all))
7730 (setq gnus-newsgroup-limit
7732 (lambda (header) (mail-header-number header))
7733 gnus-newsgroup-headers)))
7734 ;; Generate the summary buffer.
7736 (gnus-summary-prepare))
7737 (when gnus-use-trees
7738 (gnus-tree-open group)
7739 (setq gnus-summary-highlight-line-function
7740 'gnus-tree-highlight-article))
7741 ;; If the summary buffer is empty, but there are some low-scored
7742 ;; articles or some excluded dormants, we include these in the
7744 (when (and (zerop (buffer-size))
7746 (cond (gnus-newsgroup-dormant
7747 (gnus-summary-limit-include-dormant))
7748 ((and gnus-newsgroup-scored show-all)
7749 (gnus-summary-limit-include-expunged))))
7750 ;; Function `gnus-apply-kill-file' must be called in this hook.
7751 (run-hooks 'gnus-apply-kill-hook)
7752 (if (and (zerop (buffer-size))
7755 ;; This newsgroup is empty.
7756 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7757 (gnus-message 6 "No unread news")
7759 (gnus-kill-or-deaden-summary kill-buffer))
7760 ;; Return nil from this function.
7762 ;; Hide conversation thread subtrees. We cannot do this in
7763 ;; gnus-summary-prepare-hook since kill processing may not
7764 ;; work with hidden articles.
7765 (and gnus-show-threads
7766 gnus-thread-hide-subtree
7767 (gnus-summary-hide-all-threads))
7768 ;; Show first unread article if requested.
7769 (if (and (not no-article)
7771 gnus-newsgroup-unreads
7772 gnus-auto-select-first)
7773 (unless (if (eq gnus-auto-select-first 'best)
7774 (gnus-summary-best-unread-article)
7775 (gnus-summary-first-unread-article))
7776 (gnus-configure-windows 'summary))
7777 ;; Don't select any articles, just move point to the first
7778 ;; article in the group.
7779 (goto-char (point-min))
7780 (gnus-summary-position-point)
7781 (gnus-set-mode-line 'summary)
7782 (gnus-configure-windows 'summary 'force))
7783 ;; If we are in async mode, we send some info to the backend.
7784 (when gnus-newsgroup-async
7785 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7787 (gnus-kill-or-deaden-summary kill-buffer))
7788 (when (get-buffer-window gnus-group-buffer t)
7789 ;; Gotta use windows, because recenter does wierd stuff if
7790 ;; the current buffer ain't the displayed window.
7791 (let ((owin (selected-window)))
7792 (select-window (get-buffer-window gnus-group-buffer t))
7793 (when (gnus-group-goto-group group)
7795 (select-window owin))))
7796 ;; Mark this buffer as "prepared".
7797 (setq gnus-newsgroup-prepared t)
7800 (defun gnus-summary-prepare ()
7801 "Generate the summary buffer."
7802 (let ((buffer-read-only nil))
7804 (setq gnus-newsgroup-data nil
7805 gnus-newsgroup-data-reverse nil)
7806 (run-hooks 'gnus-summary-generate-hook)
7807 ;; Generate the buffer, either with threads or without.
7808 (when gnus-newsgroup-headers
7809 (gnus-summary-prepare-threads
7810 (if gnus-show-threads
7811 (gnus-sort-gathered-threads
7812 (funcall gnus-summary-thread-gathering-function
7814 (gnus-cut-threads (gnus-make-threads)))))
7815 ;; Unthreaded display.
7816 (gnus-sort-articles gnus-newsgroup-headers))))
7817 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7818 ;; Call hooks for modifying summary buffer.
7819 (goto-char (point-min))
7820 (run-hooks 'gnus-summary-prepare-hook)))
7822 (defun gnus-gather-threads-by-subject (threads)
7823 "Gather threads by looking at Subject headers."
7824 (if (not gnus-summary-make-false-root)
7826 (let ((hashtb (gnus-make-hashtable 1023))
7829 subject hthread whole-subject)
7831 (setq whole-subject (mail-header-subject (caar threads)))
7834 ;; Truncate the subject.
7835 ((numberp gnus-summary-gather-subject-limit)
7836 (setq subject (gnus-simplify-subject-re whole-subject))
7837 (if (> (length subject) gnus-summary-gather-subject-limit)
7838 (substring subject 0 gnus-summary-gather-subject-limit)
7840 ;; Fuzzily simplify it.
7841 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7842 (gnus-simplify-subject-fuzzy whole-subject))
7843 ;; Just remove the leading "Re:".
7845 (gnus-simplify-subject-re whole-subject))))
7847 (if (and gnus-summary-gather-exclude-subject
7848 (string-match gnus-summary-gather-exclude-subject
7850 () ; We don't want to do anything with this article.
7851 ;; We simplify the subject before looking it up in the
7854 (if (setq hthread (gnus-gethash subject hashtb))
7856 ;; We enter a dummy root into the thread, if we
7857 ;; haven't done that already.
7858 (unless (stringp (caar hthread))
7859 (setcar hthread (list whole-subject (car hthread))))
7860 ;; We add this new gathered thread to this gathered
7862 (setcdr (car hthread)
7863 (nconc (cdar hthread) (list (car threads))))
7864 ;; Remove it from the list of threads.
7865 (setcdr prev (cdr threads))
7866 (setq threads prev))
7867 ;; Enter this thread into the hash table.
7868 (gnus-sethash subject threads hashtb)))
7870 (setq threads (cdr threads)))
7873 (defun gnus-gather-threads-by-references (threads)
7874 "Gather threads by looking at References headers."
7875 (let ((idhashtb (gnus-make-hashtable 1023))
7876 (thhashtb (gnus-make-hashtable 1023))
7879 ids references id gthread gid entered)
7881 (when (setq references (mail-header-references (caar threads)))
7882 (setq id (mail-header-id (caar threads)))
7883 (setq ids (gnus-split-references references))
7886 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7888 (gnus-sethash (car ids) id idhashtb)
7889 (gnus-sethash id threads thhashtb))
7890 (setq gthread (gnus-gethash gid thhashtb))
7892 ;; We enter a dummy root into the thread, if we
7893 ;; haven't done that already.
7894 (unless (stringp (caar gthread))
7895 (setcar gthread (list (mail-header-subject (caar gthread))
7897 ;; We add this new gathered thread to this gathered
7899 (setcdr (car gthread)
7900 (nconc (cdar gthread) (list (car threads)))))
7901 ;; Add it into the thread hash table.
7902 (gnus-sethash id gthread thhashtb)
7904 ;; Remove it from the list of threads.
7905 (setcdr prev (cdr threads))
7906 (setq threads prev))
7907 (setq ids (cdr ids))))
7909 (setq threads (cdr threads)))
7912 (defun gnus-sort-gathered-threads (threads)
7913 "Sort subtreads inside each gathered thread by article number."
7914 (let ((result threads))
7916 (when (stringp (caar threads))
7917 (setcdr (car threads)
7918 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7919 (setq threads (cdr threads)))
7922 (defun gnus-make-threads ()
7923 "Go through the dependency hashtb and find the roots. Return all threads."
7927 (unless (car (symbol-value refs))
7928 ;; These threads do not refer back to any other articles,
7929 ;; so they're roots.
7930 (setq threads (append (cdr (symbol-value refs)) threads))))
7931 gnus-newsgroup-dependencies)
7934 (defun gnus-build-sparse-threads ()
7935 (let ((headers gnus-newsgroup-headers)
7936 (deps gnus-newsgroup-dependencies)
7937 header references generation relations
7938 cthread subject child end pthread relation)
7939 ;; First we create an alist of generations/relations, where
7940 ;; generations is how much we trust the ralation, and the relation
7942 (gnus-message 7 "Making sparse threads...")
7944 (nnheader-set-temp-buffer " *gnus sparse threads*")
7945 (while (setq header (pop headers))
7946 (when (and (setq references (mail-header-references header))
7947 (not (string= references "")))
7949 (setq child (mail-header-id header)
7950 subject (mail-header-subject header))
7952 (while (search-backward ">" nil t)
7953 (setq end (1+ (point)))
7954 (when (search-backward "<" nil t)
7955 (push (list (incf generation)
7956 child (setq child (buffer-substring (point) end))
7959 (push (list (1+ generation) child nil subject) relations)
7961 (kill-buffer (current-buffer)))
7962 ;; Sort over trustworthiness.
7963 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7964 (while (setq relation (pop relations))
7965 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7966 (unless (car (symbol-value cthread))
7967 ;; Make this article the parent of these threads.
7968 (setcar (symbol-value cthread)
7969 (vector gnus-reffed-article-number
7973 (or (caddr relation) "") 0 0 "")))
7974 (set cthread (list (vector gnus-reffed-article-number
7976 "" "" (cadr relation)
7977 (or (caddr relation) "") 0 0 ""))))
7978 (push gnus-reffed-article-number gnus-newsgroup-limit)
7979 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7980 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7981 gnus-newsgroup-reads)
7982 (decf gnus-reffed-article-number)
7983 ;; Make this new thread the child of its parent.
7984 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7985 (setcdr (symbol-value pthread)
7986 (nconc (cdr (symbol-value pthread))
7987 (list (symbol-value cthread))))
7988 (set pthread (list nil (symbol-value cthread))))))
7989 (gnus-message 7 "Making sparse threads...done")))
7991 (defun gnus-build-old-threads ()
7992 ;; Look at all the articles that refer back to old articles, and
7993 ;; fetch the headers for the articles that aren't there. This will
7994 ;; build complete threads - if the roots haven't been expired by the
7999 (when (not (car (symbol-value refs)))
8000 (setq heads (cdr (symbol-value refs)))
8002 (if (memq (mail-header-number (caar heads))
8003 gnus-newsgroup-dormant)
8004 (setq heads (cdr heads))
8005 (setq id (symbol-name refs))
8006 (while (and (setq id (gnus-build-get-header id))
8007 (not (car (gnus-gethash
8008 id gnus-newsgroup-dependencies)))))
8009 (setq heads nil)))))
8010 gnus-newsgroup-dependencies)))
8012 (defun gnus-build-get-header (id)
8013 ;; Look through the buffer of NOV lines and find the header to
8014 ;; ID. Enter this line into the dependencies hash table, and return
8015 ;; the id of the parent article (if any).
8016 (let ((deps gnus-newsgroup-dependencies)
8020 (set-buffer nntp-server-buffer)
8021 (goto-char (point-min))
8022 (while (and (not found) (search-forward id nil t))
8024 (setq found (looking-at
8025 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8026 (regexp-quote id))))
8027 (or found (beginning-of-line 2)))
8031 (setq header (gnus-nov-parse-line
8032 (read (current-buffer)) deps))
8033 (gnus-parent-id (mail-header-references header)))))
8035 (let ((number (mail-header-number header)))
8036 (push number gnus-newsgroup-limit)
8037 (push header gnus-newsgroup-headers)
8038 (if (memq number gnus-newsgroup-unselected)
8040 (push number gnus-newsgroup-unreads)
8041 (setq gnus-newsgroup-unselected
8042 (delq number gnus-newsgroup-unselected)))
8043 (push number gnus-newsgroup-ancient)))))))
8045 (defun gnus-summary-update-article (article &optional header)
8046 "Update ARTICLE in the summary buffer."
8047 (set-buffer gnus-summary-buffer)
8048 (let* ((header (or header (gnus-summary-article-header article)))
8049 (id (mail-header-id header))
8050 (data (gnus-data-find article))
8051 (thread (gnus-id-to-thread id))
8053 (gnus-id-to-thread (or (gnus-parent-id
8054 (mail-header-references header))
8056 (buffer-read-only nil)
8058 (number (mail-header-number header))
8063 (delq thread parent))
8064 (if (gnus-summary-insert-subject id header)
8065 ;; Set the (possibly) new article number in the data structure.
8066 (gnus-data-set-number data (gnus-id-to-article id))
8070 (defun gnus-rebuild-thread (id)
8071 "Rebuild the thread containing ID."
8072 (let ((buffer-read-only nil)
8073 current thread data)
8074 (if (not gnus-show-threads)
8075 (setq thread (list (car (gnus-id-to-thread id))))
8076 ;; Get the thread this article is part of.
8077 (setq thread (gnus-remove-thread id)))
8078 (setq current (save-excursion
8079 (and (zerop (forward-line -1))
8080 (gnus-summary-article-number))))
8081 ;; If this is a gathered thread, we have to go some re-gathering.
8082 (when (stringp (car thread))
8083 (let ((subject (car thread))
8085 (setq thread (cdr thread))
8087 (unless (memq (setq thr (gnus-id-to-thread
8089 (mail-header-id (caar thread)))))
8092 (setq thread (cdr thread)))
8093 ;; We now have all (unique) roots.
8094 (if (= (length roots) 1)
8095 ;; All the loose roots are now one solid root.
8096 (setq thread (car roots))
8097 (setq thread (cons subject (gnus-sort-threads roots))))))
8099 ;; We then insert this thread into the summary buffer.
8100 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8101 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8102 (setq data (nreverse gnus-newsgroup-data))
8103 (setq threads gnus-newsgroup-threads))
8104 ;; We splice the new data into the data structure.
8105 (gnus-data-enter-list current data)
8106 (gnus-data-compute-positions)
8107 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8109 (defun gnus-id-to-thread (id)
8110 "Return the (sub-)thread where ID appears."
8111 (gnus-gethash id gnus-newsgroup-dependencies))
8113 (defun gnus-id-to-article (id)
8114 "Return the article number of ID."
8115 (let ((thread (gnus-id-to-thread id)))
8118 (mail-header-number (car thread)))))
8120 (defun gnus-id-to-header (id)
8121 "Return the article headers of ID."
8122 (car (gnus-id-to-thread id)))
8124 (defun gnus-article-displayed-root-p (article)
8125 "Say whether ARTICLE is a root(ish) article."
8126 (let ((level (gnus-summary-thread-level article))
8127 (refs (mail-header-references (gnus-summary-article-header article)))
8133 ((null (gnus-parent-id refs)) t)
8135 (null (setq particle (gnus-id-to-article
8136 (gnus-parent-id refs))))
8137 (null (gnus-summary-thread-level particle)))))))
8139 (defun gnus-root-id (id)
8140 "Return the id of the root of the thread where ID appears."
8142 (while (and id (setq prev (car (gnus-gethash
8143 id gnus-newsgroup-dependencies))))
8145 id (gnus-parent-id (mail-header-references prev))))
8148 (defun gnus-remove-thread (id &optional dont-remove)
8149 "Remove the thread that has ID in it."
8150 (let ((dep gnus-newsgroup-dependencies)
8151 headers thread last-id)
8152 ;; First go up in this thread until we find the root.
8153 (setq last-id (gnus-root-id id))
8154 (setq headers (list (car (gnus-id-to-thread last-id))
8155 (caadr (gnus-id-to-thread last-id))))
8156 ;; We have now found the real root of this thread. It might have
8157 ;; been gathered into some loose thread, so we have to search
8158 ;; through the threads to find the thread we wanted.
8159 (let ((threads gnus-newsgroup-threads)
8162 (setq sub (car threads))
8163 (if (stringp (car sub))
8164 ;; This is a gathered threads, so we look at the roots
8165 ;; below it to find whether this article in in this
8168 (setq sub (cdr sub))
8170 (when (member (caar sub) headers)
8171 (setq thread (car threads)
8174 (setq sub (cdr sub))))
8175 ;; It's an ordinary thread, so we check it.
8176 (when (eq (car sub) (car headers))
8179 (setq threads (cdr threads)))
8180 ;; If this article is in no thread, then it's a root.
8183 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8184 (setq thread (gnus-gethash last-id dep)))
8187 thread ; We return this thread.
8189 (if (stringp (car thread))
8191 ;; If we use dummy roots, then we have to remove the
8192 ;; dummy root as well.
8193 (when (eq gnus-summary-make-false-root 'dummy)
8196 (setq thread (cdr thread))
8198 (gnus-remove-thread-1 (car thread))
8199 (setq thread (cdr thread))))
8200 (gnus-remove-thread-1 thread))))))))
8202 (defun gnus-remove-thread-1 (thread)
8203 "Remove the thread THREAD recursively."
8204 (let ((number (mail-header-number (car thread)))
8206 (when (setq pos (text-property-any
8207 (point-min) (point-max) 'gnus-number number))
8210 (gnus-data-remove number))
8211 (setq thread (cdr thread))
8213 (gnus-remove-thread-1 (pop thread)))))
8215 (defun gnus-sort-threads (threads)
8217 (if (not gnus-thread-sort-functions)
8219 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8220 (car gnus-thread-sort-functions)
8222 ,(gnus-make-sort-function
8223 (reverse gnus-thread-sort-functions))))))
8224 (gnus-message 7 "Sorting threads...")
8227 (gnus-message 7 "Sorting threads...done")))))
8229 (defun gnus-sort-articles (articles)
8231 (when gnus-article-sort-functions
8232 (let ((func (if (= 1 (length gnus-article-sort-functions))
8233 (car gnus-article-sort-functions)
8235 ,(gnus-make-sort-function
8236 (reverse gnus-article-sort-functions))))))
8237 (gnus-message 7 "Sorting articles...")
8239 (setq gnus-newsgroup-headers (sort articles func))
8240 (gnus-message 7 "Sorting articles...done")))))
8242 (defun gnus-make-sort-function (funs)
8243 "Return a composite sort condition based on the functions in FUNC."
8245 `(or (,(car funs) t1 t2)
8246 (and (not (,(car funs) t2 t1))
8247 ,(gnus-make-sort-function (cdr funs))))
8248 `(,(car funs) t1 t2)))
8250 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8251 (defmacro gnus-thread-header (thread)
8252 ;; Return header of first article in THREAD.
8253 ;; Note that THREAD must never, ever be anything else than a variable -
8254 ;; using some other form will lead to serious barfage.
8255 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8256 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8257 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8260 (defsubst gnus-article-sort-by-number (h1 h2)
8261 "Sort articles by article number."
8262 (< (mail-header-number h1)
8263 (mail-header-number h2)))
8265 (defun gnus-thread-sort-by-number (h1 h2)
8266 "Sort threads by root article number."
8267 (gnus-article-sort-by-number
8268 (gnus-thread-header h1) (gnus-thread-header h2)))
8270 (defsubst gnus-article-sort-by-author (h1 h2)
8271 "Sort articles by root author."
8273 (let ((extract (funcall
8274 gnus-extract-address-components
8275 (mail-header-from h1))))
8276 (or (car extract) (cdr extract)))
8277 (let ((extract (funcall
8278 gnus-extract-address-components
8279 (mail-header-from h2))))
8280 (or (car extract) (cdr extract)))))
8282 (defun gnus-thread-sort-by-author (h1 h2)
8283 "Sort threads by root author."
8284 (gnus-article-sort-by-author
8285 (gnus-thread-header h1) (gnus-thread-header h2)))
8287 (defsubst gnus-article-sort-by-subject (h1 h2)
8288 "Sort articles by root subject."
8290 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8291 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8293 (defun gnus-thread-sort-by-subject (h1 h2)
8294 "Sort threads by root subject."
8295 (gnus-article-sort-by-subject
8296 (gnus-thread-header h1) (gnus-thread-header h2)))
8298 (defsubst gnus-article-sort-by-date (h1 h2)
8299 "Sort articles by root article date."
8301 (inline (gnus-sortable-date (mail-header-date h1)))
8302 (inline (gnus-sortable-date (mail-header-date h2)))))
8304 (defun gnus-thread-sort-by-date (h1 h2)
8305 "Sort threads by root article date."
8306 (gnus-article-sort-by-date
8307 (gnus-thread-header h1) (gnus-thread-header h2)))
8309 (defsubst gnus-article-sort-by-score (h1 h2)
8310 "Sort articles by root article score.
8311 Unscored articles will be counted as having a score of zero."
8312 (> (or (cdr (assq (mail-header-number h1)
8313 gnus-newsgroup-scored))
8314 gnus-summary-default-score 0)
8315 (or (cdr (assq (mail-header-number h2)
8316 gnus-newsgroup-scored))
8317 gnus-summary-default-score 0)))
8319 (defun gnus-thread-sort-by-score (h1 h2)
8320 "Sort threads by root article score."
8321 (gnus-article-sort-by-score
8322 (gnus-thread-header h1) (gnus-thread-header h2)))
8324 (defun gnus-thread-sort-by-total-score (h1 h2)
8325 "Sort threads by the sum of all scores in the thread.
8326 Unscored articles will be counted as having a score of zero."
8327 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8329 (defun gnus-thread-total-score (thread)
8330 ;; This function find the total score of THREAD.
8332 (if (stringp (car thread))
8333 (apply gnus-thread-score-function 0
8334 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8335 (gnus-thread-total-score-1 thread))
8336 (gnus-thread-total-score-1 (list thread))))
8338 (defun gnus-thread-total-score-1 (root)
8339 ;; This function find the total score of the thread below ROOT.
8340 (setq root (car root))
8341 (apply gnus-thread-score-function
8342 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8343 gnus-summary-default-score 0)
8344 (mapcar 'gnus-thread-total-score
8345 (cdr (gnus-gethash (mail-header-id root)
8346 gnus-newsgroup-dependencies)))))
8348 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8349 (defvar gnus-tmp-prev-subject nil)
8350 (defvar gnus-tmp-false-parent nil)
8351 (defvar gnus-tmp-root-expunged nil)
8352 (defvar gnus-tmp-dummy-line nil)
8354 (defun gnus-summary-prepare-threads (threads)
8355 "Prepare summary buffer from THREADS and indentation LEVEL.
8356 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8357 or a straight list of headers."
8358 (gnus-message 7 "Generating summary...")
8360 (setq gnus-newsgroup-threads threads)
8363 (let ((gnus-tmp-level 0)
8364 (default-score (or gnus-summary-default-score 0))
8365 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8366 thread number subject stack state gnus-tmp-gathered beg-match
8367 new-roots gnus-tmp-new-adopts thread-end
8368 gnus-tmp-header gnus-tmp-unread
8369 gnus-tmp-replied gnus-tmp-subject-or-nil
8370 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8371 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8372 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8374 (setq gnus-tmp-prev-subject nil)
8376 (if (vectorp (car threads))
8377 ;; If this is a straight (sic) list of headers, then a
8378 ;; threaded summary display isn't required, so we just create
8379 ;; an unthreaded one.
8380 (gnus-summary-prepare-unthreaded threads)
8382 ;; Do the threaded display.
8384 (while (or threads stack gnus-tmp-new-adopts new-roots)
8386 (if (and (= gnus-tmp-level 0)
8387 (not (setq gnus-tmp-dummy-line nil))
8390 (not gnus-tmp-false-parent)
8391 (or gnus-tmp-new-adopts new-roots))
8392 (if gnus-tmp-new-adopts
8393 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8394 thread (list (car gnus-tmp-new-adopts))
8395 gnus-tmp-header (caar thread)
8396 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8398 (setq thread (list (car new-roots))
8399 gnus-tmp-header (caar thread)
8400 new-roots (cdr new-roots))))
8403 ;; If there are some threads, we do them before the
8404 ;; threads on the stack.
8405 (setq thread threads
8406 gnus-tmp-header (caar thread))
8407 ;; There were no current threads, so we pop something off
8409 (setq state (car stack)
8410 gnus-tmp-level (car state)
8413 gnus-tmp-header (caar thread))))
8415 (setq gnus-tmp-false-parent nil)
8416 (setq gnus-tmp-root-expunged nil)
8417 (setq thread-end nil)
8419 (if (stringp gnus-tmp-header)
8420 ;; The header is a dummy root.
8422 ((eq gnus-summary-make-false-root 'adopt)
8423 ;; We let the first article adopt the rest.
8424 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8426 (setq gnus-tmp-gathered
8428 (lambda (h) (mail-header-number (car h)))
8431 (setq thread (cons (list (caar thread)
8434 (setq gnus-tmp-level -1
8435 gnus-tmp-false-parent t))
8436 ((eq gnus-summary-make-false-root 'empty)
8437 ;; We print adopted articles with empty subject fields.
8438 (setq gnus-tmp-gathered
8440 (lambda (h) (mail-header-number (car h)))
8443 (setq gnus-tmp-level -1))
8444 ((eq gnus-summary-make-false-root 'dummy)
8445 ;; We remember that we probably want to output a dummy
8447 (setq gnus-tmp-dummy-line gnus-tmp-header)
8448 (setq gnus-tmp-prev-subject gnus-tmp-header))
8450 ;; We do not make a root for the gathered
8451 ;; sub-threads at all.
8452 (setq gnus-tmp-level -1)))
8454 (setq number (mail-header-number gnus-tmp-header)
8455 subject (mail-header-subject gnus-tmp-header))
8458 ;; If the thread has changed subject, we might want to make
8459 ;; this subthread into a root.
8460 ((and (null gnus-thread-ignore-subject)
8461 (not (zerop gnus-tmp-level))
8462 gnus-tmp-prev-subject
8464 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8465 (setq new-roots (nconc new-roots (list (car thread)))
8467 gnus-tmp-header nil))
8468 ;; If the article lies outside the current limit,
8469 ;; then we do not display it.
8470 ((and (not (memq number gnus-newsgroup-limit))
8471 (not gnus-tmp-dummy-line))
8472 (setq gnus-tmp-gathered
8474 (lambda (h) (mail-header-number (car h)))
8477 (setq gnus-tmp-new-adopts (if (cdar thread)
8478 (append gnus-tmp-new-adopts
8480 gnus-tmp-new-adopts)
8482 gnus-tmp-header nil)
8483 (when (zerop gnus-tmp-level)
8484 (setq gnus-tmp-root-expunged t)))
8485 ;; Perhaps this article is to be marked as read?
8486 ((and gnus-summary-mark-below
8487 (< (or (cdr (assq number gnus-newsgroup-scored))
8489 gnus-summary-mark-below)
8490 ;; Don't touch sparse articles.
8491 (not (memq number gnus-newsgroup-sparse))
8492 (not (memq number gnus-newsgroup-ancient)))
8493 (setq gnus-newsgroup-unreads
8494 (delq number gnus-newsgroup-unreads))
8495 (if gnus-newsgroup-auto-expire
8496 (push number gnus-newsgroup-expirable)
8497 (push (cons number gnus-low-score-mark)
8498 gnus-newsgroup-reads))))
8500 (when gnus-tmp-header
8501 ;; We may have an old dummy line to output before this
8503 (when gnus-tmp-dummy-line
8504 (gnus-summary-insert-dummy-line
8505 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8506 (setq gnus-tmp-dummy-line nil))
8508 ;; Compute the mark.
8512 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8513 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8514 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8515 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8516 (t (or (cdr (assq number gnus-newsgroup-reads))
8517 gnus-ancient-mark))))
8519 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8520 gnus-tmp-header gnus-tmp-level)
8521 gnus-newsgroup-data)
8523 ;; Actually insert the line.
8525 gnus-tmp-subject-or-nil
8527 ((and gnus-thread-ignore-subject
8528 gnus-tmp-prev-subject
8529 (not (inline (gnus-subject-equal
8530 gnus-tmp-prev-subject subject))))
8532 ((zerop gnus-tmp-level)
8533 (if (and (eq gnus-summary-make-false-root 'empty)
8534 (memq number gnus-tmp-gathered)
8535 gnus-tmp-prev-subject
8536 (inline (gnus-subject-equal
8537 gnus-tmp-prev-subject subject)))
8538 gnus-summary-same-subject
8540 (t gnus-summary-same-subject)))
8541 (if (and (eq gnus-summary-make-false-root 'adopt)
8542 (= gnus-tmp-level 1)
8543 (memq number gnus-tmp-gathered))
8544 (setq gnus-tmp-opening-bracket ?\<
8545 gnus-tmp-closing-bracket ?\>)
8546 (setq gnus-tmp-opening-bracket ?\[
8547 gnus-tmp-closing-bracket ?\]))
8549 gnus-tmp-indentation
8550 (aref gnus-thread-indent-array gnus-tmp-level)
8551 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8552 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8553 gnus-summary-default-score 0)
8555 (if (or (null gnus-summary-default-score)
8556 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8557 gnus-summary-zcore-fuzz)) ?
8558 (if (< gnus-tmp-score gnus-summary-default-score)
8559 gnus-score-below-mark gnus-score-over-mark))
8561 (cond ((memq number gnus-newsgroup-processable)
8563 ((memq number gnus-newsgroup-cached)
8565 ((memq number gnus-newsgroup-replied)
8567 (t gnus-unread-mark))
8568 gnus-tmp-from (mail-header-from gnus-tmp-header)
8571 ((string-match "(.+)" gnus-tmp-from)
8572 (substring gnus-tmp-from
8573 (1+ (match-beginning 0)) (1- (match-end 0))))
8574 ((string-match "<[^>]+> *$" gnus-tmp-from)
8575 (setq beg-match (match-beginning 0))
8576 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8577 (substring gnus-tmp-from (1+ (match-beginning 0))
8578 (1- (match-end 0))))
8579 (substring gnus-tmp-from 0 beg-match)))
8581 (when (string= gnus-tmp-name "")
8582 (setq gnus-tmp-name gnus-tmp-from))
8583 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8584 (gnus-put-text-property
8586 (progn (eval gnus-summary-line-format-spec) (point))
8587 'gnus-number number)
8590 (run-hooks 'gnus-summary-update-hook)
8593 (setq gnus-tmp-prev-subject subject)))
8595 (when (nth 1 thread)
8596 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8597 (incf gnus-tmp-level)
8598 (setq threads (if thread-end nil (cdar thread)))
8600 (setq gnus-tmp-level 0)))))
8601 (gnus-message 7 "Generating summary...done"))
8603 (defun gnus-summary-prepare-unthreaded (headers)
8604 "Generate an unthreaded summary buffer based on HEADERS."
8605 (let (header number mark)
8608 ;; We may have to root out some bad articles...
8609 (when (memq (setq number (mail-header-number
8610 (setq header (pop headers))))
8611 gnus-newsgroup-limit)
8612 ;; Mark article as read when it has a low score.
8613 (when (and gnus-summary-mark-below
8614 (< (or (cdr (assq number gnus-newsgroup-scored))
8615 gnus-summary-default-score 0)
8616 gnus-summary-mark-below)
8617 (not (memq number gnus-newsgroup-ancient)))
8618 (setq gnus-newsgroup-unreads
8619 (delq number gnus-newsgroup-unreads))
8620 (if gnus-newsgroup-auto-expire
8621 (push number gnus-newsgroup-expirable)
8622 (push (cons number gnus-low-score-mark)
8623 gnus-newsgroup-reads)))
8627 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8628 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8629 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8630 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8631 (t (or (cdr (assq number gnus-newsgroup-reads))
8632 gnus-ancient-mark))))
8633 (setq gnus-newsgroup-data
8634 (cons (gnus-data-make number mark (1+ (point)) header 0)
8635 gnus-newsgroup-data))
8636 (gnus-summary-insert-line
8637 header 0 nil mark (memq number gnus-newsgroup-replied)
8638 (memq number gnus-newsgroup-expirable)
8639 (mail-header-subject header) nil
8640 (cdr (assq number gnus-newsgroup-scored))
8641 (memq number gnus-newsgroup-processable))))))
8643 (defun gnus-select-newsgroup (group &optional read-all)
8644 "Select newsgroup GROUP.
8645 If READ-ALL is non-nil, all articles in the group are selected."
8646 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8647 (info (nth 2 entry))
8648 articles fetched-articles cached)
8650 (or (gnus-check-server
8651 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8652 (error "Couldn't open server"))
8654 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8655 (gnus-activate-group group) ; Or we can activate it...
8656 (progn ; Or we bug out.
8657 (when (equal major-mode 'gnus-summary-mode)
8658 (kill-buffer (current-buffer)))
8659 (error "Couldn't request group %s: %s"
8660 group (gnus-status-message group))))
8662 (unless (gnus-request-group group t)
8663 (when (equal major-mode 'gnus-summary-mode)
8664 (kill-buffer (current-buffer)))
8665 (error "Couldn't request group %s: %s"
8666 group (gnus-status-message group)))
8668 (setq gnus-newsgroup-name group)
8669 (setq gnus-newsgroup-unselected nil)
8670 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8672 (and gnus-asynchronous
8673 (gnus-check-backend-function
8674 'request-asynchronous gnus-newsgroup-name)
8675 (setq gnus-newsgroup-async
8676 (gnus-request-asynchronous gnus-newsgroup-name)))
8678 ;; Adjust and set lists of article marks.
8680 (gnus-adjust-marked-articles info))
8682 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8683 (when (gnus-virtual-group-p group)
8684 (setq cached gnus-newsgroup-cached))
8686 (setq gnus-newsgroup-unreads
8687 (gnus-set-difference
8688 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8689 gnus-newsgroup-dormant))
8691 (setq gnus-newsgroup-processable nil)
8693 (setq articles (gnus-articles-to-read group read-all))
8697 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8699 ((eq articles 0) nil)
8701 ;; Init the dependencies hash table.
8702 (setq gnus-newsgroup-dependencies
8703 (gnus-make-hashtable (length articles)))
8704 ;; Retrieve the headers and read them in.
8705 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8706 (setq gnus-newsgroup-headers
8708 (setq gnus-headers-retrieved-by
8709 (gnus-retrieve-headers
8710 articles gnus-newsgroup-name
8711 ;; We might want to fetch old headers, but
8712 ;; not if there is only 1 article.
8713 (and gnus-fetch-old-headers
8715 (not (eq gnus-fetch-old-headers 'some))
8716 (not (numberp gnus-fetch-old-headers)))
8717 (> (length articles) 1))))))
8718 (gnus-get-newsgroup-headers-xover articles)
8719 (gnus-get-newsgroup-headers)))
8720 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8722 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8724 (setq gnus-newsgroup-cached cached))
8726 ;; Set the initial limit.
8727 (setq gnus-newsgroup-limit (copy-sequence articles))
8728 ;; Remove canceled articles from the list of unread articles.
8729 (setq gnus-newsgroup-unreads
8730 (gnus-set-sorted-intersection
8731 gnus-newsgroup-unreads
8732 (setq fetched-articles
8733 (mapcar (lambda (headers) (mail-header-number headers))
8734 gnus-newsgroup-headers))))
8735 ;; Removed marked articles that do not exist.
8736 (gnus-update-missing-marks
8737 (gnus-sorted-complement fetched-articles articles))
8738 ;; We might want to build some more threads first.
8739 (and gnus-fetch-old-headers
8740 (eq gnus-headers-retrieved-by 'nov)
8741 (gnus-build-old-threads))
8742 ;; Check whether auto-expire is to be done in this group.
8743 (setq gnus-newsgroup-auto-expire
8744 (gnus-group-auto-expirable-p group))
8745 ;; Set up the article buffer now, if necessary.
8746 (unless gnus-single-article-buffer
8747 (gnus-article-setup-buffer))
8748 ;; First and last article in this newsgroup.
8749 (and gnus-newsgroup-headers
8750 (setq gnus-newsgroup-begin
8751 (mail-header-number (car gnus-newsgroup-headers)))
8752 (setq gnus-newsgroup-end
8754 (gnus-last-element gnus-newsgroup-headers))))
8755 (setq gnus-reffed-article-number -1)
8756 ;; GROUP is successfully selected.
8757 (or gnus-newsgroup-headers t)))))
8759 (defun gnus-articles-to-read (group read-all)
8760 ;; Find out what articles the user wants to read.
8762 ;; Select all articles if `read-all' is non-nil, or if there
8763 ;; are no unread articles.
8765 (and (zerop (length gnus-newsgroup-marked))
8766 (zerop (length gnus-newsgroup-unreads))))
8767 (gnus-uncompress-range (gnus-active group))
8768 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8769 (copy-sequence gnus-newsgroup-unreads))
8771 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8772 (scored (length scored-list))
8773 (number (length articles))
8774 (marked (+ (length gnus-newsgroup-marked)
8775 (length gnus-newsgroup-dormant)))
8783 ((and (or (<= scored marked) (= scored number))
8784 (numberp gnus-large-newsgroup)
8785 (> number gnus-large-newsgroup))
8789 "How many articles from %s (default %d): "
8790 gnus-newsgroup-name number))))
8791 (if (string-match "^[ \t]*$" input) number input)))
8792 ((and (> scored marked) (< scored number))
8795 (format "%s %s (%d scored, %d total): "
8796 "How many articles from"
8797 group scored number))))
8798 (if (string-match "^[ \t]*$" input)
8802 (setq select (if (stringp select) (string-to-number select) select))
8803 (if (or (null select) (zerop select))
8805 (if (and (not (zerop scored)) (<= (abs select) scored))
8807 (setq articles (sort scored-list '<))
8808 (setq number (length articles)))
8809 (setq articles (copy-sequence articles)))
8811 (if (< (abs select) number)
8813 ;; Select the N oldest articles.
8814 (setcdr (nthcdr (1- (abs select)) articles) nil)
8815 ;; Select the N most recent articles.
8816 (setq articles (nthcdr (- number select) articles))))
8817 (setq gnus-newsgroup-unselected
8818 (gnus-sorted-intersection
8819 gnus-newsgroup-unreads
8820 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8823 (defun gnus-killed-articles (killed articles)
8826 (if (inline (gnus-member-of-range (car articles) killed))
8827 (setq out (cons (car articles) out)))
8828 (setq articles (cdr articles)))
8831 (defun gnus-uncompress-marks (marks)
8832 "Uncompress the mark ranges in MARKS."
8833 (let ((uncompressed '(score bookmark))
8836 (if (memq (caar marks) uncompressed)
8837 (push (car marks) out)
8838 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8839 (setq marks (cdr marks)))
8842 (defun gnus-adjust-marked-articles (info)
8843 "Set all article lists and remove all marks that are no longer legal."
8844 (let* ((marked-lists (gnus-info-marks info))
8845 (active (gnus-active (gnus-info-group info)))
8848 (types gnus-article-mark-lists)
8849 (uncompressed '(score bookmark))
8850 marks var articles article mark)
8853 (setq marks (pop marked-lists))
8854 (set (setq var (intern (format "gnus-newsgroup-%s"
8855 (car (rassq (setq mark (car marks))
8857 (if (memq (car marks) uncompressed) (cdr marks)
8858 (gnus-uncompress-range (cdr marks))))
8860 (setq articles (symbol-value var))
8862 ;; All articles have to be subsets of the active articles.
8864 ;; Adjust "simple" lists.
8865 ((memq mark '(tick dormant expirable reply killed save))
8867 (when (or (< (setq article (pop articles)) min) (> article max))
8868 (set var (delq article (symbol-value var))))))
8870 ((memq mark '(score bookmark))
8872 (when (or (< (car (setq article (pop articles))) min)
8873 (> (car article) max))
8874 (set var (delq article (symbol-value var))))))))))
8876 (defun gnus-update-missing-marks (missing)
8877 "Go through the list of MISSING articles and remove them mark lists."
8879 (let ((types gnus-article-mark-lists)
8881 ;; Go through all types.
8883 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8884 (when (symbol-value var)
8885 ;; This list has articles. So we delete all missing articles
8889 (set var (delq (pop m) (symbol-value var)))))))))
8891 (defun gnus-update-marks ()
8892 "Enter the various lists of marked articles into the newsgroup info list."
8893 (let ((types gnus-article-mark-lists)
8894 (info (gnus-get-info gnus-newsgroup-name))
8895 (uncompressed '(score bookmark killed))
8896 type list newmarked symbol)
8898 ;; Add all marks lists that are non-nil to the list of marks lists.
8900 (setq type (pop types))
8901 (when (setq list (symbol-value
8903 (intern (format "gnus-newsgroup-%s"
8905 (push (cons (cdr type)
8906 (if (memq (cdr type) uncompressed) list
8907 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8910 ;; Enter these new marks into the info of the group.
8912 (setcar (nthcdr 3 info) newmarked)
8913 ;; Add the marks lists to the end of the info.
8915 (setcdr (nthcdr 2 info) (list newmarked))))
8917 ;; Cut off the end of the info if there's nothing else there.
8921 (when (nthcdr (decf i) info)
8922 (setcdr (nthcdr i info) nil)))))))
8924 (defun gnus-add-marked-articles (group type articles &optional info force)
8925 ;; Add ARTICLES of TYPE to the info of GROUP.
8926 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8927 ;; add, but replace marked articles of TYPE with ARTICLES.
8928 (let ((info (or info (gnus-get-info group)))
8929 (uncompressed '(score bookmark killed))
8932 (and (not (setq marked (nthcdr 3 info)))
8934 (setcdr (nthcdr 2 info)
8935 (list (list (cons type (gnus-compress-sequence
8937 (and (not (setq m (assq type (car marked))))
8940 (cons (cons type (gnus-compress-sequence articles t) )
8944 (setcar (nthcdr 3 info)
8945 (delq (assq type (car marked)) (car marked)))
8946 (setcdr m (gnus-compress-sequence articles t)))
8947 (setcdr m (gnus-compress-sequence
8948 (sort (nconc (gnus-uncompress-range (cdr m))
8949 (copy-sequence articles)) '<) t))))))
8951 (defun gnus-set-mode-line (where)
8952 "This function sets the mode line of the article or summary buffers.
8953 If WHERE is `summary', the summary mode line format will be used."
8954 ;; Is this mode line one we keep updated?
8955 (when (memq where gnus-updated-mode-lines)
8958 ;; We evaluate this in the summary buffer since these
8959 ;; variables are buffer-local to that buffer.
8960 (set-buffer gnus-summary-buffer)
8961 ;; We bind all these variables that are used in the `eval' form
8963 (let* ((mformat (symbol-value
8965 (format "gnus-%s-mode-line-format-spec" where))))
8966 (gnus-tmp-group-name gnus-newsgroup-name)
8967 (gnus-tmp-article-number (or gnus-current-article 0))
8968 (gnus-tmp-unread gnus-newsgroup-unreads)
8969 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8970 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8971 (gnus-tmp-unread-and-unselected
8972 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8973 (zerop gnus-tmp-unselected)) "")
8974 ((zerop gnus-tmp-unselected)
8975 (format "{%d more}" gnus-tmp-unread-and-unticked))
8976 (t (format "{%d(+%d) more}"
8977 gnus-tmp-unread-and-unticked
8978 gnus-tmp-unselected))))
8980 (if (and gnus-current-headers
8981 (vectorp gnus-current-headers))
8982 (gnus-mode-string-quote
8983 (mail-header-subject gnus-current-headers)) ""))
8985 gnus-tmp-header);; passed as argument to any user-format-funcs
8986 (setq mode-string (eval mformat))
8987 (setq max-len (max 4 (if gnus-mode-non-string-length
8989 gnus-mode-non-string-length)
8990 (length mode-string))))
8991 ;; We might have to chop a bit of the string off...
8992 (when (> (length mode-string) max-len)
8994 (concat (gnus-truncate-string mode-string (- max-len 3))
8996 ;; Pad the mode string a bit.
8997 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8998 ;; Update the mode line.
8999 (setq mode-line-buffer-identification (list mode-string))
9000 (set-buffer-modified-p t))))
9002 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9003 "Go through the HEADERS list and add all Xrefs to a hash table.
9004 The resulting hash table is returned, or nil if no Xrefs were found."
9005 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9006 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9007 (xref-hashtb (make-vector 63 0))
9008 start group entry number xrefs header)
9010 (setq header (pop headers))
9011 (when (and (setq xrefs (mail-header-xref header))
9012 (not (memq (setq number (mail-header-number header))
9015 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9016 (setq start (match-end 0))
9017 (setq group (if prefix
9018 (concat prefix (substring xrefs (match-beginning 1)
9020 (substring xrefs (match-beginning 1) (match-end 1))))
9022 (string-to-int (substring xrefs (match-beginning 2)
9024 (if (setq entry (gnus-gethash group xref-hashtb))
9025 (setcdr entry (cons number (cdr entry)))
9026 (gnus-sethash group (cons number nil) xref-hashtb)))))
9027 (and start xref-hashtb)))
9029 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9030 "Look through all the headers and mark the Xrefs as read."
9031 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9032 name entry info xref-hashtb idlist method nth4)
9034 (set-buffer gnus-group-buffer)
9035 (when (setq xref-hashtb
9036 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9039 (unless (string= from-newsgroup (setq name (symbol-name group)))
9040 (setq idlist (symbol-value group))
9041 ;; Dead groups are not updated.
9043 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9045 (if (stringp (setq nth4 (gnus-info-method info)))
9046 (setq nth4 (gnus-server-to-method nth4))))
9047 ;; Only do the xrefs if the group has the same
9048 ;; select method as the group we have just read.
9049 (or (gnus-methods-equal-p
9050 nth4 (gnus-find-method-for-group from-newsgroup))
9052 (equal nth4 (setq method (gnus-find-method-for-group
9054 (and (equal (car nth4) (car method))
9055 (equal (nth 1 nth4) (nth 1 method))))
9056 gnus-use-cross-reference
9057 (or (not (eq gnus-use-cross-reference t))
9059 ;; Only do cross-references on subscribed
9060 ;; groups, if that is what is wanted.
9061 (<= (gnus-info-level info) gnus-level-subscribed))
9062 (gnus-group-make-articles-read name idlist))))
9065 (defun gnus-group-make-articles-read (group articles)
9067 (entry (gnus-gethash group gnus-newsrc-hashtb))
9068 (info (nth 2 entry))
9069 (active (gnus-active group))
9071 ;; First peel off all illegal article numbers.
9073 (let ((ids articles)
9077 (if (and first (> id (cdr active)))
9079 ;; We'll end up in this situation in one particular
9080 ;; obscure situation. If you re-scan a group and get
9081 ;; a new article that is cross-posted to a different
9082 ;; group that has not been re-scanned, you might get
9083 ;; crossposted article that has a higher number than
9084 ;; Gnus believes possible. So we re-activate this
9085 ;; group as well. This might mean doing the
9086 ;; crossposting thingy will *increase* the number
9087 ;; of articles in some groups. Tsk, tsk.
9088 (setq active (or (gnus-activate-group group) active))))
9089 (if (or (> id (cdr active))
9090 (< id (car active)))
9091 (setq articles (delq id articles)))
9092 (setq ids (cdr ids)))))
9093 ;; If the read list is nil, we init it.
9095 (null (gnus-info-read info))
9097 (gnus-info-set-read info (cons 1 (1- (car active)))))
9098 ;; Then we add the read articles to the range.
9103 (gnus-info-read info) (setq articles (sort articles '<)))))
9104 ;; Then we have to re-compute how many unread
9105 ;; articles there are in this group.
9110 (setq num (- (1+ (cdr active)) (car active))))
9111 ((not (listp (cdr range)))
9112 (setq num (- (cdr active) (- (1+ (cdr range))
9116 (if (numberp (car range))
9118 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9119 (setq range (cdr range)))
9120 (setq num (- (cdr active) num))))
9121 ;; Update the number of unread articles.
9123 ;; Update the group buffer.
9124 (gnus-group-update-group group t)))))
9126 (defun gnus-methods-equal-p (m1 m2)
9127 (let ((m1 (or m1 gnus-select-method))
9128 (m2 (or m2 gnus-select-method)))
9130 (and (eq (car m1) (car m2))
9131 (or (not (memq 'address (assoc (symbol-name (car m1))
9132 gnus-valid-select-methods)))
9133 (equal (nth 1 m1) (nth 1 m2)))))))
9135 (defsubst gnus-header-value ()
9136 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9138 (defvar gnus-newsgroup-none-id 0)
9140 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9141 (let ((cur nntp-server-buffer)
9144 (save-excursion (set-buffer gnus-summary-buffer)
9145 gnus-newsgroup-dependencies)))
9146 headers id id-dep ref-dep end ref)
9148 (set-buffer nntp-server-buffer)
9149 (run-hooks 'gnus-parse-headers-hook)
9150 (let ((case-fold-search t)
9151 in-reply-to header p lines)
9152 (goto-char (point-min))
9153 ;; Search to the beginning of the next header. Error messages
9154 ;; do not begin with 2 or 3.
9155 (while (re-search-forward "^[23][0-9]+ " nil t)
9158 ;; This implementation of this function, with nine
9159 ;; search-forwards instead of the one re-search-forward and
9160 ;; a case (which basically was the old function) is actually
9161 ;; about twice as fast, even though it looks messier. You
9162 ;; can't have everything, I guess. Speed and elegance
9163 ;; doesn't always go hand in hand.
9172 (narrow-to-region (point)
9173 (or (and (search-forward "\n.\n" nil t)
9179 (if (search-forward "\nsubject: " nil t)
9180 (gnus-header-value) "(none)"))
9184 (if (search-forward "\nfrom: " nil t)
9185 (gnus-header-value) "(nobody)"))
9189 (if (search-forward "\ndate: " nil t)
9190 (gnus-header-value) ""))
9194 (if (search-forward "\nmessage-id: " nil t)
9195 (setq id (gnus-header-value))
9196 ;; If there was no message-id, we just fake one to make
9197 ;; subsequent routines simpler.
9198 (setq id (concat "none+"
9200 (setq gnus-newsgroup-none-id
9201 (1+ gnus-newsgroup-none-id)))))))
9205 (if (search-forward "\nreferences: " nil t)
9208 (setq end (match-end 0))
9214 (search-backward ">" end t)
9217 (search-backward "<" end t)
9219 ;; Get the references from the in-reply-to header if there
9220 ;; were no references and the in-reply-to header looks
9222 (if (and (search-forward "\nin-reply-to: " nil t)
9223 (setq in-reply-to (gnus-header-value))
9224 (string-match "<[^>]+>" in-reply-to))
9225 (setq ref (substring in-reply-to (match-beginning 0)
9233 (if (search-forward "\nlines: " nil t)
9234 (if (numberp (setq lines (read cur)))
9240 (and (search-forward "\nxref: " nil t)
9241 (gnus-header-value)))))
9242 ;; We do the threading while we read the headers. The
9243 ;; message-id and the last reference are both entered into
9244 ;; the same hash table. Some tippy-toeing around has to be
9245 ;; done in case an article has arrived before the article
9246 ;; which it refers to.
9247 (if (boundp (setq id-dep (intern id dependencies)))
9248 (if (and (car (symbol-value id-dep))
9250 ;; An article with this Message-ID has already
9251 ;; been seen, so we ignore this one, except we add
9252 ;; any additional Xrefs (in case the two articles
9253 ;; came from different servers).
9255 (mail-header-set-xref
9256 (car (symbol-value id-dep))
9257 (concat (or (mail-header-xref
9258 (car (symbol-value id-dep))) "")
9259 (or (mail-header-xref header) "")))
9261 (setcar (symbol-value id-dep) header))
9262 (set id-dep (list header)))
9264 (if (boundp (setq ref-dep (intern ref dependencies)))
9265 (setcdr (symbol-value ref-dep)
9266 (nconc (cdr (symbol-value ref-dep))
9267 (list (symbol-value id-dep))))
9268 (set ref-dep (list nil (symbol-value id-dep))))
9269 (setq headers (cons header headers)))
9270 (goto-char (point-max))
9272 (nreverse headers)))))
9274 ;; The following macros and functions were written by Felix Lee
9275 ;; <flee@cse.psu.edu>.
9277 (defmacro gnus-nov-read-integer ()
9279 (if (= (following-char) ?\t)
9281 (let ((num (condition-case nil (read buffer) (error nil))))
9282 (if (numberp num) num 0)))
9283 (or (eobp) (forward-char 1))))
9285 (defmacro gnus-nov-skip-field ()
9286 '(search-forward "\t" eol 'move))
9288 (defmacro gnus-nov-field ()
9289 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9291 ;; Goes through the xover lines and returns a list of vectors
9292 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9293 force-new dependencies)
9294 "Parse the news overview data in the server buffer, and return a
9295 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9296 ;; Get the Xref when the users reads the articles since most/some
9297 ;; NNTP servers do not include Xrefs when using XOVER.
9298 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9299 (let ((cur nntp-server-buffer)
9300 (dependencies (or dependencies gnus-newsgroup-dependencies))
9301 number headers header)
9303 (set-buffer nntp-server-buffer)
9304 ;; Allow the user to mangle the headers before parsing them.
9305 (run-hooks 'gnus-parse-headers-hook)
9306 (goto-char (point-min))
9307 (while (and sequence (not (eobp)))
9308 (setq number (read cur))
9309 (while (and sequence (< (car sequence) number))
9310 (setq sequence (cdr sequence)))
9312 (eq number (car sequence))
9314 (setq sequence (cdr sequence))
9316 (inline (gnus-nov-parse-line
9317 number dependencies force-new)))
9318 (setq headers (cons header headers)))))
9320 (setq headers (nreverse headers)))
9323 ;; This function has to be called with point after the article number
9324 ;; on the beginning of the line.
9325 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9327 (eol (gnus-point-at-eol))
9328 (buffer (current-buffer))
9329 header ref id id-dep ref-dep)
9331 ;; overview: [num subject from date id refs chars lines misc]
9332 (narrow-to-region (point) eol)
9333 (or (eobp) (forward-char))
9339 (gnus-nov-field) ; subject
9340 (gnus-nov-field) ; from
9341 (gnus-nov-field) ; date
9342 (setq id (or (gnus-nov-field)
9345 (setq none (1+ none)))))) ; id
9348 (let ((beg (point)))
9349 (search-forward "\t" eol)
9350 (if (search-backward ">" beg t)
9354 (search-backward "<" beg t)))
9356 (gnus-nov-field)) ; refs
9357 (gnus-nov-read-integer) ; chars
9358 (gnus-nov-read-integer) ; lines
9359 (if (= (following-char) ?\n)
9361 (gnus-nov-field)) ; misc
9364 (gnus-error 4 "Strange nov line")
9370 ;; We build the thread tree.
9372 (if (boundp (setq id-dep (intern id dependencies)))
9373 (if (and (car (symbol-value id-dep))
9375 ;; An article with this Message-ID has already been seen,
9376 ;; so we ignore this one, except we add any additional
9377 ;; Xrefs (in case the two articles came from different
9380 (mail-header-set-xref
9381 (car (symbol-value id-dep))
9382 (concat (or (mail-header-xref
9383 (car (symbol-value id-dep))) "")
9384 (or (mail-header-xref header) "")))
9386 (setcar (symbol-value id-dep) header))
9387 (set id-dep (list header))))
9390 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9391 (setcdr (symbol-value ref-dep)
9392 (nconc (cdr (symbol-value ref-dep))
9393 (list (symbol-value id-dep))))
9394 (set ref-dep (list nil (symbol-value id-dep))))))
9397 (defun gnus-article-get-xrefs ()
9398 "Fill in the Xref value in `gnus-current-headers', if necessary.
9399 This is meant to be called in `gnus-article-internal-prepare-hook'."
9400 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9401 gnus-current-headers)))
9402 (or (not gnus-use-cross-reference)
9404 (and (mail-header-xref headers)
9405 (not (string= (mail-header-xref headers) "")))
9406 (let ((case-fold-search t)
9409 (nnheader-narrow-to-headers)
9410 (goto-char (point-min))
9411 (if (or (and (eq (downcase (following-char)) ?x)
9412 (looking-at "Xref:"))
9413 (search-forward "\nXref:" nil t))
9415 (goto-char (1+ (match-end 0)))
9416 (setq xref (buffer-substring (point)
9417 (progn (end-of-line) (point))))
9418 (mail-header-set-xref headers xref))))))))
9420 (defun gnus-summary-insert-subject (id &optional old-header)
9421 "Find article ID and insert the summary line for that article."
9422 (let ((header (or old-header (gnus-read-header id)))
9423 (number (and (numberp id) id))
9426 ;; Rebuild the thread that this article is part of and go to the
9427 ;; article we have fetched.
9429 (when (setq pos (text-property-any
9430 (point-min) (point-max) 'gnus-number
9431 (mail-header-number old-header)))
9434 (gnus-data-remove (mail-header-number old-header))))
9436 (mail-header-set-number header (mail-header-number old-header)))
9437 (setq gnus-newsgroup-sparse
9438 (delq (setq number (mail-header-number header))
9439 gnus-newsgroup-sparse))
9440 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9441 (gnus-rebuild-thread (mail-header-id header))
9442 (gnus-summary-goto-subject number nil t))
9443 (when (and (numberp number)
9445 ;; We have to update the boundaries even if we can't fetch the
9446 ;; article if ID is a number -- so that the next `P' or `N'
9447 ;; command will fetch the previous (or next) article even
9448 ;; if the one we tried to fetch this time has been canceled.
9449 (and (> number gnus-newsgroup-end)
9450 (setq gnus-newsgroup-end number))
9451 (and (< number gnus-newsgroup-begin)
9452 (setq gnus-newsgroup-begin number))
9453 (setq gnus-newsgroup-unselected
9454 (delq number gnus-newsgroup-unselected)))
9455 ;; Report back a success?
9456 (and header (mail-header-number header))))
9458 (defun gnus-summary-work-articles (n)
9459 "Return a list of articles to be worked upon. The prefix argument,
9460 the list of process marked articles, and the current article will be
9461 taken into consideration."
9463 ((and n (numberp n))
9464 ;; A numerical prefix has been given.
9465 (let ((backward (< n 0))
9471 (push (setq article (gnus-summary-article-number))
9474 (gnus-summary-find-prev nil article)
9475 (gnus-summary-find-next nil article)))
9477 (nreverse articles)))
9478 ((and (boundp 'transient-mark-mode)
9481 ;; Work on the region between point and mark.
9482 (let ((max (max (point) (mark)))
9485 (goto-char (min (point) (mark)))
9488 (push (setq article (gnus-summary-article-number)) articles)
9489 (gnus-summary-find-next nil article)
9491 (nreverse articles))))
9492 (gnus-newsgroup-processable
9493 ;; There are process-marked articles present.
9494 (reverse gnus-newsgroup-processable))
9496 ;; Just return the current article.
9497 (list (gnus-summary-article-number)))))
9499 (defun gnus-summary-search-group (&optional backward use-level)
9500 "Search for next unread newsgroup.
9501 If optional argument BACKWARD is non-nil, search backward instead."
9503 (set-buffer gnus-group-buffer)
9504 (if (gnus-group-search-forward
9505 backward nil (if use-level (gnus-group-group-level) nil))
9506 (gnus-group-group-name))))
9508 (defun gnus-summary-best-group (&optional exclude-group)
9509 "Find the name of the best unread group.
9510 If EXCLUDE-GROUP, do not go to this group."
9512 (set-buffer gnus-group-buffer)
9514 (gnus-group-best-unread-group exclude-group))))
9516 (defun gnus-summary-find-next (&optional unread article backward)
9517 (if backward (gnus-summary-find-prev)
9518 (let* ((dummy (gnus-summary-article-intangible-p))
9519 (article (or article (gnus-summary-article-number)))
9520 (arts (gnus-data-find-list article))
9522 (when (and (not dummy)
9523 (or (not gnus-summary-check-current)
9525 (not (gnus-data-unread-p (car arts)))))
9526 (setq arts (cdr arts)))
9531 (when (gnus-data-unread-p (car arts))
9532 (setq result (car arts)
9534 (setq arts (cdr arts)))
9537 (goto-char (gnus-data-pos result))
9538 (gnus-data-number result)))))
9540 (defun gnus-summary-find-prev (&optional unread article)
9541 (let* ((eobp (eobp))
9542 (article (or article (gnus-summary-article-number)))
9543 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9545 (when (and (not eobp)
9546 (or (not gnus-summary-check-current)
9548 (not (gnus-data-unread-p (car arts)))))
9549 (setq arts (cdr arts)))
9554 (and (gnus-data-unread-p (car arts))
9555 (setq result (car arts)
9557 (setq arts (cdr arts)))
9561 (goto-char (gnus-data-pos result))
9562 (gnus-data-number result)))))
9564 (defun gnus-summary-find-subject (subject &optional unread backward article)
9565 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9566 (article (or article (gnus-summary-article-number)))
9567 (articles (gnus-data-list backward))
9568 (arts (gnus-data-find-list article articles))
9570 (when (or (not gnus-summary-check-current)
9572 (not (gnus-data-unread-p (car arts))))
9573 (setq arts (cdr arts)))
9575 (and (or (not unread)
9576 (gnus-data-unread-p (car arts)))
9577 (vectorp (gnus-data-header (car arts)))
9579 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9580 (setq result (car arts)
9582 (setq arts (cdr arts)))
9584 (goto-char (gnus-data-pos result))
9585 (gnus-data-number result))))
9587 (defun gnus-summary-search-forward (&optional unread subject backward)
9588 "Search forward for an article.
9589 If UNREAD, look for unread articles. If SUBJECT, look for
9590 articles with that subject. If BACKWARD, search backward instead."
9591 (cond (subject (gnus-summary-find-subject subject unread backward))
9592 (backward (gnus-summary-find-prev unread))
9593 (t (gnus-summary-find-next unread))))
9595 (defun gnus-recenter (&optional n)
9596 "Center point in window and redisplay frame.
9597 Also do horizontal recentering."
9599 (when (and gnus-auto-center-summary
9600 (not (eq gnus-auto-center-summary 'vertical)))
9601 (gnus-horizontal-recenter))
9604 (defun gnus-summary-recenter ()
9605 "Center point in the summary window.
9606 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9607 displayed, no centering will be performed."
9608 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9609 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9610 (let* ((top (cond ((< (window-height) 4) 0)
9611 ((< (window-height) 7) 1)
9613 (height (1- (window-height)))
9614 (bottom (save-excursion (goto-char (point-max))
9615 (forward-line (- height))
9617 (window (get-buffer-window (current-buffer))))
9618 ;; The user has to want it.
9619 (when gnus-auto-center-summary
9620 (when (get-buffer-window gnus-article-buffer)
9621 ;; Only do recentering when the article buffer is displayed,
9622 ;; Set the window start to either `bottom', which is the biggest
9623 ;; possible valid number, or the second line from the top,
9624 ;; whichever is the least.
9626 window (min bottom (save-excursion
9627 (forward-line (- top)) (point)))))
9628 ;; Do horizontal recentering while we're at it.
9629 (when (and (get-buffer-window (current-buffer) t)
9630 (not (eq gnus-auto-center-summary 'vertical)))
9631 (let ((selected (selected-window)))
9632 (select-window (get-buffer-window (current-buffer) t))
9633 (gnus-summary-position-point)
9634 (gnus-horizontal-recenter)
9635 (select-window selected))))))
9637 (defun gnus-horizontal-recenter ()
9638 "Recenter the current buffer horizontally."
9639 (if (< (current-column) (/ (window-width) 2))
9640 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9641 (let* ((orig (point))
9642 (end (window-end (get-buffer-window (current-buffer) t)))
9644 ;; Find the longest line currently displayed in the window.
9645 (goto-char (window-start))
9646 (while (and (not (eobp))
9649 (setq max (max max (current-column)))
9652 ;; Scroll horizontally to center (sort of) the point.
9653 (if (> max (window-width))
9655 (get-buffer-window (current-buffer) t)
9656 (min (- (current-column) (/ (window-width) 3))
9657 (+ 2 (- max (window-width)))))
9658 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9661 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9662 (defun gnus-short-group-name (group &optional levels)
9663 "Collapse GROUP name LEVELS."
9670 (while (string-match "\\." group skip)
9671 (setq skip (match-end 0)
9674 (if (string-match ":" group)
9675 (setq foreign (substring group 0 (match-end 0))
9676 group (substring group (match-end 0))))
9678 (if (and (string-match "\\." group)
9679 (> levels (- gnus-group-uncollapsed-levels 1)))
9680 (setq name (concat name (substring group 0 1))
9681 group (substring group (match-end 0))
9683 name (concat name "."))
9684 (setq name (concat foreign name group)
9688 (defun gnus-summary-jump-to-group (newsgroup)
9689 "Move point to NEWSGROUP in group mode buffer."
9690 ;; Keep update point of group mode buffer if visible.
9691 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9692 (save-window-excursion
9693 ;; Take care of tree window mode.
9694 (if (get-buffer-window gnus-group-buffer)
9695 (pop-to-buffer gnus-group-buffer))
9696 (gnus-group-jump-to-group newsgroup))
9698 ;; Take care of tree window mode.
9699 (if (get-buffer-window gnus-group-buffer)
9700 (pop-to-buffer gnus-group-buffer)
9701 (set-buffer gnus-group-buffer))
9702 (gnus-group-jump-to-group newsgroup))))
9704 ;; This function returns a list of article numbers based on the
9705 ;; difference between the ranges of read articles in this group and
9706 ;; the range of active articles.
9707 (defun gnus-list-of-unread-articles (group)
9708 (let* ((read (gnus-info-read (gnus-get-info group)))
9709 (active (gnus-active group))
9712 ;; If none are read, then all are unread.
9714 (setq first (car active))
9715 ;; If the range of read articles is a single range, then the
9716 ;; first unread article is the article after the last read
9717 ;; article. Sounds logical, doesn't it?
9718 (if (not (listp (cdr read)))
9719 (setq first (1+ (cdr read)))
9720 ;; `read' is a list of ranges.
9721 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9726 (while (< first nlast)
9727 (setq unread (cons first unread))
9728 (setq first (1+ first))))
9729 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9730 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9731 (setq read (cdr read)))))
9732 ;; And add the last unread articles.
9733 (while (<= first last)
9734 (setq unread (cons first unread))
9735 (setq first (1+ first)))
9736 ;; Return the list of unread articles.
9739 (defun gnus-list-of-read-articles (group)
9740 "Return a list of unread, unticked and non-dormant articles."
9741 (let* ((info (gnus-get-info group))
9742 (marked (gnus-info-marks info))
9743 (active (gnus-active group)))
9745 (gnus-set-difference
9746 (gnus-sorted-complement
9747 (gnus-uncompress-range active)
9748 (gnus-list-of-unread-articles group))
9750 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9751 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9753 ;; Various summary commands
9755 (defun gnus-summary-universal-argument (arg)
9756 "Perform any operation on all articles that are process/prefixed."
9758 (gnus-set-global-variables)
9759 (let ((articles (gnus-summary-work-articles arg))
9766 (substitute-command-keys
9767 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9770 (gnus-error 1 "Undefined key")
9773 (gnus-summary-goto-subject (setq article (pop articles)))
9774 (command-execute func)
9775 (gnus-summary-remove-process-mark article)))))
9776 (gnus-summary-position-point))
9778 (defun gnus-summary-toggle-truncation (&optional arg)
9779 "Toggle truncation of summary lines.
9780 With arg, turn line truncation on iff arg is positive."
9782 (setq truncate-lines
9783 (if (null arg) (not truncate-lines)
9784 (> (prefix-numeric-value arg) 0)))
9787 (defun gnus-summary-reselect-current-group (&optional all rescan)
9788 "Exit and then reselect the current newsgroup.
9789 The prefix argument ALL means to select all articles."
9791 (gnus-set-global-variables)
9792 (let ((current-subject (gnus-summary-article-number))
9793 (group gnus-newsgroup-name))
9794 (setq gnus-newsgroup-begin nil)
9796 ;; We have to adjust the point of group mode buffer because the
9797 ;; current point was moved to the next unread newsgroup by
9799 (gnus-summary-jump-to-group group)
9802 (gnus-group-get-new-news-this-group 1)))
9803 (gnus-group-read-group all t)
9804 (gnus-summary-goto-subject current-subject)))
9806 (defun gnus-summary-rescan-group (&optional all)
9807 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9809 (gnus-summary-reselect-current-group all t))
9811 (defun gnus-summary-update-info ()
9812 (let* ((group gnus-newsgroup-name))
9813 (when gnus-newsgroup-kill-headers
9814 (setq gnus-newsgroup-killed
9815 (gnus-compress-sequence
9817 (gnus-set-sorted-intersection
9818 (gnus-uncompress-range gnus-newsgroup-killed)
9819 (setq gnus-newsgroup-unselected
9820 (sort gnus-newsgroup-unselected '<)))
9821 (setq gnus-newsgroup-unreads
9822 (sort gnus-newsgroup-unreads '<))) t)))
9823 (unless (listp (cdr gnus-newsgroup-killed))
9824 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9825 (let ((headers gnus-newsgroup-headers))
9826 (run-hooks 'gnus-exit-group-hook)
9827 (unless gnus-save-score
9828 (setq gnus-newsgroup-scored nil))
9829 ;; Set the new ranges of read articles.
9830 (gnus-update-read-articles
9831 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9832 ;; Set the current article marks.
9834 ;; Do the cross-ref thing.
9835 (when gnus-use-cross-reference
9836 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9837 ;; Do adaptive scoring, and possibly save score files.
9838 (when gnus-newsgroup-adaptive
9839 (gnus-score-adaptive))
9840 (when gnus-use-scoring
9842 ;; Do not switch windows but change the buffer to work.
9843 (set-buffer gnus-group-buffer)
9844 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9845 (gnus-group-update-group group)))))
9847 (defun gnus-summary-exit (&optional temporary)
9848 "Exit reading current newsgroup, and then return to group selection mode.
9849 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9851 (gnus-set-global-variables)
9852 (gnus-kill-save-kill-buffer)
9853 (let* ((group gnus-newsgroup-name)
9854 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9856 (buf (current-buffer)))
9857 (run-hooks 'gnus-summary-prepare-exit-hook)
9858 ;; If we have several article buffers, we kill them at exit.
9859 (unless gnus-single-article-buffer
9860 (gnus-kill-buffer gnus-original-article-buffer)
9861 (setq gnus-article-current nil))
9862 (when gnus-use-cache
9863 (gnus-cache-possibly-remove-articles)
9864 (gnus-cache-save-buffers))
9865 (when gnus-use-trees
9866 (gnus-tree-close group))
9867 ;; Make all changes in this group permanent.
9869 (gnus-summary-update-info))
9870 (gnus-close-group group)
9871 ;; Make sure where I was, and go to next newsgroup.
9872 (set-buffer gnus-group-buffer)
9874 (gnus-group-jump-to-group group))
9875 (run-hooks 'gnus-summary-exit-hook)
9877 (gnus-group-next-unread-group 1))
9880 ;; If we have several article buffers, we kill them at exit.
9881 (unless gnus-single-article-buffer
9882 (gnus-kill-buffer gnus-article-buffer)
9883 (gnus-kill-buffer gnus-original-article-buffer)
9884 (setq gnus-article-current nil))
9886 (if (not gnus-kill-summary-on-exit)
9887 (gnus-deaden-summary)
9888 ;; We set all buffer-local variables to nil. It is unclear why
9889 ;; this is needed, but if we don't, buffer-local variables are
9890 ;; not garbage-collected, it seems. This would the lead to en
9891 ;; ever-growing Emacs.
9892 (gnus-summary-clear-local-variables)
9893 (when (get-buffer gnus-article-buffer)
9894 (bury-buffer gnus-article-buffer))
9895 ;; We clear the global counterparts of the buffer-local
9896 ;; variables as well, just to be on the safe side.
9897 (gnus-configure-windows 'group 'force)
9898 (gnus-summary-clear-local-variables)
9899 ;; Return to group mode buffer.
9900 (if (eq mode 'gnus-summary-mode)
9901 (gnus-kill-buffer buf)))
9902 (setq gnus-current-select-method gnus-select-method)
9903 (pop-to-buffer gnus-group-buffer)
9904 ;; Clear the current group name.
9905 (if (not quit-config)
9907 (gnus-group-jump-to-group group)
9908 (gnus-group-next-unread-group 1)
9909 (gnus-configure-windows 'group 'force))
9910 (if (not (buffer-name (car quit-config)))
9911 (gnus-configure-windows 'group 'force)
9912 (set-buffer (car quit-config))
9913 (and (eq major-mode 'gnus-summary-mode)
9914 (gnus-set-global-variables))
9915 (gnus-configure-windows (cdr quit-config))))
9917 (setq gnus-newsgroup-name nil)))))
9919 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9920 (defun gnus-summary-exit-no-update (&optional no-questions)
9921 "Quit reading current newsgroup without updating read article info."
9923 (gnus-set-global-variables)
9924 (let* ((group gnus-newsgroup-name)
9925 (quit-config (gnus-group-quit-config group)))
9926 (when (or no-questions
9928 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9929 ;; If we have several article buffers, we kill them at exit.
9930 (unless gnus-single-article-buffer
9931 (gnus-kill-buffer gnus-article-buffer)
9932 (gnus-kill-buffer gnus-original-article-buffer)
9933 (setq gnus-article-current nil))
9934 (if (not gnus-kill-summary-on-exit)
9935 (gnus-deaden-summary)
9936 (gnus-close-group group)
9937 (gnus-summary-clear-local-variables)
9938 (set-buffer gnus-group-buffer)
9939 (gnus-summary-clear-local-variables)
9940 (when (get-buffer gnus-summary-buffer)
9941 (kill-buffer gnus-summary-buffer)))
9942 (unless gnus-single-article-buffer
9943 (setq gnus-article-current nil))
9944 (when gnus-use-trees
9945 (gnus-tree-close group))
9946 (when (get-buffer gnus-article-buffer)
9947 (bury-buffer gnus-article-buffer))
9948 ;; Return to the group buffer.
9949 (gnus-configure-windows 'group 'force)
9950 ;; Clear the current group name.
9951 (setq gnus-newsgroup-name nil)
9952 (when (equal (gnus-group-group-name) group)
9953 (gnus-group-next-unread-group 1))
9955 (if (not (buffer-name (car quit-config)))
9956 (gnus-configure-windows 'group 'force)
9957 (set-buffer (car quit-config))
9958 (when (eq major-mode 'gnus-summary-mode)
9959 (gnus-set-global-variables))
9960 (gnus-configure-windows (cdr quit-config)))))))
9964 (defvar gnus-dead-summary-mode-map nil)
9966 (if gnus-dead-summary-mode-map
9968 (setq gnus-dead-summary-mode-map (make-keymap))
9969 (suppress-keymap gnus-dead-summary-mode-map)
9970 (substitute-key-definition
9971 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9972 (let ((keys '("\C-d" "\r" "\177")))
9974 (define-key gnus-dead-summary-mode-map
9975 (pop keys) 'gnus-summary-wake-up-the-dead))))
9977 (defvar gnus-dead-summary-mode nil
9978 "Minor mode for Gnus summary buffers.")
9980 (defun gnus-dead-summary-mode (&optional arg)
9981 "Minor mode for Gnus summary buffers."
9983 (when (eq major-mode 'gnus-summary-mode)
9984 (make-local-variable 'gnus-dead-summary-mode)
9985 (setq gnus-dead-summary-mode
9986 (if (null arg) (not gnus-dead-summary-mode)
9987 (> (prefix-numeric-value arg) 0)))
9988 (when gnus-dead-summary-mode
9989 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9990 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9991 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9992 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9993 minor-mode-map-alist)))))
9995 (defun gnus-deaden-summary ()
9996 "Make the current summary buffer into a dead summary buffer."
9997 ;; Kill any previous dead summary buffer.
9998 (when (and gnus-dead-summary
9999 (buffer-name gnus-dead-summary))
10001 (set-buffer gnus-dead-summary)
10002 (when gnus-dead-summary-mode
10003 (kill-buffer (current-buffer)))))
10004 ;; Make this the current dead summary.
10005 (setq gnus-dead-summary (current-buffer))
10006 (gnus-dead-summary-mode 1)
10007 (let ((name (buffer-name)))
10008 (when (string-match "Summary" name)
10010 (concat (substring name 0 (match-beginning 0)) "Dead "
10011 (substring name (match-beginning 0))) t))))
10013 (defun gnus-kill-or-deaden-summary (buffer)
10014 "Kill or deaden the summary BUFFER."
10015 (when (and (buffer-name buffer)
10016 (not gnus-single-article-buffer))
10018 (set-buffer buffer)
10019 (gnus-kill-buffer gnus-article-buffer)
10020 (gnus-kill-buffer gnus-original-article-buffer)))
10021 (cond (gnus-kill-summary-on-exit
10022 (when (and gnus-use-trees
10023 (and (get-buffer buffer)
10024 (buffer-name (get-buffer buffer))))
10026 (set-buffer (get-buffer buffer))
10027 (gnus-tree-close gnus-newsgroup-name)))
10028 (gnus-kill-buffer buffer))
10029 ((and (get-buffer buffer)
10030 (buffer-name (get-buffer buffer)))
10032 (set-buffer buffer)
10033 (gnus-deaden-summary)))))
10035 (defun gnus-summary-wake-up-the-dead (&rest args)
10036 "Wake up the dead summary buffer."
10038 (gnus-dead-summary-mode -1)
10039 (let ((name (buffer-name)))
10040 (when (string-match "Dead " name)
10042 (concat (substring name 0 (match-beginning 0))
10043 (substring name (match-end 0))) t)))
10044 (gnus-message 3 "This dead summary is now alive again"))
10046 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10047 (defun gnus-summary-fetch-faq (&optional faq-dir)
10048 "Fetch the FAQ for the current group.
10049 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10053 (if current-prefix-arg
10055 "Faq dir: " (and (listp gnus-group-faq-directory)
10056 gnus-group-faq-directory)))))
10057 (let (gnus-faq-buffer)
10058 (and (setq gnus-faq-buffer
10059 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10060 (gnus-configure-windows 'summary-faq))))
10062 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10063 (defun gnus-summary-describe-group (&optional force)
10064 "Describe the current newsgroup."
10066 (gnus-group-describe-group force gnus-newsgroup-name))
10068 (defun gnus-summary-describe-briefly ()
10069 "Describe summary mode commands briefly."
10072 (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")))
10074 ;; Walking around group mode buffer from summary mode.
10076 (defun gnus-summary-next-group (&optional no-article target-group backward)
10077 "Exit current newsgroup and then select next unread newsgroup.
10078 If prefix argument NO-ARTICLE is non-nil, no article is selected
10079 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10080 previous group instead."
10082 (gnus-set-global-variables)
10083 (let ((current-group gnus-newsgroup-name)
10084 (current-buffer (current-buffer))
10086 ;; First we semi-exit this group to update Xrefs and all variables.
10087 ;; We can't do a real exit, because the window conf must remain
10088 ;; the same in case the user is prompted for info, and we don't
10089 ;; want the window conf to change before that...
10090 (gnus-summary-exit t)
10091 (while (not entered)
10092 ;; Then we find what group we are supposed to enter.
10093 (set-buffer gnus-group-buffer)
10094 (gnus-group-jump-to-group current-group)
10097 (if (eq gnus-keep-same-level 'best)
10098 (gnus-summary-best-group gnus-newsgroup-name)
10099 (gnus-summary-search-group backward gnus-keep-same-level))))
10100 (if (not target-group)
10101 ;; There are no further groups, so we return to the group
10104 (gnus-message 5 "Returning to the group buffer")
10106 (set-buffer current-buffer)
10107 (gnus-summary-exit))
10108 ;; We try to enter the target group.
10109 (gnus-group-jump-to-group target-group)
10110 (let ((unreads (gnus-group-group-unread)))
10111 (if (and (or (eq t unreads)
10112 (and unreads (not (zerop unreads))))
10113 (gnus-summary-read-group
10114 target-group nil no-article current-buffer))
10116 (setq current-group target-group
10117 target-group nil)))))))
10119 (defun gnus-summary-prev-group (&optional no-article)
10120 "Exit current newsgroup and then select previous unread newsgroup.
10121 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10123 (gnus-summary-next-group no-article nil t))
10125 ;; Walking around summary lines.
10127 (defun gnus-summary-first-subject (&optional unread)
10128 "Go to the first unread subject.
10129 If UNREAD is non-nil, go to the first unread article.
10130 Returns the article selected or nil if there are no unread articles."
10135 ((null gnus-newsgroup-data)
10136 (gnus-message 3 "No articles in the group")
10138 ;; Pick the first article.
10140 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10141 (gnus-data-number (car gnus-newsgroup-data)))
10142 ;; No unread articles.
10143 ((null gnus-newsgroup-unreads)
10144 (gnus-message 3 "No more unread articles")
10146 ;; Find the first unread article.
10148 (let ((data gnus-newsgroup-data))
10150 (not (gnus-data-unread-p (car data))))
10151 (setq data (cdr data)))
10154 (goto-char (gnus-data-pos (car data)))
10155 (gnus-data-number (car data)))))))
10156 (gnus-summary-position-point)))
10158 (defun gnus-summary-next-subject (n &optional unread dont-display)
10159 "Go to next N'th summary line.
10160 If N is negative, go to the previous N'th subject line.
10161 If UNREAD is non-nil, only unread articles are selected.
10162 The difference between N and the actual number of steps taken is
10165 (let ((backward (< n 0))
10167 (while (and (> n 0)
10169 (gnus-summary-find-prev unread)
10170 (gnus-summary-find-next unread)))
10172 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10173 (if unread " unread" "")))
10174 (unless dont-display
10175 (gnus-summary-recenter)
10176 (gnus-summary-position-point))
10179 (defun gnus-summary-next-unread-subject (n)
10180 "Go to next N'th unread summary line."
10182 (gnus-summary-next-subject n t))
10184 (defun gnus-summary-prev-subject (n &optional unread)
10185 "Go to previous N'th summary line.
10186 If optional argument UNREAD is non-nil, only unread article is selected."
10188 (gnus-summary-next-subject (- n) unread))
10190 (defun gnus-summary-prev-unread-subject (n)
10191 "Go to previous N'th unread summary line."
10193 (gnus-summary-next-subject (- n) t))
10195 (defun gnus-summary-goto-subject (article &optional force silent)
10196 "Go the subject line of ARTICLE.
10197 If FORCE, also allow jumping to articles not currently shown."
10199 (data (gnus-data-find article)))
10200 ;; We read in the article if we have to.
10203 (gnus-summary-insert-subject article (and (vectorp force) force))
10204 (setq data (gnus-data-find article)))
10209 (gnus-message 3 "Can't find article %d" article))
10211 (goto-char (gnus-data-pos data))
10214 ;; Walking around summary lines with displaying articles.
10216 (defun gnus-summary-expand-window (&optional arg)
10217 "Make the summary buffer take up the entire Emacs frame.
10218 Given a prefix, will force an `article' buffer configuration."
10220 (gnus-set-global-variables)
10222 (gnus-configure-windows 'article 'force)
10223 (gnus-configure-windows 'summary 'force)))
10225 (defun gnus-summary-display-article (article &optional all-header)
10226 "Display ARTICLE in article buffer."
10227 (gnus-set-global-variables)
10231 (if gnus-summary-display-article-function
10232 (funcall gnus-summary-display-article-function article all-header)
10233 (gnus-article-prepare article all-header))
10234 (run-hooks 'gnus-select-article-hook)
10235 (unless (zerop gnus-current-article)
10236 (gnus-summary-goto-subject gnus-current-article))
10237 (gnus-summary-recenter)
10238 (when gnus-use-trees
10239 (gnus-possibly-generate-tree article)
10240 (gnus-highlight-selected-tree article))
10241 ;; Successfully display article.
10242 (gnus-article-set-window-start
10243 (cdr (assq article gnus-newsgroup-bookmarks))))))
10245 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10246 "Select the current article.
10247 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10248 non-nil, the article will be re-fetched even if it already present in
10249 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10251 ;; Make sure we are in the summary buffer to work around bbdb bug.
10252 (unless (eq major-mode 'gnus-summary-mode)
10253 (set-buffer gnus-summary-buffer))
10254 (let ((article (or article (gnus-summary-article-number)))
10255 (all-headers (not (not all-headers))) ;Must be T or NIL.
10256 gnus-summary-display-article-function
10259 (gnus-summary-article-pseudo-p article)
10260 (error "This is a pseudo-article."))
10263 (set-buffer gnus-summary-buffer)
10264 (if (or (and gnus-single-article-buffer
10265 (or (null gnus-current-article)
10266 (null gnus-article-current)
10267 (null (get-buffer gnus-article-buffer))
10268 (not (eq article (cdr gnus-article-current)))
10269 (not (equal (car gnus-article-current)
10270 gnus-newsgroup-name))))
10271 (and (not gnus-single-article-buffer)
10272 (or (null gnus-current-article)
10273 (not (eq gnus-current-article article))))
10275 ;; The requested article is different from the current article.
10277 (gnus-summary-display-article article all-headers)
10278 (setq did article))
10279 (if (or all-headers gnus-show-all-headers)
10280 (gnus-article-show-all-headers))
10283 (gnus-article-set-window-start
10284 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10286 (defun gnus-summary-set-current-mark (&optional current-mark)
10287 "Obsolete function."
10290 (defun gnus-summary-next-article (&optional unread subject backward push)
10291 "Select the next article.
10292 If UNREAD, only unread articles are selected.
10293 If SUBJECT, only articles with SUBJECT are selected.
10294 If BACKWARD, the previous article is selected instead of the next."
10296 (gnus-set-global-variables)
10298 ;; Is there such an article?
10299 ((and (gnus-summary-search-forward unread subject backward)
10300 (or (gnus-summary-display-article (gnus-summary-article-number))
10301 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10302 (gnus-summary-position-point))
10303 ;; If not, we try the first unread, if that is wanted.
10305 gnus-auto-select-same
10306 (or (gnus-summary-first-unread-article)
10307 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10308 (gnus-summary-position-point)
10309 (gnus-message 6 "Wrapped"))
10310 ;; Try to get next/previous article not displayed in this group.
10311 ((and gnus-auto-extend-newsgroup
10312 (not unread) (not subject))
10313 (gnus-summary-goto-article
10314 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10316 ;; Go to next/previous group.
10318 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10319 (gnus-summary-jump-to-group gnus-newsgroup-name))
10320 (let ((cmd last-command-char)
10322 (if (eq gnus-keep-same-level 'best)
10323 (gnus-summary-best-group gnus-newsgroup-name)
10324 (gnus-summary-search-group backward gnus-keep-same-level))))
10325 ;; For some reason, the group window gets selected. We change
10327 (select-window (get-buffer-window (current-buffer)))
10328 ;; Select next unread newsgroup automagically.
10330 ((not gnus-auto-select-next)
10331 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10332 ((or (eq gnus-auto-select-next 'quietly)
10333 (and (eq gnus-auto-select-next 'slightly-quietly)
10335 (and (eq gnus-auto-select-next 'almost-quietly)
10336 (gnus-summary-last-article-p)))
10338 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10339 (gnus-summary-exit)
10340 (gnus-message 7 "No more%s articles (%s)..."
10341 (if unread " unread" "")
10342 (if group (concat "selecting " group)
10344 (gnus-summary-next-group nil group backward)))
10346 (gnus-summary-walk-group-buffer
10347 gnus-newsgroup-name cmd unread backward)))))))
10349 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10350 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10351 (?\C-p (gnus-group-prev-unread-group 1))))
10352 keve key group ended)
10354 (set-buffer gnus-group-buffer)
10355 (gnus-summary-jump-to-group from-group)
10357 (if (eq gnus-keep-same-level 'best)
10358 (gnus-summary-best-group gnus-newsgroup-name)
10359 (gnus-summary-search-group backward gnus-keep-same-level))))
10362 5 "No more%s articles%s" (if unread " unread" "")
10364 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10365 (format " (Type %s for %s [%s])"
10366 (single-key-description cmd) group
10367 (car (gnus-gethash group gnus-newsrc-hashtb)))
10368 (format " (Type %s to exit %s)"
10369 (single-key-description cmd)
10370 gnus-newsgroup-name)))
10371 ;; Confirm auto selection.
10372 (setq key (car (setq keve (gnus-read-event-char))))
10375 ((assq key keystrokes)
10376 (let ((obuf (current-buffer)))
10377 (switch-to-buffer gnus-group-buffer)
10379 (gnus-group-jump-to-group group))
10380 (eval (cadr (assq key keystrokes)))
10381 (setq group (gnus-group-group-name))
10382 (switch-to-buffer obuf))
10385 (if (or (not group)
10386 (gnus-ephemeral-group-p gnus-newsgroup-name))
10387 (gnus-summary-exit)
10388 (gnus-summary-next-group nil group backward)))
10390 (push (cdr keve) unread-command-events))))))
10392 (defun gnus-read-event-char ()
10393 "Get the next event."
10394 (let ((event (read-event)))
10395 (cons (and (numberp event) event) event)))
10397 (defun gnus-summary-next-unread-article ()
10398 "Select unread article after current one."
10400 (gnus-summary-next-article t (and gnus-auto-select-same
10401 (gnus-summary-article-subject))))
10403 (defun gnus-summary-prev-article (&optional unread subject)
10404 "Select the article after the current one.
10405 If UNREAD is non-nil, only unread articles are selected."
10407 (gnus-summary-next-article unread subject t))
10409 (defun gnus-summary-prev-unread-article ()
10410 "Select unred article before current one."
10412 (gnus-summary-prev-article t (and gnus-auto-select-same
10413 (gnus-summary-article-subject))))
10415 (defun gnus-summary-next-page (&optional lines circular)
10416 "Show next page of the selected article.
10417 If at the end of the current article, select the next article.
10418 LINES says how many lines should be scrolled up.
10420 If CIRCULAR is non-nil, go to the start of the article instead of
10421 selecting the next article when reaching the end of the current
10424 (setq gnus-summary-buffer (current-buffer))
10425 (gnus-set-global-variables)
10426 (let ((article (gnus-summary-article-number))
10428 (gnus-configure-windows 'article)
10429 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10430 (if (and (eq gnus-summary-goto-unread 'never)
10431 (not (gnus-summary-last-article-p article)))
10432 (gnus-summary-next-article)
10433 (gnus-summary-next-unread-article))
10434 (if (or (null gnus-current-article)
10435 (null gnus-article-current)
10436 (/= article (cdr gnus-article-current))
10437 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10438 ;; Selected subject is different from current article's.
10439 (gnus-summary-display-article article)
10440 (gnus-eval-in-buffer-window
10441 gnus-article-buffer
10442 (setq endp (gnus-article-next-page lines)))
10445 (gnus-summary-beginning-of-article))
10447 (gnus-message 3 "End of message"))
10449 (if (and (eq gnus-summary-goto-unread 'never)
10450 (not (gnus-summary-last-article-p article)))
10451 (gnus-summary-next-article)
10452 (gnus-summary-next-unread-article)))))))
10453 (gnus-summary-recenter)
10454 (gnus-summary-position-point)))
10456 (defun gnus-summary-prev-page (&optional lines)
10457 "Show previous page of selected article.
10458 Argument LINES specifies lines to be scrolled down."
10460 (gnus-set-global-variables)
10461 (let ((article (gnus-summary-article-number)))
10462 (gnus-configure-windows 'article)
10463 (if (or (null gnus-current-article)
10464 (null gnus-article-current)
10465 (/= article (cdr gnus-article-current))
10466 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10467 ;; Selected subject is different from current article's.
10468 (gnus-summary-display-article article)
10469 (gnus-summary-recenter)
10470 (gnus-eval-in-buffer-window gnus-article-buffer
10471 (gnus-article-prev-page lines))))
10472 (gnus-summary-position-point))
10474 (defun gnus-summary-scroll-up (lines)
10475 "Scroll up (or down) one line current article.
10476 Argument LINES specifies lines to be scrolled up (or down if negative)."
10478 (gnus-set-global-variables)
10479 (gnus-configure-windows 'article)
10480 (gnus-summary-show-thread)
10481 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10482 (gnus-eval-in-buffer-window
10483 gnus-article-buffer
10485 (if (gnus-article-next-page lines)
10486 (gnus-message 3 "End of message")))
10488 (gnus-article-prev-page (- lines))))))
10489 (gnus-summary-recenter)
10490 (gnus-summary-position-point))
10492 (defun gnus-summary-next-same-subject ()
10493 "Select next article which has the same subject as current one."
10495 (gnus-set-global-variables)
10496 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10498 (defun gnus-summary-prev-same-subject ()
10499 "Select previous article which has the same subject as current one."
10501 (gnus-set-global-variables)
10502 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10504 (defun gnus-summary-next-unread-same-subject ()
10505 "Select next unread article which has the same subject as current one."
10507 (gnus-set-global-variables)
10508 (gnus-summary-next-article t (gnus-summary-article-subject)))
10510 (defun gnus-summary-prev-unread-same-subject ()
10511 "Select previous unread article which has the same subject as current one."
10513 (gnus-set-global-variables)
10514 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10516 (defun gnus-summary-first-unread-article ()
10517 "Select the first unread article.
10518 Return nil if there are no unread articles."
10520 (gnus-set-global-variables)
10522 (if (gnus-summary-first-subject t)
10524 (gnus-summary-show-thread)
10525 (gnus-summary-first-subject t)
10526 (gnus-summary-display-article (gnus-summary-article-number))))
10527 (gnus-summary-position-point)))
10529 (defun gnus-summary-best-unread-article ()
10530 "Select the unread article with the highest score."
10532 (gnus-set-global-variables)
10533 (let ((best -1000000)
10534 (data gnus-newsgroup-data)
10537 (and (gnus-data-unread-p (car data))
10539 (gnus-summary-article-score (gnus-data-number (car data))))
10542 article (gnus-data-number (car data))))
10543 (setq data (cdr data)))
10546 (gnus-summary-goto-article article)
10547 (error "No unread articles"))
10548 (gnus-summary-position-point))))
10550 (defun gnus-summary-last-subject ()
10551 "Go to the last displayed subject line in the group."
10552 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10554 (gnus-summary-goto-subject article))))
10556 (defun gnus-summary-goto-article (article &optional all-headers force)
10557 "Fetch ARTICLE and display it if it exists.
10558 If ALL-HEADERS is non-nil, no header lines are hidden."
10564 (mapcar (lambda (number) (list (int-to-string number)))
10565 gnus-newsgroup-limit)))
10569 (if (gnus-summary-goto-subject article force)
10570 (gnus-summary-display-article article all-headers)
10571 (gnus-message 4 "Couldn't go to article %s" article) nil)
10572 (gnus-summary-position-point)))
10574 (defun gnus-summary-goto-last-article ()
10575 "Go to the previously read article."
10578 (and gnus-last-article
10579 (gnus-summary-goto-article gnus-last-article))
10580 (gnus-summary-position-point)))
10582 (defun gnus-summary-pop-article (number)
10583 "Pop one article off the history and go to the previous.
10584 NUMBER articles will be popped off."
10587 (setq gnus-newsgroup-history
10588 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10590 (gnus-summary-goto-article (car to))
10591 (error "Article history empty")))
10592 (gnus-summary-position-point))
10594 ;; Summary commands and functions for limiting the summary buffer.
10596 (defun gnus-summary-limit-to-articles (n)
10597 "Limit the summary buffer to the next N articles.
10598 If not given a prefix, use the process marked articles instead."
10600 (gnus-set-global-variables)
10602 (let ((articles (gnus-summary-work-articles n)))
10603 (setq gnus-newsgroup-processable nil)
10604 (gnus-summary-limit articles))
10605 (gnus-summary-position-point)))
10607 (defun gnus-summary-pop-limit (&optional total)
10608 "Restore the previous limit.
10609 If given a prefix, remove all limits."
10611 (gnus-set-global-variables)
10613 (setq gnus-newsgroup-limits
10614 (list (mapcar (lambda (h) (mail-header-number h))
10615 gnus-newsgroup-headers))))
10616 (unless gnus-newsgroup-limits
10617 (error "No limit to pop"))
10619 (gnus-summary-limit nil 'pop)
10620 (gnus-summary-position-point)))
10622 (defun gnus-summary-limit-to-subject (subject &optional header)
10623 "Limit the summary buffer to articles that have subjects that match a regexp."
10624 (interactive "sRegexp: ")
10626 (setq header "subject"))
10627 (when (not (equal "" subject))
10629 (let ((articles (gnus-summary-find-matching
10630 (or header "subject") subject 'all)))
10631 (or articles (error "Found no matches for \"%s\"" subject))
10632 (gnus-summary-limit articles))
10633 (gnus-summary-position-point))))
10635 (defun gnus-summary-limit-to-author (from)
10636 "Limit the summary buffer to articles that have authors that match a regexp."
10637 (interactive "sRegexp: ")
10638 (gnus-summary-limit-to-subject from "from"))
10640 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10642 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10644 (defun gnus-summary-limit-to-unread (&optional all)
10645 "Limit the summary buffer to articles that are not marked as read.
10646 If ALL is non-nil, limit strictly to unread articles."
10649 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10650 (gnus-summary-limit-to-marks
10651 ;; Concat all the marks that say that an article is read and have
10653 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10654 gnus-killed-mark gnus-kill-file-mark
10655 gnus-low-score-mark gnus-expirable-mark
10656 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10659 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10660 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10662 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10663 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10664 If REVERSE, limit the summary buffer to articles that are not marked
10665 with MARKS. MARKS can either be a string of marks or a list of marks.
10666 Returns how many articles were removed."
10667 (interactive "sMarks: ")
10668 (gnus-set-global-variables)
10670 (let ((data gnus-newsgroup-data)
10671 (marks (if (listp marks) marks
10672 (append marks nil))) ; Transform to list.
10675 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10676 (memq (gnus-data-mark (car data)) marks))
10677 (setq articles (cons (gnus-data-number (car data)) articles)))
10678 (setq data (cdr data)))
10679 (gnus-summary-limit articles))
10680 (gnus-summary-position-point)))
10682 (defun gnus-summary-limit-to-score (&optional score)
10683 "Limit to articles with score at or above SCORE."
10685 (gnus-set-global-variables)
10686 (setq score (if score
10687 (prefix-numeric-value score)
10688 (or gnus-summary-default-score 0)))
10689 (let ((data gnus-newsgroup-data)
10692 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10694 (push (gnus-data-number (car data)) articles))
10695 (setq data (cdr data)))
10697 (gnus-summary-limit articles)
10698 (gnus-summary-position-point))))
10700 (defun gnus-summary-limit-include-dormant ()
10701 "Display all the hidden articles that are marked as dormant."
10703 (gnus-set-global-variables)
10704 (or gnus-newsgroup-dormant
10705 (error "There are no dormant articles in this group"))
10707 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10708 (gnus-summary-position-point)))
10710 (defun gnus-summary-limit-exclude-dormant ()
10711 "Hide all dormant articles."
10713 (gnus-set-global-variables)
10715 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10716 (gnus-summary-position-point)))
10718 (defun gnus-summary-limit-exclude-childless-dormant ()
10719 "Hide all dormant articles that have no children."
10721 (gnus-set-global-variables)
10722 (let ((data (gnus-data-list t))
10723 articles d children)
10724 ;; Find all articles that are either not dormant or have
10726 (while (setq d (pop data))
10727 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10728 (and (setq children
10729 (gnus-article-children (gnus-data-number d)))
10732 (when (memq (car children) articles)
10737 (push (gnus-data-number d) articles)))
10738 ;; Do the limiting.
10740 (gnus-summary-limit articles)
10741 (gnus-summary-position-point))))
10743 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10744 "Mark all unread excluded articles as read.
10745 If ALL, mark even excluded ticked and dormants as read."
10747 (let ((articles (gnus-sorted-complement
10749 (mapcar (lambda (h) (mail-header-number h))
10750 gnus-newsgroup-headers)
10752 (sort gnus-newsgroup-limit '<)))
10754 (setq gnus-newsgroup-unreads nil)
10756 (setq gnus-newsgroup-dormant nil
10757 gnus-newsgroup-marked nil
10758 gnus-newsgroup-reads
10760 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10761 gnus-newsgroup-reads))
10762 (while (setq article (pop articles))
10763 (unless (or (memq article gnus-newsgroup-dormant)
10764 (memq article gnus-newsgroup-marked))
10765 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10767 (defun gnus-summary-limit (articles &optional pop)
10769 ;; We pop the previous limit off the stack and use that.
10770 (setq articles (car gnus-newsgroup-limits)
10771 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10772 ;; We use the new limit, so we push the old limit on the stack.
10773 (setq gnus-newsgroup-limits
10774 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10776 (setq gnus-newsgroup-limit articles)
10777 (let ((total (length gnus-newsgroup-data))
10778 (data (gnus-data-find-list (gnus-summary-article-number)))
10780 ;; This will do all the work of generating the new summary buffer
10781 ;; according to the new limit.
10782 (gnus-summary-prepare)
10783 ;; Hide any threads, possibly.
10784 (and gnus-show-threads
10785 gnus-thread-hide-subtree
10786 (gnus-summary-hide-all-threads))
10787 ;; Try to return to the article you were at, or one in the
10790 ;; We try to find some article after the current one.
10792 (and (gnus-summary-goto-subject
10793 (gnus-data-number (car data)) nil t)
10796 (setq data (cdr data))))
10798 ;; If there is no data, that means that we were after the last
10799 ;; article. The same goes when we can't find any articles
10800 ;; after the current one.
10802 (goto-char (point-max))
10803 (gnus-summary-find-prev)))
10804 ;; We return how many articles were removed from the summary
10805 ;; buffer as a result of the new limit.
10806 (- total (length gnus-newsgroup-data))))
10808 (defsubst gnus-invisible-cut-children (threads)
10811 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10816 (defsubst gnus-cut-thread (thread)
10817 "Go forwards in the thread until we find an article that we want to display."
10818 (when (or (eq gnus-fetch-old-headers 'some)
10819 (eq gnus-build-sparse-threads 'some)
10820 (eq gnus-build-sparse-threads 'more))
10821 ;; Deal with old-fetched headers and sparse threads.
10825 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10826 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10827 (or (<= (length (cdr thread)) 1)
10828 (gnus-invisible-cut-children (cdr thread))))
10829 (setq thread (cadr thread))))
10832 (defun gnus-cut-threads (threads)
10833 "Cut off all uninteresting articles from the beginning of threads."
10834 (when (or (eq gnus-fetch-old-headers 'some)
10835 (eq gnus-build-sparse-threads 'some)
10836 (eq gnus-build-sparse-threads 'more))
10837 (let ((th threads))
10839 (setcar th (gnus-cut-thread (car th)))
10840 (setq th (cdr th)))))
10841 ;; Remove nixed out threads.
10842 (delq nil threads))
10844 (defun gnus-summary-initial-limit (&optional show-if-empty)
10845 "Figure out what the initial limit is supposed to be on group entry.
10846 This entails weeding out unwanted dormants, low-scored articles,
10847 fetch-old-headers verbiage, and so on."
10848 ;; Most groups have nothing to remove.
10849 (if (or gnus-inhibit-limiting
10850 (and (null gnus-newsgroup-dormant)
10851 (not (eq gnus-fetch-old-headers 'some))
10852 (null gnus-summary-expunge-below)
10853 (not (eq gnus-build-sparse-threads 'some))
10854 (not (eq gnus-build-sparse-threads 'more))
10855 (null gnus-thread-expunge-below)
10856 (not gnus-use-nocem)))
10858 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10859 (setq gnus-newsgroup-limit nil)
10862 (unless (car (symbol-value node))
10863 ;; These threads have no parents -- they are roots.
10864 (let ((nodes (cdr (symbol-value node)))
10867 (if (and gnus-thread-expunge-below
10868 (< (gnus-thread-total-score (car nodes))
10869 gnus-thread-expunge-below))
10870 (gnus-expunge-thread (pop nodes))
10871 (setq thread (pop nodes))
10872 (gnus-summary-limit-children thread))))))
10873 gnus-newsgroup-dependencies)
10874 ;; If this limitation resulted in an empty group, we might
10875 ;; pop the previous limit and use it instead.
10876 (when (and (not gnus-newsgroup-limit)
10878 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10879 gnus-newsgroup-limit))
10881 (defun gnus-summary-limit-children (thread)
10882 "Return 1 if this subthread is visible and 0 if it is not."
10883 ;; First we get the number of visible children to this thread. This
10884 ;; is done by recursing down the thread using this function, so this
10885 ;; will really go down to a leaf article first, before slowly
10886 ;; working its way up towards the root.
10890 (apply '+ (mapcar 'gnus-summary-limit-children
10893 (number (mail-header-number (car thread)))
10896 ;; If this article is dormant and has absolutely no visible
10897 ;; children, then this article isn't visible.
10898 (and (memq number gnus-newsgroup-dormant)
10900 ;; If this is "fetch-old-headered" and there is only one
10901 ;; visible child (or less), then we don't want this article.
10902 (and (eq gnus-fetch-old-headers 'some)
10903 (memq number gnus-newsgroup-ancient)
10905 ;; If this is a sparsely inserted article with no children,
10906 ;; we don't want it.
10907 (and (eq gnus-build-sparse-threads 'some)
10908 (memq number gnus-newsgroup-sparse)
10910 ;; If we use expunging, and this article is really
10911 ;; low-scored, then we don't want this article.
10912 (when (and gnus-summary-expunge-below
10914 (or (cdr (assq number gnus-newsgroup-scored))
10915 gnus-summary-default-score))
10916 gnus-summary-expunge-below))
10917 ;; We increase the expunge-tally here, but that has
10918 ;; nothing to do with the limits, really.
10919 (incf gnus-newsgroup-expunged-tally)
10920 ;; We also mark as read here, if that's wanted.
10921 (when (and gnus-summary-mark-below
10922 (< score gnus-summary-mark-below))
10923 (setq gnus-newsgroup-unreads
10924 (delq number gnus-newsgroup-unreads))
10925 (if gnus-newsgroup-auto-expire
10926 (push number gnus-newsgroup-expirable)
10927 (push (cons number gnus-low-score-mark)
10928 gnus-newsgroup-reads)))
10930 (and gnus-use-nocem
10931 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10932 ;; Nope, invisible article.
10934 ;; Ok, this article is to be visible, so we add it to the limit
10936 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10939 (defun gnus-expunge-thread (thread)
10940 "Mark all articles in THREAD as read."
10941 (let* ((number (mail-header-number (car thread))))
10942 (incf gnus-newsgroup-expunged-tally)
10943 ;; We also mark as read here, if that's wanted.
10944 (setq gnus-newsgroup-unreads
10945 (delq number gnus-newsgroup-unreads))
10946 (if gnus-newsgroup-auto-expire
10947 (push number gnus-newsgroup-expirable)
10948 (push (cons number gnus-low-score-mark)
10949 gnus-newsgroup-reads)))
10950 ;; Go recursively through all subthreads.
10951 (mapcar 'gnus-expunge-thread (cdr thread)))
10953 ;; Summary article oriented commands
10955 (defun gnus-summary-refer-parent-article (n)
10956 "Refer parent article N times.
10957 The difference between N and the number of articles fetched is returned."
10959 (gnus-set-global-variables)
10963 (let* ((header (gnus-summary-article-header))
10965 ;; If we try to find the parent of the currently
10966 ;; displayed article, then we take a look at the actual
10967 ;; References header, since this is slightly more
10968 ;; reliable than the References field we got from the
10970 (if (and (eq (mail-header-number header)
10971 (cdr gnus-article-current))
10972 (equal gnus-newsgroup-name
10973 (car gnus-article-current)))
10975 (set-buffer gnus-original-article-buffer)
10976 (nnheader-narrow-to-headers)
10978 (message-fetch-field "references")
10980 ;; It's not the current article, so we take a bet on
10981 ;; the value we got from the server.
10982 (mail-header-references header))))
10983 (if (setq ref (or ref (mail-header-references header)))
10984 (or (gnus-summary-refer-article (gnus-parent-id ref))
10985 (gnus-message 1 "Couldn't find parent"))
10986 (gnus-message 1 "No references in article %d"
10987 (gnus-summary-article-number))
10990 (gnus-summary-position-point)
10993 (defun gnus-summary-refer-references ()
10994 "Fetch all articles mentioned in the References header.
10995 Return how many articles were fetched."
10997 (gnus-set-global-variables)
10998 (let ((ref (mail-header-references (gnus-summary-article-header)))
10999 (current (gnus-summary-article-number))
11001 ;; For each Message-ID in the References header...
11002 (while (string-match "<[^>]*>" ref)
11004 ;; ... fetch that article.
11005 (gnus-summary-refer-article
11006 (prog1 (match-string 0 ref)
11007 (setq ref (substring ref (match-end 0))))))
11008 (gnus-summary-goto-subject current)
11009 (gnus-summary-position-point)
11012 (defun gnus-summary-refer-article (message-id)
11013 "Fetch an article specified by MESSAGE-ID."
11014 (interactive "sMessage-ID: ")
11015 (when (and (stringp message-id)
11016 (not (zerop (length message-id))))
11017 ;; Construct the correct Message-ID if necessary.
11018 ;; Suggested by tale@pawl.rpi.edu.
11019 (unless (string-match "^<" message-id)
11020 (setq message-id (concat "<" message-id)))
11021 (unless (string-match ">$" message-id)
11022 (setq message-id (concat message-id ">")))
11023 (let ((header (gnus-id-to-header message-id)))
11025 ;; The article is present in the buffer, to we just go to it.
11026 (gnus-summary-goto-article (mail-header-number header) nil header)
11027 ;; We fetch the article
11028 (let ((gnus-override-method
11029 (and (gnus-news-group-p gnus-newsgroup-name)
11030 gnus-refer-article-method))
11032 ;; Start the special refer-article method, if necessary.
11033 (when (and gnus-refer-article-method
11034 (gnus-news-group-p gnus-newsgroup-name))
11035 (gnus-check-server gnus-refer-article-method))
11036 ;; Fetch the header, and display the article.
11037 (if (setq number (gnus-summary-insert-subject message-id))
11038 (gnus-summary-select-article nil nil nil number)
11039 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11041 (defun gnus-summary-enter-digest-group (&optional force)
11042 "Enter a digest group based on the current article."
11044 (gnus-set-global-variables)
11045 (gnus-summary-select-article)
11046 (let ((name (format "%s-%d"
11047 (gnus-group-prefixed-name
11048 gnus-newsgroup-name (list 'nndoc ""))
11049 gnus-current-article))
11050 (ogroup gnus-newsgroup-name)
11051 (case-fold-search t)
11052 (buf (current-buffer))
11055 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11056 (insert-buffer-substring gnus-original-article-buffer)
11058 (goto-char (point-min))
11059 (or (search-forward "\n\n" nil t) (point)))
11060 (goto-char (point-min))
11061 (delete-matching-lines "^\\(Path\\):\\|^From ")
11064 (if (gnus-group-read-ephemeral-group
11065 name `(nndoc ,name (nndoc-address
11067 (nndoc-article-type ,(if force 'digest 'guess))) t)
11068 ;; Make all postings to this group go to the parent group.
11069 (nconc (gnus-info-params (gnus-get-info name))
11070 (list (cons 'to-group ogroup)))
11071 ;; Couldn't select this doc group.
11072 (switch-to-buffer buf)
11073 (gnus-set-global-variables)
11074 (gnus-configure-windows 'summary)
11075 (gnus-message 3 "Article couldn't be entered?"))
11076 (kill-buffer dig))))
11078 (defun gnus-summary-isearch-article (&optional regexp-p)
11079 "Do incremental search forward on the current article.
11080 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11082 (gnus-set-global-variables)
11083 (gnus-summary-select-article)
11084 (gnus-configure-windows 'article)
11085 (gnus-eval-in-buffer-window
11086 gnus-article-buffer
11087 (goto-char (point-min))
11088 (isearch-forward regexp-p)))
11090 (defun gnus-summary-search-article-forward (regexp &optional backward)
11091 "Search for an article containing REGEXP forward.
11092 If BACKWARD, search backward instead."
11095 (format "Search article %s (regexp%s): "
11096 (if current-prefix-arg "backward" "forward")
11097 (if gnus-last-search-regexp
11098 (concat ", default " gnus-last-search-regexp)
11100 current-prefix-arg))
11101 (gnus-set-global-variables)
11102 (if (string-equal regexp "")
11103 (setq regexp (or gnus-last-search-regexp ""))
11104 (setq gnus-last-search-regexp regexp))
11105 (unless (gnus-summary-search-article regexp backward)
11106 (error "Search failed: \"%s\"" regexp)))
11108 (defun gnus-summary-search-article-backward (regexp)
11109 "Search for an article containing REGEXP backward."
11112 (format "Search article backward (regexp%s): "
11113 (if gnus-last-search-regexp
11114 (concat ", default " gnus-last-search-regexp)
11116 (gnus-summary-search-article-forward regexp 'backward))
11118 (defun gnus-summary-search-article (regexp &optional backward)
11119 "Search for an article containing REGEXP.
11120 Optional argument BACKWARD means do search for backward.
11121 `gnus-select-article-hook' is not called during the search."
11122 (let ((gnus-select-article-hook nil) ;Disable hook.
11123 (gnus-article-display-hook nil)
11124 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11127 're-search-backward 're-search-forward))
11128 (sum (current-buffer))
11130 (gnus-save-hidden-threads
11131 (gnus-summary-select-article)
11132 (set-buffer gnus-article-buffer)
11134 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11136 (re-search-backward regexp nil t)
11137 (re-search-forward regexp nil t))
11138 ;; We found the regexp.
11140 (setq found 'found)
11141 (beginning-of-line)
11143 (get-buffer-window (current-buffer))
11147 ;; We didn't find it, so we go to the next article.
11149 (if (not (if backward (gnus-summary-find-prev)
11150 (gnus-summary-find-next)))
11151 ;; No more articles.
11153 ;; Select the next article and adjust point.
11154 (gnus-summary-select-article)
11155 (set-buffer gnus-article-buffer)
11157 (goto-char (if backward (point-max) (point-min))))))
11158 (gnus-message 7 ""))
11159 ;; Return whether we found the regexp.
11160 (when (eq found 'found)
11161 (gnus-summary-show-thread)
11162 (gnus-summary-goto-subject gnus-current-article)
11163 (gnus-summary-position-point)
11166 (defun gnus-summary-find-matching (header regexp &optional backward unread
11168 "Return a list of all articles that match REGEXP on HEADER.
11169 The search stars on the current article and goes forwards unless
11170 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11171 If UNREAD is non-nil, only unread articles will
11172 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11173 in the comparisons."
11174 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11175 (gnus-data-find-list
11176 (gnus-summary-article-number) (gnus-data-list backward))))
11177 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11178 (case-fold-search (not not-case-fold))
11180 (or (fboundp (intern (concat "mail-header-" header)))
11181 (error "%s is not a valid header" header))
11183 (setq d (car data))
11184 (and (or (not unread) ; We want all articles...
11185 (gnus-data-unread-p d)) ; Or just unreads.
11186 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11187 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11188 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11189 (setq data (cdr data)))
11190 (nreverse articles)))
11192 (defun gnus-summary-execute-command (header regexp command &optional backward)
11193 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11194 If HEADER is an empty string (or nil), the match is done on the entire
11195 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11197 (list (let ((completion-ignore-case t))
11200 (mapcar (lambda (string) (list string))
11201 '("Number" "Subject" "From" "Lines" "Date"
11202 "Message-ID" "Xref" "References" "Body"))
11203 nil 'require-match))
11204 (read-string "Regexp: ")
11205 (read-key-sequence "Command: ")
11206 current-prefix-arg))
11207 (when (equal header "Body")
11209 (gnus-set-global-variables)
11210 ;; Hidden thread subtrees must be searched as well.
11211 (gnus-summary-show-all-threads)
11212 ;; We don't want to change current point nor window configuration.
11214 (save-window-excursion
11215 (gnus-message 6 "Executing %s..." (key-description command))
11216 ;; We'd like to execute COMMAND interactively so as to give arguments.
11217 (gnus-execute header regexp
11218 `(lambda () (call-interactively ',(key-binding command)))
11220 (gnus-message 6 "Executing %s...done" (key-description command)))))
11222 (defun gnus-summary-beginning-of-article ()
11223 "Scroll the article back to the beginning."
11225 (gnus-set-global-variables)
11226 (gnus-summary-select-article)
11227 (gnus-configure-windows 'article)
11228 (gnus-eval-in-buffer-window
11229 gnus-article-buffer
11231 (goto-char (point-min))
11232 (and gnus-break-pages (gnus-narrow-to-page))))
11234 (defun gnus-summary-end-of-article ()
11235 "Scroll to the end of the article."
11237 (gnus-set-global-variables)
11238 (gnus-summary-select-article)
11239 (gnus-configure-windows 'article)
11240 (gnus-eval-in-buffer-window
11241 gnus-article-buffer
11243 (goto-char (point-max))
11245 (and gnus-break-pages (gnus-narrow-to-page))))
11247 (defun gnus-summary-show-article (&optional arg)
11248 "Force re-fetching of the current article.
11249 If ARG (the prefix) is non-nil, show the raw article without any
11250 article massaging functions being run."
11252 (gnus-set-global-variables)
11254 ;; Select the article the normal way.
11255 (gnus-summary-select-article nil 'force)
11256 ;; Bind the article treatment functions to nil.
11257 (let ((gnus-have-all-headers t)
11258 gnus-article-display-hook
11259 gnus-article-prepare-hook
11262 (gnus-summary-select-article nil 'force)))
11263 (gnus-summary-goto-subject gnus-current-article)
11264 ; (gnus-configure-windows 'article)
11265 (gnus-summary-position-point))
11267 (defun gnus-summary-verbose-headers (&optional arg)
11268 "Toggle permanent full header display.
11269 If ARG is a positive number, turn header display on.
11270 If ARG is a negative number, turn header display off."
11272 (gnus-set-global-variables)
11273 (gnus-summary-toggle-header arg)
11274 (setq gnus-show-all-headers
11275 (cond ((or (not (numberp arg))
11277 (not gnus-show-all-headers))
11281 (defun gnus-summary-toggle-header (&optional arg)
11282 "Show the headers if they are hidden, or hide them if they are shown.
11283 If ARG is a positive number, show the entire header.
11284 If ARG is a negative number, hide the unwanted header lines."
11286 (gnus-set-global-variables)
11288 (set-buffer gnus-article-buffer)
11289 (let* ((buffer-read-only nil)
11290 (inhibit-point-motion-hooks t)
11291 (hidden (text-property-any
11292 (goto-char (point-min)) (search-forward "\n\n")
11295 (goto-char (point-min))
11296 (when (search-forward "\n\n" nil t)
11297 (delete-region (point-min) (1- (point))))
11298 (goto-char (point-min))
11300 (set-buffer gnus-original-article-buffer)
11301 (goto-char (point-min))
11302 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11303 (insert-buffer-substring gnus-original-article-buffer 1 e)
11304 (let ((gnus-inhibit-hiding t))
11305 (run-hooks 'gnus-article-display-hook))
11306 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11307 (gnus-article-hide-headers)))))
11309 (defun gnus-summary-show-all-headers ()
11310 "Make all header lines visible."
11312 (gnus-set-global-variables)
11313 (gnus-article-show-all-headers))
11315 (defun gnus-summary-toggle-mime (&optional arg)
11316 "Toggle MIME processing.
11317 If ARG is a positive number, turn MIME processing on."
11319 (gnus-set-global-variables)
11320 (setq gnus-show-mime
11321 (if (null arg) (not gnus-show-mime)
11322 (> (prefix-numeric-value arg) 0)))
11323 (gnus-summary-select-article t 'force))
11325 (defun gnus-summary-caesar-message (&optional arg)
11326 "Caesar rotate the current article by 13.
11327 The numerical prefix specifies how manu places to rotate each letter
11330 (gnus-set-global-variables)
11331 (gnus-summary-select-article)
11332 (let ((mail-header-separator ""))
11333 (gnus-eval-in-buffer-window
11334 gnus-article-buffer
11337 (let ((start (window-start)))
11338 (news-caesar-buffer-body arg)
11339 (set-window-start (get-buffer-window (current-buffer)) start))))))
11341 (defun gnus-summary-stop-page-breaking ()
11342 "Stop page breaking in the current article."
11344 (gnus-set-global-variables)
11345 (gnus-summary-select-article)
11346 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11348 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11349 "Move the current article to a different newsgroup.
11350 If N is a positive number, move the N next articles.
11351 If N is a negative number, move the N previous articles.
11352 If N is nil and any articles have been marked with the process mark,
11353 move those articles instead.
11354 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11355 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11356 re-spool using this method.
11358 For this function to work, both the current newsgroup and the
11359 newsgroup that you want to move to have to support the `request-move'
11360 and `request-accept' functions."
11362 (unless action (setq action 'move))
11363 (gnus-set-global-variables)
11364 ;; Check whether the source group supports the required functions.
11365 (cond ((and (eq action 'move)
11366 (not (gnus-check-backend-function
11367 'request-move-article gnus-newsgroup-name)))
11368 (error "The current group does not support article moving"))
11369 ((and (eq action 'crosspost)
11370 (not (gnus-check-backend-function
11371 'request-replace-article gnus-newsgroup-name)))
11372 (error "The current group does not support article editing")))
11373 (let ((articles (gnus-summary-work-articles n))
11374 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11375 (names '((move "Move" "Moving")
11376 (copy "Copy" "Copying")
11377 (crosspost "Crosspost" "Crossposting")))
11378 (copy-buf (save-excursion
11379 (nnheader-set-temp-buffer " *copy article*")))
11380 art-group to-method new-xref article to-groups)
11381 (unless (assq action names)
11382 (error "Unknown action %s" action))
11383 ;; Read the newsgroup name.
11384 (when (and (not to-newsgroup)
11385 (not select-method))
11387 (gnus-read-move-group-name
11388 (cadr (assq action names))
11389 (symbol-value (intern (format "gnus-current-%s-group" action)))
11391 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11392 (setq to-method (or select-method
11393 (gnus-find-method-for-group to-newsgroup)))
11394 ;; Check the method we are to move this article to...
11395 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11396 (error "%s does not support article copying" (car to-method)))
11397 (or (gnus-check-server to-method)
11398 (error "Can't open server %s" (car to-method)))
11399 (gnus-message 6 "%s to %s: %s..."
11400 (caddr (assq action names))
11401 (or (car select-method) to-newsgroup) articles)
11403 (setq article (pop articles))
11407 ;; Move the article.
11409 (gnus-request-move-article
11410 article ; Article to move
11411 gnus-newsgroup-name ; From newsgrouo
11412 (nth 1 (gnus-find-method-for-group
11413 gnus-newsgroup-name)) ; Server
11414 (list 'gnus-request-accept-article
11415 to-newsgroup (list 'quote select-method)
11416 (not articles)) ; Accept form
11417 (not articles))) ; Only save nov last time
11418 ;; Copy the article.
11421 (set-buffer copy-buf)
11422 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11423 (gnus-request-accept-article
11424 to-newsgroup select-method (not articles))))
11425 ;; Crosspost the article.
11426 ((eq action 'crosspost)
11427 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11428 (setq new-xref (concat gnus-newsgroup-name ":" article))
11429 (if (and xref (not (string= xref "")))
11431 (when (string-match "^Xref: " xref)
11432 (setq xref (substring xref (match-end 0))))
11433 (setq new-xref (concat xref " " new-xref)))
11434 (setq new-xref (concat (system-name) " " new-xref)))
11436 (set-buffer copy-buf)
11437 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11438 (nnheader-replace-header "xref" new-xref)
11439 (gnus-request-accept-article
11440 to-newsgroup select-method (not articles)))))))
11441 (if (not art-group)
11442 (gnus-message 1 "Couldn't %s article %s"
11443 (cadr (assq action names)) article)
11446 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11448 (gnus-group-prefixed-name
11451 (gnus-find-method-for-group to-newsgroup)))
11452 gnus-newsrc-hashtb)))
11453 (info (nth 2 entry))
11454 (to-group (gnus-info-group info)))
11455 ;; Update the group that has been moved to.
11457 (memq action '(move copy)))
11458 (unless (member to-group to-groups)
11459 (push to-group to-groups))
11461 (unless (memq article gnus-newsgroup-unreads)
11462 (gnus-info-set-read
11463 info (gnus-add-to-range (gnus-info-read info)
11464 (list (cdr art-group)))))
11466 ;; Copy any marks over to the new group.
11467 (let ((marks gnus-article-mark-lists)
11468 (to-article (cdr art-group)))
11470 ;; See whether the article is to be put in the cache.
11471 (when gnus-use-cache
11472 (gnus-cache-possibly-enter-article
11473 to-group to-article
11474 (let ((header (copy-sequence
11475 (gnus-summary-article-header article))))
11476 (mail-header-set-number header to-article)
11478 (memq article gnus-newsgroup-marked)
11479 (memq article gnus-newsgroup-dormant)
11480 (memq article gnus-newsgroup-unreads)))
11483 (when (memq article (symbol-value
11484 (intern (format "gnus-newsgroup-%s"
11486 ;; If the other group is the same as this group,
11487 ;; then we have to add the mark to the list.
11488 (when (equal to-group gnus-newsgroup-name)
11489 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11492 (intern (format "gnus-newsgroup-%s"
11494 ;; Copy mark to other group.
11495 (gnus-add-marked-articles
11496 to-group (cdar marks) (list to-article) info))
11497 (setq marks (cdr marks)))))
11499 ;; Update the Xref header in this article to point to
11500 ;; the new crossposted article we have just created.
11501 (when (eq action 'crosspost)
11503 (set-buffer copy-buf)
11504 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11505 (nnheader-replace-header
11506 "xref" (concat new-xref " " (gnus-group-prefixed-name
11507 (car art-group) to-method)
11508 ":" (cdr art-group)))
11509 (gnus-request-replace-article
11510 article gnus-newsgroup-name (current-buffer)))))
11512 (gnus-summary-goto-subject article)
11513 (when (eq action 'move)
11514 (gnus-summary-mark-article article gnus-canceled-mark)))
11515 (gnus-summary-remove-process-mark article))
11516 ;; Re-activate all groups that have been moved to.
11518 (gnus-activate-group (pop to-groups)))
11520 (gnus-kill-buffer copy-buf)
11521 (gnus-summary-position-point)
11522 (gnus-set-mode-line 'summary)))
11524 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11525 "Move the current article to a different newsgroup.
11526 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11527 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11528 re-spool using this method."
11530 (gnus-summary-move-article n nil select-method 'copy))
11532 (defun gnus-summary-crosspost-article (&optional n)
11533 "Crosspost the current article to some other group."
11535 (gnus-summary-move-article n nil nil 'crosspost))
11537 (defvar gnus-summary-respool-default-method nil
11538 "Default method for respooling an article.
11539 If nil, use to the current newsgroup method.")
11541 (defun gnus-summary-respool-article (&optional n method)
11542 "Respool the current article.
11543 The article will be squeezed through the mail spooling process again,
11544 which means that it will be put in some mail newsgroup or other
11545 depending on `nnmail-split-methods'.
11546 If N is a positive number, respool the N next articles.
11547 If N is a negative number, respool the N previous articles.
11548 If N is nil and any articles have been marked with the process mark,
11549 respool those articles instead.
11551 Respooling can be done both from mail groups and \"real\" newsgroups.
11552 In the former case, the articles in question will be moved from the
11553 current group into whatever groups they are destined to. In the
11554 latter case, they will be copied into the relevant groups."
11556 (list current-prefix-arg
11557 (let* ((methods (gnus-methods-using 'respool))
11559 (symbol-name (or gnus-summary-respool-default-method
11560 (car (gnus-find-method-for-group
11561 gnus-newsgroup-name)))))
11563 (gnus-completing-read
11564 methname "What backend do you want to use when? "
11565 methods nil t nil 'gnus-method-history))
11568 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11569 (list (intern method) ""))
11573 (cdr (completing-read
11575 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11576 (gnus-set-global-variables)
11578 (error "No method given for respooling"))
11579 (if (assoc (symbol-name
11580 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11581 (gnus-methods-using 'respool))
11582 (gnus-summary-move-article n nil method)
11583 (gnus-summary-copy-article n nil method)))
11585 (defun gnus-summary-import-article (file)
11586 "Import a random file into a mail newsgroup."
11587 (interactive "fImport file: ")
11588 (gnus-set-global-variables)
11589 (let ((group gnus-newsgroup-name)
11590 (now (current-time))
11592 (or (gnus-check-backend-function 'request-accept-article group)
11593 (error "%s does not support article importing" group))
11594 (or (file-readable-p file)
11595 (not (file-regular-p file))
11596 (error "Can't read %s" file))
11598 (set-buffer (get-buffer-create " *import file*"))
11599 (buffer-disable-undo (current-buffer))
11601 (insert-file-contents file)
11602 (goto-char (point-min))
11603 (unless (nnheader-article-p)
11604 ;; This doesn't look like an article, so we fudge some headers.
11605 (setq atts (file-attributes file)
11606 lines (count-lines (point-min) (point-max)))
11607 (insert "From: " (read-string "From: ") "\n"
11608 "Subject: " (read-string "Subject: ") "\n"
11609 "Date: " (timezone-make-date-arpa-standard
11610 (current-time-string (nth 5 atts))
11611 (current-time-zone now)
11612 (current-time-zone now)) "\n"
11613 "Message-ID: " (gnus-inews-message-id) "\n"
11614 "Lines: " (int-to-string lines) "\n"
11615 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11616 (gnus-request-accept-article group nil t)
11617 (kill-buffer (current-buffer)))))
11619 (defun gnus-summary-expire-articles (&optional now)
11620 "Expire all articles that are marked as expirable in the current group."
11622 (gnus-set-global-variables)
11623 (when (gnus-check-backend-function
11624 'request-expire-articles gnus-newsgroup-name)
11625 ;; This backend supports expiry.
11626 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11627 (expirable (if total
11628 (gnus-list-of-read-articles gnus-newsgroup-name)
11629 (setq gnus-newsgroup-expirable
11630 (sort gnus-newsgroup-expirable '<))))
11631 (expiry-wait (if now 'immediate
11632 (gnus-group-get-parameter
11633 gnus-newsgroup-name 'expiry-wait)))
11636 ;; There are expirable articles in this group, so we run them
11637 ;; through the expiry process.
11638 (gnus-message 6 "Expiring articles...")
11639 ;; The list of articles that weren't expired is returned.
11641 (let ((nnmail-expiry-wait-function nil)
11642 (nnmail-expiry-wait expiry-wait))
11643 (setq es (gnus-request-expire-articles
11644 expirable gnus-newsgroup-name)))
11645 (setq es (gnus-request-expire-articles
11646 expirable gnus-newsgroup-name)))
11647 (or total (setq gnus-newsgroup-expirable es))
11648 ;; We go through the old list of expirable, and mark all
11649 ;; really expired articles as nonexistent.
11650 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11651 (let ((gnus-use-cache nil))
11653 (unless (memq (car expirable) es)
11654 (when (gnus-data-find (car expirable))
11655 (gnus-summary-mark-article
11656 (car expirable) gnus-canceled-mark)))
11657 (setq expirable (cdr expirable)))))
11658 (gnus-message 6 "Expiring articles...done")))))
11660 (defun gnus-summary-expire-articles-now ()
11661 "Expunge all expirable articles in the current group.
11662 This means that *all* articles that are marked as expirable will be
11663 deleted forever, right now."
11665 (gnus-set-global-variables)
11666 (or gnus-expert-user
11668 "Are you really, really, really sure you want to delete all these messages? ")
11670 (gnus-summary-expire-articles t))
11672 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11673 (defun gnus-summary-delete-article (&optional n)
11674 "Delete the N next (mail) articles.
11675 This command actually deletes articles. This is not a marking
11676 command. The article will disappear forever from your life, never to
11678 If N is negative, delete backwards.
11679 If N is nil and articles have been marked with the process mark,
11680 delete these instead."
11682 (gnus-set-global-variables)
11683 (or (gnus-check-backend-function 'request-expire-articles
11684 gnus-newsgroup-name)
11685 (error "The current newsgroup does not support article deletion."))
11686 ;; Compute the list of articles to delete.
11687 (let ((articles (gnus-summary-work-articles n))
11689 (if (and gnus-novice-user
11690 (not (gnus-y-or-n-p
11691 (format "Do you really want to delete %s forever? "
11692 (if (> (length articles) 1)
11693 (format "these %s articles" (length articles))
11694 "this article")))))
11696 ;; Delete the articles.
11697 (setq not-deleted (gnus-request-expire-articles
11698 articles gnus-newsgroup-name 'force))
11700 (gnus-summary-remove-process-mark (car articles))
11701 ;; The backend might not have been able to delete the article
11703 (or (memq (car articles) not-deleted)
11704 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11705 (setq articles (cdr articles))))
11706 (gnus-summary-position-point)
11707 (gnus-set-mode-line 'summary)
11710 (defun gnus-summary-edit-article (&optional force)
11711 "Enter into a buffer and edit the current article.
11712 This will have permanent effect only in mail groups.
11713 If FORCE is non-nil, allow editing of articles even in read-only
11717 (set-buffer gnus-summary-buffer)
11718 (gnus-set-global-variables)
11719 (when (and (not force)
11720 (gnus-group-read-only-p))
11721 (error "The current newsgroup does not support article editing."))
11722 (gnus-summary-select-article t nil t)
11723 (gnus-configure-windows 'article)
11724 (select-window (get-buffer-window gnus-article-buffer))
11725 (gnus-message 6 "C-c C-c to end edits")
11726 (setq buffer-read-only nil)
11728 (use-local-map (copy-keymap (current-local-map)))
11729 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11730 (buffer-enable-undo)
11732 (goto-char (point-min))
11733 (search-forward "\n\n" nil t)))
11735 (defun gnus-summary-edit-article-done ()
11736 "Make edits to the current article permanent."
11738 (if (gnus-group-read-only-p)
11740 (gnus-summary-edit-article-postpone)
11742 1 "The current newsgroup does not support article editing."))
11743 (let ((buf (format "%s" (buffer-string))))
11746 (if (not (gnus-request-replace-article
11747 (cdr gnus-article-current) (car gnus-article-current)
11749 (error "Couldn't replace article.")
11750 (gnus-article-mode)
11751 (use-local-map gnus-article-mode-map)
11752 (setq buffer-read-only t)
11753 (buffer-disable-undo (current-buffer))
11754 (gnus-configure-windows 'summary)
11755 (gnus-summary-update-article (cdr gnus-article-current))
11756 (when gnus-use-cache
11757 (gnus-cache-update-article
11758 (cdr gnus-article-current) (car gnus-article-current)))
11759 (when gnus-keep-backlog
11760 (gnus-backlog-remove-article
11761 (car gnus-article-current) (cdr gnus-article-current))))
11763 (when (get-buffer gnus-original-article-buffer)
11764 (set-buffer gnus-original-article-buffer)
11765 (setq gnus-original-article nil)))
11766 (setq gnus-article-current nil
11767 gnus-current-article nil)
11768 (run-hooks 'gnus-article-display-hook)
11769 (and (gnus-visual-p 'summary-highlight 'highlight)
11770 (run-hooks 'gnus-visual-mark-article-hook)))))
11772 (defun gnus-summary-edit-article-postpone ()
11773 "Postpone changes to the current article."
11775 (gnus-article-mode)
11776 (use-local-map gnus-article-mode-map)
11777 (setq buffer-read-only t)
11778 (buffer-disable-undo (current-buffer))
11779 (gnus-configure-windows 'summary)
11780 (and (gnus-visual-p 'summary-highlight 'highlight)
11781 (run-hooks 'gnus-visual-mark-article-hook)))
11783 (defun gnus-summary-respool-query ()
11784 "Query where the respool algorithm would put this article."
11786 (gnus-set-global-variables)
11787 (gnus-summary-select-article)
11789 (set-buffer gnus-article-buffer)
11791 (goto-char (point-min))
11792 (search-forward "\n\n")
11793 (narrow-to-region (point-min) (point))
11794 (pp-eval-expression
11795 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11797 ;; Summary marking commands.
11799 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11800 "Mark articles which has the same subject as read, and then select the next.
11801 If UNMARK is positive, remove any kind of mark.
11802 If UNMARK is negative, tick articles."
11804 (gnus-set-global-variables)
11806 (setq unmark (prefix-numeric-value unmark)))
11808 (gnus-summary-mark-same-subject
11809 (gnus-summary-article-subject) unmark)))
11810 ;; Select next unread article. If auto-select-same mode, should
11811 ;; select the first unread article.
11812 (gnus-summary-next-article t (and gnus-auto-select-same
11813 (gnus-summary-article-subject)))
11814 (gnus-message 7 "%d article%s marked as %s"
11815 count (if (= count 1) " is" "s are")
11816 (if unmark "unread" "read"))))
11818 (defun gnus-summary-kill-same-subject (&optional unmark)
11819 "Mark articles which has the same subject as read.
11820 If UNMARK is positive, remove any kind of mark.
11821 If UNMARK is negative, tick articles."
11823 (gnus-set-global-variables)
11825 (setq unmark (prefix-numeric-value unmark)))
11827 (gnus-summary-mark-same-subject
11828 (gnus-summary-article-subject) unmark)))
11829 ;; If marked as read, go to next unread subject.
11831 ;; Go to next unread subject.
11832 (gnus-summary-next-subject 1 t))
11833 (gnus-message 7 "%d articles are marked as %s"
11834 count (if unmark "unread" "read"))))
11836 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11837 "Mark articles with same SUBJECT as read, and return marked number.
11838 If optional argument UNMARK is positive, remove any kinds of marks.
11839 If optional argument UNMARK is negative, mark articles as unread instead."
11843 ((null unmark) ; Mark as read.
11846 (gnus-summary-mark-article-as-read gnus-killed-mark)
11847 (gnus-summary-show-thread) t)
11848 (gnus-summary-find-subject subject))
11849 (setq count (1+ count))))
11850 ((> unmark 0) ; Tick.
11853 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11854 (gnus-summary-show-thread) t)
11855 (gnus-summary-find-subject subject))
11856 (setq count (1+ count))))
11857 (t ; Mark as unread.
11860 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11861 (gnus-summary-show-thread) t)
11862 (gnus-summary-find-subject subject))
11863 (setq count (1+ count)))))
11864 (gnus-set-mode-line 'summary)
11865 ;; Return the number of marked articles.
11868 (defun gnus-summary-mark-as-processable (n &optional unmark)
11869 "Set the process mark on the next N articles.
11870 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11871 the process mark instead. The difference between N and the actual
11872 number of articles marked is returned."
11874 (gnus-set-global-variables)
11875 (let ((backward (< n 0))
11880 (gnus-summary-remove-process-mark
11881 (gnus-summary-article-number))
11882 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11883 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11885 (if (/= 0 n) (gnus-message 7 "No more articles"))
11886 (gnus-summary-recenter)
11887 (gnus-summary-position-point)
11890 (defun gnus-summary-unmark-as-processable (n)
11891 "Remove the process mark from the next N articles.
11892 If N is negative, mark backward instead. The difference between N and
11893 the actual number of articles marked is returned."
11895 (gnus-set-global-variables)
11896 (gnus-summary-mark-as-processable n t))
11898 (defun gnus-summary-unmark-all-processable ()
11899 "Remove the process mark from all articles."
11901 (gnus-set-global-variables)
11903 (while gnus-newsgroup-processable
11904 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11905 (gnus-summary-position-point))
11907 (defun gnus-summary-mark-as-expirable (n)
11908 "Mark N articles forward as expirable.
11909 If N is negative, mark backward instead. The difference between N and
11910 the actual number of articles marked is returned."
11912 (gnus-set-global-variables)
11913 (gnus-summary-mark-forward n gnus-expirable-mark))
11915 (defun gnus-summary-mark-article-as-replied (article)
11916 "Mark ARTICLE replied and update the summary line."
11917 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11918 (let ((buffer-read-only nil))
11919 (when (gnus-summary-goto-subject article)
11920 (gnus-summary-update-secondary-mark article))))
11922 (defun gnus-summary-set-bookmark (article)
11923 "Set a bookmark in current article."
11924 (interactive (list (gnus-summary-article-number)))
11925 (gnus-set-global-variables)
11926 (if (or (not (get-buffer gnus-article-buffer))
11927 (not gnus-current-article)
11928 (not gnus-article-current)
11929 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11930 (error "No current article selected"))
11931 ;; Remove old bookmark, if one exists.
11932 (let ((old (assq article gnus-newsgroup-bookmarks)))
11933 (if old (setq gnus-newsgroup-bookmarks
11934 (delq old gnus-newsgroup-bookmarks))))
11935 ;; Set the new bookmark, which is on the form
11936 ;; (article-number . line-number-in-body).
11937 (setq gnus-newsgroup-bookmarks
11941 (set-buffer gnus-article-buffer)
11945 (goto-char (point-min))
11946 (search-forward "\n\n" nil t)
11949 gnus-newsgroup-bookmarks))
11950 (gnus-message 6 "A bookmark has been added to the current article."))
11952 (defun gnus-summary-remove-bookmark (article)
11953 "Remove the bookmark from the current article."
11954 (interactive (list (gnus-summary-article-number)))
11955 (gnus-set-global-variables)
11956 ;; Remove old bookmark, if one exists.
11957 (let ((old (assq article gnus-newsgroup-bookmarks)))
11960 (setq gnus-newsgroup-bookmarks
11961 (delq old gnus-newsgroup-bookmarks))
11962 (gnus-message 6 "Removed bookmark."))
11963 (gnus-message 6 "No bookmark in current article."))))
11965 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11966 (defun gnus-summary-mark-as-dormant (n)
11967 "Mark N articles forward as dormant.
11968 If N is negative, mark backward instead. The difference between N and
11969 the actual number of articles marked is returned."
11971 (gnus-set-global-variables)
11972 (gnus-summary-mark-forward n gnus-dormant-mark))
11974 (defun gnus-summary-set-process-mark (article)
11975 "Set the process mark on ARTICLE and update the summary line."
11976 (setq gnus-newsgroup-processable
11978 (delq article gnus-newsgroup-processable)))
11979 (when (gnus-summary-goto-subject article)
11980 (gnus-summary-show-thread)
11981 (gnus-summary-update-secondary-mark article)))
11983 (defun gnus-summary-remove-process-mark (article)
11984 "Remove the process mark from ARTICLE and update the summary line."
11985 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11986 (when (gnus-summary-goto-subject article)
11987 (gnus-summary-show-thread)
11988 (gnus-summary-update-secondary-mark article)))
11990 (defun gnus-summary-set-saved-mark (article)
11991 "Set the process mark on ARTICLE and update the summary line."
11992 (push article gnus-newsgroup-saved)
11993 (when (gnus-summary-goto-subject article)
11994 (gnus-summary-update-secondary-mark article)))
11996 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11997 "Mark N articles as read forwards.
11998 If N is negative, mark backwards instead.
11999 Mark with MARK. If MARK is ? , ?! or ??, articles will be
12001 The difference between N and the actual number of articles marked is
12004 (gnus-set-global-variables)
12005 (let ((backward (< n 0))
12006 (gnus-summary-goto-unread
12007 (and gnus-summary-goto-unread
12008 (not (eq gnus-summary-goto-unread 'never))
12009 (not (memq mark (list gnus-unread-mark
12010 gnus-ticked-mark gnus-dormant-mark)))))
12012 (mark (or mark gnus-del-mark)))
12013 (while (and (> n 0)
12014 (gnus-summary-mark-article nil mark no-expire)
12015 (zerop (gnus-summary-next-subject
12017 (and gnus-summary-goto-unread
12018 (not (eq gnus-summary-goto-unread 'never)))
12021 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12022 (gnus-summary-recenter)
12023 (gnus-summary-position-point)
12024 (gnus-set-mode-line 'summary)
12027 (defun gnus-summary-mark-article-as-read (mark)
12028 "Mark the current article quickly as read with MARK."
12029 (let ((article (gnus-summary-article-number)))
12030 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12031 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12032 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12033 (setq gnus-newsgroup-reads
12034 (cons (cons article mark) gnus-newsgroup-reads))
12035 ;; Possibly remove from cache, if that is used.
12036 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12037 ;; Allow the backend to change the mark.
12038 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12039 ;; Check for auto-expiry.
12040 (when (and gnus-newsgroup-auto-expire
12041 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12042 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12043 (= mark gnus-ancient-mark)
12044 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12045 (setq mark gnus-expirable-mark)
12046 (push article gnus-newsgroup-expirable))
12047 ;; Set the mark in the buffer.
12048 (gnus-summary-update-mark mark 'unread)
12051 (defun gnus-summary-mark-article-as-unread (mark)
12052 "Mark the current article quickly as unread with MARK."
12053 (let ((article (gnus-summary-article-number)))
12054 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12055 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12056 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12057 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12058 (cond ((= mark gnus-ticked-mark)
12059 (push article gnus-newsgroup-marked))
12060 ((= mark gnus-dormant-mark)
12061 (push article gnus-newsgroup-dormant))
12063 (push article gnus-newsgroup-unreads)))
12064 (setq gnus-newsgroup-reads
12065 (delq (assq article gnus-newsgroup-reads)
12066 gnus-newsgroup-reads))
12068 ;; See whether the article is to be put in the cache.
12069 (and gnus-use-cache
12070 (vectorp (gnus-summary-article-header article))
12072 (gnus-cache-possibly-enter-article
12073 gnus-newsgroup-name article
12074 (gnus-summary-article-header article)
12075 (= mark gnus-ticked-mark)
12076 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12079 (gnus-summary-update-mark mark 'unread)
12082 (defun gnus-summary-mark-article (&optional article mark no-expire)
12083 "Mark ARTICLE with MARK. MARK can be any character.
12084 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12085 `??' (dormant) and `?E' (expirable).
12086 If MARK is nil, then the default character `?D' is used.
12087 If ARTICLE is nil, then the article on the current line will be
12089 ;; The mark might be a string.
12090 (and (stringp mark)
12091 (setq mark (aref mark 0)))
12092 ;; If no mark is given, then we check auto-expiring.
12093 (and (not no-expire)
12094 gnus-newsgroup-auto-expire
12096 (and (numberp mark)
12097 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12098 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12099 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12100 (setq mark gnus-expirable-mark))
12101 (let* ((mark (or mark gnus-del-mark))
12102 (article (or article (gnus-summary-article-number))))
12103 (or article (error "No article on current line"))
12104 (if (or (= mark gnus-unread-mark)
12105 (= mark gnus-ticked-mark)
12106 (= mark gnus-dormant-mark))
12107 (gnus-mark-article-as-unread article mark)
12108 (gnus-mark-article-as-read article mark))
12110 ;; See whether the article is to be put in the cache.
12111 (and gnus-use-cache
12112 (not (= mark gnus-canceled-mark))
12113 (vectorp (gnus-summary-article-header article))
12115 (gnus-cache-possibly-enter-article
12116 gnus-newsgroup-name article
12117 (gnus-summary-article-header article)
12118 (= mark gnus-ticked-mark)
12119 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12121 (if (gnus-summary-goto-subject article nil t)
12122 (let ((buffer-read-only nil))
12123 (gnus-summary-show-thread)
12125 (gnus-summary-update-mark mark 'unread)
12128 (defun gnus-summary-update-secondary-mark (article)
12129 "Update the secondary (read, process, cache) mark."
12130 (gnus-summary-update-mark
12131 (cond ((memq article gnus-newsgroup-processable)
12133 ((memq article gnus-newsgroup-cached)
12135 ((memq article gnus-newsgroup-replied)
12137 ((memq article gnus-newsgroup-saved)
12139 (t gnus-unread-mark))
12141 (when (gnus-visual-p 'summary-highlight 'highlight)
12142 (run-hooks 'gnus-summary-update-hook))
12145 (defun gnus-summary-update-mark (mark type)
12146 (beginning-of-line)
12147 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12148 (buffer-read-only nil))
12150 (<= (+ forward (point)) (point-max)))
12151 ;; Go to the right position on the line.
12152 (goto-char (+ forward (point)))
12153 ;; Replace the old mark with the new mark.
12154 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12155 ;; Optionally update the marks by some user rule.
12156 (when (eq type 'unread)
12157 (gnus-data-set-mark
12158 (gnus-data-find (gnus-summary-article-number)) mark)
12159 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12161 (defun gnus-mark-article-as-read (article &optional mark)
12162 "Enter ARTICLE in the pertinent lists and remove it from others."
12163 ;; Make the article expirable.
12164 (let ((mark (or mark gnus-del-mark)))
12165 (if (= mark gnus-expirable-mark)
12166 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12167 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12168 ;; Remove from unread and marked lists.
12169 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12170 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12171 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12172 (push (cons article mark) gnus-newsgroup-reads)
12173 ;; Possibly remove from cache, if that is used.
12174 (when gnus-use-cache
12175 (gnus-cache-enter-remove-article article))))
12177 (defun gnus-mark-article-as-unread (article &optional mark)
12178 "Enter ARTICLE in the pertinent lists and remove it from others."
12179 (let ((mark (or mark gnus-ticked-mark)))
12180 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12181 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12182 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12183 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12184 (cond ((= mark gnus-ticked-mark)
12185 (push article gnus-newsgroup-marked))
12186 ((= mark gnus-dormant-mark)
12187 (push article gnus-newsgroup-dormant))
12189 (push article gnus-newsgroup-unreads)))
12190 (setq gnus-newsgroup-reads
12191 (delq (assq article gnus-newsgroup-reads)
12192 gnus-newsgroup-reads))))
12194 (defalias 'gnus-summary-mark-as-unread-forward
12195 'gnus-summary-tick-article-forward)
12196 (make-obsolete 'gnus-summary-mark-as-unread-forward
12197 'gnus-summary-tick-article-forward)
12198 (defun gnus-summary-tick-article-forward (n)
12199 "Tick N articles forwards.
12200 If N is negative, tick backwards instead.
12201 The difference between N and the number of articles ticked is returned."
12203 (gnus-summary-mark-forward n gnus-ticked-mark))
12205 (defalias 'gnus-summary-mark-as-unread-backward
12206 'gnus-summary-tick-article-backward)
12207 (make-obsolete 'gnus-summary-mark-as-unread-backward
12208 'gnus-summary-tick-article-backward)
12209 (defun gnus-summary-tick-article-backward (n)
12210 "Tick N articles backwards.
12211 The difference between N and the number of articles ticked is returned."
12213 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12215 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12216 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12217 (defun gnus-summary-tick-article (&optional article clear-mark)
12218 "Mark current article as unread.
12219 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12220 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12222 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12223 gnus-ticked-mark)))
12225 (defun gnus-summary-mark-as-read-forward (n)
12226 "Mark N articles as read forwards.
12227 If N is negative, mark backwards instead.
12228 The difference between N and the actual number of articles marked is
12231 (gnus-summary-mark-forward n gnus-del-mark t))
12233 (defun gnus-summary-mark-as-read-backward (n)
12234 "Mark the N articles as read backwards.
12235 The difference between N and the actual number of articles marked is
12238 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12240 (defun gnus-summary-mark-as-read (&optional article mark)
12241 "Mark current article as read.
12242 ARTICLE specifies the article to be marked as read.
12243 MARK specifies a string to be inserted at the beginning of the line."
12244 (gnus-summary-mark-article article mark))
12246 (defun gnus-summary-clear-mark-forward (n)
12247 "Clear marks from N articles forward.
12248 If N is negative, clear backward instead.
12249 The difference between N and the number of marks cleared is returned."
12251 (gnus-summary-mark-forward n gnus-unread-mark))
12253 (defun gnus-summary-clear-mark-backward (n)
12254 "Clear marks from N articles backward.
12255 The difference between N and the number of marks cleared is returned."
12257 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12259 (defun gnus-summary-mark-unread-as-read ()
12260 "Intended to be used by `gnus-summary-mark-article-hook'."
12261 (when (memq gnus-current-article gnus-newsgroup-unreads)
12262 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12264 (defun gnus-summary-mark-read-and-unread-as-read ()
12265 "Intended to be used by `gnus-summary-mark-article-hook'."
12266 (let ((mark (gnus-summary-article-mark)))
12267 (when (or (gnus-unread-mark-p mark)
12268 (gnus-read-mark-p mark))
12269 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12271 (defun gnus-summary-mark-region-as-read (point mark all)
12272 "Mark all unread articles between point and mark as read.
12273 If given a prefix, mark all articles between point and mark as read,
12274 even ticked and dormant ones."
12275 (interactive "r\nP")
12279 (beginning-of-line)
12284 (memq (setq article (gnus-summary-article-number))
12285 gnus-newsgroup-unreads))
12286 (gnus-summary-mark-article article gnus-del-mark))
12288 (gnus-summary-find-next))))))
12290 (defun gnus-summary-mark-below (score mark)
12291 "Mark articles with score less than SCORE with MARK."
12292 (interactive "P\ncMark: ")
12293 (gnus-set-global-variables)
12294 (setq score (if score
12295 (prefix-numeric-value score)
12296 (or gnus-summary-default-score 0)))
12298 (set-buffer gnus-summary-buffer)
12299 (goto-char (point-min))
12302 (and (< (gnus-summary-article-score) score)
12303 (gnus-summary-mark-article nil mark))
12304 (gnus-summary-find-next)))))
12306 (defun gnus-summary-kill-below (&optional score)
12307 "Mark articles with score below SCORE as read."
12309 (gnus-set-global-variables)
12310 (gnus-summary-mark-below score gnus-killed-mark))
12312 (defun gnus-summary-clear-above (&optional score)
12313 "Clear all marks from articles with score above SCORE."
12315 (gnus-set-global-variables)
12316 (gnus-summary-mark-above score gnus-unread-mark))
12318 (defun gnus-summary-tick-above (&optional score)
12319 "Tick all articles with score above SCORE."
12321 (gnus-set-global-variables)
12322 (gnus-summary-mark-above score gnus-ticked-mark))
12324 (defun gnus-summary-mark-above (score mark)
12325 "Mark articles with score over SCORE with MARK."
12326 (interactive "P\ncMark: ")
12327 (gnus-set-global-variables)
12328 (setq score (if score
12329 (prefix-numeric-value score)
12330 (or gnus-summary-default-score 0)))
12332 (set-buffer gnus-summary-buffer)
12333 (goto-char (point-min))
12335 (if (> (gnus-summary-article-score) score)
12336 (gnus-summary-mark-article nil mark))
12338 (gnus-summary-find-next)))))
12340 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12341 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12342 (defun gnus-summary-limit-include-expunged ()
12343 "Display all the hidden articles that were expunged for low scores."
12345 (gnus-set-global-variables)
12346 (let ((buffer-read-only nil))
12347 (let ((scored gnus-newsgroup-scored)
12350 (or (gnus-summary-goto-subject (caar scored))
12351 (and (setq h (gnus-summary-article-header (caar scored)))
12352 (< (cdar scored) gnus-summary-expunge-below)
12353 (setq headers (cons h headers))))
12354 (setq scored (cdr scored)))
12355 (or headers (error "No expunged articles hidden."))
12356 (goto-char (point-min))
12357 (gnus-summary-prepare-unthreaded (nreverse headers)))
12358 (goto-char (point-min))
12359 (gnus-summary-position-point)))
12361 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12362 "Mark all articles not marked as unread in this newsgroup as read.
12363 If prefix argument ALL is non-nil, all articles are marked as read.
12364 If QUIETLY is non-nil, no questions will be asked.
12365 If TO-HERE is non-nil, it should be a point in the buffer. All
12366 articles before this point will be marked as read.
12367 The number of articles marked as read is returned."
12369 (gnus-set-global-variables)
12372 (not gnus-interactive-catchup) ;Without confirmation?
12376 "Mark absolutely all articles as read? "
12377 "Mark all unread articles as read? ")))
12379 (not gnus-newsgroup-adaptive)
12380 (not gnus-newsgroup-auto-expire))
12383 (setq gnus-newsgroup-marked nil
12384 gnus-newsgroup-dormant nil))
12385 (setq gnus-newsgroup-unreads nil))
12386 ;; We actually mark all articles as canceled, which we
12387 ;; have to do when using auto-expiry or adaptive scoring.
12388 (gnus-summary-show-all-threads)
12389 (if (gnus-summary-first-subject (not all))
12391 (if to-here (< (point) to-here) t)
12392 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12393 (gnus-summary-find-next (not all)))))
12395 (setq gnus-newsgroup-unreads nil))
12396 (gnus-set-mode-line 'summary)))
12397 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12398 (if (and (not to-here) (eq 'nnvirtual (car method)))
12399 (nnvirtual-catchup-group
12400 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12401 (gnus-summary-position-point)))
12403 (defun gnus-summary-catchup-to-here (&optional all)
12404 "Mark all unticked articles before the current one as read.
12405 If ALL is non-nil, also mark ticked and dormant articles as read."
12407 (gnus-set-global-variables)
12409 (gnus-save-hidden-threads
12410 (let ((beg (point)))
12411 ;; We check that there are unread articles.
12412 (when (or all (gnus-summary-find-prev))
12413 (gnus-summary-catchup all t beg)))))
12414 (gnus-summary-position-point))
12416 (defun gnus-summary-catchup-all (&optional quietly)
12417 "Mark all articles in this newsgroup as read."
12419 (gnus-set-global-variables)
12420 (gnus-summary-catchup t quietly))
12422 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12423 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12424 If prefix argument ALL is non-nil, all articles are marked as read."
12426 (gnus-set-global-variables)
12427 (gnus-summary-catchup all quietly nil 'fast)
12428 ;; Select next newsgroup or exit.
12429 (if (eq gnus-auto-select-next 'quietly)
12430 (gnus-summary-next-group nil)
12431 (gnus-summary-exit)))
12433 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12434 "Mark all articles in this newsgroup as read, and then exit."
12436 (gnus-set-global-variables)
12437 (gnus-summary-catchup-and-exit t quietly))
12439 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12440 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12441 "Mark all articles in this group as read and select the next group.
12442 If given a prefix, mark all articles, unread as well as ticked, as
12445 (gnus-set-global-variables)
12447 (gnus-summary-catchup all))
12448 (gnus-summary-next-article t nil nil t))
12450 ;; Thread-based commands.
12452 (defun gnus-summary-articles-in-thread (&optional article)
12453 "Return a list of all articles in the current thread.
12454 If ARTICLE is non-nil, return all articles in the thread that starts
12455 with that article."
12456 (let* ((article (or article (gnus-summary-article-number)))
12457 (data (gnus-data-find-list article))
12458 (top-level (gnus-data-level (car data)))
12460 (cond ((null gnus-thread-operation-ignore-subject)
12461 (gnus-simplify-subject-re
12462 (mail-header-subject (gnus-data-header (car data)))))
12463 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12464 (gnus-simplify-subject-fuzzy
12465 (mail-header-subject (gnus-data-header (car data)))))
12467 (end-point (save-excursion
12468 (if (gnus-summary-go-to-next-thread)
12469 (point) (point-max))))
12472 (< (gnus-data-pos (car data)) end-point))
12473 (when (or (not top-subject)
12474 (string= top-subject
12475 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12476 (gnus-simplify-subject-fuzzy
12477 (mail-header-subject
12478 (gnus-data-header (car data))))
12479 (gnus-simplify-subject-re
12480 (mail-header-subject
12481 (gnus-data-header (car data)))))))
12482 (push (gnus-data-number (car data)) articles))
12483 (unless (and (setq data (cdr data))
12484 (> (gnus-data-level (car data)) top-level))
12486 ;; Return the list of articles.
12487 (nreverse articles)))
12489 (defun gnus-summary-rethread-current ()
12490 "Rethread the thread the current article is part of."
12492 (gnus-set-global-variables)
12493 (let* ((gnus-show-threads t)
12494 (article (gnus-summary-article-number))
12495 (id (mail-header-id (gnus-summary-article-header)))
12496 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12498 (error "No article on the current line"))
12499 (gnus-rebuild-thread id)
12500 (gnus-summary-goto-subject article)))
12502 (defun gnus-summary-reparent-thread ()
12503 "Make current article child of the marked (or previous) article.
12505 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12506 is non-nil or the Subject: of both articles are the same."
12508 (or (not (gnus-group-read-only-p))
12509 (error "The current newsgroup does not support article editing."))
12510 (or (<= (length gnus-newsgroup-processable) 1)
12511 (error "No more than one article may be marked."))
12512 (save-window-excursion
12513 (let ((gnus-article-buffer " *reparent*")
12514 (current-article (gnus-summary-article-number))
12515 ; first grab the marked article, otherwise one line up.
12516 (parent-article (if (not (null gnus-newsgroup-processable))
12517 (car gnus-newsgroup-processable)
12519 (if (eq (forward-line -1) 0)
12520 (gnus-summary-article-number)
12521 (error "Beginning of summary buffer."))))))
12522 (or (not (eq current-article parent-article))
12523 (error "An article may not be self-referential."))
12524 (let ((message-id (mail-header-id
12525 (gnus-summary-article-header parent-article))))
12526 (or (and message-id (not (equal message-id "")))
12527 (error "No message-id in desired parent."))
12528 (gnus-summary-select-article t t nil current-article)
12529 (set-buffer gnus-article-buffer)
12530 (setq buffer-read-only nil)
12531 (let ((buf (format "%s" (buffer-string))))
12534 (goto-char (point-min))
12535 (if (search-forward-regexp "^References: " nil t)
12536 (insert message-id " " )
12537 (insert "References: " message-id "\n"))
12538 (or (gnus-request-replace-article current-article
12539 (car gnus-article-current)
12540 gnus-article-buffer)
12541 (error "Couldn't replace article."))
12542 (set-buffer gnus-summary-buffer)
12543 (gnus-summary-unmark-all-processable)
12544 (gnus-summary-rethread-current)
12545 (gnus-message 3 "Article %d is now the child of article %d."
12546 current-article parent-article)))))
12548 (defun gnus-summary-toggle-threads (&optional arg)
12549 "Toggle showing conversation threads.
12550 If ARG is positive number, turn showing conversation threads on."
12552 (gnus-set-global-variables)
12553 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12554 (setq gnus-show-threads
12555 (if (null arg) (not gnus-show-threads)
12556 (> (prefix-numeric-value arg) 0)))
12557 (gnus-summary-prepare)
12558 (gnus-summary-goto-subject current)
12559 (gnus-summary-position-point)))
12561 (defun gnus-summary-show-all-threads ()
12562 "Show all threads."
12564 (gnus-set-global-variables)
12566 (let ((buffer-read-only nil))
12567 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12568 (gnus-summary-position-point))
12570 (defun gnus-summary-show-thread ()
12571 "Show thread subtrees.
12572 Returns nil if no thread was there to be shown."
12574 (gnus-set-global-variables)
12575 (let ((buffer-read-only nil)
12577 ;; first goto end then to beg, to have point at beg after let
12578 (end (progn (end-of-line) (point)))
12579 (beg (progn (beginning-of-line) (point))))
12581 ;; Any hidden lines here?
12582 (search-forward "\r" end t)
12583 (subst-char-in-region beg end ?\^M ?\n t)
12585 (gnus-summary-position-point))))
12587 (defun gnus-summary-hide-all-threads ()
12588 "Hide all thread subtrees."
12590 (gnus-set-global-variables)
12592 (goto-char (point-min))
12593 (gnus-summary-hide-thread)
12594 (while (zerop (gnus-summary-next-thread 1 t))
12595 (gnus-summary-hide-thread)))
12596 (gnus-summary-position-point))
12598 (defun gnus-summary-hide-thread ()
12599 "Hide thread subtrees.
12600 Returns nil if no threads were there to be hidden."
12602 (gnus-set-global-variables)
12603 (let ((buffer-read-only nil)
12605 (article (gnus-summary-article-number)))
12607 ;; Go forward until either the buffer ends or the subthread
12609 (when (and (not (eobp))
12610 (or (zerop (gnus-summary-next-thread 1 t))
12611 (goto-char (point-max))))
12613 (if (and (> (point) start)
12614 (search-backward "\n" start t))
12616 (subst-char-in-region start (point) ?\n ?\^M)
12617 (gnus-summary-goto-subject article))
12620 ;;(gnus-summary-position-point)
12623 (defun gnus-summary-go-to-next-thread (&optional previous)
12624 "Go to the same level (or less) next thread.
12625 If PREVIOUS is non-nil, go to previous thread instead.
12626 Return the article number moved to, or nil if moving was impossible."
12627 (let ((level (gnus-summary-thread-level))
12628 (way (if previous -1 1))
12631 (while (and (not (eobp))
12632 (< level (gnus-summary-thread-level)))
12633 (forward-line way))
12640 (gnus-summary-article-number)
12641 (goto-char beg)))))
12643 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12644 "Go to the same level (or less) next thread.
12645 If PREVIOUS is non-nil, go to previous thread instead.
12646 Return the article number moved to, or nil if moving was impossible."
12647 (if (and (eq gnus-summary-make-false-root 'dummy)
12648 (gnus-summary-article-intangible-p))
12649 (let ((beg (point)))
12650 (while (and (zerop (forward-line 1))
12651 (not (gnus-summary-article-intangible-p))
12652 (not (zerop (save-excursion
12653 (gnus-summary-thread-level))))))
12659 (let* ((level (gnus-summary-thread-level))
12660 (article (gnus-summary-article-number))
12661 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12664 (if (<= (gnus-data-level (car data)) level)
12665 (setq oart (gnus-data-number (car data))
12667 (setq data (cdr data))))
12669 (gnus-summary-goto-subject oart)))))
12671 (defun gnus-summary-next-thread (n &optional silent)
12672 "Go to the same level next N'th thread.
12673 If N is negative, search backward instead.
12674 Returns the difference between N and the number of skips actually
12677 If SILENT, don't output messages."
12679 (gnus-set-global-variables)
12680 (let ((backward (< n 0))
12683 (while (and (> n 0)
12684 (gnus-summary-go-to-next-thread backward))
12687 (gnus-summary-position-point))
12688 (when (and (not silent) (/= 0 n))
12689 (gnus-message 7 "No more threads"))
12692 (defun gnus-summary-prev-thread (n)
12693 "Go to the same level previous N'th thread.
12694 Returns the difference between N and the number of skips actually
12697 (gnus-set-global-variables)
12698 (gnus-summary-next-thread (- n)))
12700 (defun gnus-summary-go-down-thread ()
12701 "Go down one level in the current thread."
12702 (let ((children (gnus-summary-article-children)))
12704 (gnus-summary-goto-subject (car children)))))
12706 (defun gnus-summary-go-up-thread ()
12707 "Go up one level in the current thread."
12708 (let ((parent (gnus-summary-article-parent)))
12710 (gnus-summary-goto-subject parent))))
12712 (defun gnus-summary-down-thread (n)
12713 "Go down thread N steps.
12714 If N is negative, go up instead.
12715 Returns the difference between N and how many steps down that were
12718 (gnus-set-global-variables)
12721 (while (and (> n 0)
12722 (if up (gnus-summary-go-up-thread)
12723 (gnus-summary-go-down-thread)))
12725 (gnus-summary-position-point)
12726 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12729 (defun gnus-summary-up-thread (n)
12730 "Go up thread N steps.
12731 If N is negative, go up instead.
12732 Returns the difference between N and how many steps down that were
12735 (gnus-set-global-variables)
12736 (gnus-summary-down-thread (- n)))
12738 (defun gnus-summary-top-thread ()
12739 "Go to the top of the thread."
12741 (gnus-set-global-variables)
12742 (while (gnus-summary-go-up-thread))
12743 (gnus-summary-article-number))
12745 (defun gnus-summary-kill-thread (&optional unmark)
12746 "Mark articles under current thread as read.
12747 If the prefix argument is positive, remove any kinds of marks.
12748 If the prefix argument is negative, tick articles instead."
12750 (gnus-set-global-variables)
12752 (setq unmark (prefix-numeric-value unmark)))
12753 (let ((articles (gnus-summary-articles-in-thread)))
12755 ;; Expand the thread.
12756 (gnus-summary-show-thread)
12757 ;; Mark all the articles.
12759 (gnus-summary-goto-subject (car articles))
12760 (cond ((null unmark)
12761 (gnus-summary-mark-article-as-read gnus-killed-mark))
12763 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12765 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12766 (setq articles (cdr articles))))
12767 ;; Hide killed subtrees.
12769 gnus-thread-hide-killed
12770 (gnus-summary-hide-thread))
12771 ;; If marked as read, go to next unread subject.
12773 ;; Go to next unread subject.
12774 (gnus-summary-next-subject 1 t)))
12775 (gnus-set-mode-line 'summary))
12777 ;; Summary sorting commands
12779 (defun gnus-summary-sort-by-number (&optional reverse)
12780 "Sort summary buffer by article number.
12781 Argument REVERSE means reverse order."
12783 (gnus-summary-sort 'number reverse))
12785 (defun gnus-summary-sort-by-author (&optional reverse)
12786 "Sort summary buffer by author name alphabetically.
12787 If case-fold-search is non-nil, case of letters is ignored.
12788 Argument REVERSE means reverse order."
12790 (gnus-summary-sort 'author reverse))
12792 (defun gnus-summary-sort-by-subject (&optional reverse)
12793 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12794 If case-fold-search is non-nil, case of letters is ignored.
12795 Argument REVERSE means reverse order."
12797 (gnus-summary-sort 'subject reverse))
12799 (defun gnus-summary-sort-by-date (&optional reverse)
12800 "Sort summary buffer by date.
12801 Argument REVERSE means reverse order."
12803 (gnus-summary-sort 'date reverse))
12805 (defun gnus-summary-sort-by-score (&optional reverse)
12806 "Sort summary buffer by score.
12807 Argument REVERSE means reverse order."
12809 (gnus-summary-sort 'score reverse))
12811 (defun gnus-summary-sort (predicate reverse)
12812 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12813 (gnus-set-global-variables)
12814 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12815 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12816 (gnus-thread-sort-functions
12821 (,thread t2 t1)))))
12822 (gnus-article-sort-functions
12827 (,article t2 t1)))))
12829 (gnus-summary-prepare-hook nil))
12830 ;; We do the sorting by regenerating the threads.
12831 (gnus-summary-prepare)
12832 ;; Hide subthreads if needed.
12833 (when (and gnus-show-threads gnus-thread-hide-subtree)
12834 (gnus-summary-hide-all-threads)))
12835 ;; If in async mode, we send some info to the backend.
12836 (when gnus-newsgroup-async
12837 (gnus-request-asynchronous
12838 gnus-newsgroup-name gnus-newsgroup-data)))
12840 (defun gnus-sortable-date (date)
12841 "Make sortable string by string-lessp from DATE.
12842 Timezone package is used."
12845 (setq date (inline (timezone-fix-time
12847 (aref (inline (timezone-parse-date date)) 4))))
12849 (timezone-make-sortable-date
12850 (aref date 0) (aref date 1) (aref date 2)
12852 (timezone-make-time-string
12853 (aref date 3) (aref date 4) (aref date 5))))))
12856 ;; Summary saving commands.
12858 (defun gnus-summary-save-article (&optional n not-saved)
12859 "Save the current article using the default saver function.
12860 If N is a positive number, save the N next articles.
12861 If N is a negative number, save the N previous articles.
12862 If N is nil and any articles have been marked with the process mark,
12863 save those articles instead.
12864 The variable `gnus-default-article-saver' specifies the saver function."
12866 (gnus-set-global-variables)
12867 (let ((articles (gnus-summary-work-articles n))
12868 file header article)
12870 (setq header (gnus-summary-article-header
12871 (setq article (pop articles))))
12872 (if (not (vectorp header))
12873 ;; This is a pseudo-article.
12874 (if (assq 'name header)
12875 (gnus-copy-file (cdr (assq 'name header)))
12876 (gnus-message 1 "Article %d is unsaveable" article))
12877 ;; This is a real article.
12878 (save-window-excursion
12879 (gnus-summary-select-article t nil nil article))
12880 (unless gnus-save-all-headers
12881 ;; Remove headers accoring to `gnus-saved-headers'.
12882 (let ((gnus-visible-headers
12883 (or gnus-saved-headers gnus-visible-headers)))
12884 (gnus-article-hide-headers nil t)))
12885 ;; Remove any X-Gnus lines.
12887 (set-buffer gnus-article-buffer)
12889 (let ((buffer-read-only nil))
12890 (nnheader-narrow-to-headers)
12891 (while (re-search-forward "^X-Gnus" nil t)
12892 (gnus-delete-line)))))
12893 (save-window-excursion
12894 (if (not gnus-default-article-saver)
12895 (error "No default saver is defined.")
12896 (setq file (funcall
12897 gnus-default-article-saver
12899 ((not gnus-prompt-before-saving)
12901 ((eq gnus-prompt-before-saving 'always)
12904 (gnus-summary-remove-process-mark article)
12906 (gnus-summary-set-saved-mark article))))
12907 (gnus-summary-position-point)
12910 (defun gnus-summary-pipe-output (&optional arg)
12911 "Pipe the current article to a subprocess.
12912 If N is a positive number, pipe the N next articles.
12913 If N is a negative number, pipe the N previous articles.
12914 If N is nil and any articles have been marked with the process mark,
12915 pipe those articles instead."
12917 (gnus-set-global-variables)
12918 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12919 (gnus-summary-save-article arg t))
12920 (gnus-configure-windows 'pipe))
12922 (defun gnus-summary-save-article-mail (&optional arg)
12923 "Append the current article to an mail file.
12924 If N is a positive number, save the N next articles.
12925 If N is a negative number, save the N previous articles.
12926 If N is nil and any articles have been marked with the process mark,
12927 save those articles instead."
12929 (gnus-set-global-variables)
12930 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12931 (gnus-summary-save-article arg)))
12933 (defun gnus-summary-save-article-rmail (&optional arg)
12934 "Append the current article to an rmail file.
12935 If N is a positive number, save the N next articles.
12936 If N is a negative number, save the N previous articles.
12937 If N is nil and any articles have been marked with the process mark,
12938 save those articles instead."
12940 (gnus-set-global-variables)
12941 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12942 (gnus-summary-save-article arg)))
12944 (defun gnus-summary-save-article-file (&optional arg)
12945 "Append the current article to a file.
12946 If N is a positive number, save the N next articles.
12947 If N is a negative number, save the N previous articles.
12948 If N is nil and any articles have been marked with the process mark,
12949 save those articles instead."
12951 (gnus-set-global-variables)
12952 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12953 (gnus-summary-save-article arg)))
12955 (defun gnus-summary-save-article-body-file (&optional arg)
12956 "Append the current article body to a file.
12957 If N is a positive number, save the N next articles.
12958 If N is a negative number, save the N previous articles.
12959 If N is nil and any articles have been marked with the process mark,
12960 save those articles instead."
12962 (gnus-set-global-variables)
12963 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12964 (gnus-summary-save-article arg)))
12966 (defun gnus-get-split-value (methods)
12967 "Return a value based on the split METHODS."
12968 (let (split-name method result match)
12971 (set-buffer gnus-original-article-buffer)
12973 (nnheader-narrow-to-headers)
12975 (goto-char (point-min))
12976 (setq method (pop methods))
12977 (setq match (car method))
12980 ;; Regular expression.
12982 (re-search-forward match nil t)
12984 ((gnus-functionp match)
12988 (setq result (funcall match gnus-newsgroup-name))))
12993 (setq result (eval match)))))
12994 (setq split-name (append (cdr method) split-name))
12995 (cond ((stringp result)
12996 (push result split-name))
12998 (setq split-name (append result split-name)))))))))
13001 (defun gnus-read-move-group-name (prompt default articles prefix)
13002 "Read a group name."
13003 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13004 (minibuffer-confirm-incomplete nil) ; XEmacs
13011 (assoc (symbol-name
13012 (car (gnus-find-method-for-group
13014 gnus-valid-select-methods))
13015 (push (list (symbol-name g)) group-map)))
13016 gnus-active-hashtb))
13018 (format "%s %s to:"
13020 (if (> (length articles) 1)
13021 (format "these %d articles" (length articles))
13026 (gnus-completing-read default prom
13027 group-map nil nil prefix
13028 'gnus-group-history))
13029 ((= 1 (length split-name))
13030 (gnus-completing-read (car split-name) prom group-map
13032 'gnus-group-history))
13034 (gnus-completing-read nil prom
13035 (mapcar (lambda (el) (list el))
13036 (nreverse split-name))
13038 'gnus-group-history)))))
13040 (if (or (string= to-newsgroup "")
13041 (string= to-newsgroup prefix))
13042 (setq to-newsgroup (or default "")))
13043 (or (gnus-active to-newsgroup)
13044 (gnus-activate-group to-newsgroup)
13045 (error "No such group: %s" to-newsgroup)))
13048 (defun gnus-read-save-file-name (prompt default-name)
13049 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13051 ;; Let the split methods have their say.
13053 ;; No split name was found.
13056 (concat prompt " (default "
13057 (file-name-nondirectory default-name) ") ")
13058 (file-name-directory default-name)
13060 ;; A single split name was found
13061 ((= 1 (length split-name))
13063 (concat prompt " (default " (car split-name) ") ")
13064 gnus-article-save-directory
13065 (concat gnus-article-save-directory (car split-name))))
13066 ;; A list of splits was found.
13068 (setq split-name (nreverse split-name))
13070 (let ((file-name-history (nconc split-name file-name-history)))
13073 (concat prompt " (`M-p' for defaults) ")
13074 gnus-article-save-directory
13075 (car split-name))))
13076 (car (push result file-name-history)))))))
13077 ;; If we have read a directory, we append the default file name.
13078 (when (file-directory-p file)
13079 (setq file (concat (file-name-as-directory file)
13080 (file-name-nondirectory default-name))))
13081 ;; Possibly translate some charaters.
13082 (nnheader-translate-file-chars file)))
13084 (defun gnus-article-archive-name (group)
13085 "Return the first instance of an \"Archive-name\" in the current buffer."
13086 (let ((case-fold-search t))
13087 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13088 (match-string 1))))
13090 (defun gnus-summary-save-in-rmail (&optional filename)
13091 "Append this article to Rmail file.
13092 Optional argument FILENAME specifies file name.
13093 Directory to save to is default to `gnus-article-save-directory'."
13095 (gnus-set-global-variables)
13096 (let ((default-name
13097 (funcall gnus-rmail-save-name gnus-newsgroup-name
13098 gnus-current-headers gnus-newsgroup-last-rmail)))
13100 (cond ((eq filename 'default)
13102 (filename filename)
13103 (t (gnus-read-save-file-name
13104 "Save in rmail file:" default-name))))
13105 (gnus-make-directory (file-name-directory filename))
13106 (gnus-eval-in-buffer-window
13107 gnus-original-article-buffer
13111 (gnus-output-to-rmail filename))))
13112 ;; Remember the directory name to save articles
13113 (setq gnus-newsgroup-last-rmail filename)))
13115 (defun gnus-summary-save-in-mail (&optional filename)
13116 "Append this article to Unix mail file.
13117 Optional argument FILENAME specifies file name.
13118 Directory to save to is default to `gnus-article-save-directory'."
13120 (gnus-set-global-variables)
13121 (let ((default-name
13122 (funcall gnus-mail-save-name gnus-newsgroup-name
13123 gnus-current-headers gnus-newsgroup-last-mail)))
13125 (cond ((eq filename 'default)
13127 (filename filename)
13128 (t (gnus-read-save-file-name
13129 "Save in Unix mail file:" default-name))))
13131 (expand-file-name filename
13133 (file-name-directory default-name))))
13134 (gnus-make-directory (file-name-directory filename))
13135 (gnus-eval-in-buffer-window
13136 gnus-original-article-buffer
13140 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13141 (gnus-output-to-rmail filename)
13142 (let ((mail-use-rfc822 t))
13143 (rmail-output filename 1 t t))))))
13144 ;; Remember the directory name to save articles.
13145 (setq gnus-newsgroup-last-mail filename)))
13147 (defun gnus-summary-save-in-file (&optional filename)
13148 "Append this article to file.
13149 Optional argument FILENAME specifies file name.
13150 Directory to save to is default to `gnus-article-save-directory'."
13152 (gnus-set-global-variables)
13153 (let ((default-name
13154 (funcall gnus-file-save-name gnus-newsgroup-name
13155 gnus-current-headers gnus-newsgroup-last-file)))
13157 (cond ((eq filename 'default)
13159 (filename filename)
13160 (t (gnus-read-save-file-name
13161 "Save in file:" default-name))))
13162 (gnus-make-directory (file-name-directory filename))
13163 (gnus-eval-in-buffer-window
13164 gnus-original-article-buffer
13168 (gnus-output-to-file filename))))
13169 ;; Remember the directory name to save articles.
13170 (setq gnus-newsgroup-last-file filename)))
13172 (defun gnus-summary-save-body-in-file (&optional filename)
13173 "Append this article body to a file.
13174 Optional argument FILENAME specifies file name.
13175 The directory to save in defaults to `gnus-article-save-directory'."
13177 (gnus-set-global-variables)
13178 (let ((default-name
13179 (funcall gnus-file-save-name gnus-newsgroup-name
13180 gnus-current-headers gnus-newsgroup-last-file)))
13182 (cond ((eq filename 'default)
13184 (filename filename)
13185 (t (gnus-read-save-file-name
13186 "Save body in file:" default-name))))
13187 (gnus-make-directory (file-name-directory filename))
13188 (gnus-eval-in-buffer-window
13189 gnus-article-buffer
13193 (goto-char (point-min))
13194 (and (search-forward "\n\n" nil t)
13195 (narrow-to-region (point) (point-max)))
13196 (gnus-output-to-file filename))))
13197 ;; Remember the directory name to save articles.
13198 (setq gnus-newsgroup-last-file filename)))
13200 (defun gnus-summary-save-in-pipe (&optional command)
13201 "Pipe this article to subprocess."
13203 (gnus-set-global-variables)
13205 (cond ((eq command 'default)
13206 gnus-last-shell-command)
13208 (t (read-string "Shell command on article: "
13209 gnus-last-shell-command))))
13210 (if (string-equal command "")
13211 (setq command gnus-last-shell-command))
13212 (gnus-eval-in-buffer-window
13213 gnus-article-buffer
13216 (shell-command-on-region (point-min) (point-max) command nil)))
13217 (setq gnus-last-shell-command command))
13219 ;; Summary extract commands
13221 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13222 (let ((buffer-read-only nil)
13223 (article (gnus-summary-article-number))
13225 (or (gnus-summary-goto-subject article)
13226 (error (format "No such article: %d" article)))
13227 (gnus-summary-position-point)
13228 ;; If all commands are to be bunched up on one line, we collect
13230 (if gnus-view-pseudos-separately
13232 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13235 (setq action (cdr (assq 'action (car ps))))
13236 (setq files (list (cdr (assq 'name (car ps)))))
13237 (while (and ps (cdr ps)
13238 (string= (or action "1")
13239 (or (cdr (assq 'action (cadr ps))) "2")))
13240 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13241 (setcdr ps (cddr ps)))
13244 (if (not (string-match "%s" action))
13245 (setq files (cons " " files)))
13246 (setq files (cons " " files))
13247 (and (assq 'execute (car ps))
13248 (setcdr (assq 'execute (car ps))
13249 (funcall (if (string-match "%s" action)
13252 (mapconcat (lambda (f) f) files " ")))))
13253 (setq ps (cdr ps)))))
13254 (if (and gnus-view-pseudos (not not-view))
13256 (and (assq 'execute (car pslist))
13257 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13258 (eq gnus-view-pseudos 'not-confirm)))
13259 (setq pslist (cdr pslist)))
13262 (setq after-article (or (cdr (assq 'article (car pslist)))
13263 (gnus-summary-article-number)))
13264 (gnus-summary-goto-subject after-article)
13267 (insert " " (file-name-nondirectory
13268 (cdr (assq 'name (car pslist))))
13269 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13271 (forward-line -1) ; back to `b'
13272 (gnus-add-text-properties
13273 b (1- e) (list 'gnus-number gnus-reffed-article-number
13274 gnus-mouse-face-prop gnus-mouse-face))
13276 after-article gnus-reffed-article-number
13277 gnus-unread-mark b (car pslist) 0 (- e b))
13278 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13279 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13280 (setq pslist (cdr pslist)))))))
13282 (defun gnus-pseudos< (p1 p2)
13283 (let ((c1 (cdr (assq 'action p1)))
13284 (c2 (cdr (assq 'action p2))))
13285 (and c1 c2 (string< c1 c2))))
13287 (defun gnus-request-pseudo-article (props)
13288 (cond ((assq 'execute props)
13289 (gnus-execute-command (cdr (assq 'execute props)))))
13290 (let ((gnus-current-article (gnus-summary-article-number)))
13291 (run-hooks 'gnus-mark-article-hook)))
13293 (defun gnus-execute-command (command &optional automatic)
13295 (gnus-article-setup-buffer)
13296 (set-buffer gnus-article-buffer)
13297 (setq buffer-read-only nil)
13298 (let ((command (if automatic command (read-string "Command: " command)))
13299 ;; Just binding this here doesn't help, because there might
13300 ;; be output from the process after exiting the scope of
13302 ;; (buffer-read-only nil)
13305 (insert "$ " command "\n\n")
13306 (if gnus-view-pseudo-asynchronously
13307 (start-process "gnus-execute" nil "sh" "-c" command)
13308 (call-process "sh" nil t nil "-c" command)))))
13310 (defun gnus-copy-file (file &optional to)
13313 (list (read-file-name "Copy file: " default-directory)
13314 (read-file-name "Copy file to: " default-directory)))
13315 (gnus-set-global-variables)
13316 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13317 (and (file-directory-p to)
13318 (setq to (concat (file-name-as-directory to)
13319 (file-name-nondirectory file))))
13320 (copy-file file to))
13322 ;; Summary kill commands.
13324 (defun gnus-summary-edit-global-kill (article)
13325 "Edit the \"global\" kill file."
13326 (interactive (list (gnus-summary-article-number)))
13327 (gnus-set-global-variables)
13328 (gnus-group-edit-global-kill article))
13330 (defun gnus-summary-edit-local-kill ()
13331 "Edit a local kill file applied to the current newsgroup."
13333 (gnus-set-global-variables)
13334 (setq gnus-current-headers (gnus-summary-article-header))
13335 (gnus-set-global-variables)
13336 (gnus-group-edit-local-kill
13337 (gnus-summary-article-number) gnus-newsgroup-name))
13341 ;;; Gnus article mode
13344 (put 'gnus-article-mode 'mode-class 'special)
13346 (if gnus-article-mode-map
13348 (setq gnus-article-mode-map (make-keymap))
13349 (suppress-keymap gnus-article-mode-map)
13351 (gnus-define-keys gnus-article-mode-map
13352 " " gnus-article-goto-next-page
13353 "\177" gnus-article-goto-prev-page
13354 [delete] gnus-article-goto-prev-page
13355 "\C-c^" gnus-article-refer-article
13356 "h" gnus-article-show-summary
13357 "s" gnus-article-show-summary
13358 "\C-c\C-m" gnus-article-mail
13359 "?" gnus-article-describe-briefly
13360 gnus-mouse-2 gnus-article-push-button
13361 "\r" gnus-article-press-button
13362 "\t" gnus-article-next-button
13363 "\M-\t" gnus-article-prev-button
13364 "\C-c\C-b" gnus-bug)
13366 (substitute-key-definition
13367 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13369 (defun gnus-article-mode ()
13370 "Major mode for displaying an article.
13372 All normal editing commands are switched off.
13374 The following commands are available:
13376 \\<gnus-article-mode-map>
13377 \\[gnus-article-next-page]\t Scroll the article one page forwards
13378 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13379 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13380 \\[gnus-article-show-summary]\t Display the summary buffer
13381 \\[gnus-article-mail]\t Send a reply to the address near point
13382 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13383 \\[gnus-info-find-node]\t Go to the Gnus info node"
13385 (when (and menu-bar-mode
13386 (gnus-visual-p 'article-menu 'menu))
13387 (gnus-article-make-menu-bar))
13388 (kill-all-local-variables)
13389 (gnus-simplify-mode-line)
13390 (setq mode-name "Article")
13391 (setq major-mode 'gnus-article-mode)
13392 (make-local-variable 'minor-mode-alist)
13393 (or (assq 'gnus-show-mime minor-mode-alist)
13394 (setq minor-mode-alist
13395 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13396 (use-local-map gnus-article-mode-map)
13397 (make-local-variable 'page-delimiter)
13398 (setq page-delimiter gnus-page-delimiter)
13399 (buffer-disable-undo (current-buffer))
13400 (setq buffer-read-only t) ;Disable modification
13401 (run-hooks 'gnus-article-mode-hook))
13403 (defun gnus-article-setup-buffer ()
13404 "Initialize the article buffer."
13405 (let* ((name (if gnus-single-article-buffer "*Article*"
13406 (concat "*Article " gnus-newsgroup-name "*")))
13408 (progn (string-match "\\*Article" name)
13409 (concat " *Original Article"
13410 (substring name (match-end 0))))))
13411 (setq gnus-article-buffer name)
13412 (setq gnus-original-article-buffer original)
13413 ;; This might be a variable local to the summary buffer.
13414 (unless gnus-single-article-buffer
13416 (set-buffer gnus-summary-buffer)
13417 (setq gnus-article-buffer name)
13418 (setq gnus-original-article-buffer original)
13419 (gnus-set-global-variables))
13420 (make-local-variable 'gnus-summary-buffer))
13421 ;; Init original article buffer.
13423 (set-buffer (get-buffer-create gnus-original-article-buffer))
13424 (buffer-disable-undo (current-buffer))
13425 (setq major-mode 'gnus-original-article-mode)
13426 (make-local-variable 'gnus-original-article))
13427 (if (get-buffer name)
13430 (buffer-disable-undo (current-buffer))
13431 (setq buffer-read-only t)
13432 (gnus-add-current-to-buffer-list)
13433 (or (eq major-mode 'gnus-article-mode)
13434 (gnus-article-mode))
13437 (set-buffer (get-buffer-create name))
13438 (gnus-add-current-to-buffer-list)
13439 (gnus-article-mode)
13440 (current-buffer)))))
13442 ;; Set article window start at LINE, where LINE is the number of lines
13443 ;; from the head of the article.
13444 (defun gnus-article-set-window-start (&optional line)
13446 (get-buffer-window gnus-article-buffer t)
13448 (set-buffer gnus-article-buffer)
13449 (goto-char (point-min))
13452 (gnus-message 6 "Moved to bookmark")
13453 (search-forward "\n\n" nil t)
13454 (forward-line line)
13457 (defun gnus-kill-all-overlays ()
13458 "Delete all overlays in the current buffer."
13459 (when (fboundp 'overlay-lists)
13460 (let* ((overlayss (overlay-lists))
13461 (buffer-read-only nil)
13462 (overlays (nconc (car overlayss) (cdr overlayss))))
13464 (delete-overlay (pop overlays))))))
13466 (defun gnus-request-article-this-buffer (article group)
13467 "Get an article and insert it into this buffer."
13468 (let (do-update-line)
13472 (gnus-kill-all-overlays)
13473 (setq group (or group gnus-newsgroup-name))
13475 ;; Open server if it has closed.
13476 (gnus-check-server (gnus-find-method-for-group group))
13478 ;; Using `gnus-request-article' directly will insert the article into
13479 ;; `nntp-server-buffer' - so we'll save some time by not having to
13480 ;; copy it from the server buffer into the article buffer.
13482 ;; We only request an article by message-id when we do not have the
13483 ;; headers for it, so we'll have to get those.
13484 (when (stringp article)
13485 (let ((gnus-override-method gnus-refer-article-method))
13486 (gnus-read-header article)))
13488 ;; If the article number is negative, that means that this article
13489 ;; doesn't belong in this newsgroup (possibly), so we find its
13490 ;; message-id and request it by id instead of number.
13491 (when (and (numberp article)
13492 gnus-summary-buffer
13493 (get-buffer gnus-summary-buffer)
13494 (buffer-name (get-buffer gnus-summary-buffer)))
13496 (set-buffer gnus-summary-buffer)
13497 (let ((header (gnus-summary-article-header article)))
13500 ((memq article gnus-newsgroup-sparse)
13501 ;; This is a sparse gap article.
13502 (setq do-update-line article)
13503 (setq article (mail-header-id header))
13504 (let ((gnus-override-method gnus-refer-article-method))
13505 (gnus-read-header article))
13506 (setq gnus-newsgroup-sparse
13507 (delq article gnus-newsgroup-sparse)))
13509 ;; It's a real article.
13510 (setq article (mail-header-id header)))
13512 ;; It is an extracted pseudo-article.
13513 (setq article 'pseudo)
13514 (gnus-request-pseudo-article header))))
13516 (let ((method (gnus-find-method-for-group
13517 gnus-newsgroup-name)))
13518 (if (not (eq (car method) 'nneething))
13520 (let ((dir (concat (file-name-as-directory (nth 1 method))
13521 (mail-header-subject header))))
13522 (if (file-directory-p dir)
13524 (setq article 'nneething)
13525 (gnus-group-enter-directory dir)))))))))
13528 ;; Refuse to select canceled articles.
13529 ((and (numberp article)
13530 gnus-summary-buffer
13531 (get-buffer gnus-summary-buffer)
13532 (buffer-name (get-buffer gnus-summary-buffer))
13533 (eq (cdr (save-excursion
13534 (set-buffer gnus-summary-buffer)
13535 (assq article gnus-newsgroup-reads)))
13536 gnus-canceled-mark))
13538 ;; We first check `gnus-original-article-buffer'.
13539 ((and (get-buffer gnus-original-article-buffer)
13542 (set-buffer gnus-original-article-buffer)
13543 (and (equal (car gnus-original-article) group)
13544 (eq (cdr gnus-original-article) article))))
13545 (insert-buffer-substring gnus-original-article-buffer)
13547 ;; Check the backlog.
13548 ((and gnus-keep-backlog
13549 (gnus-backlog-request-article group article (current-buffer)))
13551 ;; Check the cache.
13552 ((and gnus-use-cache
13554 (gnus-cache-request-article article group))
13556 ;; Get the article and put into the article buffer.
13557 ((or (stringp article) (numberp article))
13558 (let ((gnus-override-method
13559 (and (stringp article) gnus-refer-article-method))
13560 (buffer-read-only nil))
13562 (gnus-kill-all-overlays)
13563 (if (gnus-request-article article group (current-buffer))
13565 (and gnus-keep-backlog
13567 (gnus-backlog-enter-article
13568 group article (current-buffer)))
13570 ;; It was a pseudo.
13573 ;; Take the article from the original article buffer
13574 ;; and place it in the buffer it's supposed to be in.
13575 (when (and (get-buffer gnus-article-buffer)
13576 ;;(numberp article)
13577 (equal (buffer-name (current-buffer))
13578 (buffer-name (get-buffer gnus-article-buffer))))
13580 (if (get-buffer gnus-original-article-buffer)
13581 (set-buffer (get-buffer gnus-original-article-buffer))
13582 (set-buffer (get-buffer-create gnus-original-article-buffer))
13583 (buffer-disable-undo (current-buffer))
13584 (setq major-mode 'gnus-original-article-mode)
13585 (setq buffer-read-only t)
13586 (gnus-add-current-to-buffer-list))
13587 (let (buffer-read-only)
13589 (insert-buffer-substring gnus-article-buffer))
13590 (setq gnus-original-article (cons group article))))
13592 ;; Update sparse articles.
13593 (when (and do-update-line
13594 (or (numberp article)
13595 (stringp article)))
13596 (let ((buf (current-buffer)))
13597 (set-buffer gnus-summary-buffer)
13598 (gnus-summary-update-article do-update-line)
13599 (gnus-summary-goto-subject do-update-line nil t)
13600 (set-window-point (get-buffer-window (current-buffer) t)
13602 (set-buffer buf))))))
13604 (defun gnus-read-header (id &optional header)
13605 "Read the headers of article ID and enter them into the Gnus system."
13606 (let ((group gnus-newsgroup-name)
13607 (gnus-override-method
13608 (and (gnus-news-group-p gnus-newsgroup-name)
13609 gnus-refer-article-method))
13611 ;; First we check to see whether the header in question is already
13614 ;; This is a Message-ID.
13615 (setq header (or header (gnus-id-to-header id)))
13616 ;; This is an article number.
13617 (setq header (or header (gnus-summary-article-header id))))
13619 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13620 ;; We have found the header.
13622 ;; We have to really fetch the header to this article.
13624 (if (gnus-check-backend-function 'request-head group)
13625 (gnus-request-head id group)
13626 (gnus-request-article id group)))
13628 (set-buffer nntp-server-buffer)
13629 (and (search-forward "\n\n" nil t)
13630 (delete-region (1- (point)) (point-max)))
13631 (goto-char (point-max))
13633 (goto-char (point-min))
13637 ((cdr where) (cdr where))
13638 (header (mail-header-number header))
13639 (t gnus-reffed-article-number))
13641 (insert " Article retrieved.\n"))
13643 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13644 ; (setcar (gnus-id-to-thread id) nil))
13645 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13646 () ; Malformed head.
13647 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13648 (if (and (stringp id)
13649 (not (string= (gnus-group-real-name group)
13651 ;; If we fetched by Message-ID and the article came
13652 ;; from a different group, we fudge some bogus article
13653 ;; numbers for this article.
13654 (mail-header-set-number header gnus-reffed-article-number))
13655 (decf gnus-reffed-article-number)
13656 (push header gnus-newsgroup-headers)
13657 (setq gnus-current-headers header)
13658 (push (mail-header-number header) gnus-newsgroup-limit))
13661 (defun gnus-article-prepare (article &optional all-headers header)
13662 "Prepare ARTICLE in article mode buffer.
13663 ARTICLE should either be an article number or a Message-ID.
13664 If ARTICLE is an id, HEADER should be the article headers.
13665 If ALL-HEADERS is non-nil, no headers are hidden."
13667 ;; Make sure we start in a summary buffer.
13668 (unless (eq major-mode 'gnus-summary-mode)
13669 (set-buffer gnus-summary-buffer))
13670 (setq gnus-summary-buffer (current-buffer))
13671 ;; Make sure the connection to the server is alive.
13672 (unless (gnus-server-opened
13673 (gnus-find-method-for-group gnus-newsgroup-name))
13674 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13675 (gnus-request-group gnus-newsgroup-name t))
13676 (let* ((article (if header (mail-header-number header) article))
13677 (summary-buffer (current-buffer))
13678 (internal-hook gnus-article-internal-prepare-hook)
13679 (group gnus-newsgroup-name)
13682 (gnus-article-setup-buffer)
13683 (set-buffer gnus-article-buffer)
13684 ;; Deactivate active regions.
13685 (when (and (boundp 'transient-mark-mode)
13686 transient-mark-mode)
13687 (setq mark-active nil))
13688 (if (not (setq result (let ((buffer-read-only nil))
13689 (gnus-request-article-this-buffer
13691 ;; There is no such article.
13693 (when (and (numberp article)
13694 (not (memq article gnus-newsgroup-sparse)))
13695 (setq gnus-article-current
13696 (cons gnus-newsgroup-name article))
13697 (set-buffer gnus-summary-buffer)
13698 (setq gnus-current-article article)
13699 (gnus-summary-mark-article article gnus-canceled-mark))
13700 (unless (memq article gnus-newsgroup-sparse)
13702 1 "No such article (may have expired or been canceled)")))
13703 (if (or (eq result 'pseudo) (eq result 'nneething))
13706 (set-buffer summary-buffer)
13707 (setq gnus-last-article gnus-current-article
13708 gnus-newsgroup-history (cons gnus-current-article
13709 gnus-newsgroup-history)
13710 gnus-current-article 0
13711 gnus-current-headers nil
13712 gnus-article-current nil)
13713 (if (eq result 'nneething)
13714 (gnus-configure-windows 'summary)
13715 (gnus-configure-windows 'article))
13716 (gnus-set-global-variables))
13717 (gnus-set-mode-line 'article))
13718 ;; The result from the `request' was an actual article -
13719 ;; or at least some text that is now displayed in the
13721 (if (and (numberp article)
13722 (not (eq article gnus-current-article)))
13723 ;; Seems like a new article has been selected.
13724 ;; `gnus-current-article' must be an article number.
13726 (set-buffer summary-buffer)
13727 (setq gnus-last-article gnus-current-article
13728 gnus-newsgroup-history (cons gnus-current-article
13729 gnus-newsgroup-history)
13730 gnus-current-article article
13731 gnus-current-headers
13732 (gnus-summary-article-header gnus-current-article)
13733 gnus-article-current
13734 (cons gnus-newsgroup-name gnus-current-article))
13735 (unless (vectorp gnus-current-headers)
13736 (setq gnus-current-headers nil))
13737 (gnus-summary-show-thread)
13738 (run-hooks 'gnus-mark-article-hook)
13739 (gnus-set-mode-line 'summary)
13740 (and (gnus-visual-p 'article-highlight 'highlight)
13741 (run-hooks 'gnus-visual-mark-article-hook))
13742 ;; Set the global newsgroup variables here.
13743 ;; Suggested by Jim Sisolak
13744 ;; <sisolak@trans4.neep.wisc.edu>.
13745 (gnus-set-global-variables)
13746 (setq gnus-have-all-headers
13747 (or all-headers gnus-show-all-headers))
13748 (and gnus-use-cache
13749 (vectorp (gnus-summary-article-header article))
13750 (gnus-cache-possibly-enter-article
13752 (gnus-summary-article-header article)
13753 (memq article gnus-newsgroup-marked)
13754 (memq article gnus-newsgroup-dormant)
13755 (memq article gnus-newsgroup-unreads)))))
13756 (when (or (numberp article)
13758 ;; Hooks for getting information from the article.
13759 ;; This hook must be called before being narrowed.
13760 (let (buffer-read-only)
13761 (run-hooks 'internal-hook)
13762 (run-hooks 'gnus-article-prepare-hook)
13763 ;; Decode MIME message.
13765 (if (or (not gnus-strict-mime)
13766 (gnus-fetch-field "Mime-Version"))
13767 (funcall gnus-show-mime-method)
13768 (funcall gnus-decode-encoded-word-method)))
13769 ;; Perform the article display hooks.
13770 (run-hooks 'gnus-article-display-hook))
13772 (goto-char (point-min))
13773 (and gnus-break-pages (gnus-narrow-to-page)))
13774 (gnus-set-mode-line 'article)
13775 (gnus-configure-windows 'article)
13776 (goto-char (point-min))
13779 (defun gnus-article-show-all-headers ()
13780 "Show all article headers in article mode buffer."
13782 (gnus-article-setup-buffer)
13783 (set-buffer gnus-article-buffer)
13784 (let ((buffer-read-only nil))
13785 (gnus-unhide-text (point-min) (point-max)))))
13787 (defun gnus-article-hide-headers-if-wanted ()
13788 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13789 Provided for backwards compatibility."
13790 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13791 gnus-inhibit-hiding
13792 (gnus-article-hide-headers)))
13794 (defsubst gnus-article-header-rank ()
13795 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13796 (let ((list gnus-sorted-header-list)
13799 (when (looking-at (car list))
13801 (setq list (cdr list))
13805 (defun gnus-article-hide-headers (&optional arg delete)
13806 "Toggle whether to hide unwanted headers and possibly sort them as well.
13807 If given a negative prefix, always show; if given a positive prefix,
13810 (if (gnus-article-check-hidden-text 'headers arg)
13811 ;; Show boring headers as well.
13812 (gnus-article-show-hidden-text 'boring-headers)
13813 ;; This function might be inhibited.
13814 (unless gnus-inhibit-hiding
13816 (set-buffer gnus-article-buffer)
13818 (let ((buffer-read-only nil)
13819 (props (nconc (list 'gnus-type 'headers)
13820 gnus-hidden-properties))
13821 (max (1+ (length gnus-sorted-header-list)))
13822 (ignored (when (not (stringp gnus-visible-headers))
13823 (cond ((stringp gnus-ignored-headers)
13824 gnus-ignored-headers)
13825 ((listp gnus-ignored-headers)
13826 (mapconcat 'identity gnus-ignored-headers
13829 (cond ((stringp gnus-visible-headers)
13830 gnus-visible-headers)
13831 ((and gnus-visible-headers
13832 (listp gnus-visible-headers))
13833 (mapconcat 'identity gnus-visible-headers "\\|"))))
13835 ;; First we narrow to just the headers.
13837 (goto-char (point-min))
13838 ;; Hide any "From " lines at the beginning of (mail) articles.
13839 (while (looking-at "From ")
13842 (gnus-hide-text (point-min) (point) props))
13843 ;; Then treat the rest of the header lines.
13846 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13847 ;; Then we use the two regular expressions
13848 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13849 ;; select which header lines is to remain visible in the
13851 (goto-char (point-min))
13852 (while (re-search-forward "^[^ \t]*:" nil t)
13853 (beginning-of-line)
13854 ;; We add the headers we want to keep to a list and delete
13855 ;; them from the buffer.
13856 (gnus-put-text-property
13857 (point) (1+ (point)) 'message-rank
13858 (if (or (and visible (looking-at visible))
13860 (not (looking-at ignored))))
13861 (gnus-article-header-rank)
13864 (message-sort-headers-1)
13865 (when (setq beg (text-property-any
13866 (point-min) (point-max) 'message-rank (+ 2 max)))
13867 ;; We make the unwanted headers invisible.
13869 (delete-region beg (point-max))
13870 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13871 (gnus-hide-text-type beg (point-max) 'headers))
13872 ;; Work around XEmacs lossage.
13873 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
13875 (defun gnus-article-hide-boring-headers (&optional arg)
13876 "Toggle hiding of headers that aren't very interesting.
13877 If given a negative prefix, always show; if given a positive prefix,
13880 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13882 (set-buffer gnus-article-buffer)
13884 (let ((buffer-read-only nil)
13885 (list gnus-boring-article-headers)
13886 (inhibit-point-motion-hooks t)
13888 (nnheader-narrow-to-headers)
13890 (setq elem (pop list))
13891 (goto-char (point-min))
13893 ;; Hide empty headers.
13895 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13897 (gnus-hide-text-type
13898 (progn (beginning-of-line) (point))
13901 (if (re-search-forward "^[^ \t]" nil t)
13902 (match-beginning 0)
13905 ;; Hide boring Newsgroups header.
13906 ((eq elem 'newsgroups)
13907 (when (equal (message-fetch-field "newsgroups")
13908 (gnus-group-real-name gnus-newsgroup-name))
13909 (gnus-article-hide-header "newsgroups")))
13910 ((eq elem 'followup-to)
13911 (when (equal (message-fetch-field "followup-to")
13912 (message-fetch-field "newsgroups"))
13913 (gnus-article-hide-header "followup-to")))
13914 ((eq elem 'reply-to)
13915 (let ((from (message-fetch-field "from"))
13916 (reply-to (message-fetch-field "reply-to")))
13920 (nth 1 (funcall gnus-extract-address-components from))
13921 (nth 1 (funcall gnus-extract-address-components
13923 (gnus-article-hide-header "reply-to"))))
13925 (let ((date (message-fetch-field "date")))
13927 (< (gnus-days-between date (current-time-string))
13929 (gnus-article-hide-header "date")))))))))))
13931 (defun gnus-article-hide-header (header)
13933 (goto-char (point-min))
13934 (when (re-search-forward (concat "^" header ":") nil t)
13935 (gnus-hide-text-type
13936 (progn (beginning-of-line) (point))
13939 (if (re-search-forward "^[^ \t]" nil t)
13940 (match-beginning 0)
13942 'boring-headers))))
13944 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13945 (defun gnus-article-treat-overstrike ()
13946 "Translate overstrikes into bold text."
13949 (set-buffer gnus-article-buffer)
13950 (let ((buffer-read-only nil))
13951 (while (search-forward "\b" nil t)
13952 (let ((next (following-char))
13953 (previous (char-after (- (point) 2))))
13954 (cond ((eq next previous)
13955 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
13956 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
13958 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
13959 (gnus-put-text-property
13960 (- (point) 2) (1- (point)) 'face 'underline))
13962 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
13963 (gnus-put-text-property
13964 (point) (1+ (point)) 'face 'underline))))))))
13966 (defun gnus-article-word-wrap ()
13967 "Format too long lines."
13970 (set-buffer gnus-article-buffer)
13971 (let ((buffer-read-only nil))
13973 (goto-char (point-min))
13974 (search-forward "\n\n" nil t)
13976 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13977 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13978 (adaptive-fill-mode t))
13979 (while (not (eobp))
13980 (and (>= (current-column) (min fill-column (window-width)))
13981 (/= (preceding-char) ?:)
13982 (fill-paragraph nil))
13983 (end-of-line 2))))))
13985 (defun gnus-article-remove-cr ()
13986 "Remove carriage returns from an article."
13989 (set-buffer gnus-article-buffer)
13990 (let ((buffer-read-only nil))
13991 (goto-char (point-min))
13992 (while (search-forward "\r" nil t)
13993 (replace-match "" t t)))))
13995 (defun gnus-article-remove-trailing-blank-lines ()
13996 "Remove all trailing blank lines from the article."
13999 (set-buffer gnus-article-buffer)
14000 (let ((buffer-read-only nil))
14001 (goto-char (point-max))
14005 (while (looking-at "^[ \t]*$")
14010 (defun gnus-article-display-x-face (&optional force)
14011 "Look for an X-Face header and display it if present."
14012 (interactive (list 'force))
14014 (set-buffer gnus-article-buffer)
14015 ;; Delete the old process, if any.
14016 (when (process-status "gnus-x-face")
14017 (delete-process "gnus-x-face"))
14018 (let ((inhibit-point-motion-hooks t)
14019 (case-fold-search nil)
14022 (nnheader-narrow-to-headers)
14023 (setq from (message-fetch-field "from"))
14024 (goto-char (point-min))
14025 (when (and gnus-article-x-face-command
14027 ;; Check whether this face is censored.
14028 (not gnus-article-x-face-too-ugly)
14029 (and gnus-article-x-face-too-ugly from
14030 (not (string-match gnus-article-x-face-too-ugly
14032 ;; Has to be present.
14033 (re-search-forward "^X-Face: " nil t))
14034 ;; We now have the area of the buffer where the X-Face is stored.
14035 (let ((beg (point))
14036 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14037 ;; We display the face.
14038 (if (symbolp gnus-article-x-face-command)
14039 ;; The command is a lisp function, so we call it.
14040 (if (gnus-functionp gnus-article-x-face-command)
14041 (funcall gnus-article-x-face-command beg end)
14042 (error "%s is not a function" gnus-article-x-face-command))
14043 ;; The command is a string, so we interpret the command
14044 ;; as a, well, command, and fork it off.
14045 (let ((process-connection-type nil))
14046 (process-kill-without-query
14048 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
14049 (process-send-region "gnus-x-face" beg end)
14050 (process-send-eof "gnus-x-face")))))))))
14052 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14053 (defun gnus-decode-rfc1522 ()
14054 "Hack to remove QP encoding from headers."
14055 (let ((case-fold-search t)
14056 (inhibit-point-motion-hooks t)
14057 (buffer-read-only nil)
14061 (goto-char (point-min))
14062 (or (search-forward "\n\n" nil t) (point-max)))
14064 (while (re-search-forward
14065 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14066 (setq string (match-string 1))
14067 (narrow-to-region (match-beginning 0) (match-end 0))
14068 (delete-region (point-min) (point-max))
14070 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14071 (subst-char-in-region (point-min) (point-max) ?_ ? )
14073 (goto-char (point-min))))))
14075 (defun gnus-article-de-quoted-unreadable (&optional force)
14076 "Do a naive translation of a quoted-printable-encoded article.
14077 This is in no way, shape or form meant as a replacement for real MIME
14078 processing, but is simply a stop-gap measure until MIME support is
14080 If FORCE, decode the article whether it is marked as quoted-printable
14082 (interactive (list 'force))
14084 (set-buffer gnus-article-buffer)
14085 (let ((case-fold-search t)
14086 (buffer-read-only nil)
14087 (type (gnus-fetch-field "content-transfer-encoding")))
14088 (gnus-decode-rfc1522)
14090 (and type (string-match "quoted-printable" (downcase type))))
14091 (goto-char (point-min))
14092 (search-forward "\n\n" nil 'move)
14093 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14095 (defun gnus-mime-decode-quoted-printable (from to)
14096 "Decode Quoted-Printable in the region between FROM and TO."
14099 (while (search-forward "=" to t)
14100 (cond ((eq (following-char) ?\n)
14103 ((looking-at "[0-9A-F][0-9A-F]")
14104 (subst-char-in-region
14105 (1- (point)) (point) ?=
14106 (hexl-hex-string-to-integer
14107 (buffer-substring (point) (+ 2 (point)))))
14111 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14113 (defun gnus-article-hide-pgp (&optional arg)
14114 "Toggle hiding of any PGP headers and signatures in the current article.
14115 If given a negative prefix, always show; if given a positive prefix,
14118 (unless (gnus-article-check-hidden-text 'pgp arg)
14120 (set-buffer gnus-article-buffer)
14121 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14122 buffer-read-only beg end)
14124 (goto-char (point-min))
14125 ;; Hide the "header".
14126 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14127 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14129 ;; Hide the actual signature.
14130 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14131 (setq end (1+ (match-beginning 0)))
14134 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14136 ;; Perhaps we shouldn't hide to the end of the buffer
14137 ;; if there is no end to the signature?
14140 ;; Hide "- " PGP quotation markers.
14141 (when (and beg end)
14142 (narrow-to-region beg end)
14143 (goto-char (point-min))
14144 (while (re-search-forward "^- " nil t)
14145 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14148 (defun gnus-article-hide-signature (&optional arg)
14149 "Hide the signature in the current article.
14150 If given a negative prefix, always show; if given a positive prefix,
14153 (unless (gnus-article-check-hidden-text 'signature arg)
14155 (set-buffer gnus-article-buffer)
14157 (let ((buffer-read-only nil))
14158 (when (gnus-narrow-to-signature)
14159 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14161 (defun gnus-article-strip-leading-blank-lines ()
14162 "Remove all blank lines from the beginning of the article."
14165 (set-buffer gnus-article-buffer)
14166 (let (buffer-read-only)
14167 (goto-char (point-min))
14168 (when (search-forward "\n\n" nil t)
14169 (while (looking-at "[ \t]$")
14170 (gnus-delete-line))))))
14172 (defvar mime::preview/content-list)
14173 (defvar mime::preview-content-info/point-min)
14174 (defun gnus-narrow-to-signature ()
14175 "Narrow to the signature."
14177 (if (and (boundp 'mime::preview/content-list)
14178 mime::preview/content-list)
14179 (let ((pcinfo (car (last mime::preview/content-list))))
14181 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14184 (goto-char (point-max))
14185 (when (re-search-backward gnus-signature-separator nil t)
14187 (when (or (null gnus-signature-limit)
14188 (and (numberp gnus-signature-limit)
14189 (< (- (point-max) (point)) gnus-signature-limit))
14190 (and (gnus-functionp gnus-signature-limit)
14191 (funcall gnus-signature-limit))
14192 (and (stringp gnus-signature-limit)
14193 (not (re-search-forward gnus-signature-limit nil t))))
14194 (narrow-to-region (point) (point-max))
14197 (defun gnus-article-check-hidden-text (type arg)
14198 "Return nil if hiding is necessary."
14200 (set-buffer gnus-article-buffer)
14201 (let ((hide (gnus-article-hidden-text-p type)))
14202 (cond ((or (and (null arg) (eq hide 'hidden))
14203 (and arg (< 0 (prefix-numeric-value arg))))
14204 (gnus-article-show-hidden-text type))
14206 (gnus-article-show-hidden-text type t))
14209 (defun gnus-article-hidden-text-p (type)
14210 "Say whether the current buffer contains hidden text of type TYPE."
14211 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14213 (if (get-text-property pos 'invisible)
14217 (defun gnus-article-hide (&optional arg force)
14218 "Hide all the gruft in the current article.
14219 This means that PGP stuff, signatures, cited text and (some)
14220 headers will be hidden.
14221 If given a prefix, show the hidden text instead."
14222 (interactive (list current-prefix-arg 'force))
14223 (gnus-article-hide-headers arg)
14224 (gnus-article-hide-pgp arg)
14225 (gnus-article-hide-citation-maybe arg force)
14226 (gnus-article-hide-signature arg))
14228 (defun gnus-article-show-hidden-text (type &optional hide)
14229 "Show all hidden text of type TYPE.
14230 If HIDE, hide the text instead."
14232 (set-buffer gnus-article-buffer)
14233 (let ((buffer-read-only nil)
14234 (inhibit-point-motion-hooks t)
14236 (while (gnus-goto-char (text-property-any
14237 beg (point-max) 'gnus-type type))
14241 (gnus-hide-text beg (point) gnus-hidden-properties)
14242 (gnus-unhide-text beg (point)))
14243 (setq beg (point)))
14246 (defvar gnus-article-time-units
14247 `((year . ,(* 365.25 24 60 60))
14248 (week . ,(* 7 24 60 60))
14249 (day . ,(* 24 60 60))
14250 (hour . ,(* 60 60))
14253 "Mapping from time units to seconds.")
14255 (defun gnus-article-date-ut (&optional type highlight)
14256 "Convert DATE date to universal time in the current article.
14257 If TYPE is `local', convert to local time; if it is `lapsed', output
14258 how much time has lapsed since DATE."
14259 (interactive (list 'ut t))
14260 (let* ((header (or gnus-current-headers
14261 (gnus-summary-article-header) ""))
14262 (date (and (vectorp header) (mail-header-date header)))
14263 (date-regexp "^Date: \\|^X-Sent: ")
14264 (now (current-time))
14265 (inhibit-point-motion-hooks t)
14267 (when (and date (not (string= date "")))
14269 (set-buffer gnus-article-buffer)
14271 (nnheader-narrow-to-headers)
14272 (let ((buffer-read-only nil))
14273 ;; Delete any old Date headers.
14274 (if (re-search-forward date-regexp nil t)
14276 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14277 eface (get-text-property (1- (gnus-point-at-eol))
14279 (message-remove-header date-regexp t)
14280 (beginning-of-line))
14281 (goto-char (point-max)))
14282 (insert (gnus-make-date-line date type))
14283 ;; Do highlighting.
14285 (when (and (gnus-visual-p 'article-highlight 'highlight)
14286 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14287 (gnus-put-text-property (match-beginning 1) (match-end 1)
14289 (gnus-put-text-property (match-beginning 2) (match-end 2)
14290 'face eface))))))))
14292 (defun gnus-make-date-line (date type)
14293 "Return a DATE line of TYPE."
14295 ;; Convert to the local timezone. We have to slap a
14296 ;; `condition-case' round the calls to the timezone
14297 ;; functions since they aren't particularly resistant to
14300 (concat "Date: " (condition-case ()
14301 (timezone-make-date-arpa-standard date)
14304 ;; Convert to Universal Time.
14308 (timezone-make-date-arpa-standard date nil "UT")
14311 ;; Get the original date from the article.
14312 ((eq type 'original)
14313 (concat "Date: " date "\n"))
14314 ;; Do an X-Sent lapsed format.
14316 ;; If the date is seriously mangled, the timezone
14317 ;; functions are liable to bug out, so we condition-case
14318 ;; the entire thing.
14319 (let* ((now (current-time))
14324 (timezone-make-date-arpa-standard
14325 (current-time-string now)
14326 (current-time-zone now) "UT"))
14328 (timezone-make-date-arpa-standard
14331 (real-sec (+ (* (float (car real-time)) 65536)
14333 (sec (abs real-sec))
14336 ((equal real-time '(0 0))
14337 "X-Sent: Unknown\n")
14343 ;; This is a bit convoluted, but basically we go
14344 ;; through the time units for years, weeks, etc,
14345 ;; and divide things to see whether that results
14346 ;; in positive answers.
14349 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14350 ;; The (remaining) seconds are too few to
14351 ;; be divided into this time unit.
14353 ;; It's big enough, so we output it.
14354 (setq sec (- sec (* num (cdr unit))))
14356 (concat (if prev ", " "") (int-to-string
14358 " " (symbol-name (car unit))
14359 (if (> num 1) "s" ""))
14361 gnus-article-time-units "")
14362 ;; If dates are odd, then it might appear like the
14363 ;; article was sent in the future.
14366 " in the future\n"))))))
14368 (error "Unknown conversion type: %s" type))))
14370 (defun gnus-article-date-local (&optional highlight)
14371 "Convert the current article date to the local timezone."
14372 (interactive (list t))
14373 (gnus-article-date-ut 'local highlight))
14375 (defun gnus-article-date-original (&optional highlight)
14376 "Convert the current article date to what it was originally.
14377 This is only useful if you have used some other date conversion
14378 function and want to see what the date was before converting."
14379 (interactive (list t))
14380 (gnus-article-date-ut 'original highlight))
14382 (defun gnus-article-date-lapsed (&optional highlight)
14383 "Convert the current article date to time lapsed since it was sent."
14384 (interactive (list t))
14385 (gnus-article-date-ut 'lapsed highlight))
14387 (defun gnus-article-maybe-highlight ()
14388 "Do some article highlighting if `gnus-visual' is non-nil."
14389 (if (gnus-visual-p 'article-highlight 'highlight)
14390 (gnus-article-highlight-some)))
14394 (defun gnus-output-to-rmail (file-name)
14395 "Append the current article to an Rmail file named FILE-NAME."
14397 ;; Most of these codes are borrowed from rmailout.el.
14398 (setq file-name (expand-file-name file-name))
14399 (setq rmail-default-rmail-file file-name)
14400 (let ((artbuf (current-buffer))
14401 (tmpbuf (get-buffer-create " *Gnus-output*")))
14403 (or (get-file-buffer file-name)
14404 (file-exists-p file-name)
14405 (if (gnus-yes-or-no-p
14406 (concat "\"" file-name "\" does not exist, create it? "))
14407 (let ((file-buffer (create-file-buffer file-name)))
14409 (set-buffer file-buffer)
14410 (rmail-insert-rmail-file-header)
14411 (let ((require-final-newline nil))
14412 (write-region (point-min) (point-max) file-name t 1)))
14413 (kill-buffer file-buffer))
14414 (error "Output file does not exist")))
14415 (set-buffer tmpbuf)
14416 (buffer-disable-undo (current-buffer))
14418 (insert-buffer-substring artbuf)
14419 (gnus-convert-article-to-rmail)
14420 ;; Decide whether to append to a file or to an Emacs buffer.
14421 (let ((outbuf (get-file-buffer file-name)))
14423 (append-to-file (point-min) (point-max) file-name)
14424 ;; File has been visited, in buffer OUTBUF.
14425 (set-buffer outbuf)
14426 (let ((buffer-read-only nil)
14427 (msg (and (boundp 'rmail-current-message)
14428 (symbol-value 'rmail-current-message))))
14429 ;; If MSG is non-nil, buffer is in RMAIL mode.
14432 (narrow-to-region (point-max) (point-max))))
14433 (insert-buffer-substring tmpbuf)
14436 (goto-char (point-min))
14438 (search-backward "\^_")
14439 (narrow-to-region (point) (point-max))
14440 (goto-char (1+ (point-min)))
14441 (rmail-count-new-messages t)
14442 (rmail-show-message msg)))))))
14443 (kill-buffer tmpbuf)))
14445 (defun gnus-output-to-file (file-name)
14446 "Append the current article to a file named FILE-NAME."
14447 (setq file-name (expand-file-name file-name))
14448 (let ((artbuf (current-buffer))
14449 (tmpbuf (get-buffer-create " *Gnus-output*")))
14451 (set-buffer tmpbuf)
14452 (buffer-disable-undo (current-buffer))
14454 (insert-buffer-substring artbuf)
14455 ;; Append newline at end of the buffer as separator, and then
14456 ;; save it to file.
14457 (goto-char (point-max))
14459 (append-to-file (point-min) (point-max) file-name))
14460 (kill-buffer tmpbuf)))
14462 (defun gnus-convert-article-to-rmail ()
14463 "Convert article in current buffer to Rmail message format."
14464 (let ((buffer-read-only nil))
14465 ;; Convert article directly into Babyl format.
14466 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14467 (goto-char (point-min))
14468 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14469 (while (search-forward "\n\^_" nil t) ;single char
14470 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14471 (goto-char (point-max))
14474 (defun gnus-narrow-to-page (&optional arg)
14475 "Narrow the article buffer to a page.
14476 If given a numerical ARG, move forward ARG pages."
14478 (setq arg (if arg (prefix-numeric-value arg) 0))
14480 (set-buffer gnus-article-buffer)
14481 (goto-char (point-min))
14483 (when (gnus-visual-p 'page-marker)
14484 (let ((buffer-read-only nil))
14485 (gnus-remove-text-with-property 'gnus-prev)
14486 (gnus-remove-text-with-property 'gnus-next)))
14489 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14491 (re-search-forward page-delimiter nil 'move arg)))
14492 (goto-char (match-end 0)))
14495 (if (re-search-forward page-delimiter nil 'move)
14496 (match-beginning 0)
14498 (when (and (gnus-visual-p 'page-marker)
14499 (not (= (point-min) 1)))
14501 (goto-char (point-min))
14502 (gnus-insert-prev-page-button)))
14503 (when (and (gnus-visual-p 'page-marker)
14504 (not (= (1- (point-max)) (buffer-size))))
14506 (goto-char (point-max))
14507 (gnus-insert-next-page-button)))))
14509 ;; Article mode commands
14511 (defun gnus-article-goto-next-page ()
14512 "Show the next page of the article."
14514 (when (gnus-article-next-page)
14515 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14517 (defun gnus-article-goto-prev-page ()
14518 "Show the next page of the article."
14520 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14521 (gnus-article-prev-page nil)))
14523 (defun gnus-article-next-page (&optional lines)
14524 "Show the next page of the current article.
14525 If end of article, return non-nil. Otherwise return nil.
14526 Argument LINES specifies lines to be scrolled up."
14528 (move-to-window-line -1)
14529 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14530 (if (save-excursion
14532 (and (pos-visible-in-window-p) ;Not continuation line.
14534 ;; Nothing in this page.
14535 (if (or (not gnus-break-pages)
14538 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14540 (gnus-narrow-to-page 1) ;Go to next page.
14542 ;; More in this page.
14546 ;; Long lines may cause an end-of-buffer error.
14547 (goto-char (point-max))))
14548 (move-to-window-line 0)
14551 (defun gnus-article-prev-page (&optional lines)
14552 "Show previous page of current article.
14553 Argument LINES specifies lines to be scrolled down."
14555 (move-to-window-line 0)
14556 (if (and gnus-break-pages
14558 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14560 (gnus-narrow-to-page -1) ;Go to previous page.
14561 (goto-char (point-max))
14565 (scroll-down lines)
14567 (move-to-window-line 0))))
14569 (defun gnus-article-refer-article ()
14570 "Read article specified by message-id around point."
14572 (let ((point (point)))
14573 (search-forward ">" nil t) ;Move point to end of "<....>".
14574 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14575 (let ((message-id (match-string 1)))
14577 (set-buffer gnus-summary-buffer)
14578 (gnus-summary-refer-article message-id))
14579 (goto-char (point))
14580 (error "No references around point"))))
14582 (defun gnus-article-show-summary ()
14583 "Reconfigure windows to show summary buffer."
14585 (gnus-configure-windows 'article)
14586 (gnus-summary-goto-subject gnus-current-article))
14588 (defun gnus-article-describe-briefly ()
14589 "Describe article mode commands briefly."
14592 (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")))
14594 (defun gnus-article-summary-command ()
14595 "Execute the last keystroke in the summary buffer."
14597 (let ((obuf (current-buffer))
14598 (owin (current-window-configuration))
14600 (switch-to-buffer gnus-summary-buffer 'norecord)
14601 (setq func (lookup-key (current-local-map) (this-command-keys)))
14602 (call-interactively func)
14604 (set-window-configuration owin)
14605 (set-window-point (get-buffer-window (current-buffer)) (point))))
14607 (defun gnus-article-summary-command-nosave ()
14608 "Execute the last keystroke in the summary buffer."
14611 (pop-to-buffer gnus-summary-buffer 'norecord)
14612 (setq func (lookup-key (current-local-map) (this-command-keys)))
14613 (call-interactively func)))
14615 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14616 "Read a summary buffer key sequence and execute it from the article buffer."
14619 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14620 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14624 (set-buffer gnus-summary-buffer)
14625 (push (or key last-command-event) unread-command-events)
14626 (setq keys (read-key-sequence nil)))
14629 (if (member keys nosaves)
14631 (pop-to-buffer gnus-summary-buffer 'norecord)
14632 (if (setq func (lookup-key (current-local-map) keys))
14633 (call-interactively func)
14635 (let ((obuf (current-buffer))
14636 (owin (current-window-configuration))
14639 (if not-restore-window
14640 (pop-to-buffer gnus-summary-buffer 'norecord)
14641 (switch-to-buffer gnus-summary-buffer 'norecord))
14642 (setq in-buffer (current-buffer))
14643 (if (setq func (lookup-key (current-local-map) keys))
14644 (call-interactively func)
14646 (when (eq in-buffer (current-buffer))
14648 (unless not-restore-window
14649 (set-window-configuration owin))
14650 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14654 ;;; Kill file handling.
14658 (defalias 'gnus-batch-kill 'gnus-batch-score)
14660 (defun gnus-batch-score ()
14661 "Run batched scoring.
14662 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14663 Newsgroups is a list of strings in Bnews format. If you want to score
14664 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14665 score the alt hierarchy, you'd say \"!alt.all\"."
14668 (gnus-newsrc-parse-options
14669 (apply (function concat)
14670 (mapcar (lambda (g) (concat g " "))
14671 command-line-args-left))))
14672 (gnus-expert-user t)
14673 (nnmail-spool-file nil)
14674 (gnus-use-dribble-file nil)
14675 (yes (car yes-and-no))
14676 (no (cdr yes-and-no))
14678 ;; Disable verbose message.
14679 gnus-novice-user gnus-large-newsgroup)
14680 ;; Eat all arguments.
14681 (setq command-line-args-left nil)
14684 ;; Apply kills to specified newsgroups in command line arguments.
14685 (setq newsrc (cdr gnus-newsrc-alist))
14687 (setq group (caar newsrc))
14688 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14689 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14691 (or (eq (car entry) t)
14692 (not (zerop (car entry)))))
14693 (if yes (string-match yes group) t)
14694 (or (null no) (not (string-match no group))))
14696 (gnus-summary-read-group group nil t nil t)
14697 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14698 (gnus-summary-exit))))
14699 (setq newsrc (cdr newsrc)))
14701 (switch-to-buffer gnus-group-buffer)
14702 (gnus-group-save-newsrc)))
14704 (defun gnus-apply-kill-file ()
14705 "Apply a kill file to the current newsgroup.
14706 Returns the number of articles marked as read."
14707 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14708 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14709 (gnus-apply-kill-file-internal)
14712 (defun gnus-kill-save-kill-buffer ()
14713 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14714 (when (get-file-buffer file)
14716 (set-buffer (get-file-buffer file))
14717 (and (buffer-modified-p) (save-buffer))
14718 (kill-buffer (current-buffer))))))
14720 (defvar gnus-kill-file-name "KILL"
14721 "Suffix of the kill files.")
14723 (defun gnus-newsgroup-kill-file (newsgroup)
14724 "Return the name of a kill file name for NEWSGROUP.
14725 If NEWSGROUP is nil, return the global kill file name instead."
14727 ;; The global KILL file is placed at top of the directory.
14728 ((or (null newsgroup)
14729 (string-equal newsgroup ""))
14730 (expand-file-name gnus-kill-file-name
14731 gnus-kill-files-directory))
14732 ;; Append ".KILL" to newsgroup name.
14733 ((gnus-use-long-file-name 'not-kill)
14734 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14735 "." gnus-kill-file-name)
14736 gnus-kill-files-directory))
14737 ;; Place "KILL" under the hierarchical directory.
14739 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14740 "/" gnus-kill-file-name)
14741 gnus-kill-files-directory))))
14748 (defvar gnus-dribble-ignore nil)
14749 (defvar gnus-dribble-eval-file nil)
14751 (defun gnus-dribble-file-name ()
14752 "Return the dribble file for the current .newsrc."
14754 (if gnus-dribble-directory
14755 (concat (file-name-as-directory gnus-dribble-directory)
14756 (file-name-nondirectory gnus-current-startup-file))
14757 gnus-current-startup-file)
14760 (defun gnus-dribble-enter (string)
14761 "Enter STRING into the dribble buffer."
14762 (if (and (not gnus-dribble-ignore)
14763 gnus-dribble-buffer
14764 (buffer-name gnus-dribble-buffer))
14765 (let ((obuf (current-buffer)))
14766 (set-buffer gnus-dribble-buffer)
14767 (insert string "\n")
14768 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14769 (set-buffer obuf))))
14771 (defun gnus-dribble-read-file ()
14772 "Read the dribble file from disk."
14773 (let ((dribble-file (gnus-dribble-file-name)))
14775 (set-buffer (setq gnus-dribble-buffer
14777 (file-name-nondirectory dribble-file))))
14778 (gnus-add-current-to-buffer-list)
14780 (setq buffer-file-name dribble-file)
14782 (buffer-disable-undo (current-buffer))
14783 (bury-buffer (current-buffer))
14784 (set-buffer-modified-p nil)
14785 (let ((auto (make-auto-save-file-name))
14786 (gnus-dribble-ignore t)
14788 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14789 ;; Load whichever file is newest -- the auto save file
14790 ;; or the "real" file.
14791 (if (file-newer-than-file-p auto dribble-file)
14792 (insert-file-contents auto)
14793 (insert-file-contents dribble-file))
14794 (unless (zerop (buffer-size))
14795 (set-buffer-modified-p t))
14796 ;; Set the file modes to reflect the .newsrc file modes.
14798 (when (and (file-exists-p gnus-current-startup-file)
14799 (setq modes (file-modes gnus-current-startup-file)))
14800 (set-file-modes dribble-file modes))
14801 ;; Possibly eval the file later.
14802 (when (gnus-y-or-n-p
14803 "Auto-save file exists. Do you want to read it? ")
14804 (setq gnus-dribble-eval-file t)))))))
14806 (defun gnus-dribble-eval-file ()
14807 (when gnus-dribble-eval-file
14808 (setq gnus-dribble-eval-file nil)
14810 (let ((gnus-dribble-ignore t))
14811 (set-buffer gnus-dribble-buffer)
14812 (eval-buffer (current-buffer))))))
14814 (defun gnus-dribble-delete-file ()
14815 (when (file-exists-p (gnus-dribble-file-name))
14816 (delete-file (gnus-dribble-file-name)))
14817 (when gnus-dribble-buffer
14819 (set-buffer gnus-dribble-buffer)
14820 (let ((auto (make-auto-save-file-name)))
14821 (if (file-exists-p auto)
14822 (delete-file auto))
14824 (set-buffer-modified-p nil)))))
14826 (defun gnus-dribble-save ()
14827 (when (and gnus-dribble-buffer
14828 (buffer-name gnus-dribble-buffer))
14830 (set-buffer gnus-dribble-buffer)
14833 (defun gnus-dribble-clear ()
14834 (when (gnus-buffer-exists-p gnus-dribble-buffer)
14836 (set-buffer gnus-dribble-buffer)
14838 (set-buffer-modified-p nil)
14839 (setq buffer-saved-size (buffer-size)))))
14843 ;;; Server Communication
14846 (defun gnus-start-news-server (&optional confirm)
14847 "Open a method for getting news.
14848 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14850 (if gnus-current-select-method
14851 ;; Stream is already opened.
14853 ;; Open NNTP server.
14854 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14857 ;; Read server name with completion.
14858 (setq gnus-nntp-server
14859 (completing-read "NNTP server: "
14860 (mapcar (lambda (server) (list server))
14861 (cons (list gnus-nntp-server)
14862 gnus-secondary-servers))
14863 nil nil gnus-nntp-server))))
14865 (if (and gnus-nntp-server
14866 (stringp gnus-nntp-server)
14867 (not (string= gnus-nntp-server "")))
14868 (setq gnus-select-method
14869 (cond ((or (string= gnus-nntp-server "")
14870 (string= gnus-nntp-server "::"))
14871 (list 'nnspool (system-name)))
14872 ((string-match "^:" gnus-nntp-server)
14873 (list 'nnmh gnus-nntp-server
14874 (list 'nnmh-directory
14875 (file-name-as-directory
14877 (concat "~/" (substring
14878 gnus-nntp-server 1)))))
14879 (list 'nnmh-get-new-mail nil)))
14881 (list 'nntp gnus-nntp-server)))))
14883 (setq how (car gnus-select-method))
14884 (cond ((eq how 'nnspool)
14886 (gnus-message 5 "Looking up local news spool..."))
14889 (gnus-message 5 "Looking up mh spool..."))
14892 (setq gnus-current-select-method gnus-select-method)
14893 (run-hooks 'gnus-open-server-hook)
14895 ;; gnus-open-server-hook might have opened it
14896 (gnus-server-opened gnus-select-method)
14897 (gnus-open-server gnus-select-method)
14900 "%s (%s) open error: '%s'. Continue? "
14901 (car gnus-select-method) (cadr gnus-select-method)
14902 (gnus-status-message gnus-select-method)))
14903 (gnus-error 1 "Couldn't open server on %s"
14904 (nth 1 gnus-select-method))))))
14906 (defun gnus-check-group (group)
14907 "Try to make sure that the server where GROUP exists is alive."
14908 (let ((method (gnus-find-method-for-group group)))
14909 (or (gnus-server-opened method)
14910 (gnus-open-server method))))
14912 (defun gnus-check-server (&optional method silent)
14913 "Check whether the connection to METHOD is down.
14914 If METHOD is nil, use `gnus-select-method'.
14915 If it is down, start it up (again)."
14916 (let ((method (or method gnus-select-method)))
14917 ;; Transform virtual server names into select methods.
14918 (when (stringp method)
14919 (setq method (gnus-server-to-method method)))
14920 (if (gnus-server-opened method)
14921 ;; The stream is already opened.
14923 ;; Open the server.
14925 (gnus-message 5 "Opening %s server%s..." (car method)
14926 (if (equal (nth 1 method) "") ""
14927 (format " on %s" (nth 1 method)))))
14928 (run-hooks 'gnus-open-server-hook)
14930 (gnus-open-server method)
14934 (defun gnus-get-function (method function)
14935 "Return a function symbol based on METHOD and FUNCTION."
14936 ;; Translate server names into methods.
14938 (error "Attempted use of a nil select method"))
14939 (when (stringp method)
14940 (setq method (gnus-server-to-method method)))
14941 (let ((func (intern (format "%s-%s" (car method) function))))
14942 ;; If the functions isn't bound, we require the backend in
14944 (unless (fboundp func)
14945 (require (car method))
14946 (unless (fboundp func)
14947 ;; This backend doesn't implement this function.
14948 (error "No such function: %s" func)))
14953 ;;; Interface functions to the backends.
14956 (defun gnus-open-server (method)
14957 "Open a connection to METHOD."
14958 (when (stringp method)
14959 (setq method (gnus-server-to-method method)))
14960 (let ((elem (assoc method gnus-opened-servers)))
14961 ;; If this method was previously denied, we just return nil.
14962 (if (eq (nth 1 elem) 'denied)
14964 (gnus-message 1 "Denied server")
14966 ;; Open the server.
14968 (funcall (gnus-get-function method 'open-server)
14969 (nth 1 method) (nthcdr 2 method))))
14970 ;; If this hasn't been opened before, we add it to the list.
14972 (setq elem (list method nil)
14973 gnus-opened-servers (cons elem gnus-opened-servers)))
14974 ;; Set the status of this server.
14975 (setcar (cdr elem) (if result 'ok 'denied))
14976 ;; Return the result from the "open" call.
14979 (defun gnus-close-server (method)
14980 "Close the connection to METHOD."
14981 (when (stringp method)
14982 (setq method (gnus-server-to-method method)))
14983 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14985 (defun gnus-request-list (method)
14986 "Request the active file from METHOD."
14987 (when (stringp method)
14988 (setq method (gnus-server-to-method method)))
14989 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14991 (defun gnus-request-list-newsgroups (method)
14992 "Request the newsgroups file from METHOD."
14993 (when (stringp method)
14994 (setq method (gnus-server-to-method method)))
14995 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14997 (defun gnus-request-newgroups (date method)
14998 "Request all new groups since DATE from METHOD."
14999 (when (stringp method)
15000 (setq method (gnus-server-to-method method)))
15001 (funcall (gnus-get-function method 'request-newgroups)
15002 date (nth 1 method)))
15004 (defun gnus-server-opened (method)
15005 "Check whether a connection to METHOD has been opened."
15006 (when (stringp method)
15007 (setq method (gnus-server-to-method method)))
15008 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15010 (defun gnus-status-message (method)
15011 "Return the status message from METHOD.
15012 If METHOD is a string, it is interpreted as a group name. The method
15013 this group uses will be queried."
15014 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15016 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15018 (defun gnus-request-group (group &optional dont-check method)
15019 "Request GROUP. If DONT-CHECK, no information is required."
15020 (let ((method (or method (gnus-find-method-for-group group))))
15021 (when (stringp method)
15022 (setq method (gnus-server-to-method method)))
15023 (funcall (gnus-get-function method 'request-group)
15024 (gnus-group-real-name group) (nth 1 method) dont-check)))
15026 (defun gnus-request-asynchronous (group &optional articles)
15027 "Request that GROUP behave asynchronously.
15028 ARTICLES is the `data' of the group."
15029 (let ((method (gnus-find-method-for-group group)))
15030 (funcall (gnus-get-function method 'request-asynchronous)
15031 (gnus-group-real-name group) (nth 1 method) articles)))
15033 (defun gnus-list-active-group (group)
15034 "Request active information on GROUP."
15035 (let ((method (gnus-find-method-for-group group))
15036 (func 'list-active-group))
15037 (when (gnus-check-backend-function func group)
15038 (funcall (gnus-get-function method func)
15039 (gnus-group-real-name group) (nth 1 method)))))
15041 (defun gnus-request-group-description (group)
15042 "Request a description of GROUP."
15043 (let ((method (gnus-find-method-for-group group))
15044 (func 'request-group-description))
15045 (when (gnus-check-backend-function func group)
15046 (funcall (gnus-get-function method func)
15047 (gnus-group-real-name group) (nth 1 method)))))
15049 (defun gnus-close-group (group)
15050 "Request the GROUP be closed."
15051 (let ((method (gnus-find-method-for-group group)))
15052 (funcall (gnus-get-function method 'close-group)
15053 (gnus-group-real-name group) (nth 1 method))))
15055 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15056 "Request headers for ARTICLES in GROUP.
15057 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15058 (let ((method (gnus-find-method-for-group group)))
15059 (if (and gnus-use-cache (numberp (car articles)))
15060 (gnus-cache-retrieve-headers articles group fetch-old)
15061 (funcall (gnus-get-function method 'retrieve-headers)
15062 articles (gnus-group-real-name group) (nth 1 method)
15065 (defun gnus-retrieve-groups (groups method)
15066 "Request active information on GROUPS from METHOD."
15067 (when (stringp method)
15068 (setq method (gnus-server-to-method method)))
15069 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15071 (defun gnus-request-type (group &optional article)
15072 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15073 (let ((method (gnus-find-method-for-group group)))
15074 (if (not (gnus-check-backend-function 'request-type (car method)))
15076 (funcall (gnus-get-function method 'request-type)
15077 (gnus-group-real-name group) article))))
15079 (defun gnus-request-update-mark (group article mark)
15080 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15081 (let ((method (gnus-find-method-for-group group)))
15082 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15084 (funcall (gnus-get-function method 'request-update-mark)
15085 (gnus-group-real-name group) article mark))))
15087 (defun gnus-request-article (article group &optional buffer)
15088 "Request the ARTICLE in GROUP.
15089 ARTICLE can either be an article number or an article Message-ID.
15090 If BUFFER, insert the article in that group."
15091 (let ((method (gnus-find-method-for-group group)))
15092 (funcall (gnus-get-function method 'request-article)
15093 article (gnus-group-real-name group) (nth 1 method) buffer)))
15095 (defun gnus-request-head (article group)
15096 "Request the head of ARTICLE in GROUP."
15097 (let ((method (gnus-find-method-for-group group)))
15098 (funcall (gnus-get-function method 'request-head)
15099 article (gnus-group-real-name group) (nth 1 method))))
15101 (defun gnus-request-body (article group)
15102 "Request the body of ARTICLE in GROUP."
15103 (let ((method (gnus-find-method-for-group group)))
15104 (funcall (gnus-get-function method 'request-body)
15105 article (gnus-group-real-name group) (nth 1 method))))
15107 (defun gnus-request-post (method)
15108 "Post the current buffer using METHOD."
15109 (when (stringp method)
15110 (setq method (gnus-server-to-method method)))
15111 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15113 (defun gnus-request-scan (group method)
15114 "Request a SCAN being performed in GROUP from METHOD.
15115 If GROUP is nil, all groups on METHOD are scanned."
15116 (let ((method (if group (gnus-find-method-for-group group) method)))
15117 (funcall (gnus-get-function method 'request-scan)
15118 (and group (gnus-group-real-name group)) (nth 1 method))))
15120 (defsubst gnus-request-update-info (info method)
15121 "Request that METHOD update INFO."
15122 (when (stringp method)
15123 (setq method (gnus-server-to-method method)))
15124 (when (gnus-check-backend-function 'request-update-info (car method))
15125 (funcall (gnus-get-function method 'request-update-info)
15126 (gnus-group-real-name (gnus-info-group info))
15127 info (nth 1 method))))
15129 (defun gnus-request-expire-articles (articles group &optional force)
15130 (let ((method (gnus-find-method-for-group group)))
15131 (funcall (gnus-get-function method 'request-expire-articles)
15132 articles (gnus-group-real-name group) (nth 1 method)
15135 (defun gnus-request-move-article
15136 (article group server accept-function &optional last)
15137 (let ((method (gnus-find-method-for-group group)))
15138 (funcall (gnus-get-function method 'request-move-article)
15139 article (gnus-group-real-name group)
15140 (nth 1 method) accept-function last)))
15142 (defun gnus-request-accept-article (group method &optional last)
15143 ;; Make sure there's a newline at the end of the article.
15144 (when (stringp method)
15145 (setq method (gnus-server-to-method method)))
15146 (when (and (not method)
15148 (setq method (gnus-find-method-for-group group)))
15149 (goto-char (point-max))
15152 (let ((func (car (or method (gnus-find-method-for-group group)))))
15153 (funcall (intern (format "%s-request-accept-article" func))
15154 (if (stringp group) (gnus-group-real-name group) group)
15158 (defun gnus-request-replace-article (article group buffer)
15159 (let ((func (car (gnus-find-method-for-group group))))
15160 (funcall (intern (format "%s-request-replace-article" func))
15161 article (gnus-group-real-name group) buffer)))
15163 (defun gnus-request-associate-buffer (group)
15164 (let ((method (gnus-find-method-for-group group)))
15165 (funcall (gnus-get-function method 'request-associate-buffer)
15166 (gnus-group-real-name group))))
15168 (defun gnus-request-restore-buffer (article group)
15169 "Request a new buffer restored to the state of ARTICLE."
15170 (let ((method (gnus-find-method-for-group group)))
15171 (funcall (gnus-get-function method 'request-restore-buffer)
15172 article (gnus-group-real-name group) (nth 1 method))))
15174 (defun gnus-request-create-group (group &optional method)
15175 (when (stringp method)
15176 (setq method (gnus-server-to-method method)))
15177 (let ((method (or method (gnus-find-method-for-group group))))
15178 (funcall (gnus-get-function method 'request-create-group)
15179 (gnus-group-real-name group) (nth 1 method))))
15181 (defun gnus-request-delete-group (group &optional force)
15182 (let ((method (gnus-find-method-for-group group)))
15183 (funcall (gnus-get-function method 'request-delete-group)
15184 (gnus-group-real-name group) force (nth 1 method))))
15186 (defun gnus-request-rename-group (group new-name)
15187 (let ((method (gnus-find-method-for-group group)))
15188 (funcall (gnus-get-function method 'request-rename-group)
15189 (gnus-group-real-name group)
15190 (gnus-group-real-name new-name) (nth 1 method))))
15192 (defun gnus-member-of-valid (symbol group)
15193 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15194 (memq symbol (assoc
15195 (symbol-name (car (gnus-find-method-for-group group)))
15196 gnus-valid-select-methods)))
15198 (defun gnus-method-option-p (method option)
15199 "Return non-nil if select METHOD has OPTION as a parameter."
15200 (when (stringp method)
15201 (setq method (gnus-server-to-method method)))
15202 (memq option (assoc (format "%s" (car method))
15203 gnus-valid-select-methods)))
15205 (defun gnus-server-extend-method (group method)
15206 ;; This function "extends" a virtual server. If the server is
15207 ;; "hello", and the select method is ("hello" (my-var "something"))
15208 ;; in the group "alt.alt", this will result in a new virtual server
15209 ;; called "hello+alt.alt".
15211 (gnus-copy-sequence
15212 (if (equal (car method) "native") gnus-select-method
15213 (cdr (assoc (car method) gnus-server-alist))))))
15214 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15215 (nconc entry (cdr method))))
15217 (defun gnus-find-method-for-group (group &optional info)
15218 "Find the select method that GROUP uses."
15219 (or gnus-override-method
15221 gnus-select-method)
15222 (let ((info (or info (gnus-get-info group)))
15225 (not (setq method (gnus-info-method info)))
15226 (equal method "native"))
15229 (cond ((stringp method)
15230 (gnus-server-to-method method))
15231 ((stringp (car method))
15232 (gnus-server-extend-method group method))
15235 (cond ((equal (cadr method) "")
15237 ((null (cadr method))
15238 (list (car method) ""))
15240 (gnus-server-add-address method)))))))
15242 (defun gnus-check-backend-function (func group)
15243 "Check whether GROUP supports function FUNC."
15244 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15246 (fboundp (intern (format "%s-%s" method func)))))
15248 (defun gnus-methods-using (feature)
15249 "Find all methods that have FEATURE."
15250 (let ((valids gnus-valid-select-methods)
15253 (if (memq feature (car valids))
15254 (setq outs (cons (car valids) outs)))
15255 (setq valids (cdr valids)))
15260 ;;; Active & Newsrc File Handling
15263 (defun gnus-setup-news (&optional rawfile level dont-connect)
15264 "Setup news information.
15265 If RAWFILE is non-nil, the .newsrc file will also be read.
15266 If LEVEL is non-nil, the news will be set up at level LEVEL."
15267 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15270 ;; Clear some variables to re-initialize news information.
15271 (setq gnus-newsrc-alist nil
15272 gnus-active-hashtb nil)
15273 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15274 (gnus-read-newsrc-file rawfile))
15276 (when (and (not (assoc "archive" gnus-server-alist))
15277 gnus-message-archive-method)
15278 (push (cons "archive" gnus-message-archive-method)
15279 gnus-server-alist))
15281 ;; If we don't read the complete active file, we fill in the
15283 (if (or (null gnus-read-active-file)
15284 (eq gnus-read-active-file 'some))
15285 (gnus-update-active-hashtb-from-killed))
15287 ;; Read the active file and create `gnus-active-hashtb'.
15288 ;; If `gnus-read-active-file' is nil, then we just create an empty
15289 ;; hash table. The partial filling out of the hash table will be
15290 ;; done in `gnus-get-unread-articles'.
15291 (and gnus-read-active-file
15293 (gnus-read-active-file))
15295 (or gnus-active-hashtb
15296 (setq gnus-active-hashtb (make-vector 4095 0)))
15298 ;; Initialize the cache.
15299 (when gnus-use-cache
15302 ;; Possibly eval the dribble file.
15303 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15305 ;; Slave Gnusii should then clear the dribble buffer.
15306 (when (and init gnus-slave)
15307 (gnus-dribble-clear))
15309 (gnus-update-format-specifications)
15311 ;; See whether we need to read the description file.
15312 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15313 (not gnus-description-hashtb)
15315 gnus-read-active-file)
15316 (gnus-read-all-descriptions-files))
15318 ;; Find new newsgroups and treat them.
15319 (if (and init gnus-check-new-newsgroups (not level)
15320 (gnus-check-server gnus-select-method))
15321 (gnus-find-new-newsgroups))
15323 ;; We might read in new NoCeM messages here.
15324 (when (and gnus-use-nocem
15326 (not dont-connect))
15327 (gnus-nocem-scan-groups))
15329 ;; Find the number of unread articles in each non-dead group.
15330 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15331 (gnus-get-unread-articles level))
15333 (if (and init gnus-check-bogus-newsgroups
15334 gnus-read-active-file (not level)
15335 (gnus-server-opened gnus-select-method))
15336 (gnus-check-bogus-newsgroups))))
15338 (defun gnus-find-new-newsgroups (&optional arg)
15339 "Search for new newsgroups and add them.
15340 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15341 The `-n' option line from .newsrc is respected.
15342 If ARG (the prefix), use the `ask-server' method to query
15343 the server for new groups."
15345 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15346 (null gnus-read-active-file)
15347 (eq gnus-read-active-file 'some))
15348 'ask-server gnus-check-new-newsgroups)))
15349 (unless (gnus-check-first-time-used)
15350 (if (or (consp check)
15351 (eq check 'ask-server))
15352 ;; Ask the server for new groups.
15353 (gnus-ask-server-for-new-groups)
15354 ;; Go through the active hashtb and look for new groups.
15356 group new-newsgroups)
15357 (gnus-message 5 "Looking for new newsgroups...")
15358 (unless gnus-have-read-active-file
15359 (gnus-read-active-file))
15360 (setq gnus-newsrc-last-checked-date (current-time-string))
15361 (unless gnus-killed-hashtb
15362 (gnus-make-hashtable-from-killed))
15363 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15364 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15367 (if (or (null (setq group (symbol-name sym)))
15369 (null (symbol-value sym))
15370 (gnus-gethash group gnus-killed-hashtb)
15371 (gnus-gethash group gnus-newsrc-hashtb))
15373 (let ((do-sub (gnus-matches-options-n group)))
15375 ((eq do-sub 'subscribe)
15376 (setq groups (1+ groups))
15377 (gnus-sethash group group gnus-killed-hashtb)
15378 (funcall gnus-subscribe-options-newsgroup-method group))
15379 ((eq do-sub 'ignore)
15382 (setq groups (1+ groups))
15383 (gnus-sethash group group gnus-killed-hashtb)
15384 (if gnus-subscribe-hierarchical-interactive
15385 (setq new-newsgroups (cons group new-newsgroups))
15386 (funcall gnus-subscribe-newsgroup-method group)))))))
15387 gnus-active-hashtb)
15388 (when new-newsgroups
15389 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15390 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15392 (gnus-message 6 "%d new newsgroup%s arrived."
15393 groups (if (> groups 1) "s have" " has"))
15394 (gnus-message 6 "No new newsgroups.")))))))
15396 (defun gnus-matches-options-n (group)
15397 ;; Returns `subscribe' if the group is to be unconditionally
15398 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15399 ;; no match for the group.
15401 ;; First we check the two user variables.
15403 ((and gnus-options-subscribe
15404 (string-match gnus-options-subscribe group))
15406 ((and gnus-auto-subscribed-groups
15407 (string-match gnus-auto-subscribed-groups group))
15409 ((and gnus-options-not-subscribe
15410 (string-match gnus-options-not-subscribe group))
15412 ;; Then we go through the list that was retrieved from the .newsrc
15413 ;; file. This list has elements on the form
15414 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15415 ;; is in the reverse order of the options line) is returned.
15417 (let ((regs gnus-newsrc-options-n))
15419 (not (string-match (caar regs) group)))
15420 (setq regs (cdr regs)))
15421 (and regs (cdar regs))))))
15423 (defun gnus-ask-server-for-new-groups ()
15424 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15425 (methods (cons gnus-select-method
15427 (when gnus-message-archive-method
15430 (and (consp gnus-check-new-newsgroups)
15431 gnus-check-new-newsgroups)
15432 gnus-secondary-select-methods))))
15434 (new-date (current-time-string))
15435 group new-newsgroups got-new method hashtb
15436 gnus-override-subscribe-method)
15437 ;; Go through both primary and secondary select methods and
15438 ;; request new newsgroups.
15439 (while (setq method (gnus-server-get-method nil (pop methods)))
15440 (setq new-newsgroups nil)
15441 (setq gnus-override-subscribe-method method)
15442 (when (and (gnus-check-server method)
15443 (gnus-request-newgroups date method))
15446 (setq hashtb (gnus-make-hashtable 100))
15447 (set-buffer nntp-server-buffer)
15448 ;; Enter all the new groups into a hashtable.
15449 (gnus-active-to-gnus-format method hashtb 'ignore))
15450 ;; Now all new groups from `method' are in `hashtb'.
15452 (lambda (group-sym)
15453 (if (or (null (setq group (symbol-name group-sym)))
15454 (not (boundp group-sym))
15455 (null (symbol-value group-sym))
15456 (gnus-gethash group gnus-newsrc-hashtb)
15457 (member group gnus-zombie-list)
15458 (member group gnus-killed-list))
15459 ;; The group is already known.
15461 ;; Make this group active.
15462 (when (symbol-value group-sym)
15463 (gnus-set-active group (symbol-value group-sym)))
15464 ;; Check whether we want it or not.
15465 (let ((do-sub (gnus-matches-options-n group)))
15467 ((eq do-sub 'subscribe)
15469 (gnus-sethash group group gnus-killed-hashtb)
15470 (funcall gnus-subscribe-options-newsgroup-method group))
15471 ((eq do-sub 'ignore)
15475 (gnus-sethash group group gnus-killed-hashtb)
15476 (if gnus-subscribe-hierarchical-interactive
15477 (push group new-newsgroups)
15478 (funcall gnus-subscribe-newsgroup-method group)))))))
15480 (when new-newsgroups
15481 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15482 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15484 (gnus-message 6 "%d new newsgroup%s arrived."
15485 groups (if (> groups 1) "s have" " has")))
15486 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15489 (defun gnus-check-first-time-used ()
15490 (if (or (> (length gnus-newsrc-alist) 1)
15491 (file-exists-p gnus-startup-file)
15492 (file-exists-p (concat gnus-startup-file ".el"))
15493 (file-exists-p (concat gnus-startup-file ".eld")))
15495 (gnus-message 6 "First time user; subscribing you to default groups")
15496 (unless (gnus-read-active-file-p)
15497 (gnus-read-active-file))
15498 (setq gnus-newsrc-last-checked-date (current-time-string))
15499 (let ((groups gnus-default-subscribed-newsgroups)
15503 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15506 (if (null (setq group (symbol-name sym)))
15508 (let ((do-sub (gnus-matches-options-n group)))
15510 ((eq do-sub 'subscribe)
15511 (gnus-sethash group group gnus-killed-hashtb)
15512 (funcall gnus-subscribe-options-newsgroup-method group))
15513 ((eq do-sub 'ignore)
15516 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15517 gnus-active-hashtb)
15519 (if (gnus-active (car groups))
15520 (gnus-group-change-level
15521 (car groups) gnus-level-default-subscribed gnus-level-killed))
15522 (setq groups (cdr groups)))
15523 (gnus-group-make-help-group)
15524 (and gnus-novice-user
15525 (gnus-message 7 "`A k' to list killed groups"))))))
15527 (defun gnus-subscribe-group (group previous &optional method)
15528 (gnus-group-change-level
15530 (list t group gnus-level-default-subscribed nil nil method)
15532 gnus-level-default-subscribed gnus-level-killed previous t))
15534 ;; `gnus-group-change-level' is the fundamental function for changing
15535 ;; subscription levels of newsgroups. This might mean just changing
15536 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15537 ;; again, which subscribes/unsubscribes a group, which is equally
15538 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15539 ;; from 8-9 to 1-7 means that you remove the group from the list of
15540 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15541 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15542 ;; which is trivial.
15543 ;; ENTRY can either be a string (newsgroup name) or a list (if
15544 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15545 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15547 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15548 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15550 (defun gnus-group-change-level (entry level &optional oldlevel
15551 previous fromkilled)
15552 (let (group info active num)
15553 ;; Glean what info we can from the arguments
15555 (if fromkilled (setq group (nth 1 entry))
15556 (setq group (car (nth 2 entry))))
15557 (setq group entry))
15558 (if (and (stringp entry)
15560 (< oldlevel gnus-level-zombie))
15561 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15562 (if (and (not oldlevel)
15564 (setq oldlevel (gnus-info-level (nth 2 entry)))
15565 (setq oldlevel (or oldlevel 9)))
15566 (if (stringp previous)
15567 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15569 (if (and (>= oldlevel gnus-level-zombie)
15570 (gnus-gethash group gnus-newsrc-hashtb))
15571 ;; We are trying to subscribe a group that is already
15575 (or (gnus-ephemeral-group-p group)
15576 (gnus-dribble-enter
15577 (format "(gnus-group-change-level %S %S %S %S %S)"
15578 group level oldlevel (car (nth 2 previous)) fromkilled)))
15580 ;; Then we remove the newgroup from any old structures, if needed.
15581 ;; If the group was killed, we remove it from the killed or zombie
15582 ;; list. If not, and it is in fact going to be killed, we remove
15583 ;; it from the newsrc hash table and assoc.
15585 ((>= oldlevel gnus-level-zombie)
15586 (if (= oldlevel gnus-level-zombie)
15587 (setq gnus-zombie-list (delete group gnus-zombie-list))
15588 (setq gnus-killed-list (delete group gnus-killed-list))))
15590 (if (and (>= level gnus-level-zombie)
15593 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15595 (setcdr (gnus-gethash (car (nth 3 entry))
15596 gnus-newsrc-hashtb)
15598 (setcdr (cdr entry) (cdddr entry))))))
15600 ;; Finally we enter (if needed) the list where it is supposed to
15601 ;; go, and change the subscription level. If it is to be killed,
15602 ;; we enter it into the killed or zombie list.
15604 ((>= level gnus-level-zombie)
15605 ;; Remove from the hash table.
15606 (gnus-sethash group nil gnus-newsrc-hashtb)
15607 ;; We do not enter foreign groups into the list of dead
15609 (unless (gnus-group-foreign-p group)
15610 (if (= level gnus-level-zombie)
15611 (setq gnus-zombie-list (cons group gnus-zombie-list))
15612 (setq gnus-killed-list (cons group gnus-killed-list)))))
15614 ;; If the list is to be entered into the newsrc assoc, and
15615 ;; it was killed, we have to create an entry in the newsrc
15616 ;; hashtb format and fix the pointers in the newsrc assoc.
15617 (if (< oldlevel gnus-level-zombie)
15618 ;; It was alive, and it is going to stay alive, so we
15619 ;; just change the level and don't change any pointers or
15620 ;; hash table entries.
15621 (setcar (cdaddr entry) level)
15623 (setq info (cdr entry)
15625 (setq active (gnus-active group))
15627 (if active (- (1+ (cdr active)) (car active)) t))
15628 ;; Check whether the group is foreign. If so, the
15629 ;; foreign select method has to be entered into the
15631 (let ((method (or gnus-override-subscribe-method
15632 (gnus-group-method group))))
15633 (if (eq method gnus-select-method)
15634 (setq info (list group level nil))
15635 (setq info (list group level nil nil method)))))
15638 (let ((p gnus-newsrc-alist))
15642 (setq entry (cons info (cddr previous)))
15645 (setcdr (cdr previous) entry)
15646 (gnus-sethash group (cons num (cdr previous))
15647 gnus-newsrc-hashtb))
15648 (setcdr previous entry)
15649 (gnus-sethash group (cons num previous)
15650 gnus-newsrc-hashtb))
15652 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15653 (when gnus-group-change-level-function
15654 (funcall gnus-group-change-level-function group level oldlevel)))))
15656 (defun gnus-kill-newsgroup (newsgroup)
15657 "Obsolete function. Kills a newsgroup."
15658 (gnus-group-change-level
15659 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15661 (defun gnus-check-bogus-newsgroups (&optional confirm)
15662 "Remove bogus newsgroups.
15663 If CONFIRM is non-nil, the user has to confirm the deletion of every
15665 (let ((newsrc (cdr gnus-newsrc-alist))
15666 bogus group entry info)
15667 (gnus-message 5 "Checking bogus newsgroups...")
15668 (unless (gnus-read-active-file-p)
15669 (gnus-read-active-file))
15670 (when (gnus-read-active-file-p)
15671 ;; Find all bogus newsgroup that are subscribed.
15673 (setq info (pop newsrc)
15674 group (gnus-info-group info))
15675 (unless (or (gnus-active group) ; Active
15676 (gnus-info-method info) ; Foreign
15678 (not (gnus-y-or-n-p
15679 (format "Remove bogus newsgroup: %s " group)))))
15680 ;; Found a bogus newsgroup.
15681 (push group bogus)))
15682 ;; Remove all bogus subscribed groups by first killing them, and
15683 ;; then removing them from the list of killed groups.
15685 (when (setq entry (gnus-gethash (setq group (pop bogus))
15686 gnus-newsrc-hashtb))
15687 (gnus-group-change-level entry gnus-level-killed)
15688 (setq gnus-killed-list (delete group gnus-killed-list))))
15689 ;; Then we remove all bogus groups from the list of killed and
15690 ;; zombie groups. They are are removed without confirmation.
15691 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15694 (setq killed (symbol-value (car dead-lists)))
15696 (unless (gnus-active (setq group (pop killed)))
15697 ;; The group is bogus.
15698 ;; !!!Slow as hell.
15699 (set (car dead-lists)
15700 (delete group (symbol-value (car dead-lists))))))
15701 (setq dead-lists (cdr dead-lists))))
15702 (gnus-message 5 "Checking bogus newsgroups...done"))))
15704 (defun gnus-check-duplicate-killed-groups ()
15705 "Remove duplicates from the list of killed groups."
15707 (let ((killed gnus-killed-list))
15709 (gnus-message 9 "%d" (length killed))
15710 (setcdr killed (delete (car killed) (cdr killed)))
15711 (setq killed (cdr killed)))))
15713 ;; We want to inline a function from gnus-cache, so we cheat here:
15716 (require 'gnus-cache))
15718 (defun gnus-get-unread-articles-in-group (info active &optional update)
15720 ;; Allow the backend to update the info in the group.
15722 (gnus-request-update-info
15723 info (gnus-find-method-for-group (gnus-info-group info))))
15724 (gnus-activate-group (gnus-info-group info) nil t))
15725 (let* ((range (gnus-info-read info))
15727 ;; If a cache is present, we may have to alter the active info.
15728 (when (and gnus-use-cache info)
15729 (inline (gnus-cache-possibly-alter-active
15730 (gnus-info-group info) active)))
15731 ;; Modify the list of read articles according to what articles
15732 ;; are available; then tally the unread articles and add the
15733 ;; number to the group hash table entry.
15735 ((zerop (cdr active))
15738 (setq num (- (1+ (cdr active)) (car active))))
15739 ((not (listp (cdr range)))
15740 ;; Fix a single (num . num) range according to the
15741 ;; active hash table.
15742 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15743 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15744 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15745 ;; Compute number of unread articles.
15746 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15748 ;; The read list is a list of ranges. Fix them according to
15749 ;; the active hash table.
15750 ;; First peel off any elements that are below the lower
15752 (while (and (cdr range)
15754 (or (and (atom (cadr range)) (cadr range))
15756 (if (numberp (car range))
15759 (or (and (numberp (cadr range))
15762 (setcdr (car range)
15763 (or (and (numberp (nth 1 range)) (nth 1 range))
15765 (setcdr range (cddr range)))
15766 ;; Adjust the first element to be the same as the lower limit.
15767 (if (and (not (atom (car range)))
15768 (< (cdar range) (car active)))
15769 (setcdr (car range) (1- (car active))))
15770 ;; Then we want to peel off any elements that are higher
15771 ;; than the upper active limit.
15772 (let ((srange range))
15773 ;; Go past all legal elements.
15774 (while (and (cdr srange)
15775 (<= (or (and (atom (cadr srange))
15777 (caadr srange)) (cdr active)))
15778 (setq srange (cdr srange)))
15780 ;; Nuke all remaining illegal elements.
15781 (setcdr srange nil))
15783 ;; Adjust the final element.
15784 (if (and (not (atom (car srange)))
15785 (> (cdar srange) (cdr active)))
15786 (setcdr (car srange) (cdr active))))
15787 ;; Compute the number of unread articles.
15789 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15791 (or (and (atom (car range)) (car range))
15793 (setq range (cdr range)))
15794 (setq num (max 0 (- (cdr active) num)))))
15795 ;; Set the number of unread articles.
15797 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15800 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15801 ;; and compute how many unread articles there are in each group.
15802 (defun gnus-get-unread-articles (&optional level)
15803 (let* ((newsrc (cdr gnus-newsrc-alist))
15804 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15807 (cond ((and gnus-activate-foreign-newsgroups
15808 (not (numberp gnus-activate-foreign-newsgroups)))
15809 (1+ gnus-level-subscribed))
15810 ((numberp gnus-activate-foreign-newsgroups)
15811 gnus-activate-foreign-newsgroups)
15814 info group active method)
15815 (gnus-message 5 "Checking new news...")
15818 (setq active (gnus-active (setq group (gnus-info-group
15819 (setq info (pop newsrc))))))
15821 ;; Check newsgroups. If the user doesn't want to check them, or
15822 ;; they can't be checked (for instance, if the news server can't
15823 ;; be reached) we just set the number of unread articles in this
15824 ;; newsgroup to t. This means that Gnus thinks that there are
15825 ;; unread articles, but it has no idea how many.
15826 (if (and (setq method (gnus-info-method info))
15827 (not (gnus-server-equal
15829 (setq method (gnus-server-get-method nil method))))
15830 (not (gnus-secondary-method-p method)))
15831 ;; These groups are foreign. Check the level.
15832 (when (<= (gnus-info-level info) foreign-level)
15833 (setq active (gnus-activate-group group 'scan))
15834 (unless (inline (gnus-virtual-group-p group))
15835 (inline (gnus-close-group group)))
15836 (when (fboundp (intern (concat (symbol-name (car method))
15837 "-request-update-info")))
15838 (inline (gnus-request-update-info info method))))
15839 ;; These groups are native or secondary.
15840 (when (and (<= (gnus-info-level info) level)
15841 (not gnus-read-active-file))
15842 (setq active (gnus-activate-group group 'scan))
15843 (inline (gnus-close-group group))))
15845 ;; Get the number of unread articles in the group.
15847 (inline (gnus-get-unread-articles-in-group info active))
15848 ;; The group couldn't be reached, so we nix out the number of
15849 ;; unread articles and stuff.
15850 (gnus-set-active group nil)
15851 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15853 (gnus-message 5 "Checking new news...done")))
15855 ;; Create a hash table out of the newsrc alist. The `car's of the
15856 ;; alist elements are used as keys.
15857 (defun gnus-make-hashtable-from-newsrc-alist ()
15858 (let ((alist gnus-newsrc-alist)
15859 (ohashtb gnus-newsrc-hashtb)
15861 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15863 (setq prev (setq gnus-newsrc-alist
15864 (if (equal (caar gnus-newsrc-alist)
15867 (cons (list "dummy.group" 0 nil) alist)))))
15871 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15873 gnus-newsrc-hashtb)
15875 alist (cdr alist)))))
15877 (defun gnus-make-hashtable-from-killed ()
15878 "Create a hash table from the killed and zombie lists."
15879 (let ((lists '(gnus-killed-list gnus-zombie-list))
15881 (setq gnus-killed-hashtb
15882 (gnus-make-hashtable
15883 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15884 (while (setq list (pop lists))
15885 (setq list (symbol-value list))
15887 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15889 (defun gnus-activate-group (group &optional scan dont-check)
15890 ;; Check whether a group has been activated or not.
15891 ;; If SCAN, request a scan of that group as well.
15892 (let ((method (gnus-find-method-for-group group))
15894 (and (gnus-check-server method)
15895 ;; We escape all bugs and quit here to make it possible to
15896 ;; continue if a group is so out-there that it reports bugs
15900 (gnus-check-backend-function 'request-scan (car method))
15901 (gnus-request-scan group method))
15904 (gnus-request-group group dont-check)
15908 (set-buffer nntp-server-buffer)
15909 (goto-char (point-min))
15910 ;; Parse the result we got from `gnus-request-group'.
15911 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15913 (goto-char (match-beginning 1))
15915 group (setq active (cons (read (current-buffer))
15916 (read (current-buffer)))))
15917 ;; Return the new active info.
15920 (defun gnus-update-read-articles (group unread)
15921 "Update the list of read and ticked articles in GROUP using the
15922 UNREAD and TICKED lists.
15923 Note: UNSELECTED has to be sorted over `<'.
15924 Returns whether the updating was successful."
15925 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15926 (entry (gnus-gethash group gnus-newsrc-hashtb))
15927 (info (nth 2 entry))
15929 (unread (sort (copy-sequence unread) '<))
15931 (if (or (not info) (not active))
15932 ;; There is no info on this group if it was, in fact,
15933 ;; killed. Gnus stores no information on killed groups, so
15934 ;; there's nothing to be done.
15935 ;; One could store the information somewhere temporarily,
15936 ;; perhaps... Hmmm...
15938 ;; Remove any negative articles numbers.
15939 (while (and unread (< (car unread) 0))
15940 (setq unread (cdr unread)))
15941 ;; Remove any expired article numbers
15942 (while (and unread (< (car unread) (car active)))
15943 (setq unread (cdr unread)))
15944 ;; Compute the ranges of read articles by looking at the list of
15945 ;; unread articles.
15947 (if (/= (car unread) prev)
15948 (setq read (cons (if (= prev (1- (car unread))) prev
15949 (cons prev (1- (car unread)))) read)))
15950 (setq prev (1+ (car unread)))
15951 (setq unread (cdr unread)))
15952 (when (<= prev (cdr active))
15953 (setq read (cons (cons prev (cdr active)) read)))
15954 ;; Enter this list into the group info.
15955 (gnus-info-set-read
15956 info (if (> (length read) 1) (nreverse read) read))
15957 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15958 (gnus-get-unread-articles-in-group info (gnus-active group))
15961 (defun gnus-make-articles-unread (group articles)
15962 "Mark ARTICLES in GROUP as unread."
15963 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15964 (gnus-gethash (gnus-group-real-name group)
15965 gnus-newsrc-hashtb))))
15966 (ranges (gnus-info-read info))
15969 (when (gnus-member-of-range
15970 (setq article (pop articles)) ranges)
15971 (setq news (cons article news))))
15973 (gnus-info-set-read
15974 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15975 (gnus-group-update-group group t))))
15977 ;; Enter all dead groups into the hashtb.
15978 (defun gnus-update-active-hashtb-from-killed ()
15979 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15980 (lists (list gnus-killed-list gnus-zombie-list))
15983 (setq killed (car lists))
15985 (gnus-sethash (car killed) nil hashtb)
15986 (setq killed (cdr killed)))
15987 (setq lists (cdr lists)))))
15989 (defun gnus-get-killed-groups ()
15990 "Go through the active hashtb and all all unknown groups as killed."
15991 ;; First make sure active file has been read.
15992 (unless (gnus-read-active-file-p)
15993 (let ((gnus-read-active-file t))
15994 (gnus-read-active-file)))
15995 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
15996 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16000 (group (symbol-name sym)))
16001 (if (or (null group)
16002 (gnus-gethash group gnus-killed-hashtb)
16003 (gnus-gethash group gnus-newsrc-hashtb))
16005 (let ((do-sub (gnus-matches-options-n group)))
16006 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16008 (setq groups (1+ groups))
16009 (setq gnus-killed-list
16010 (cons group gnus-killed-list))
16011 (gnus-sethash group group gnus-killed-hashtb))))))
16012 gnus-active-hashtb))
16014 ;; Get the active file(s) from the backend(s).
16015 (defun gnus-read-active-file ()
16016 (gnus-group-set-mode-line)
16019 (if (gnus-check-server gnus-select-method)
16020 ;; The native server is available.
16021 (cons gnus-select-method gnus-secondary-select-methods)
16022 ;; The native server is down, so we just do the
16024 gnus-secondary-select-methods)
16025 ;; Also read from the archive server.
16026 (when gnus-message-archive-method
16027 (list "archive"))))
16029 (setq gnus-have-read-active-file nil)
16031 (set-buffer nntp-server-buffer)
16033 (let* ((method (if (stringp (car methods))
16034 (gnus-server-get-method nil (car methods))
16036 (where (nth 1 method))
16037 (mesg (format "Reading active file%s via %s..."
16038 (if (and where (not (zerop (length where))))
16039 (concat " from " where) "")
16041 (gnus-message 5 mesg)
16042 (when (gnus-check-server method)
16043 ;; Request that the backend scan its incoming messages.
16044 (and (gnus-check-backend-function 'request-scan (car method))
16045 (gnus-request-scan nil method))
16047 ((and (eq gnus-read-active-file 'some)
16048 (gnus-check-backend-function 'retrieve-groups (car method)))
16049 (let ((newsrc (cdr gnus-newsrc-alist))
16050 (gmethod (gnus-server-get-method nil method))
16052 (while (setq info (pop newsrc))
16053 (when (gnus-server-equal
16054 (gnus-find-method-for-group
16055 (gnus-info-group info) info)
16057 (push (gnus-group-real-name (gnus-info-group info))
16060 (gnus-check-server method)
16061 (setq list-type (gnus-retrieve-groups groups method))
16065 1.2 "Cannot read partial active file from %s server."
16067 ((eq list-type 'active)
16068 (gnus-active-to-gnus-format method gnus-active-hashtb))
16070 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16072 (if (not (gnus-request-list method))
16073 (unless (equal method gnus-message-archive-method)
16074 (gnus-error 1 "Cannot read active file from %s server."
16076 (gnus-message 5 mesg)
16077 (gnus-active-to-gnus-format method gnus-active-hashtb)
16078 ;; We mark this active file as read.
16079 (push method gnus-have-read-active-file)
16080 (gnus-message 5 "%sdone" mesg))))))
16081 (setq methods (cdr methods))))))
16083 ;; Read an active file and place the results in `gnus-active-hashtb'.
16084 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16086 (setq method gnus-select-method))
16087 (let ((cur (current-buffer))
16089 (if (and gnus-active-hashtb
16090 (not (equal method gnus-select-method)))
16092 (setq gnus-active-hashtb
16093 (if (equal method gnus-select-method)
16094 (gnus-make-hashtable
16095 (count-lines (point-min) (point-max)))
16096 (gnus-make-hashtable 4096)))))))
16097 ;; Delete unnecessary lines.
16098 (goto-char (point-min))
16099 (while (search-forward "\nto." nil t)
16100 (delete-region (1+ (match-beginning 0))
16101 (progn (forward-line 1) (point))))
16102 (or (string= gnus-ignored-newsgroups "")
16104 (goto-char (point-min))
16105 (delete-matching-lines gnus-ignored-newsgroups)))
16106 ;; Make the group names readable as a lisp expression even if they
16107 ;; contain special characters.
16108 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16109 (goto-char (point-max))
16110 (while (re-search-backward "[][';?()#]" nil t)
16112 ;; If these are groups from a foreign select method, we insert the
16113 ;; group prefix in front of the group names.
16114 (and method (not (gnus-server-equal
16115 (gnus-server-get-method nil method)
16116 (gnus-server-get-method nil gnus-select-method)))
16117 (let ((prefix (gnus-group-prefixed-name "" method)))
16118 (goto-char (point-min))
16119 (while (and (not (eobp))
16120 (progn (insert prefix)
16121 (zerop (forward-line 1)))))))
16122 ;; Store the active file in a hash table.
16123 (goto-char (point-min))
16124 (if (string-match "%[oO]" gnus-group-line-format)
16125 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16126 ;; If we want information on moderated groups, we use this
16128 (let* ((mod-hashtb (make-vector 7 0))
16129 (m (intern "m" mod-hashtb))
16131 (while (not (eobp))
16132 (condition-case nil
16134 (narrow-to-region (point) (gnus-point-at-eol))
16135 (setq group (let ((obarray hashtb)) (read cur)))
16136 (if (and (numberp (setq max (read cur)))
16137 (numberp (setq min (read cur)))
16139 (skip-chars-forward " \t")
16141 (or (= (following-char) ?=)
16142 (= (following-char) ?x)
16143 (= (following-char) ?j)))))
16144 (set group (cons min max))
16146 ;; Enter moderated groups into a list.
16147 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16148 (setq gnus-moderated-list
16149 (cons (symbol-name group) gnus-moderated-list))))
16156 ;; And if we do not care about moderation, we use this loop,
16157 ;; which is faster.
16158 (let (group max min)
16159 (while (not (eobp))
16162 (narrow-to-region (point) (gnus-point-at-eol))
16163 ;; group gets set to a symbol interned in the hash table
16164 ;; (what a hack!!) - jwz
16165 (setq group (let ((obarray hashtb)) (read cur)))
16166 (if (and (numberp (setq max (read cur)))
16167 (numberp (setq min (read cur)))
16169 (skip-chars-forward " \t")
16171 (or (= (following-char) ?=)
16172 (= (following-char) ?x)
16173 (= (following-char) ?j)))))
16174 (set group (cons min max))
16182 (gnus-message 3 "Warning - illegal active: %s"
16184 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16186 (forward-line 1))))))
16188 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16189 ;; Parse a "groups" active file.
16190 (let ((cur (current-buffer))
16192 (if (and method gnus-active-hashtb)
16194 (setq gnus-active-hashtb
16195 (gnus-make-hashtable
16196 (count-lines (point-min) (point-max)))))))
16197 (prefix (and method
16198 (not (gnus-server-equal
16199 (gnus-server-get-method nil method)
16200 (gnus-server-get-method nil gnus-select-method)))
16201 (gnus-group-prefixed-name "" method))))
16203 (goto-char (point-min))
16204 ;; We split this into to separate loops, one with the prefix
16205 ;; and one without to speed the reading up somewhat.
16207 (let (min max opoint group)
16208 (while (not (eobp))
16211 (read cur) (read cur)
16212 (setq min (read cur)
16215 (skip-chars-forward " \t")
16218 (set (let ((obarray hashtb)) (read cur))
16220 (error (and group (symbolp group) (set group nil))))
16222 (let (min max group)
16223 (while (not (eobp))
16225 (if (= (following-char) ?2)
16227 (read cur) (read cur)
16228 (setq min (read cur)
16230 (set (setq group (let ((obarray hashtb)) (read cur)))
16232 (error (and group (symbolp group) (set group nil))))
16233 (forward-line 1))))))
16235 (defun gnus-read-newsrc-file (&optional force)
16236 "Read startup file.
16237 If FORCE is non-nil, the .newsrc file is read."
16238 ;; Reset variables that might be defined in the .newsrc.eld file.
16239 (let ((variables gnus-variable-list))
16241 (set (car variables) nil)
16242 (setq variables (cdr variables))))
16243 (let* ((newsrc-file gnus-current-startup-file)
16244 (quick-file (concat newsrc-file ".el")))
16246 ;; We always load the .newsrc.eld file. If always contains
16247 ;; much information that can not be gotten from the .newsrc
16248 ;; file (ticked articles, killed groups, foreign methods, etc.)
16249 (gnus-read-newsrc-el-file quick-file)
16251 (if (and (file-exists-p gnus-current-startup-file)
16253 (and (file-newer-than-file-p newsrc-file quick-file)
16254 (file-newer-than-file-p newsrc-file
16255 (concat quick-file "d")))
16256 (not gnus-newsrc-alist)))
16257 ;; We read the .newsrc file. Note that if there if a
16258 ;; .newsrc.eld file exists, it has already been read, and
16259 ;; the `gnus-newsrc-hashtb' has been created. While reading
16260 ;; the .newsrc file, Gnus will only use the information it
16261 ;; can find there for changing the data already read -
16262 ;; ie. reading the .newsrc file will not trash the data
16263 ;; already read (except for read articles).
16265 (gnus-message 5 "Reading %s..." newsrc-file)
16266 (set-buffer (find-file-noselect newsrc-file))
16267 (buffer-disable-undo (current-buffer))
16268 (gnus-newsrc-to-gnus-format)
16269 (kill-buffer (current-buffer))
16270 (gnus-message 5 "Reading %s...done" newsrc-file)))
16272 ;; Read any slave files.
16274 (gnus-master-read-slave-newsrc))
16276 ;; Convert old to new.
16277 (gnus-convert-old-newsrc))))
16279 (defun gnus-continuum-version (version)
16280 "Return VERSION as a floating point number."
16281 (when (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16282 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16283 (number (match-string 2 version))
16285 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16286 (setq major (string-to-number (match-string 1 number)))
16287 (setq minor (string-to-number (match-string 2 number)))
16288 (setq least (if (match-beginning 3)
16289 (string-to-number (match-string 3 number))
16293 (format "%s00%02d%02d"
16295 ((string= alpha "(ding)") "4.99")
16296 ((string= alpha "September") "5.01")
16297 ((string= alpha "Red") "5.03"))
16299 (format "%d.%02d%02d" major minor least))))))
16301 (defun gnus-convert-old-newsrc ()
16302 "Convert old newsrc into the new format, if needed."
16303 (let ((fcv (and gnus-newsrc-file-version
16304 (gnus-continuum-version gnus-newsrc-file-version))))
16306 ;; No .newsrc.eld file was loaded.
16308 ;; Gnus 5 .newsrc.eld was loaded.
16309 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16310 (gnus-convert-old-ticks)))))
16312 (defun gnus-convert-old-ticks ()
16313 (let ((newsrc (cdr gnus-newsrc-alist))
16314 marks info dormant ticked)
16315 (while (setq info (pop newsrc))
16316 (when (setq marks (gnus-info-marks info))
16317 (setq dormant (cdr (assq 'dormant marks))
16318 ticked (cdr (assq 'tick marks)))
16319 (when (or dormant ticked)
16320 (gnus-info-set-read
16323 (gnus-info-read info)
16324 (nconc (gnus-uncompress-range dormant)
16325 (gnus-uncompress-range ticked)))))))))
16327 (defun gnus-read-newsrc-el-file (file)
16328 (let ((ding-file (concat file "d")))
16329 ;; We always, always read the .eld file.
16330 (gnus-message 5 "Reading %s..." ding-file)
16331 (let (gnus-newsrc-assoc)
16332 (condition-case nil
16333 (load ding-file t t t)
16335 (gnus-error 1 "Error in %s" ding-file)))
16336 (when gnus-newsrc-assoc
16337 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16338 (gnus-make-hashtable-from-newsrc-alist)
16339 (when (file-newer-than-file-p file ding-file)
16340 ;; Old format quick file
16341 (gnus-message 5 "Reading %s..." file)
16342 ;; The .el file is newer than the .eld file, so we read that one
16344 (gnus-read-old-newsrc-el-file file))))
16346 ;; Parse the old-style quick startup file
16347 (defun gnus-read-old-newsrc-el-file (file)
16348 (let (newsrc killed marked group m info)
16350 (let ((gnus-killed-assoc nil)
16351 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16353 (condition-case nil
16356 (setq newsrc gnus-newsrc-assoc
16357 killed gnus-killed-assoc
16358 marked gnus-marked-assoc)))
16359 (setq gnus-newsrc-alist nil)
16360 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16363 (gnus-info-set-read info (cddr group))
16364 (gnus-info-set-level
16365 info (if (nth 1 group) gnus-level-default-subscribed
16366 gnus-level-default-unsubscribed))
16367 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16370 (if (nth 1 group) gnus-level-default-subscribed
16371 gnus-level-default-unsubscribed)
16373 gnus-newsrc-alist))
16374 ;; Copy marks into info.
16375 (when (setq m (assoc (car group) marked))
16376 (unless (nthcdr 3 info)
16377 (nconc info (list nil)))
16378 (gnus-info-set-marks
16379 info (list (cons 'tick (gnus-compress-sequence
16380 (sort (cdr m) '<) t))))))
16381 (setq newsrc killed)
16383 (setcar newsrc (caar newsrc))
16384 (setq newsrc (cdr newsrc)))
16385 (setq gnus-killed-list killed))
16386 ;; The .el file version of this variable does not begin with
16387 ;; "options", while the .eld version does, so we just add it if it
16390 gnus-newsrc-options
16392 (and (not (string-match "^ *options" gnus-newsrc-options))
16393 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16394 (and (not (string-match "\n$" gnus-newsrc-options))
16395 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16396 ;; Finally, if we read some options lines, we parse them.
16397 (or (string= gnus-newsrc-options "")
16398 (gnus-newsrc-parse-options gnus-newsrc-options))))
16400 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16401 (gnus-make-hashtable-from-newsrc-alist)))
16403 (defun gnus-make-newsrc-file (file)
16404 "Make server dependent file name by catenating FILE and server host name."
16405 (let* ((file (expand-file-name file nil))
16406 (real-file (concat file "-" (nth 1 gnus-select-method))))
16407 (if (or (file-exists-p real-file)
16408 (file-exists-p (concat real-file ".el"))
16409 (file-exists-p (concat real-file ".eld")))
16412 (defun gnus-newsrc-to-gnus-format ()
16413 (setq gnus-newsrc-options "")
16414 (setq gnus-newsrc-options-n nil)
16416 (or gnus-active-hashtb
16417 (setq gnus-active-hashtb (make-vector 4095 0)))
16418 (let ((buf (current-buffer))
16419 (already-read (> (length gnus-newsrc-alist) 1))
16420 group subscribed options-symbol newsrc Options-symbol
16422 (goto-char (point-min))
16423 ;; We intern the symbol `options' in the active hashtb so that we
16424 ;; can `eq' against it later.
16425 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16426 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16428 (while (not (eobp))
16429 ;; We first read the first word on the line by narrowing and
16430 ;; then reading into `gnus-active-hashtb'. Most groups will
16431 ;; already exist in that hashtb, so this will save some string
16435 (progn (skip-chars-forward "^ \t!:\n") (point)))
16436 (goto-char (point-min))
16438 (and (/= (point-min) (point-max))
16439 (let ((obarray gnus-active-hashtb)) (read buf))))
16441 ;; Now, the symbol we have read is either `options' or a group
16442 ;; name. If it is an options line, we just add it to a string.
16444 ((or (eq symbol options-symbol)
16445 (eq symbol Options-symbol))
16446 (setq gnus-newsrc-options
16447 ;; This concating is quite inefficient, but since our
16448 ;; thorough studies show that approx 99.37% of all
16449 ;; .newsrc files only contain a single options line, we
16450 ;; don't give a damn, frankly, my dear.
16451 (concat gnus-newsrc-options
16453 (gnus-point-at-bol)
16454 ;; Options may continue on the next line.
16455 (or (and (re-search-forward "^[^ \t]" nil 'move)
16456 (progn (beginning-of-line) (point)))
16460 ;; Group names can be just numbers.
16461 (when (numberp symbol)
16462 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16463 (or (boundp symbol) (set symbol nil))
16464 ;; It was a group name.
16465 (setq subscribed (= (following-char) ?:)
16466 group (symbol-name symbol)
16469 ;; If the line ends here, this is clearly a buggy line, so
16470 ;; we put point a the beginning of line and let the cond
16471 ;; below do the error handling.
16472 (beginning-of-line)
16473 ;; We skip to the beginning of the ranges.
16474 (skip-chars-forward "!: \t"))
16475 ;; We are now at the beginning of the list of read articles.
16476 ;; We read them range by range.
16479 ((looking-at "[0-9]+")
16480 ;; We narrow and read a number instead of buffer-substring/
16481 ;; string-to-int because it's faster. narrow/widen is
16482 ;; faster than save-restriction/narrow, and save-restriction
16483 ;; produces a garbage object.
16485 (narrow-to-region (match-beginning 0) (match-end 0))
16488 ;; If the next character is a dash, then this is a range.
16489 (if (= (following-char) ?-)
16491 ;; We read the upper bound of the range.
16493 (if (not (looking-at "[0-9]+"))
16494 ;; This is a buggy line, by we pretend that
16495 ;; it's kinda OK. Perhaps the user should be
16497 (setq reads (cons num1 reads))
16502 (narrow-to-region (match-beginning 0)
16507 ;; It was just a simple number, so we add it to the
16509 (setq reads (cons num1 reads)))
16510 ;; If the next char in ?\n, then we have reached the end
16511 ;; of the line and return nil.
16512 (/= (following-char) ?\n))
16513 ((= (following-char) ?\n)
16514 ;; End of line, so we end.
16517 ;; Not numbers and not eol, so this might be a buggy
16520 ;; If it was eob instead of ?\n, we allow it.
16522 ;; The line was buggy.
16524 (gnus-error 3.1 "Mangled line: %s"
16525 (buffer-substring (gnus-point-at-bol)
16526 (gnus-point-at-eol)))))
16528 ;; Skip past ", ". Spaces are illegal in these ranges, but
16529 ;; we allow them, because it's a common mistake to put a
16530 ;; space after the comma.
16531 (skip-chars-forward ", "))
16533 ;; We have already read .newsrc.eld, so we gently update the
16534 ;; data in the hash table with the information we have just
16537 (let ((info (gnus-get-info group))
16540 ;; There is an entry for this file in the alist.
16542 (gnus-info-set-read info (nreverse reads))
16543 ;; We update the level very gently. In fact, we
16544 ;; only change it if there's been a status change
16545 ;; from subscribed to unsubscribed, or vice versa.
16546 (setq level (gnus-info-level info))
16547 (cond ((and (<= level gnus-level-subscribed)
16549 (setq level (if reads
16550 gnus-level-default-unsubscribed
16551 (1+ gnus-level-default-unsubscribed))))
16552 ((and (> level gnus-level-subscribed) subscribed)
16553 (setq level gnus-level-default-subscribed)))
16554 (gnus-info-set-level info level))
16555 ;; This is a new group.
16556 (setq info (list group
16558 gnus-level-default-subscribed
16560 (1+ gnus-level-subscribed)
16561 gnus-level-default-unsubscribed))
16562 (nreverse reads))))
16563 (setq newsrc (cons info newsrc))))))
16566 (setq newsrc (nreverse newsrc))
16568 (if (not already-read)
16570 ;; We now have two newsrc lists - `newsrc', which is what we
16571 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16572 ;; what we've read from .newsrc.eld. We have to merge these
16573 ;; lists. We do this by "attaching" any (foreign) groups in the
16574 ;; gnus-newsrc-alist to the (native) group that precedes them.
16575 (let ((rc (cdr gnus-newsrc-alist))
16576 (prev gnus-newsrc-alist)
16579 (or (null (nth 4 (car rc))) ; It's a native group.
16580 (assoc (caar rc) newsrc) ; It's already in the alist.
16581 (if (setq entry (assoc (caar prev) newsrc))
16582 (setcdr (setq mentry (memq entry newsrc))
16583 (cons (car rc) (cdr mentry)))
16584 (setq newsrc (cons (car rc) newsrc))))
16588 (setq gnus-newsrc-alist newsrc)
16589 ;; We make the newsrc hashtb.
16590 (gnus-make-hashtable-from-newsrc-alist)
16592 ;; Finally, if we read some options lines, we parse them.
16593 (or (string= gnus-newsrc-options "")
16594 (gnus-newsrc-parse-options gnus-newsrc-options))))
16596 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16597 ;; The return value will be a list on the form
16598 ;; ((regexp1 . ignore)
16599 ;; (regexp2 . subscribe)...)
16600 ;; When handling new newsgroups, groups that match a `ignore' regexp
16601 ;; will be ignored, and groups that match a `subscribe' regexp will be
16602 ;; subscribed. A line like
16603 ;; options -n !all rec.all
16604 ;; will lead to a list that looks like
16605 ;; (("^rec\\..+" . subscribe)
16606 ;; ("^.+" . ignore))
16607 ;; So all "rec.*" groups will be subscribed, while all the other
16608 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16609 ;; different from "options -n rec.all !all".
16610 (defun gnus-newsrc-parse-options (options)
16613 (gnus-set-work-buffer)
16614 (insert (regexp-quote options))
16615 ;; First we treat all continuation lines.
16616 (goto-char (point-min))
16617 (while (re-search-forward "\n[ \t]+" nil t)
16618 (replace-match " " t t))
16619 ;; Then we transform all "all"s into ".+"s.
16620 (goto-char (point-min))
16621 (while (re-search-forward "\\ball\\b" nil t)
16622 (replace-match ".+" t t))
16623 (goto-char (point-min))
16624 ;; We remove all other options than the "-n" ones.
16625 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16626 (replace-match " ")
16628 (goto-char (point-min))
16630 ;; We are only interested in "options -n" lines - we
16631 ;; ignore the other option lines.
16632 (while (re-search-forward "[ \t]-n" nil t)
16634 (or (save-excursion
16635 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16637 (gnus-point-at-eol)))
16638 ;; Search for all "words"...
16639 (while (re-search-forward "[^ \t,\n]+" eol t)
16640 (if (= (char-after (match-beginning 0)) ?!)
16641 ;; If the word begins with a bang (!), this is a "not"
16642 ;; spec. We put this spec (minus the bang) and the
16643 ;; symbol `ignore' into the list.
16644 (setq out (cons (cons (concat
16645 "^" (buffer-substring
16646 (1+ (match-beginning 0))
16649 ;; There was no bang, so this is a "yes" spec.
16650 (setq out (cons (cons (concat "^" (match-string 0))
16651 'subscribe) out)))))
16653 (setq gnus-newsrc-options-n out))))
16655 (defun gnus-save-newsrc-file (&optional force)
16656 "Save .newsrc file."
16657 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16658 ;; from the variable gnus-newsrc-alist.
16659 (when (and (or gnus-newsrc-alist gnus-killed-list)
16660 gnus-current-startup-file)
16662 (if (and (or gnus-use-dribble-file gnus-slave)
16664 (or (not gnus-dribble-buffer)
16665 (not (buffer-name gnus-dribble-buffer))
16666 (zerop (save-excursion
16667 (set-buffer gnus-dribble-buffer)
16669 (gnus-message 4 "(No changes need to be saved)")
16670 (run-hooks 'gnus-save-newsrc-hook)
16672 (gnus-slave-save-newsrc)
16674 (when gnus-save-newsrc-file
16675 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16676 (gnus-gnus-to-newsrc-format)
16677 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16678 ;; Save .newsrc.eld.
16679 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16680 (make-local-variable 'version-control)
16681 (setq version-control 'never)
16682 (setq buffer-file-name
16683 (concat gnus-current-startup-file ".eld"))
16684 (setq default-directory (file-name-directory buffer-file-name))
16685 (gnus-add-current-to-buffer-list)
16686 (buffer-disable-undo (current-buffer))
16688 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16689 (gnus-gnus-to-quick-newsrc-format)
16690 (run-hooks 'gnus-save-quick-newsrc-hook)
16692 (kill-buffer (current-buffer))
16694 5 "Saving %s.eld...done" gnus-current-startup-file))
16695 (gnus-dribble-delete-file)
16696 (gnus-group-set-mode-line)))))
16698 (defun gnus-gnus-to-quick-newsrc-format ()
16699 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16700 (insert ";; Gnus startup file.\n")
16701 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16702 (insert ";; to read .newsrc.\n")
16703 (insert "(setq gnus-newsrc-file-version "
16704 (prin1-to-string gnus-version) ")\n")
16706 (if gnus-save-killed-list gnus-variable-list
16707 ;; Remove the `gnus-killed-list' from the list of variables
16708 ;; to be saved, if required.
16709 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16710 ;; Peel off the "dummy" group.
16711 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16713 ;; Insert the variables into the file.
16715 (when (and (boundp (setq variable (pop variables)))
16716 (symbol-value variable))
16717 (insert "(setq " (symbol-name variable) " '")
16718 (prin1 (symbol-value variable) (current-buffer))
16721 (defun gnus-gnus-to-newsrc-format ()
16722 ;; Generate and save the .newsrc file.
16724 (set-buffer (create-file-buffer gnus-current-startup-file))
16725 (let ((newsrc (cdr gnus-newsrc-alist))
16726 (standard-output (current-buffer))
16727 info ranges range method)
16728 (setq buffer-file-name gnus-current-startup-file)
16729 (setq default-directory (file-name-directory buffer-file-name))
16730 (buffer-disable-undo (current-buffer))
16733 (if gnus-newsrc-options (insert gnus-newsrc-options))
16734 ;; Write subscribed and unsubscribed.
16735 (while (setq info (pop newsrc))
16736 ;; Don't write foreign groups to .newsrc.
16737 (when (or (null (setq method (gnus-info-method info)))
16738 (equal method "native")
16739 (gnus-server-equal method gnus-select-method))
16740 (insert (gnus-info-group info)
16741 (if (> (gnus-info-level info) gnus-level-subscribed)
16743 (when (setq ranges (gnus-info-read info))
16745 (if (not (listp (cdr ranges)))
16746 (if (= (car ranges) (cdr ranges))
16747 (princ (car ranges))
16748 (princ (car ranges))
16750 (princ (cdr ranges)))
16751 (while (setq range (pop ranges))
16752 (if (or (atom range) (= (car range) (cdr range)))
16753 (princ (or (and (atom range) range) (car range)))
16754 (princ (car range))
16756 (princ (cdr range)))
16757 (if ranges (insert ",")))))
16759 (make-local-variable 'version-control)
16760 (setq version-control 'never)
16761 ;; It has been reported that sometime the modtime on the .newsrc
16762 ;; file seems to be off. We really do want to overwrite it, so
16763 ;; we clear the modtime here before saving. It's a bit odd,
16765 ;; sometimes the modtime clear isn't sufficient. most brute force:
16766 ;; delete the silly thing entirely first. but this fails to provide
16767 ;; such niceties as .newsrc~ creation.
16768 (if gnus-modtime-botch
16769 (delete-file gnus-startup-file)
16770 (clear-visited-file-modtime))
16771 (run-hooks 'gnus-save-standard-newsrc-hook)
16773 (kill-buffer (current-buffer)))))
16777 ;;; Slave functions.
16780 (defun gnus-slave-save-newsrc ()
16782 (set-buffer gnus-dribble-buffer)
16784 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16785 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16787 (defun gnus-master-read-slave-newsrc ()
16790 (file-name-directory gnus-current-startup-file)
16794 (file-name-nondirectory gnus-current-startup-file)
16798 (if (not slave-files)
16799 () ; There are no slave files to read.
16800 (gnus-message 7 "Reading slave newsrcs...")
16802 (set-buffer (get-buffer-create " *gnus slave*"))
16803 (buffer-disable-undo (current-buffer))
16805 (sort (mapcar (lambda (file)
16806 (list (nth 5 (file-attributes file)) file))
16809 (or (< (caar f1) (caar f2))
16810 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16813 (setq file (nth 1 (car slave-files)))
16814 (insert-file-contents file)
16815 (if (condition-case ()
16817 (eval-buffer (current-buffer))
16820 (gnus-error 3.2 "Possible error in %s" file)
16822 (or gnus-slave ; Slaves shouldn't delete these files.
16826 (setq slave-files (cdr slave-files))))
16827 (gnus-message 7 "Reading slave newsrcs...done"))))
16831 ;;; Group description.
16834 (defun gnus-read-all-descriptions-files ()
16835 (let ((methods (cons gnus-select-method
16837 (when gnus-message-archive-method
16839 gnus-secondary-select-methods))))
16841 (gnus-read-descriptions-file (car methods))
16842 (setq methods (cdr methods)))
16845 (defun gnus-read-descriptions-file (&optional method)
16846 (let ((method (or method gnus-select-method)))
16847 (when (stringp method)
16848 (setq method (gnus-server-to-method method)))
16849 ;; We create the hashtable whether we manage to read the desc file
16850 ;; to avoid trying to re-read after a failed read.
16851 (or gnus-description-hashtb
16852 (setq gnus-description-hashtb
16853 (gnus-make-hashtable (length gnus-active-hashtb))))
16854 ;; Mark this method's desc file as read.
16855 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16856 gnus-description-hashtb)
16858 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16860 ((not (gnus-check-server method))
16861 (gnus-message 1 "Couldn't open server")
16863 ((not (gnus-request-list-newsgroups method))
16864 (gnus-message 1 "Couldn't read newsgroups descriptions")
16870 (set-buffer nntp-server-buffer)
16871 (goto-char (point-min))
16872 (if (or (search-forward "\n.\n" nil t)
16873 (goto-char (point-max)))
16875 (beginning-of-line)
16876 (narrow-to-region (point-min) (point))))
16877 (goto-char (point-min))
16878 (while (not (eobp))
16879 ;; If we get an error, we set group to 0, which is not a
16883 (let ((obarray gnus-description-hashtb))
16884 ;; Group is set to a symbol interned in this
16886 (read nntp-server-buffer))
16888 (skip-chars-forward " \t")
16889 ;; ... which leads to this line being effectively ignored.
16890 (and (symbolp group)
16891 (set group (buffer-substring
16892 (point) (progn (end-of-line) (point)))))
16893 (forward-line 1))))
16894 (gnus-message 5 "Reading descriptions file...done")
16897 (defun gnus-group-get-description (group)
16898 "Get the description of a group by sending XGTITLE to the server."
16899 (when (gnus-request-group-description group)
16901 (set-buffer nntp-server-buffer)
16902 (goto-char (point-min))
16903 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16904 (match-string 1)))))
16908 ;;; Buffering of read articles.
16911 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16912 (defvar gnus-backlog-articles nil)
16913 (defvar gnus-backlog-hashtb nil)
16915 (defun gnus-backlog-buffer ()
16916 "Return the backlog buffer."
16917 (or (get-buffer gnus-backlog-buffer)
16919 (set-buffer (get-buffer-create gnus-backlog-buffer))
16920 (buffer-disable-undo (current-buffer))
16921 (setq buffer-read-only t)
16922 (gnus-add-current-to-buffer-list)
16923 (get-buffer gnus-backlog-buffer))))
16925 (defun gnus-backlog-setup ()
16926 "Initialize backlog variables."
16927 (unless gnus-backlog-hashtb
16928 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16930 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16932 (defun gnus-backlog-shutdown ()
16933 "Clear all backlog variables and buffers."
16934 (when (get-buffer gnus-backlog-buffer)
16935 (kill-buffer gnus-backlog-buffer))
16936 (setq gnus-backlog-hashtb nil
16937 gnus-backlog-articles nil))
16939 (defun gnus-backlog-enter-article (group number buffer)
16940 (gnus-backlog-setup)
16941 (let ((ident (intern (concat group ":" (int-to-string number))
16942 gnus-backlog-hashtb))
16944 (if (memq ident gnus-backlog-articles)
16945 () ; It's already kept.
16946 ;; Remove the oldest article, if necessary.
16947 (and (numberp gnus-keep-backlog)
16948 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16949 (gnus-backlog-remove-oldest-article))
16950 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16951 ;; Insert the new article.
16953 (set-buffer (gnus-backlog-buffer))
16954 (let (buffer-read-only)
16955 (goto-char (point-max))
16956 (or (bolp) (insert "\n"))
16958 (insert-buffer-substring buffer)
16959 ;; Tag the beginning of the article with the ident.
16960 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
16962 (defun gnus-backlog-remove-oldest-article ()
16964 (set-buffer (gnus-backlog-buffer))
16965 (goto-char (point-min))
16966 (if (zerop (buffer-size))
16967 () ; The buffer is empty.
16968 (let ((ident (get-text-property (point) 'gnus-backlog))
16970 ;; Remove the ident from the list of articles.
16972 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16973 ;; Delete the article itself.
16975 (point) (next-single-property-change
16976 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16978 (defun gnus-backlog-remove-article (group number)
16979 "Remove article NUMBER in GROUP from the backlog."
16980 (when (numberp number)
16981 (gnus-backlog-setup)
16982 (let ((ident (intern (concat group ":" (int-to-string number))
16983 gnus-backlog-hashtb))
16985 (when (memq ident gnus-backlog-articles)
16986 ;; It was in the backlog.
16988 (set-buffer (gnus-backlog-buffer))
16989 (let (buffer-read-only)
16990 (when (setq beg (text-property-any
16991 (point-min) (point-max) 'gnus-backlog
16993 ;; Find the end (i. e., the beginning of the next article).
16995 (next-single-property-change
16996 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
16997 (delete-region beg end)
17001 (defun gnus-backlog-request-article (group number buffer)
17002 (when (numberp number)
17003 (gnus-backlog-setup)
17004 (let ((ident (intern (concat group ":" (int-to-string number))
17005 gnus-backlog-hashtb))
17007 (when (memq ident gnus-backlog-articles)
17008 ;; It was in the backlog.
17010 (set-buffer (gnus-backlog-buffer))
17011 (if (not (setq beg (text-property-any
17012 (point-min) (point-max) 'gnus-backlog
17014 ;; It wasn't in the backlog after all.
17016 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17017 ;; Find the end (i. e., the beginning of the next article).
17019 (next-single-property-change
17020 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17021 (let ((buffer-read-only nil))
17023 (insert-buffer-substring gnus-backlog-buffer beg end)
17026 ;; Allow redefinition of Gnus functions.
17028 (gnus-ems-redefine)
17032 ;;; gnus.el ends here