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))
38 (eval-when-compile (require 'cl))
41 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/")
42 "*Directory variable from which all other Gnus file variables are derived.")
44 ;; Site dependent variables. These variables should be defined in
47 (defvar gnus-default-nntp-server nil
48 "Specify a default NNTP server.
49 This variable should be defined in paths.el, and should never be set
51 If you want to change servers, you should use `gnus-select-method'.
52 See the documentation to that variable.")
54 (defvar gnus-backup-default-subscribed-newsgroups
55 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
56 "Default default new newsgroups the first time Gnus is run.
57 Should be set in paths.el, and shouldn't be touched by the user.")
59 (defvar gnus-local-domain nil
60 "Local domain name without a host name.
61 The DOMAINNAME environment variable is used instead if it is defined.
62 If the `system-name' function returns the full Internet name, there is
63 no need to set this variable.")
65 (defvar gnus-local-organization nil
66 "String with a description of what organization (if any) the user belongs to.
67 The ORGANIZATION environment variable is used instead if it is defined.
68 If this variable contains a function, this function will be called
69 with the current newsgroup name as the argument. The function should
72 In any case, if the string (either in the variable, in the environment
73 variable, or returned by the function) is a file name, the contents of
74 this file will be used as the organization.")
76 ;; Customization variables
78 ;; Don't touch this variable.
79 (defvar gnus-nntp-service "nntp"
80 "*NNTP service name (\"nntp\" or 119).
81 This is an obsolete variable, which is scarcely used. If you use an
82 nntp server for your newsgroup and want to change the port number
83 used to 899, you would say something along these lines:
85 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
87 (defvar gnus-nntpserver-file "/etc/nntpserver"
88 "*A file with only the name of the nntp server in it.")
90 ;; This function is used to check both the environment variable
91 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
92 ;; an nntp server name default.
93 (defun gnus-getenv-nntpserver ()
94 (or (getenv "NNTPSERVER")
95 (and (file-readable-p gnus-nntpserver-file)
97 (set-buffer (get-buffer-create " *gnus nntp*"))
98 (buffer-disable-undo (current-buffer))
99 (insert-file-contents gnus-nntpserver-file)
100 (let ((name (buffer-string)))
102 (if (string-match "^[ \t\n]*$" name)
105 (kill-buffer (current-buffer))))))))
107 (defvar gnus-select-method
109 (list 'nntp (or (condition-case ()
110 (gnus-getenv-nntpserver)
112 (if (and gnus-default-nntp-server
113 (not (string= gnus-default-nntp-server "")))
114 gnus-default-nntp-server)
116 (if (or (null gnus-nntp-service)
117 (equal gnus-nntp-service "nntp"))
119 (list gnus-nntp-service)))
120 "*Default method for selecting a newsgroup.
121 This variable should be a list, where the first element is how the
122 news is to be fetched, the second is the address.
124 For instance, if you want to get your news via NNTP from
125 \"flab.flab.edu\", you could say:
127 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
129 If you want to use your local spool, say:
131 (setq gnus-select-method (list 'nnspool (system-name)))
133 If you use this variable, you must set `gnus-nntp-server' to nil.
135 There is a lot more to know about select methods and virtual servers -
136 see the manual for details.")
138 (defvar gnus-message-archive-method
141 (nnfolder-directory ,(nnheader-concat message-directory "archive"))
142 (nnfolder-active-file
143 ,(nnheader-concat message-directory "archive/active"))
144 (nnfolder-get-new-mail nil)
145 (nnfolder-inhibit-expiry t))
146 "*Method used for archiving messages you've sent.
147 This should be a mail method.
149 It's probably not a very effective to change this variable once you've
150 run Gnus once. After doing that, you must edit this server from the
153 (defvar gnus-refer-article-method nil
154 "*Preferred method for fetching an article by Message-ID.
155 If you are reading news from the local spool (with nnspool), fetching
156 articles by Message-ID is painfully slow. By setting this method to an
157 nntp method, you might get acceptable results.
159 The value of this variable must be a valid select method as discussed
160 in the documentation of `gnus-select-method'.")
162 (defvar gnus-secondary-select-methods nil
163 "*A list of secondary methods that will be used for reading news.
164 This is a list where each element is a complete select method (see
165 `gnus-select-method').
167 If, for instance, you want to read your mail with the nnml backend,
168 you could set this variable:
170 (setq gnus-secondary-select-methods '((nnml \"\")))")
172 (defvar gnus-secondary-servers nil
173 "*List of NNTP servers that the user can choose between interactively.
174 To make Gnus query you for a server, you have to give `gnus' a
175 non-numeric prefix - `C-u M-x gnus', in short.")
177 (defvar gnus-nntp-server nil
178 "*The name of the host running the NNTP server.
179 This variable is semi-obsolete. Use the `gnus-select-method'
182 (defvar gnus-startup-file "~/.newsrc"
183 "*Your `.newsrc' file.
184 `.newsrc-SERVER' will be used instead if that exists.")
186 (defvar gnus-init-file "~/.gnus"
187 "*Your Gnus elisp startup file.
188 If a file with the .el or .elc suffixes exist, it will be read
191 (defvar gnus-group-faq-directory
192 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
193 "/ftp@sunsite.auc.dk:/pub/usenet/"
194 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
195 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
196 "/ftp@rtfm.mit.edu:/pub/usenet/"
197 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
198 "/ftp@ftp.sunet.se:/pub/usenet/"
199 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
200 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
201 "/ftp@ftp.hk.super.net:/mirror/faqs/")
202 "*Directory where the group FAQs are stored.
203 This will most commonly be on a remote machine, and the file will be
206 This variable can also be a list of directories. In that case, the
207 first element in the list will be used by default, and the others will
208 be used as backup sites.
210 Note that Gnus uses an aol machine as the default directory. If this
211 feels fundamentally unclean, just think of it as a way to finally get
212 something of value back from them.
214 If the default site is too slow, try one of these:
216 North America: mirrors.aol.com /pub/rtfm/usenet
217 ftp.seas.gwu.edu /pub/rtfm
218 rtfm.mit.edu /pub/usenet
219 Europe: ftp.uni-paderborn.de /pub/FAQ
220 src.doc.ic.ac.uk /usenet/news-FAQS
221 ftp.sunet.se /pub/usenet
222 sunsite.auc.dk /pub/usenet
223 Asia: nctuccca.edu.tw /USENET/FAQ
224 hwarang.postech.ac.kr /pub/usenet
225 ftp.hk.super.net /mirror/faqs")
227 (defvar gnus-group-archive-directory
228 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
229 "*The address of the (ding) archives.")
231 (defvar gnus-group-recent-archive-directory
232 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
233 "*The address of the most recent (ding) articles.")
235 (defvar gnus-default-subscribed-newsgroups nil
236 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
237 It should be a list of strings.
238 If it is `t', Gnus will not do anything special the first time it is
239 started; it'll just use the normal newsgroups subscription methods.")
241 (defvar gnus-use-cross-reference t
242 "*Non-nil means that cross referenced articles will be marked as read.
243 If nil, ignore cross references. If t, mark articles as read in
244 subscribed newsgroups. If neither t nor nil, mark as read in all
247 (defvar gnus-single-article-buffer t
248 "*If non-nil, display all articles in the same buffer.
249 If nil, each group will get its own article buffer.")
251 (defvar gnus-use-dribble-file t
252 "*Non-nil means that Gnus will use a dribble file to store user updates.
253 If Emacs should crash without saving the .newsrc files, complete
254 information can be restored from the dribble file.")
256 (defvar gnus-dribble-directory nil
257 "*The directory where dribble files will be saved.
258 If this variable is nil, the directory where the .newsrc files are
259 saved will be used.")
261 (defvar gnus-asynchronous nil
262 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
264 (defvar gnus-kill-summary-on-exit t
265 "*If non-nil, kill the summary buffer when you exit from it.
266 If nil, the summary will become a \"*Dead Summary*\" buffer, and
267 it will be killed sometime later.")
269 (defvar gnus-large-newsgroup 200
270 "*The number of articles which indicates a large newsgroup.
271 If the number of articles in a newsgroup is greater than this value,
272 confirmation is required for selecting the newsgroup.")
274 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
275 (defvar gnus-no-groups-message "No news is horrible news"
276 "*Message displayed by Gnus when no groups are available.")
278 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
279 "*Non-nil means that the default name of a file to save articles in is the group name.
280 If it's nil, the directory form of the group name is used instead.
282 If this variable is a list, and the list contains the element
283 `not-score', long file names will not be used for score files; if it
284 contains the element `not-save', long file names will not be used for
285 saving; and if it contains the element `not-kill', long file names
286 will not be used for kill files.")
288 (defvar gnus-article-save-directory gnus-directory
289 "*Name of the directory articles will be saved in (default \"~/News\").")
291 (defvar gnus-kill-files-directory gnus-directory
292 "*Name of the directory where kill files will be stored (default \"~/News\").")
294 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
295 "*A function to save articles in your favorite format.
296 The function must be interactively callable (in other words, it must
297 be an Emacs command).
299 Gnus provides the following functions:
301 * gnus-summary-save-in-rmail (Rmail format)
302 * gnus-summary-save-in-mail (Unix mail format)
303 * gnus-summary-save-in-folder (MH folder)
304 * gnus-summary-save-in-file (article format).
305 * gnus-summary-save-in-vm (use VM's folder format).")
307 (defvar gnus-prompt-before-saving 'always
308 "*This variable says how much prompting is to be done when saving articles.
309 If it is nil, no prompting will be done, and the articles will be
310 saved to the default files. If this variable is `always', each and
311 every article that is saved will be preceded by a prompt, even when
312 saving large batches of articles. If this variable is neither nil not
313 `always', there the user will be prompted once for a file name for
314 each invocation of the saving commands.")
316 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
317 "*A function generating a file name to save articles in Rmail format.
318 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
320 (defvar gnus-mail-save-name (function gnus-plain-save-name)
321 "*A function generating a file name to save articles in Unix mail format.
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
324 (defvar gnus-folder-save-name (function gnus-folder-save-name)
325 "*A function generating a file name to save articles in MH folder.
326 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
328 (defvar gnus-file-save-name (function gnus-numeric-save-name)
329 "*A function generating a file name to save articles in article format.
330 The function is called with NEWSGROUP, HEADERS, and optional
333 (defvar gnus-split-methods
334 '((gnus-article-archive-name))
335 "*Variable used to suggest where articles are to be saved.
336 For instance, if you would like to save articles related to Gnus in
337 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
338 you could set this variable to something like:
340 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
341 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
343 This variable is an alist where the where the key is the match and the
344 value is a list of possible files to save in if the match is non-nil.
346 If the match is a string, it is used as a regexp match on the
347 article. If the match is a symbol, that symbol will be funcalled
348 from the buffer of the article to be saved with the newsgroup as the
349 parameter. If it is a list, it will be evaled in the same buffer.
351 If this form or function returns a string, this string will be used as
352 a possible file name; and if it returns a non-nil list, that list will
353 be used as possible file names.")
355 (defvar gnus-move-split-methods nil
356 "*Variable used to suggest where articles are to be moved to.
357 It uses the same syntax as the `gnus-split-methods' variable.")
359 (defvar gnus-save-score nil
360 "*If non-nil, save group scoring info.")
362 (defvar gnus-use-adaptive-scoring nil
363 "*If non-nil, use some adaptive scoring scheme.")
365 (defvar gnus-use-cache 'passive
366 "*If nil, Gnus will ignore the article cache.
367 If `passive', it will allow entering (and reading) articles
368 explicitly entered into the cache. If anything else, use the
369 cache to the full extent of the law.")
371 (defvar gnus-use-trees nil
372 "*If non-nil, display a thread tree buffer.")
374 (defvar gnus-use-grouplens nil
375 "*If non-nil, use GroupLens ratings.")
377 (defvar gnus-keep-backlog nil
378 "*If non-nil, Gnus will keep read articles for later re-retrieval.
379 If it is a number N, then Gnus will only keep the last N articles
380 read. If it is neither nil nor a number, Gnus will keep all read
381 articles. This is not a good idea.")
383 (defvar gnus-use-nocem nil
384 "*If non-nil, Gnus will read NoCeM cancel messages.")
386 (defvar gnus-use-demon nil
387 "If non-nil, Gnus might use some demons.")
389 (defvar gnus-use-scoring t
390 "*If non-nil, enable scoring.")
392 (defvar gnus-use-picons nil
393 "*If non-nil, display picons.")
395 (defvar gnus-fetch-old-headers nil
396 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
397 If an unread article in the group refers to an older, already read (or
398 just marked as read) article, the old article will not normally be
399 displayed in the Summary buffer. If this variable is non-nil, Gnus
400 will attempt to grab the headers to the old articles, and thereby
401 build complete threads. If it has the value `some', only enough
402 headers to connect otherwise loose threads will be displayed.
403 This variable can also be a number. In that case, no more than that
404 number of old headers will be fetched.
406 The server has to support NOV for any of this to work.")
409 ;(defvar gnus-visual t
410 ; "*If non-nil, will do various highlighting.
411 ;If nil, no mouse highlights (or any other highlights) will be
412 ;performed. This might speed up Gnus some when generating large group
413 ;and summary buffers.")
415 (defvar gnus-novice-user t
416 "*Non-nil means that you are a usenet novice.
417 If non-nil, verbose messages may be displayed and confirmations may be
420 (defvar gnus-expert-user nil
421 "*Non-nil means that you will never be asked for confirmation about anything.
422 And that means *anything*.")
424 (defvar gnus-verbose 7
425 "*Integer that says how verbose Gnus should be.
426 The higher the number, the more messages Gnus will flash to say what
427 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
428 display most important messages; and at ten, Gnus will keep on
429 jabbering all the time.")
431 (defvar gnus-keep-same-level nil
432 "*Non-nil means that the next newsgroup after the current will be on the same level.
433 When you type, for instance, `n' after reading the last article in the
434 current newsgroup, you will go to the next newsgroup. If this variable
435 is nil, the next newsgroup will be the next from the group
437 If this variable is non-nil, Gnus will either put you in the
438 next newsgroup with the same level, or, if no such newsgroup is
439 available, the next newsgroup with the lowest possible level higher
440 than the current level.
441 If this variable is `best', Gnus will make the next newsgroup the one
442 with the best level.")
444 (defvar gnus-summary-make-false-root 'adopt
445 "*nil means that Gnus won't gather loose threads.
446 If the root of a thread has expired or been read in a previous
447 session, the information necessary to build a complete thread has been
448 lost. Instead of having many small sub-threads from this original thread
449 scattered all over the summary buffer, Gnus can gather them.
451 If non-nil, Gnus will try to gather all loose sub-threads from an
452 original thread into one large thread.
454 If this variable is non-nil, it should be one of `none', `adopt',
457 If this variable is `none', Gnus will not make a false root, but just
458 present the sub-threads after another.
459 If this variable is `dummy', Gnus will create a dummy root that will
460 have all the sub-threads as children.
461 If this variable is `adopt', Gnus will make one of the \"children\"
462 the parent and mark all the step-children as such.
463 If this variable is `empty', the \"children\" are printed with empty
464 subject fields. (Or rather, they will be printed with a string
465 given by the `gnus-summary-same-subject' variable.)")
467 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
468 "*A regexp to match subjects to be excluded from loose thread gathering.
469 As loose thread gathering is done on subjects only, that means that
470 there can be many false gatherings performed. By rooting out certain
471 common subjects, gathering might become saner.")
473 (defvar gnus-summary-gather-subject-limit nil
474 "*Maximum length of subject comparisons when gathering loose threads.
475 Use nil to compare full subjects. Setting this variable to a low
476 number will help gather threads that have been corrupted by
477 newsreaders chopping off subject lines, but it might also mean that
478 unrelated articles that have subject that happen to begin with the
479 same few characters will be incorrectly gathered.
481 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
482 comparing subjects.")
484 (defvar gnus-simplify-ignored-prefixes nil
485 "*Regexp, matches for which are removed from subject lines when simplifying.")
487 (defvar gnus-build-sparse-threads nil
488 "*If non-nil, fill in the gaps in threads.
489 If `some', only fill in the gaps that are needed to tie loose threads
490 together. If `more', fill in all leaf nodes that Gnus can find. If
491 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
493 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
494 "Function used for gathering loose threads.
495 There are two pre-defined functions: `gnus-gather-threads-by-subject',
496 which only takes Subjects into consideration; and
497 `gnus-gather-threads-by-references', which compared the References
498 headers of the articles to find matches.")
500 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
501 (defvar gnus-summary-same-subject ""
502 "*String indicating that the current article has the same subject as the previous.
503 This variable will only be used if the value of
504 `gnus-summary-make-false-root' is `empty'.")
506 (defvar gnus-summary-goto-unread t
507 "*If non-nil, marking commands will go to the next unread article.
508 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
509 whether it is read or not.")
511 (defvar gnus-group-goto-unread t
512 "*If non-nil, movement commands will go to the next unread and subscribed group.")
514 (defvar gnus-goto-next-group-when-activating t
515 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
517 (defvar gnus-check-new-newsgroups t
518 "*Non-nil means that Gnus will add new newsgroups at startup.
519 If this variable is `ask-server', Gnus will ask the server for new
520 groups since the last time it checked. This means that the killed list
521 is no longer necessary, so you could set `gnus-save-killed-list' to
524 A variant is to have this variable be a list of select methods. Gnus
525 will then use the `ask-server' method on all these select methods to
526 query for new groups from all those servers.
529 (setq gnus-check-new-newsgroups
530 '((nntp \"some.server\") (nntp \"other.server\")))
532 If this variable is nil, then you have to tell Gnus explicitly to
533 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
535 (defvar gnus-check-bogus-newsgroups nil
536 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
537 If this variable is nil, then you have to tell Gnus explicitly to
538 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
540 (defvar gnus-read-active-file t
541 "*Non-nil means that Gnus will read the entire active file at startup.
542 If this variable is nil, Gnus will only know about the groups in your
545 If this variable is `some', Gnus will try to only read the relevant
546 parts of the active file from the server. Not all servers support
547 this, and it might be quite slow with other servers, but this should
548 generally be faster than both the t and nil value.
550 If you set this variable to nil or `some', you probably still want to
551 be told about new newsgroups that arrive. To do that, set
552 `gnus-check-new-newsgroups' to `ask-server'. This may not work
553 properly with all servers.")
555 (defvar gnus-level-subscribed 5
556 "*Groups with levels less than or equal to this variable are subscribed.")
558 (defvar gnus-level-unsubscribed 7
559 "*Groups with levels less than or equal to this variable are unsubscribed.
560 Groups with levels less than `gnus-level-subscribed', which should be
561 less than this variable, are subscribed.")
563 (defvar gnus-level-zombie 8
564 "*Groups with this level are zombie groups.")
566 (defvar gnus-level-killed 9
567 "*Groups with this level are killed.")
569 (defvar gnus-level-default-subscribed 3
570 "*New subscribed groups will be subscribed at this level.")
572 (defvar gnus-level-default-unsubscribed 6
573 "*New unsubscribed groups will be unsubscribed at this level.")
575 (defvar gnus-activate-level (1+ gnus-level-subscribed)
576 "*Groups higher than this level won't be activated on startup.
577 Setting this variable to something log might save lots of time when
578 you have many groups that you aren't interested in.")
580 (defvar gnus-activate-foreign-newsgroups 4
581 "*If nil, Gnus will not check foreign newsgroups at startup.
582 If it is non-nil, it should be a number between one and nine. Foreign
583 newsgroups that have a level lower or equal to this number will be
584 activated on startup. For instance, if you want to active all
585 subscribed newsgroups, but not the rest, you'd set this variable to
586 `gnus-level-subscribed'.
588 If you subscribe to lots of newsgroups from different servers, startup
589 might take a while. By setting this variable to nil, you'll save time,
590 but you won't be told how many unread articles there are in the
593 (defvar gnus-save-newsrc-file t
594 "*Non-nil means that Gnus will save the `.newsrc' file.
595 Gnus always saves its own startup file, which is called
596 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
597 be readily understood by other newsreaders. If you don't plan on
598 using other newsreaders, set this variable to nil to save some time on
601 (defvar gnus-save-killed-list t
602 "*If non-nil, save the list of killed groups to the startup file.
603 If you set this variable to nil, you'll save both time (when starting
604 and quitting) and space (both memory and disk), but it will also mean
605 that Gnus has no record of which groups are new and which are old, so
606 the automatic new newsgroups subscription methods become meaningless.
608 You should always set `gnus-check-new-newsgroups' to `ask-server' or
609 nil if you set this variable to nil.")
611 (defvar gnus-interactive-catchup t
612 "*If non-nil, require your confirmation when catching up a group.")
614 (defvar gnus-interactive-exit t
615 "*If non-nil, require your confirmation when exiting Gnus.")
617 (defvar gnus-kill-killed t
618 "*If non-nil, Gnus will apply kill files to already killed articles.
619 If it is nil, Gnus will never apply kill files to articles that have
620 already been through the scoring process, which might very well save lots
623 (defvar gnus-extract-address-components 'gnus-extract-address-components
624 "*Function for extracting address components from a From header.
625 Two pre-defined function exist: `gnus-extract-address-components',
626 which is the default, quite fast, and too simplistic solution, and
627 `mail-extract-address-components', which works much better, but is
630 (defvar gnus-summary-default-score 0
631 "*Default article score level.
632 If this variable is nil, scoring will be disabled.")
634 (defvar gnus-summary-zcore-fuzz 0
635 "*Fuzziness factor for the zcore in the summary buffer.
636 Articles with scores closer than this to `gnus-summary-default-score'
637 will not be marked.")
639 (defvar gnus-simplify-subject-fuzzy-regexp nil
640 "*Strings to be removed when doing fuzzy matches.
641 This can either be a regular expression or list of regular expressions
642 that will be removed from subject strings if fuzzy subject
643 simplification is selected.")
645 (defvar gnus-permanently-visible-groups nil
646 "*Regexp to match groups that should always be listed in the group buffer.
647 This means that they will still be listed when there are no unread
648 articles in the groups.")
650 (defvar gnus-list-groups-with-ticked-articles t
651 "*If non-nil, list groups that have only ticked articles.
652 If nil, only list groups that have unread articles.")
654 (defvar gnus-group-default-list-level gnus-level-subscribed
655 "*Default listing level.
656 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
658 (defvar gnus-group-use-permanent-levels nil
659 "*If non-nil, once you set a level, Gnus will use this level.")
661 (defvar gnus-group-list-inactive-groups t
662 "*If non-nil, inactive groups will be listed.")
664 (defvar gnus-show-mime nil
665 "*If non-nil, do mime processing of articles.
666 The articles will simply be fed to the function given by
667 `gnus-show-mime-method'.")
669 (defvar gnus-strict-mime t
670 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
672 (defvar gnus-show-mime-method 'metamail-buffer
673 "*Function to process a MIME message.
674 The function is called from the article buffer.")
676 (defvar gnus-decode-encoded-word-method (lambda ())
677 "*Function to decode a MIME encoded-words.
678 The function is called from the article buffer.")
680 (defvar gnus-show-threads t
681 "*If non-nil, display threads in summary mode.")
683 (defvar gnus-thread-hide-subtree nil
684 "*If non-nil, hide all threads initially.
685 If threads are hidden, you have to run the command
686 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
687 to expose hidden threads.")
689 (defvar gnus-thread-hide-killed t
690 "*If non-nil, hide killed threads automatically.")
692 (defvar gnus-thread-ignore-subject nil
693 "*If non-nil, ignore subjects and do all threading based on the Reference header.
694 If nil, which is the default, articles that have different subjects
695 from their parents will start separate threads.")
697 (defvar gnus-thread-operation-ignore-subject t
698 "*If non-nil, subjects will be ignored when doing thread commands.
699 This affects commands like `gnus-summary-kill-thread' and
700 `gnus-summary-lower-thread'.
702 If this variable is nil, articles in the same thread with different
703 subjects will not be included in the operation in question. If this
704 variable is `fuzzy', only articles that have subjects that are fuzzily
705 equal will be included.")
707 (defvar gnus-thread-indent-level 4
708 "*Number that says how much each sub-thread should be indented.")
710 (defvar gnus-ignored-newsgroups
711 (purecopy (mapconcat 'identity
712 '("^to\\." ; not "real" groups
713 "^[0-9. \t]+ " ; all digits in name
714 "[][\"#'()]" ; bogus characters
717 "*A regexp to match uninteresting newsgroups in the active file.
718 Any lines in the active file matching this regular expression are
719 removed from the newsgroup list before anything else is done to it,
720 thus making them effectively non-existent.")
722 (defvar gnus-ignored-headers
723 "^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:"
724 "*All headers that match this regexp will be hidden.
725 This variable can also be a list of regexps of headers to be ignored.
726 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
728 (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-"
729 "*All headers that do not match this regexp will be hidden.
730 This variable can also be a list of regexp of headers to remain visible.
731 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
733 (defvar gnus-sorted-header-list
734 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
735 "^Cc:" "^Date:" "^Organization:")
736 "*This variable is a list of regular expressions.
737 If it is non-nil, headers that match the regular expressions will
738 be placed first in the article buffer in the sequence specified by
741 (defvar gnus-boring-article-headers
742 '(empty followup-to reply-to)
743 "*Headers that are only to be displayed if they have interesting data.
744 Possible values in this list are `empty', `newsgroups', `followup-to',
745 `reply-to', and `date'.")
747 (defvar gnus-show-all-headers nil
748 "*If non-nil, don't hide any headers.")
750 (defvar gnus-save-all-headers t
751 "*If non-nil, don't remove any headers before saving.")
753 (defvar gnus-saved-headers gnus-visible-headers
754 "*Headers to keep if `gnus-save-all-headers' is nil.
755 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
756 If that variable is nil, however, all headers that match this regexp
757 will be kept while the rest will be deleted before saving.")
759 (defvar gnus-inhibit-startup-message nil
760 "*If non-nil, the startup message will not be displayed.")
762 (defvar gnus-signature-separator "^-- *$"
763 "Regexp matching signature separator.")
765 (defvar gnus-signature-limit nil
766 "Provide a limit to what is considered a signature.
767 If it is a number, no signature may not be longer (in characters) than
768 that number. If it is a function, the function will be called without
769 any parameters, and if it returns nil, there is no signature in the
770 buffer. If it is a string, it will be used as a regexp. If it
771 matches, the text in question is not a signature.")
773 (defvar gnus-auto-extend-newsgroup t
774 "*If non-nil, extend newsgroup forward and backward when requested.")
776 (defvar gnus-auto-select-first t
777 "*If nil, don't select the first unread article when entering a group.
778 If this variable is `best', select the highest-scored unread article
779 in the group. If neither nil nor `best', select the first unread
782 If you want to prevent automatic selection of the first unread article
783 in some newsgroups, set the variable to nil in
784 `gnus-select-group-hook'.")
786 (defvar gnus-auto-select-next t
787 "*If non-nil, offer to go to the next group from the end of the previous.
788 If the value is t and the next newsgroup is empty, Gnus will exit
789 summary mode and go back to group mode. If the value is neither nil
790 nor t, Gnus will select the following unread newsgroup. In
791 particular, if the value is the symbol `quietly', the next unread
792 newsgroup will be selected without any confirmation, and if it is
793 `almost-quietly', the next group will be selected without any
794 confirmation if you are located on the last article in the group.
795 Finally, if this variable is `slightly-quietly', the `Z n' command
796 will go to the next group without confirmation.")
798 (defvar gnus-auto-select-same nil
799 "*If non-nil, select the next article with the same subject.")
801 (defvar gnus-summary-check-current nil
802 "*If non-nil, consider the current article when moving.
803 The \"unread\" movement commands will stay on the same line if the
804 current article is unread.")
806 (defvar gnus-auto-center-summary t
807 "*If non-nil, always center the current summary buffer.
808 In particular, if `vertical' do only vertical recentering. If non-nil
809 and non-`vertical', do both horizontal and vertical recentering.")
811 (defvar gnus-break-pages t
812 "*If non-nil, do page breaking on articles.
813 The page delimiter is specified by the `gnus-page-delimiter'
816 (defvar gnus-page-delimiter "^\^L"
817 "*Regexp describing what to use as article page delimiters.
818 The default value is \"^\^L\", which is a form linefeed at the
819 beginning of a line.")
821 (defvar gnus-use-full-window t
822 "*If non-nil, use the entire Emacs screen.")
824 (defvar gnus-window-configuration nil
825 "Obsolete variable. See `gnus-buffer-configuration'.")
827 (defvar gnus-window-min-width 2
828 "*Minimum width of Gnus buffers.")
830 (defvar gnus-window-min-height 1
831 "*Minimum height of Gnus buffers.")
833 (defvar gnus-buffer-configuration
837 (if gnus-carpal '(group-carpal 4))))
841 (if gnus-carpal '(summary-carpal 4))))
848 (if gnus-carpal '(summary-carpal 4))
850 (vertical ((height . 5) (width . 15)
852 (left . -1) (top . 1))
862 (if gnus-carpal '(summary-carpal 4))
863 (if gnus-use-trees '(tree 0.25))
868 (if gnus-carpal '(server-carpal 2))))
872 (if gnus-carpal '(browse-carpal 2))))
875 (message 1.0 point)))
878 (article 1.0 point)))
889 (edit-group 1.0 point)))
893 (edit-server 1.0 point)))
897 (edit-score 1.0 point)))
904 (message 1.0 point)))
907 (message 1.0 point)))
910 (message 1.0 point)))
914 (message 1.0 point)))
921 (if gnus-carpal '(summary-carpal 4))
922 ("*Shell Command Output*" 1.0)))
925 ("*Gnus Help Bug*" 0.5)
926 ("*Gnus Bug*" 1.0 point)))
930 (message 1.0 point))))
931 "Window configuration for all possible Gnus buffers.
932 This variable is a list of lists. Each of these lists has a NAME and
933 a RULE. The NAMEs are commonsense names like `group', which names a
934 rule used when displaying the group buffer; `summary', which names a
935 rule for what happens when you enter a group and do not display an
936 article buffer; and so on. See the value of this variable for a
937 complete list of NAMEs.
939 Each RULE is a list of vectors. The first element in this vector is
940 the name of the buffer to be displayed; the second element is the
941 percentage of the screen this buffer is to occupy (a number in the
942 0.0-0.99 range); the optional third element is `point', which should
943 be present to denote which buffer point is to go to after making this
944 buffer configuration.")
946 (defvar gnus-window-to-buffer
947 '((group . gnus-group-buffer)
948 (summary . gnus-summary-buffer)
949 (article . gnus-article-buffer)
950 (server . gnus-server-buffer)
951 (browse . "*Gnus Browse Server*")
952 (edit-group . gnus-group-edit-buffer)
953 (edit-server . gnus-server-edit-buffer)
954 (group-carpal . gnus-carpal-group-buffer)
955 (summary-carpal . gnus-carpal-summary-buffer)
956 (server-carpal . gnus-carpal-server-buffer)
957 (browse-carpal . gnus-carpal-browse-buffer)
958 (edit-score . gnus-score-edit-buffer)
959 (message . gnus-message-buffer)
960 (mail . gnus-message-buffer)
961 (post-news . gnus-message-buffer)
962 (faq . gnus-faq-buffer)
963 (picons . "*Picons*")
964 (tree . gnus-tree-buffer)
965 (info . gnus-info-buffer)
966 (article-copy . gnus-article-copy)
967 (draft . gnus-draft-buffer))
968 "Mapping from short symbols to buffer names or buffer variables.")
970 (defvar gnus-carpal nil
971 "*If non-nil, display clickable icons.")
973 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
974 "*Function called with a group name when new group is detected.
975 A few pre-made functions are supplied: `gnus-subscribe-randomly'
976 inserts new groups at the beginning of the list of groups;
977 `gnus-subscribe-alphabetically' inserts new groups in strict
978 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
979 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
980 for your decision; `gnus-subscribe-killed' kills all new groups;
981 `gnus-subscribe-zombies' will make all new groups into zombies.")
983 ;; Suggested by a bug report by Hallvard B Furuseth.
984 ;; <h.b.furuseth@usit.uio.no>.
985 (defvar gnus-subscribe-options-newsgroup-method
986 (function gnus-subscribe-alphabetically)
987 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
988 If, for instance, you want to subscribe to all newsgroups in the
989 \"no\" and \"alt\" hierarchies, you'd put the following in your
992 options -n no.all alt.all
994 Gnus will the subscribe all new newsgroups in these hierarchies with
995 the subscription method in this variable.")
997 (defvar gnus-subscribe-hierarchical-interactive nil
998 "*If non-nil, Gnus will offer to subscribe hierarchically.
999 When a new hierarchy appears, Gnus will ask the user:
1001 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1003 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1004 subscribe to all newsgroups in the hierarchy and `s' will skip this
1005 hierarchy in its entirety.")
1007 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1008 "*Function used for sorting the group buffer.
1009 This function will be called with group info entries as the arguments
1010 for the groups to be sorted. Pre-made functions include
1011 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1012 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1013 `gnus-group-sort-by-rank'.
1015 This variable can also be a list of sorting functions. In that case,
1016 the most significant sort function should be the last function in the
1019 ;; Mark variables suggested by Thomas Michanek
1020 ;; <Thomas.Michanek@telelogic.se>.
1021 (defvar gnus-unread-mark ?
1022 "*Mark used for unread articles.")
1023 (defvar gnus-ticked-mark ?!
1024 "*Mark used for ticked articles.")
1025 (defvar gnus-dormant-mark ??
1026 "*Mark used for dormant articles.")
1027 (defvar gnus-del-mark ?r
1028 "*Mark used for del'd articles.")
1029 (defvar gnus-read-mark ?R
1030 "*Mark used for read articles.")
1031 (defvar gnus-expirable-mark ?E
1032 "*Mark used for expirable articles.")
1033 (defvar gnus-killed-mark ?K
1034 "*Mark used for killed articles.")
1035 (defvar gnus-souped-mark ?F
1036 "*Mark used for killed articles.")
1037 (defvar gnus-kill-file-mark ?X
1038 "*Mark used for articles killed by kill files.")
1039 (defvar gnus-low-score-mark ?Y
1040 "*Mark used for articles with a low score.")
1041 (defvar gnus-catchup-mark ?C
1042 "*Mark used for articles that are caught up.")
1043 (defvar gnus-replied-mark ?A
1044 "*Mark used for articles that have been replied to.")
1045 (defvar gnus-cached-mark ?*
1046 "*Mark used for articles that are in the cache.")
1047 (defvar gnus-saved-mark ?S
1048 "*Mark used for articles that have been saved to.")
1049 (defvar gnus-process-mark ?#
1051 (defvar gnus-ancient-mark ?O
1052 "*Mark used for ancient articles.")
1053 (defvar gnus-sparse-mark ?Q
1054 "*Mark used for sparsely reffed articles.")
1055 (defvar gnus-canceled-mark ?G
1056 "*Mark used for canceled articles.")
1057 (defvar gnus-score-over-mark ?+
1058 "*Score mark used for articles with high scores.")
1059 (defvar gnus-score-below-mark ?-
1060 "*Score mark used for articles with low scores.")
1061 (defvar gnus-empty-thread-mark ?
1062 "*There is no thread under the article.")
1063 (defvar gnus-not-empty-thread-mark ?=
1064 "*There is a thread under the article.")
1066 (defvar gnus-view-pseudo-asynchronously nil
1067 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1069 (defvar gnus-view-pseudos nil
1070 "*If `automatic', pseudo-articles will be viewed automatically.
1071 If `not-confirm', pseudos will be viewed automatically, and the user
1072 will not be asked to confirm the command.")
1074 (defvar gnus-view-pseudos-separately t
1075 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1076 If nil, all files that use the same viewing command will be given as a
1077 list of parameters to that command.")
1079 (defvar gnus-insert-pseudo-articles t
1080 "*If non-nil, insert pseudo-articles when decoding articles.")
1082 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1083 "*Format of group lines.
1084 It works along the same lines as a normal formatting string,
1085 with some simple extensions.
1087 %M Only marked articles (character, \"*\" or \" \")
1088 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1089 %L Level of subscribedness (integer)
1090 %N Number of unread articles (integer)
1091 %I Number of dormant articles (integer)
1092 %i Number of ticked and dormant (integer)
1093 %T Number of ticked articles (integer)
1094 %R Number of read articles (integer)
1095 %t Total number of articles (integer)
1096 %y Number of unread, unticked articles (integer)
1097 %G Group name (string)
1098 %g Qualified group name (string)
1099 %D Group description (string)
1100 %s Select method (string)
1101 %o Moderated group (char, \"m\")
1102 %p Process mark (char)
1103 %O Moderated group (string, \"(m)\" or \"\")
1104 %P Topic indentation (string)
1105 %l Whether there are GroupLens predictions for this group (string)
1106 %n Select from where (string)
1107 %z A string that look like `<%s:%n>' if a foreign select method is used
1108 %u User defined specifier. The next character in the format string should
1109 be a letter. Gnus will call the function gnus-user-format-function-X,
1110 where X is the letter following %u. The function will be passed the
1111 current header as argument. The function should return a string, which
1112 will be inserted into the buffer just like information from any other
1115 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1116 the mouse point move inside the area. There can only be one such area.
1118 Note that this format specification is not always respected. For
1119 reasons of efficiency, when listing killed groups, this specification
1120 is ignored altogether. If the spec is changed considerably, your
1121 output may end up looking strange when listing both alive and killed
1124 If you use %o or %O, reading the active file will be slower and quite
1125 a bit of extra memory will be used. %D will also worsen performance.
1126 Also note that if you change the format specification to include any
1127 of these specs, you must probably re-start Gnus to see them go into
1130 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1131 "*The format specification of the lines in the summary buffer.
1133 It works along the same lines as a normal formatting string,
1134 with some simple extensions.
1136 %N Article number, left padded with spaces (string)
1138 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1139 %n Name of the poster (string)
1140 %a Extracted name of the poster (string)
1141 %A Extracted address of the poster (string)
1142 %F Contents of the From: header (string)
1143 %x Contents of the Xref: header (string)
1144 %D Date of the article (string)
1145 %d Date of the article (string) in DD-MMM format
1146 %M Message-id of the article (string)
1147 %r References of the article (string)
1148 %c Number of characters in the article (integer)
1149 %L Number of lines in the article (integer)
1150 %I Indentation based on thread level (a string of spaces)
1151 %T A string with two possible values: 80 spaces if the article
1152 is on thread level two or larger and 0 spaces on level one
1153 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1154 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1155 %[ Opening bracket (character, \"[\" or \"<\")
1156 %] Closing bracket (character, \"]\" or \">\")
1157 %> Spaces of length thread-level (string)
1158 %< Spaces of length (- 20 thread-level) (string)
1159 %i Article score (number)
1160 %z Article zcore (character)
1161 %t Number of articles under the current thread (number).
1162 %e Whether the thread is empty or not (character).
1163 %l GroupLens score (string).
1164 %u User defined specifier. The next character in the format string should
1165 be a letter. Gnus will call the function gnus-user-format-function-X,
1166 where X is the letter following %u. The function will be passed the
1167 current header as argument. The function should return a string, which
1168 will be inserted into the summary just like information from any other
1171 Text between %( and %) will be highlighted with `gnus-mouse-face'
1172 when the mouse point is placed inside the area. There can only be one
1175 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1176 with care. For reasons of efficiency, Gnus will compute what column
1177 these characters will end up in, and \"hard-code\" that. This means that
1178 it is illegal to have these specs after a variable-length spec. Well,
1179 you might not be arrested, but your summary buffer will look strange,
1180 which is bad enough.
1182 The smart choice is to have these specs as for to the left as
1185 This restriction may disappear in later versions of Gnus.")
1187 (defvar gnus-summary-dummy-line-format
1189 "*The format specification for the dummy roots in the summary buffer.
1190 It works along the same lines as a normal formatting string,
1191 with some simple extensions.
1195 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1196 "*The format specification for the summary mode line.
1197 It works along the same lines as a normal formatting string,
1198 with some simple extensions:
1201 %p Unprefixed group name
1202 %A Current article number
1204 %U Number of unread articles in the group
1205 %e Number of unselected articles in the group
1206 %Z A string with unread/unselected article counts
1207 %g Shortish group name
1208 %S Subject of the current article
1209 %u User-defined spec
1210 %s Current score file name
1211 %d Number of dormant articles
1212 %r Number of articles that have been marked as read in this session
1213 %E Number of articles expunged by the score files")
1215 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1216 "*The format specification for the article mode line.
1217 See `gnus-summary-mode-line-format' for a closer description.")
1219 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1220 "*The format specification for the group mode line.
1221 It works along the same lines as a normal formatting string,
1222 with some simple extensions:
1224 %S The native news server.
1225 %M The native select method.
1226 %: \":\" if %S isn't \"\".")
1228 (defvar gnus-valid-select-methods
1229 '(("nntp" post address prompt-address)
1230 ("nnspool" post address)
1231 ("nnvirtual" post-mail virtual prompt-address)
1232 ("nnmbox" mail respool address)
1233 ("nnml" mail respool address)
1234 ("nnmh" mail respool address)
1235 ("nndir" post-mail prompt-address address)
1236 ("nneething" none address prompt-address)
1237 ("nndoc" none address prompt-address)
1238 ("nnbabyl" mail address respool)
1239 ("nnkiboze" post address virtual)
1240 ("nnsoup" post-mail address)
1241 ("nndraft" post-mail)
1242 ("nnfolder" mail respool address))
1243 "An alist of valid select methods.
1244 The first element of each list lists should be a string with the name
1245 of the select method. The other elements may be be the category of
1246 this method (ie. `post', `mail', `none' or whatever) or other
1247 properties that this method has (like being respoolable).
1248 If you implement a new select method, all you should have to change is
1249 this variable. I think.")
1251 (defvar gnus-updated-mode-lines '(group article summary tree)
1252 "*List of buffers that should update their mode lines.
1253 The list may contain the symbols `group', `article' and `summary'. If
1254 the corresponding symbol is present, Gnus will keep that mode line
1255 updated with information that may be pertinent.
1256 If this variable is nil, screen refresh may be quicker.")
1258 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1259 (defvar gnus-mode-non-string-length nil
1260 "*Max length of mode-line non-string contents.
1261 If this is nil, Gnus will take space as is needed, leaving the rest
1262 of the modeline intact.")
1265 ;(defvar gnus-mouse-face 'highlight
1266 ; "*Face used for mouse highlighting in Gnus.
1267 ;No mouse highlights will be done if `gnus-visual' is nil.")
1269 (defvar gnus-summary-mark-below 0
1270 "*Mark all articles with a score below this variable as read.
1271 This variable is local to each summary buffer and usually set by the
1274 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1275 "*List of functions used for sorting articles in the summary buffer.
1276 This variable is only used when not using a threaded display.")
1278 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1279 "*List of functions used for sorting threads in the summary buffer.
1280 By default, threads are sorted by article number.
1282 Each function takes two threads and return non-nil if the first thread
1283 should be sorted before the other. If you use more than one function,
1284 the primary sort function should be the last. You should probably
1285 always include `gnus-thread-sort-by-number' in the list of sorting
1286 functions -- preferably first.
1288 Ready-mady functions include `gnus-thread-sort-by-number',
1289 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1290 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1291 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1293 (defvar gnus-thread-score-function '+
1294 "*Function used for calculating the total score of a thread.
1296 The function is called with the scores of the article and each
1297 subthread and should then return the score of the thread.
1299 Some functions you can use are `+', `max', or `min'.")
1301 (defvar gnus-summary-expunge-below nil
1302 "All articles that have a score less than this variable will be expunged.")
1304 (defvar gnus-thread-expunge-below nil
1305 "All threads that have a total score less than this variable will be expunged.
1306 See `gnus-thread-score-function' for en explanation of what a
1307 \"thread score\" is.")
1309 (defvar gnus-auto-subscribed-groups
1310 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1311 "*All new groups that match this regexp will be subscribed automatically.
1312 Note that this variable only deals with new groups. It has no effect
1313 whatsoever on old groups.")
1315 (defvar gnus-options-subscribe nil
1316 "*All new groups matching this regexp will be subscribed unconditionally.
1317 Note that this variable deals only with new newsgroups. This variable
1318 does not affect old newsgroups.")
1320 (defvar gnus-options-not-subscribe nil
1321 "*All new groups matching this regexp will be ignored.
1322 Note that this variable deals only with new newsgroups. This variable
1323 does not affect old (already subscribed) newsgroups.")
1325 (defvar gnus-auto-expirable-newsgroups nil
1326 "*Groups in which to automatically mark read articles as expirable.
1327 If non-nil, this should be a regexp that should match all groups in
1328 which to perform auto-expiry. This only makes sense for mail groups.")
1330 (defvar gnus-total-expirable-newsgroups nil
1331 "*Groups in which to perform expiry of all read articles.
1332 Use with extreme caution. All groups that match this regexp will be
1333 expiring - which means that all read articles will be deleted after
1334 (say) one week. (This only goes for mail groups and the like, of
1337 (defvar gnus-group-uncollapsed-levels 1
1338 "Number of group name elements to leave alone when making a short group name.")
1340 (defvar gnus-hidden-properties '(invisible t intangible t)
1341 "Property list to use for hiding text.")
1343 (defvar gnus-modtime-botch nil
1344 "*Non-nil means .newsrc should be deleted prior to save.
1345 Its use is due to the bogus appearance that .newsrc was modified on
1350 (defvar gnus-group-mode-hook nil
1351 "*A hook for Gnus group mode.")
1353 (defvar gnus-summary-mode-hook nil
1354 "*A hook for Gnus summary mode.
1355 This hook is run before any variables are set in the summary buffer.")
1357 (defvar gnus-article-mode-hook nil
1358 "*A hook for Gnus article mode.")
1360 (defvar gnus-summary-prepare-exit-hook nil
1361 "*A hook called when preparing to exit from the summary buffer.
1362 It calls `gnus-summary-expire-articles' by default.")
1363 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1365 (defvar gnus-summary-exit-hook nil
1366 "*A hook called on exit from the summary buffer.")
1368 (defvar gnus-group-catchup-group-hook nil
1369 "*A hook run when catching up a group from the group buffer.")
1371 (defvar gnus-group-update-group-hook nil
1372 "*A hook called when updating group lines.")
1374 (defvar gnus-open-server-hook nil
1375 "*A hook called just before opening connection to the news server.")
1377 (defvar gnus-load-hook nil
1378 "*A hook run while Gnus is loaded.")
1380 (defvar gnus-startup-hook nil
1381 "*A hook called at startup.
1382 This hook is called after Gnus is connected to the NNTP server.")
1384 (defvar gnus-get-new-news-hook nil
1385 "*A hook run just before Gnus checks for new news.")
1387 (defvar gnus-after-getting-new-news-hook nil
1388 "*A hook run after Gnus checks for new news.")
1390 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1391 "*A function that is called to generate the group buffer.
1392 The function is called with three arguments: The first is a number;
1393 all group with a level less or equal to that number should be listed,
1394 if the second is non-nil, empty groups should also be displayed. If
1395 the third is non-nil, it is a number. No groups with a level lower
1396 than this number should be displayed.
1398 The only current function implemented is `gnus-group-prepare-flat'.")
1400 (defvar gnus-group-prepare-hook nil
1401 "*A hook called after the group buffer has been generated.
1402 If you want to modify the group buffer, you can use this hook.")
1404 (defvar gnus-summary-prepare-hook nil
1405 "*A hook called after the summary buffer has been generated.
1406 If you want to modify the summary buffer, you can use this hook.")
1408 (defvar gnus-summary-generate-hook nil
1409 "*A hook run just before generating the summary buffer.
1410 This hook is commonly used to customize threading variables and the
1413 (defvar gnus-article-prepare-hook nil
1414 "*A hook called after an article has been prepared in the article buffer.
1415 If you want to run a special decoding program like nkf, use this hook.")
1417 ;(defvar gnus-article-display-hook nil
1418 ; "*A hook called after the article is displayed in the article buffer.
1419 ;The hook is designed to change the contents of the article
1420 ;buffer. Typical functions that this hook may contain are
1421 ;`gnus-article-hide-headers' (hide selected headers),
1422 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1423 ;`gnus-article-hide-signature' (hide signature) and
1424 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1425 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1426 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1427 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1429 (defvar gnus-article-x-face-too-ugly nil
1430 "Regexp matching posters whose face shouldn't be shown automatically.")
1432 (defvar gnus-select-group-hook nil
1433 "*A hook called when a newsgroup is selected.
1435 If you'd like to simplify subjects like the
1436 `gnus-summary-next-same-subject' command does, you can use the
1439 (setq gnus-select-group-hook
1442 (mapcar (lambda (header)
1443 (mail-header-set-subject
1445 (gnus-simplify-subject
1446 (mail-header-subject header) 're-only)))
1447 gnus-newsgroup-headers))))")
1449 (defvar gnus-select-article-hook nil
1450 "*A hook called when an article is selected.")
1452 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1453 "*A hook called to apply kill files to a group.
1454 This hook is intended to apply a kill file to the selected newsgroup.
1455 The function `gnus-apply-kill-file' is called by default.
1457 Since a general kill file is too heavy to use only for a few
1458 newsgroups, I recommend you to use a lighter hook function. For
1459 example, if you'd like to apply a kill file to articles which contains
1460 a string `rmgroup' in subject in newsgroup `control', you can use the
1463 (setq gnus-apply-kill-hook
1466 (cond ((string-match \"control\" gnus-newsgroup-name)
1467 (gnus-kill \"Subject\" \"rmgroup\")
1468 (gnus-expunge \"X\"))))))")
1470 (defvar gnus-visual-mark-article-hook
1471 (list 'gnus-highlight-selected-summary)
1472 "*Hook run after selecting an article in the summary buffer.
1473 It is meant to be used for highlighting the article in some way. It
1474 is not run if `gnus-visual' is nil.")
1476 (defvar gnus-parse-headers-hook nil
1477 "*A hook called before parsing the headers.")
1478 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1480 (defvar gnus-exit-group-hook nil
1481 "*A hook called when exiting (not quitting) summary mode.")
1483 (defvar gnus-suspend-gnus-hook nil
1484 "*A hook called when suspending (not exiting) Gnus.")
1486 (defvar gnus-exit-gnus-hook nil
1487 "*A hook called when exiting Gnus.")
1489 (defvar gnus-after-exiting-gnus-hook nil
1490 "*A hook called after exiting Gnus.")
1492 (defvar gnus-save-newsrc-hook nil
1493 "*A hook called before saving any of the newsrc files.")
1495 (defvar gnus-save-quick-newsrc-hook nil
1496 "*A hook called just before saving the quick newsrc file.
1497 Can be used to turn version control on or off.")
1499 (defvar gnus-save-standard-newsrc-hook nil
1500 "*A hook called just before saving the standard newsrc file.
1501 Can be used to turn version control on or off.")
1503 (defvar gnus-summary-update-hook
1504 (list 'gnus-summary-highlight-line)
1505 "*A hook called when a summary line is changed.
1506 The hook will not be called if `gnus-visual' is nil.
1508 The default function `gnus-summary-highlight-line' will
1509 highlight the line according to the `gnus-summary-highlight'
1512 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1513 "*A hook called when a group line is changed.
1514 The hook will not be called if `gnus-visual' is nil.
1516 The default function `gnus-group-highlight-line' will
1517 highlight the line according to the `gnus-group-highlight'
1520 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1521 "*A hook called when an article is selected for the first time.
1522 The hook is intended to mark an article as read (or unread)
1523 automatically when it is selected.")
1525 (defvar gnus-group-change-level-function nil
1526 "Function run when a group level is changed.
1527 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1529 ;; Remove any hilit infestation.
1530 (add-hook 'gnus-startup-hook
1532 (remove-hook 'gnus-summary-prepare-hook
1533 'hilit-rehighlight-buffer-quietly)
1534 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1535 (setq gnus-mark-article-hook
1536 '(gnus-summary-mark-read-and-unread-as-read))
1537 (remove-hook 'gnus-article-prepare-hook
1538 'hilit-rehighlight-buffer-quietly)))
1541 ;; Internal variables
1543 (defvar gnus-tree-buffer "*Tree*"
1544 "Buffer where Gnus thread trees are displayed.")
1547 (defvar gnus-use-generic-from nil)
1549 (defvar gnus-thread-indent-array nil)
1550 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1552 (defvar gnus-newsrc-file-version nil)
1554 (defvar gnus-method-history nil)
1555 ;; Variable holding the user answers to all method prompts.
1557 (defvar gnus-group-history nil)
1558 ;; Variable holding the user answers to all group prompts.
1560 (defvar gnus-server-alist nil
1561 "List of available servers.")
1563 (defvar gnus-group-indentation-function nil)
1565 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1567 (defvar gnus-goto-missing-group-function nil)
1569 (defvar gnus-override-subscribe-method nil)
1571 (defvar gnus-group-goto-next-group-function nil
1572 "Function to override finding the next group after listing groups.")
1574 (defconst gnus-article-mark-lists
1575 '((marked . tick) (replied . reply)
1576 (expirable . expire) (killed . killed)
1577 (bookmarks . bookmark) (dormant . dormant)
1578 (scored . score) (saved . save)
1582 ;; Avoid highlighting in kill files.
1583 (defvar gnus-summary-inhibit-highlight nil)
1584 (defvar gnus-newsgroup-selected-overlay nil)
1586 (defvar gnus-inhibit-hiding nil)
1587 (defvar gnus-group-indentation "")
1588 (defvar gnus-inhibit-limiting nil)
1589 (defvar gnus-created-frames nil)
1591 (defvar gnus-article-mode-map nil)
1592 (defvar gnus-dribble-buffer nil)
1593 (defvar gnus-headers-retrieved-by nil)
1594 (defvar gnus-article-reply nil)
1595 (defvar gnus-override-method nil)
1596 (defvar gnus-article-check-size nil)
1598 (defvar gnus-current-score-file nil)
1599 (defvar gnus-newsgroup-adaptive-score-file nil)
1600 (defvar gnus-scores-exclude-files nil)
1602 (defvar gnus-opened-servers nil)
1604 (defvar gnus-current-move-group nil)
1605 (defvar gnus-current-copy-group nil)
1606 (defvar gnus-current-crosspost-group nil)
1608 (defvar gnus-newsgroup-dependencies nil)
1609 (defvar gnus-newsgroup-async nil)
1610 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1612 (defvar gnus-newsgroup-adaptive nil)
1614 (defvar gnus-summary-display-table nil)
1615 (defvar gnus-summary-display-article-function nil)
1617 (defvar gnus-summary-highlight-line-function nil
1618 "Function called after highlighting a summary line.")
1620 (defvar gnus-group-line-format-alist
1621 `((?M gnus-tmp-marked-mark ?c)
1622 (?S gnus-tmp-subscribed ?c)
1623 (?L gnus-tmp-level ?d)
1624 (?N (cond ((eq number t) "*" )
1628 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1629 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1631 (?R gnus-tmp-number-of-read ?s)
1632 (?t gnus-tmp-number-total ?d)
1633 (?y gnus-tmp-number-of-unread ?s)
1634 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1635 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1636 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1637 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1638 (?g gnus-tmp-group ?s)
1639 (?G gnus-tmp-qualified-group ?s)
1640 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1641 (?D gnus-tmp-newsgroup-description ?s)
1642 (?o gnus-tmp-moderated ?c)
1643 (?O gnus-tmp-moderated-string ?s)
1644 (?p gnus-tmp-process-marked ?c)
1645 (?s gnus-tmp-news-server ?s)
1646 (?n gnus-tmp-news-method ?s)
1647 (?P gnus-group-indentation ?s)
1648 (?l gnus-tmp-grouplens ?s)
1649 (?z gnus-tmp-news-method-string ?s)
1650 (?u gnus-tmp-user-defined ?s)))
1652 (defvar gnus-summary-line-format-alist
1653 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1654 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1655 (?s gnus-tmp-subject-or-nil ?s)
1656 (?n gnus-tmp-name ?s)
1657 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1659 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1661 (?F gnus-tmp-from ?s)
1662 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1663 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1664 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1665 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1666 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1667 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1668 (?L gnus-tmp-lines ?d)
1669 (?I gnus-tmp-indentation ?s)
1670 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1671 (?R gnus-tmp-replied ?c)
1672 (?\[ gnus-tmp-opening-bracket ?c)
1673 (?\] gnus-tmp-closing-bracket ?c)
1674 (?\> (make-string gnus-tmp-level ? ) ?s)
1675 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1676 (?i gnus-tmp-score ?d)
1677 (?z gnus-tmp-score-char ?c)
1678 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1679 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1680 (?U gnus-tmp-unread ?c)
1681 (?t (gnus-summary-number-of-articles-in-thread
1682 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1684 (?e (gnus-summary-number-of-articles-in-thread
1685 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1687 (?u gnus-tmp-user-defined ?s))
1688 "An alist of format specifications that can appear in summary lines,
1689 and what variables they correspond with, along with the type of the
1690 variable (string, integer, character, etc).")
1692 (defvar gnus-summary-dummy-line-format-alist
1693 `((?S gnus-tmp-subject ?s)
1694 (?N gnus-tmp-number ?d)
1695 (?u gnus-tmp-user-defined ?s)))
1697 (defvar gnus-summary-mode-line-format-alist
1698 `((?G gnus-tmp-group-name ?s)
1699 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1700 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1701 (?A gnus-tmp-article-number ?d)
1702 (?Z gnus-tmp-unread-and-unselected ?s)
1703 (?V gnus-version ?s)
1704 (?U gnus-tmp-unread ?d)
1705 (?S gnus-tmp-subject ?s)
1706 (?e gnus-tmp-unselected ?d)
1707 (?u gnus-tmp-user-defined ?s)
1708 (?d (length gnus-newsgroup-dormant) ?d)
1709 (?t (length gnus-newsgroup-marked) ?d)
1710 (?r (length gnus-newsgroup-reads) ?d)
1711 (?E gnus-newsgroup-expunged-tally ?d)
1712 (?s (gnus-current-score-file-nondirectory) ?s)))
1714 (defvar gnus-article-mode-line-format-alist
1715 gnus-summary-mode-line-format-alist)
1717 (defvar gnus-group-mode-line-format-alist
1718 `((?S gnus-tmp-news-server ?s)
1719 (?M gnus-tmp-news-method ?s)
1720 (?u gnus-tmp-user-defined ?s)
1721 (?: gnus-tmp-colon ?s)))
1723 (defvar gnus-have-read-active-file nil)
1725 (defconst gnus-maintainer
1726 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1727 "The mail address of the Gnus maintainers.")
1729 (defconst gnus-version-number "5.2.14"
1730 "Version number for this version of Gnus.")
1732 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1733 "Version string for this version of Gnus.")
1735 (defvar gnus-info-nodes
1736 '((gnus-group-mode "(gnus)The Group Buffer")
1737 (gnus-summary-mode "(gnus)The Summary Buffer")
1738 (gnus-article-mode "(gnus)The Article Buffer"))
1739 "Alist of major modes and related Info nodes.")
1741 (defvar gnus-group-buffer "*Group*")
1742 (defvar gnus-summary-buffer "*Summary*")
1743 (defvar gnus-article-buffer "*Article*")
1744 (defvar gnus-server-buffer "*Server*")
1746 (defvar gnus-work-buffer " *gnus work*")
1748 (defvar gnus-original-article-buffer " *Original Article*")
1749 (defvar gnus-original-article nil)
1751 (defvar gnus-buffer-list nil
1752 "Gnus buffers that should be killed on exit.")
1754 (defvar gnus-slave nil
1755 "Whether this Gnus is a slave or not.")
1757 (defvar gnus-variable-list
1758 '(gnus-newsrc-options gnus-newsrc-options-n
1759 gnus-newsrc-last-checked-date
1760 gnus-newsrc-alist gnus-server-alist
1761 gnus-killed-list gnus-zombie-list
1762 gnus-topic-topology gnus-topic-alist
1764 "Gnus variables saved in the quick startup file.")
1766 (defvar gnus-newsrc-options nil
1767 "Options line in the .newsrc file.")
1769 (defvar gnus-newsrc-options-n nil
1770 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1772 (defvar gnus-newsrc-last-checked-date nil
1773 "Date Gnus last asked server for new newsgroups.")
1775 (defvar gnus-topic-topology nil
1776 "The complete topic hierarchy.")
1778 (defvar gnus-topic-alist nil
1779 "The complete topic-group alist.")
1781 (defvar gnus-newsrc-alist nil
1782 "Assoc list of read articles.
1783 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1785 (defvar gnus-newsrc-hashtb nil
1786 "Hashtable of gnus-newsrc-alist.")
1788 (defvar gnus-killed-list nil
1789 "List of killed newsgroups.")
1791 (defvar gnus-killed-hashtb nil
1792 "Hash table equivalent of gnus-killed-list.")
1794 (defvar gnus-zombie-list nil
1795 "List of almost dead newsgroups.")
1797 (defvar gnus-description-hashtb nil
1798 "Descriptions of newsgroups.")
1800 (defvar gnus-list-of-killed-groups nil
1801 "List of newsgroups that have recently been killed by the user.")
1803 (defvar gnus-active-hashtb nil
1804 "Hashtable of active articles.")
1806 (defvar gnus-moderated-list nil
1807 "List of moderated newsgroups.")
1809 (defvar gnus-group-marked nil)
1811 (defvar gnus-current-startup-file nil
1812 "Startup file for the current host.")
1814 (defvar gnus-last-search-regexp nil
1815 "Default regexp for article search command.")
1817 (defvar gnus-last-shell-command nil
1818 "Default shell command on article.")
1820 (defvar gnus-current-select-method nil
1821 "The current method for selecting a newsgroup.")
1823 (defvar gnus-group-list-mode nil)
1825 (defvar gnus-article-internal-prepare-hook nil)
1827 (defvar gnus-newsgroup-name nil)
1828 (defvar gnus-newsgroup-begin nil)
1829 (defvar gnus-newsgroup-end nil)
1830 (defvar gnus-newsgroup-last-rmail nil)
1831 (defvar gnus-newsgroup-last-mail nil)
1832 (defvar gnus-newsgroup-last-folder nil)
1833 (defvar gnus-newsgroup-last-file nil)
1834 (defvar gnus-newsgroup-auto-expire nil)
1835 (defvar gnus-newsgroup-active nil)
1837 (defvar gnus-newsgroup-data nil)
1838 (defvar gnus-newsgroup-data-reverse nil)
1839 (defvar gnus-newsgroup-limit nil)
1840 (defvar gnus-newsgroup-limits nil)
1842 (defvar gnus-newsgroup-unreads nil
1843 "List of unread articles in the current newsgroup.")
1845 (defvar gnus-newsgroup-unselected nil
1846 "List of unselected unread articles in the current newsgroup.")
1848 (defvar gnus-newsgroup-reads nil
1849 "Alist of read articles and article marks in the current newsgroup.")
1851 (defvar gnus-newsgroup-expunged-tally nil)
1853 (defvar gnus-newsgroup-marked nil
1854 "List of ticked articles in the current newsgroup (a subset of unread art).")
1856 (defvar gnus-newsgroup-killed nil
1857 "List of ranges of articles that have been through the scoring process.")
1859 (defvar gnus-newsgroup-cached nil
1860 "List of articles that come from the article cache.")
1862 (defvar gnus-newsgroup-saved nil
1863 "List of articles that have been saved.")
1865 (defvar gnus-newsgroup-kill-headers nil)
1867 (defvar gnus-newsgroup-replied nil
1868 "List of articles that have been replied to in the current newsgroup.")
1870 (defvar gnus-newsgroup-expirable nil
1871 "List of articles in the current newsgroup that can be expired.")
1873 (defvar gnus-newsgroup-processable nil
1874 "List of articles in the current newsgroup that can be processed.")
1876 (defvar gnus-newsgroup-bookmarks nil
1877 "List of articles in the current newsgroup that have bookmarks.")
1879 (defvar gnus-newsgroup-dormant nil
1880 "List of dormant articles in the current newsgroup.")
1882 (defvar gnus-newsgroup-scored nil
1883 "List of scored articles in the current newsgroup.")
1885 (defvar gnus-newsgroup-headers nil
1886 "List of article headers in the current newsgroup.")
1888 (defvar gnus-newsgroup-threads nil)
1890 (defvar gnus-newsgroup-prepared nil
1891 "Whether the current group has been prepared properly.")
1893 (defvar gnus-newsgroup-ancient nil
1894 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1896 (defvar gnus-newsgroup-sparse nil)
1898 (defvar gnus-current-article nil)
1899 (defvar gnus-article-current nil)
1900 (defvar gnus-current-headers nil)
1901 (defvar gnus-have-all-headers nil)
1902 (defvar gnus-last-article nil)
1903 (defvar gnus-newsgroup-history nil)
1904 (defvar gnus-current-kill-article nil)
1906 ;; Save window configuration.
1907 (defvar gnus-prev-winconf nil)
1909 (defvar gnus-summary-mark-positions nil)
1910 (defvar gnus-group-mark-positions nil)
1912 (defvar gnus-reffed-article-number nil)
1914 ;;; Let the byte-compiler know that we know about this variable.
1915 (defvar rmail-default-rmail-file)
1917 (defvar gnus-cache-removable-articles nil)
1919 (defvar gnus-dead-summary nil)
1921 (defconst gnus-summary-local-variables
1922 '(gnus-newsgroup-name
1923 gnus-newsgroup-begin gnus-newsgroup-end
1924 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1925 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1926 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1927 gnus-newsgroup-unselected gnus-newsgroup-marked
1928 gnus-newsgroup-reads gnus-newsgroup-saved
1929 gnus-newsgroup-replied gnus-newsgroup-expirable
1930 gnus-newsgroup-processable gnus-newsgroup-killed
1931 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1932 gnus-newsgroup-headers gnus-newsgroup-threads
1933 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1934 gnus-current-article gnus-current-headers gnus-have-all-headers
1935 gnus-last-article gnus-article-internal-prepare-hook
1936 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1937 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1938 gnus-newsgroup-async gnus-thread-expunge-below
1939 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1940 (gnus-summary-mark-below . global)
1941 gnus-newsgroup-active gnus-scores-exclude-files
1942 gnus-newsgroup-history gnus-newsgroup-ancient
1943 gnus-newsgroup-sparse
1944 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1945 gnus-newsgroup-adaptive-score-file
1946 (gnus-newsgroup-expunged-tally . 0)
1947 gnus-cache-removable-articles gnus-newsgroup-cached
1948 gnus-newsgroup-data gnus-newsgroup-data-reverse
1949 gnus-newsgroup-limit gnus-newsgroup-limits)
1950 "Variables that are buffer-local to the summary buffers.")
1952 (defconst gnus-bug-message
1953 "Sending a bug report to the Gnus Towers.
1954 ========================================
1956 The buffer below is a mail buffer. When you press `C-c C-c', it will
1957 be sent to the Gnus Bug Exterminators.
1959 At the bottom of the buffer you'll see lots of variable settings.
1960 Please do not delete those. They will tell the Bug People what your
1961 environment is, so that it will be easier to locate the bugs.
1963 If you have found a bug that makes Emacs go \"beep\", set
1964 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1965 and include the backtrace in your bug report.
1967 Please describe the bug in annoying, painstaking detail.
1969 Thank you for your help in stamping out bugs.
1972 ;;; End of variables.
1974 ;; Define some autoload functions Gnus might use.
1977 ;; This little mapcar goes through the list below and marks the
1978 ;; symbols in question as autoloaded functions.
1981 (let ((interactive (nth 1 (memq ':interactive package))))
1985 (when (consp function)
1986 (setq keymap (car (memq 'keymap function)))
1987 (setq function (car function)))
1988 (autoload function (car package) nil interactive keymap)))
1989 (if (eq (nth 1 package) ':interactive)
1992 '(("metamail" metamail-buffer)
1993 ("info" Info-goto-node)
1994 ("hexl" hexl-hex-string-to-integer)
1995 ("pp" pp pp-to-string pp-eval-expression)
1996 ("mail-extr" mail-extract-address-components)
1997 ("nnmail" nnmail-split-fancy nnmail-article-group)
1998 ("nnvirtual" nnvirtual-catchup-group)
1999 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2000 timezone-make-sortable-date timezone-make-time-string)
2001 ("rmailout" rmail-output)
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-cancel-article gnus-summary-supersede-article
2087 gnus-post-news gnus-inews-news gnus-cancel-news
2088 gnus-summary-reply gnus-summary-reply-with-original
2089 gnus-summary-mail-forward gnus-summary-mail-other-window
2091 ("gnus-picon" :interactive t gnus-article-display-picons
2092 gnus-group-display-picons gnus-picons-article-display-x-face)
2093 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2094 gnus-grouplens-mode)
2095 ("gnus-vm" gnus-vm-mail-setup)
2096 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2097 gnus-summary-save-article-vm))))
2101 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2102 ;; If you want the cursor to go somewhere else, set these two
2103 ;; functions in some startup hook to whatever you want.
2104 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2105 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2107 ;;; Various macros and substs.
2109 (defun gnus-header-from (header)
2110 (mail-header-from header))
2112 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2113 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2114 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2115 (w (make-symbol "w"))
2116 (buf (make-symbol "buf")))
2117 `(let* ((,tempvar (selected-window))
2119 (,w (get-buffer-window ,buf 'visible)))
2124 (pop-to-buffer ,buf))
2126 (select-window ,tempvar)))))
2128 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2129 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2130 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2132 (defmacro gnus-gethash (string hashtable)
2133 "Get hash value of STRING in HASHTABLE."
2134 `(symbol-value (intern-soft ,string ,hashtable)))
2136 (defmacro gnus-sethash (string value hashtable)
2137 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2138 `(set (intern ,string ,hashtable) ,value))
2140 (defmacro gnus-intern-safe (string hashtable)
2141 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2142 `(let ((symbol (intern ,string ,hashtable)))
2147 (defmacro gnus-group-unread (group)
2148 "Get the currently computed number of unread articles in GROUP."
2149 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2151 (defmacro gnus-group-entry (group)
2152 "Get the newsrc entry for GROUP."
2153 `(gnus-gethash ,group gnus-newsrc-hashtb))
2155 (defmacro gnus-active (group)
2156 "Get active info on GROUP."
2157 `(gnus-gethash ,group gnus-active-hashtb))
2159 (defmacro gnus-set-active (group active)
2160 "Set GROUP's active info."
2161 `(gnus-sethash ,group ,active gnus-active-hashtb))
2163 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2164 ;; function `substring' might cut on a middle of multi-octet
2166 (defun gnus-truncate-string (str width)
2167 (substring str 0 width))
2169 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2170 ;; to limit the length of a string. This function is necessary since
2171 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2172 (defsubst gnus-limit-string (str width)
2173 (if (> (length str) width)
2174 (substring str 0 width)
2177 (defsubst gnus-simplify-subject-re (subject)
2178 "Remove \"Re:\" from subject lines."
2179 (if (string-match "^[Rr][Ee]: *" subject)
2180 (substring subject (match-end 0))
2183 (defsubst gnus-functionp (form)
2184 "Return non-nil if FORM is funcallable."
2185 (or (and (symbolp form) (fboundp form))
2186 (and (listp form) (eq (car form) 'lambda))))
2188 (defsubst gnus-goto-char (point)
2189 (and point (goto-char point)))
2191 (defmacro gnus-buffer-exists-p (buffer)
2192 `(let ((buffer ,buffer))
2194 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2197 (defmacro gnus-kill-buffer (buffer)
2198 `(let ((buf ,buffer))
2199 (if (gnus-buffer-exists-p buf)
2200 (kill-buffer buf))))
2202 (defsubst gnus-point-at-bol ()
2203 "Return point at the beginning of the line."
2210 (defsubst gnus-point-at-eol ()
2211 "Return point at the end of the line."
2218 (defun gnus-alive-p ()
2219 "Say whether Gnus is running or not."
2220 (and gnus-group-buffer
2221 (get-buffer gnus-group-buffer)))
2223 (defun gnus-delete-first (elt list)
2224 "Delete by side effect the first occurrence of ELT as a member of LIST."
2225 (if (equal (car list) elt)
2228 (while (and (cdr list)
2229 (not (equal (cadr list) elt)))
2230 (setq list (cdr list)))
2232 (setcdr list (cddr list)))
2235 ;; Delete the current line (and the next N lines.);
2236 (defmacro gnus-delete-line (&optional n)
2237 `(delete-region (progn (beginning-of-line) (point))
2238 (progn (forward-line ,(or n 1)) (point))))
2240 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2241 (defvar gnus-init-inhibit nil)
2242 (defun gnus-read-init-file (&optional inhibit-next)
2243 (if gnus-init-inhibit
2244 (setq gnus-init-inhibit nil)
2245 (setq gnus-init-inhibit inhibit-next)
2247 (or (and (file-exists-p gnus-init-file)
2248 ;; Don't try to load a directory.
2249 (not (file-directory-p gnus-init-file)))
2250 (file-exists-p (concat gnus-init-file ".el"))
2251 (file-exists-p (concat gnus-init-file ".elc")))
2253 (load gnus-init-file nil t)
2255 (error "Error in %s: %s" gnus-init-file var))))))
2257 ;; Info access macros.
2259 (defmacro gnus-info-group (info)
2261 (defmacro gnus-info-rank (info)
2263 (defmacro gnus-info-read (info)
2265 (defmacro gnus-info-marks (info)
2267 (defmacro gnus-info-method (info)
2269 (defmacro gnus-info-params (info)
2272 (defmacro gnus-info-level (info)
2273 `(let ((rank (gnus-info-rank ,info)))
2277 (defmacro gnus-info-score (info)
2278 `(let ((rank (gnus-info-rank ,info)))
2279 (or (and (consp rank) (cdr rank)) 0)))
2281 (defmacro gnus-info-set-group (info group)
2282 `(setcar ,info ,group))
2283 (defmacro gnus-info-set-rank (info rank)
2284 `(setcar (nthcdr 1 ,info) ,rank))
2285 (defmacro gnus-info-set-read (info read)
2286 `(setcar (nthcdr 2 ,info) ,read))
2287 (defmacro gnus-info-set-marks (info marks)
2288 `(setcar (nthcdr 3 ,info) ,marks))
2289 (defmacro gnus-info-set-method (info method)
2290 `(setcar (nthcdr 4 ,info) ,method))
2291 (defmacro gnus-info-set-params (info params)
2292 `(setcar (nthcdr 5 ,info) ,params))
2294 (defmacro gnus-info-set-level (info level)
2295 `(let ((rank (cdr ,info)))
2296 (if (consp (car rank))
2297 (setcar (car rank) ,level)
2298 (setcar rank ,level))))
2299 (defmacro gnus-info-set-score (info score)
2300 `(let ((rank (cdr ,info)))
2301 (if (consp (car rank))
2302 (setcdr (car rank) ,score)
2303 (setcar rank (cons (car rank) ,score)))))
2305 (defmacro gnus-get-info (group)
2306 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2308 (defun gnus-byte-code (func)
2309 "Return a form that can be `eval'ed based on FUNC."
2310 (let ((fval (symbol-function func)))
2311 (if (byte-code-function-p fval)
2312 (let ((flist (append fval nil)))
2313 (setcar flist 'byte-code)
2315 (cons 'progn (cddr fval)))))
2317 ;; Find out whether the gnus-visual TYPE is wanted.
2318 (defun gnus-visual-p (&optional type class)
2319 (and gnus-visual ; Has to be non-nil, at least.
2320 (if (not type) ; We don't care about type.
2322 (if (listp gnus-visual) ; It's a list, so we check it.
2323 (or (memq type gnus-visual)
2324 (memq class gnus-visual))
2327 ;;; Load the compatability functions.
2337 (defvar gnus-shutdown-alist nil)
2339 (defun gnus-add-shutdown (function &rest symbols)
2340 "Run FUNCTION whenever one of SYMBOLS is shut down."
2341 (push (cons function symbols) gnus-shutdown-alist))
2343 (defun gnus-shutdown (symbol)
2344 "Shut down everything that waits for SYMBOL."
2345 (let ((alist gnus-shutdown-alist)
2347 (while (setq entry (pop alist))
2348 (when (memq symbol (cdr entry))
2349 (funcall (car entry))))))
2353 ;; Format specs. The chunks below are the machine-generated forms
2354 ;; that are to be evaled as the result of the default format strings.
2355 ;; We write them in here to get them byte-compiled. That way the
2356 ;; default actions will be quite fast, while still retaining the full
2357 ;; flexibility of the user-defined format specs.
2359 ;; First we have lots of dummy defvars to let the compiler know these
2360 ;; are really dynamic variables.
2362 (defvar gnus-tmp-unread)
2363 (defvar gnus-tmp-replied)
2364 (defvar gnus-tmp-score-char)
2365 (defvar gnus-tmp-indentation)
2366 (defvar gnus-tmp-opening-bracket)
2367 (defvar gnus-tmp-lines)
2368 (defvar gnus-tmp-name)
2369 (defvar gnus-tmp-closing-bracket)
2370 (defvar gnus-tmp-subject-or-nil)
2371 (defvar gnus-tmp-subject)
2372 (defvar gnus-tmp-marked)
2373 (defvar gnus-tmp-marked-mark)
2374 (defvar gnus-tmp-subscribed)
2375 (defvar gnus-tmp-process-marked)
2376 (defvar gnus-tmp-number-of-unread)
2377 (defvar gnus-tmp-group-name)
2378 (defvar gnus-tmp-group)
2379 (defvar gnus-tmp-article-number)
2380 (defvar gnus-tmp-unread-and-unselected)
2381 (defvar gnus-tmp-news-method)
2382 (defvar gnus-tmp-news-server)
2383 (defvar gnus-tmp-article-number)
2384 (defvar gnus-mouse-face)
2385 (defvar gnus-mouse-face-prop)
2387 (defun gnus-summary-line-format-spec ()
2388 (insert gnus-tmp-unread gnus-tmp-replied
2389 gnus-tmp-score-char gnus-tmp-indentation)
2390 (gnus-put-text-property
2394 gnus-tmp-opening-bracket
2395 (format "%4d: %-20s"
2397 (if (> (length gnus-tmp-name) 20)
2398 (substring gnus-tmp-name 0 20)
2400 gnus-tmp-closing-bracket)
2402 gnus-mouse-face-prop gnus-mouse-face)
2403 (insert " " gnus-tmp-subject-or-nil "\n"))
2405 (defvar gnus-summary-line-format-spec
2406 (gnus-byte-code 'gnus-summary-line-format-spec))
2408 (defun gnus-summary-dummy-line-format-spec ()
2410 (gnus-put-text-property
2415 gnus-mouse-face-prop gnus-mouse-face)
2416 (insert " " gnus-tmp-subject "\n"))
2418 (defvar gnus-summary-dummy-line-format-spec
2419 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2421 (defun gnus-group-line-format-spec ()
2422 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2423 gnus-tmp-process-marked
2424 gnus-group-indentation
2425 (format "%5s: " gnus-tmp-number-of-unread))
2426 (gnus-put-text-property
2429 (insert gnus-tmp-group "\n")
2431 gnus-mouse-face-prop gnus-mouse-face))
2432 (defvar gnus-group-line-format-spec
2433 (gnus-byte-code 'gnus-group-line-format-spec))
2435 (defvar gnus-format-specs
2436 `((version . ,emacs-version)
2437 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2438 (summary-dummy ,gnus-summary-dummy-line-format
2439 ,gnus-summary-dummy-line-format-spec)
2440 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2442 (defvar gnus-article-mode-line-format-spec nil)
2443 (defvar gnus-summary-mode-line-format-spec nil)
2444 (defvar gnus-group-mode-line-format-spec nil)
2446 ;;; Phew. All that gruft is over, fortunately.
2450 ;;; Gnus Utility Functions
2453 (defun gnus-extract-address-components (from)
2455 ;; First find the address - the thing with the @ in it. This may
2456 ;; not be accurate in mail addresses, but does the trick most of
2457 ;; the time in news messages.
2458 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2459 (setq address (substring from (match-beginning 0) (match-end 0))))
2460 ;; Then we check whether the "name <address>" format is used.
2462 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2463 ;; Linear white space is not required.
2464 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2465 (and (setq name (substring from 0 (match-beginning 0)))
2466 ;; Strip any quotes from the name.
2467 (string-match "\".*\"" name)
2468 (setq name (substring name 1 (1- (match-end 0))))))
2469 ;; If not, then "address (name)" is used.
2471 (and (string-match "(.+)" from)
2472 (setq name (substring from (1+ (match-beginning 0))
2473 (1- (match-end 0)))))
2474 (and (string-match "()" from)
2475 (setq name address))
2476 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2477 ;; XOVER might not support folded From headers.
2478 (and (string-match "(.*" from)
2479 (setq name (substring from (1+ (match-beginning 0))
2481 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2482 (list (or name from) (or address from))))
2484 (defun gnus-fetch-field (field)
2485 "Return the value of the header FIELD of current article."
2488 (let ((case-fold-search t)
2489 (inhibit-point-motion-hooks t))
2490 (nnheader-narrow-to-headers)
2491 (message-fetch-field field)))))
2493 (defun gnus-goto-colon ()
2495 (search-forward ":" (gnus-point-at-eol) t))
2498 (defun gnus-update-format (var)
2499 "Update the format specification near point."
2504 ;; Find the end of the current word.
2505 (re-search-forward "[ \t\n]" nil t)
2507 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2508 (match-string 1)))))
2509 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2510 (match-string 1 var))))
2511 (entry (assq type gnus-format-specs))
2514 (setq gnus-format-specs (delq entry gnus-format-specs)))
2516 (intern (format "%s-spec" var))
2517 (gnus-parse-format (setq value (symbol-value (intern var)))
2518 (symbol-value (intern (format "%s-alist" var)))
2519 (not (string-match "mode" var))))
2520 (setq spec (symbol-value (intern (format "%s-spec" var))))
2521 (push (list type value spec) gnus-format-specs)
2523 (pop-to-buffer "*Gnus Format*")
2525 (lisp-interaction-mode)
2526 (insert (pp-to-string spec))))
2528 (defun gnus-update-format-specifications (&optional force)
2529 "Update all (necessary) format specifications."
2530 ;; Make the indentation array.
2531 (gnus-make-thread-indent-array)
2533 ;; See whether all the stored info needs to be flushed.
2535 (not (equal emacs-version
2536 (cdr (assq 'version gnus-format-specs)))))
2537 (setq gnus-format-specs nil))
2539 ;; Go through all the formats and see whether they need updating.
2540 (let ((types '(summary summary-dummy group
2541 summary-mode group-mode article-mode))
2542 new-format entry type val)
2543 (while (setq type (pop types))
2544 ;; Jump to the proper buffer to find out the value of
2545 ;; the variable, if possible. (It may be buffer-local.)
2547 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2549 (when (and (boundp buffer)
2550 (setq val (symbol-value buffer))
2552 (buffer-name (get-buffer val)))
2553 (set-buffer (get-buffer val)))
2554 (setq new-format (symbol-value
2555 (intern (format "gnus-%s-line-format" type))))))
2556 (setq entry (cdr (assq type gnus-format-specs)))
2558 (equal (car entry) new-format))
2559 ;; Use the old format.
2560 (set (intern (format "gnus-%s-line-format-spec" type))
2562 ;; This is a new format.
2564 (if (not (stringp new-format))
2565 ;; This is a function call or something.
2567 ;; This is a "real" format.
2571 (intern (format "gnus-%s-line-format-alist"
2572 (if (eq type 'article-mode)
2573 'summary-mode type))))
2574 (not (string-match "mode$" (symbol-name type))))))
2575 ;; Enter the new format spec into the list.
2578 (setcar (cdr entry) val)
2579 (setcar entry new-format))
2580 (push (list type new-format val) gnus-format-specs))
2581 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2583 (unless (assq 'version gnus-format-specs)
2584 (push (cons 'version emacs-version) gnus-format-specs))
2586 (gnus-update-group-mark-positions)
2587 (gnus-update-summary-mark-positions))
2589 (defun gnus-update-summary-mark-positions ()
2590 "Compute where the summary marks are to go."
2592 (when (and gnus-summary-buffer
2593 (get-buffer gnus-summary-buffer)
2594 (buffer-name (get-buffer gnus-summary-buffer)))
2595 (set-buffer gnus-summary-buffer))
2596 (let ((gnus-replied-mark 129)
2597 (gnus-score-below-mark 130)
2598 (gnus-score-over-mark 130)
2601 (spec gnus-summary-line-format-spec)
2604 (gnus-set-work-buffer)
2605 (let ((gnus-summary-line-format-spec spec))
2606 (gnus-summary-insert-line
2607 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2608 (goto-char (point-min))
2609 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2611 (goto-char (point-min))
2612 (push (cons 'replied (and (search-forward "\201" nil t)
2615 (goto-char (point-min))
2616 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2618 (setq gnus-summary-mark-positions pos))))
2620 (defun gnus-update-group-mark-positions ()
2622 (let ((gnus-process-mark 128)
2623 (gnus-group-marked '("dummy.group"))
2624 (gnus-active-hashtb (make-vector 10 0)))
2625 (gnus-set-active "dummy.group" '(0 . 0))
2626 (gnus-set-work-buffer)
2627 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2628 (goto-char (point-min))
2629 (setq gnus-group-mark-positions
2630 (list (cons 'process (and (search-forward "\200" nil t)
2631 (- (point) 2))))))))
2633 (defvar gnus-mouse-face-0 'highlight)
2634 (defvar gnus-mouse-face-1 'highlight)
2635 (defvar gnus-mouse-face-2 'highlight)
2636 (defvar gnus-mouse-face-3 'highlight)
2637 (defvar gnus-mouse-face-4 'highlight)
2639 (defun gnus-mouse-face-function (form type)
2640 `(gnus-put-text-property
2641 (point) (progn ,@form (point))
2642 gnus-mouse-face-prop
2645 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2647 (defvar gnus-face-0 'bold)
2648 (defvar gnus-face-1 'italic)
2649 (defvar gnus-face-2 'bold-italic)
2650 (defvar gnus-face-3 'bold)
2651 (defvar gnus-face-4 'bold)
2653 (defun gnus-face-face-function (form type)
2654 `(gnus-put-text-property
2655 (point) (progn ,@form (point))
2656 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2658 (defun gnus-max-width-function (el max-width)
2659 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2661 `(if (> (length ,el) ,max-width)
2662 (substring ,el 0 ,max-width)
2664 `(let ((val (eval ,el)))
2666 (setq val (int-to-string val)))
2667 (if (> (length val) ,max-width)
2668 (substring val 0 ,max-width)
2671 (defun gnus-parse-format (format spec-alist &optional insert)
2672 ;; This function parses the FORMAT string with the help of the
2673 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2674 ;; string. If the FORMAT string contains the specifiers %( and %)
2675 ;; the text between them will have the mouse-face text property.
2677 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2679 (gnus-parse-complex-format format spec-alist)
2680 ;; This is a simple format.
2681 (gnus-parse-simple-format format spec-alist insert)))
2683 (defun gnus-parse-complex-format (format spec-alist)
2685 (gnus-set-work-buffer)
2687 (goto-char (point-min))
2688 (while (re-search-forward "\"" nil t)
2689 (replace-match "\\\"" nil t))
2690 (goto-char (point-min))
2692 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2693 (let ((number (if (match-beginning 1)
2694 (match-string 1) "0"))
2695 (delim (aref (match-string 2) 0)))
2696 (if (or (= delim ?\() (= delim ?\{))
2697 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2699 (replace-match "\")\""))))
2700 (goto-char (point-max))
2702 (goto-char (point-min))
2703 (let ((form (read (current-buffer))))
2704 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2706 (defun gnus-complex-form-to-spec (form spec-alist)
2711 (gnus-parse-simple-format sform spec-alist t)
2712 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2713 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2717 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2718 ;; This function parses the FORMAT string with the help of the
2719 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2722 spec flist fstring newspec elem beg result dontinsert)
2724 (gnus-set-work-buffer)
2726 (goto-char (point-min))
2727 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2729 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2731 beg (1+ (match-beginning 0)))
2732 ;; First check if there are any specs that look anything like
2733 ;; "%12,12A", ie. with a "max width specification". These have
2734 ;; to be treated specially.
2735 (if (setq beg (match-beginning 1))
2739 (1+ (match-beginning 1)) (match-end 1))))
2741 (setq beg (match-beginning 2)))
2742 ;; Find the specification from `spec-alist'.
2743 (unless (setq elem (cdr (assq spec spec-alist)))
2744 (setq elem '("*" ?s)))
2745 ;; Treat user defined format specifiers specially.
2746 (when (eq (car elem) 'gnus-tmp-user-defined)
2749 (list (intern (concat "gnus-user-format-function-"
2751 'gnus-tmp-header) ?s))
2752 (delete-region (match-beginning 3) (match-end 3)))
2753 (if (not (zerop max-width))
2754 (let ((el (car elem)))
2755 (cond ((= (cadr elem) ?c)
2756 (setq el (list 'char-to-string el)))
2758 (setq el (list 'int-to-string el))))
2759 (setq flist (cons (gnus-max-width-function el max-width)
2763 (setq flist (cons (car elem) flist))
2764 (setq newspec (cadr elem)))))
2765 ;; Remove the old specification (and possibly a ",12" string).
2766 (delete-region beg (match-end 2))
2767 ;; Insert the new specification.
2770 (setq fstring (buffer-substring 1 (point-max))))
2771 ;; Do some postprocessing to increase efficiency.
2776 ((string= fstring "")
2778 ;; Not a format string.
2779 ((not (string-match "%" fstring))
2781 ;; A format string with just a single string spec.
2782 ((string= fstring "%s")
2784 ;; A single character.
2785 ((string= fstring "%c")
2788 ((string= fstring "%d")
2791 (list `(princ ,(car flist)))
2792 (list `(int-to-string ,(car flist)))))
2793 ;; Just lots of chars and strings.
2794 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2796 ;; A single string spec at the beginning of the spec.
2797 ((string-match "\\`%[sc][^%]+\\'" fstring)
2798 (list (car flist) (substring fstring 2)))
2799 ;; A single string spec in the middle of the spec.
2800 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2801 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2802 ;; A single string spec in the end of the spec.
2803 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2804 (list (match-string 1 fstring) (car flist)))
2805 ;; A more complex spec.
2807 (list (cons 'format (cons fstring (nreverse flist)))))))
2813 (cons 'insert result)))
2814 (cond ((stringp result)
2817 (cons 'concat result))
2820 (defun gnus-eval-format (format &optional alist props)
2821 "Eval the format variable FORMAT, using ALIST.
2822 If PROPS, insert the result."
2823 (let ((form (gnus-parse-format format alist props)))
2825 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2828 (defun gnus-remove-text-with-property (prop)
2829 "Delete all text in the current buffer with text property PROP."
2831 (goto-char (point-min))
2833 (while (get-text-property (point) prop)
2835 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2837 (defun gnus-set-work-buffer ()
2838 (if (get-buffer gnus-work-buffer)
2840 (set-buffer gnus-work-buffer)
2842 (set-buffer (get-buffer-create gnus-work-buffer))
2843 (kill-all-local-variables)
2844 (buffer-disable-undo (current-buffer))
2845 (gnus-add-current-to-buffer-list)))
2847 ;; Article file names when saving.
2849 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2850 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2851 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2852 Otherwise, it is like ~/News/news/group/num."
2855 (concat (if (gnus-use-long-file-name 'not-save)
2856 (gnus-capitalize-newsgroup newsgroup)
2857 (gnus-newsgroup-directory-form newsgroup))
2858 "/" (int-to-string (mail-header-number headers)))
2859 gnus-article-save-directory)))
2861 (string-equal (file-name-directory default)
2862 (file-name-directory last-file))
2863 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2865 (or last-file default))))
2867 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2868 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2869 If variable `gnus-use-long-file-name' is non-nil, it is
2870 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2873 (concat (if (gnus-use-long-file-name 'not-save)
2875 (gnus-newsgroup-directory-form newsgroup))
2876 "/" (int-to-string (mail-header-number headers)))
2877 gnus-article-save-directory)))
2879 (string-equal (file-name-directory default)
2880 (file-name-directory last-file))
2881 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2883 (or last-file default))))
2885 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2886 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2887 If variable `gnus-use-long-file-name' is non-nil, it is
2888 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2891 (if (gnus-use-long-file-name 'not-save)
2892 (gnus-capitalize-newsgroup newsgroup)
2893 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2894 gnus-article-save-directory)))
2896 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2897 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2898 If variable `gnus-use-long-file-name' is non-nil, it is
2899 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2902 (if (gnus-use-long-file-name 'not-save)
2904 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2905 gnus-article-save-directory)))
2907 ;; For subscribing new newsgroup
2909 (defun gnus-subscribe-hierarchical-interactive (groups)
2910 (let ((groups (sort groups 'string<))
2911 prefixes prefix start ans group starts)
2913 (setq prefixes (list "^"))
2914 (while (and groups prefixes)
2915 (while (not (string-match (car prefixes) (car groups)))
2916 (setq prefixes (cdr prefixes)))
2917 (setq prefix (car prefixes))
2918 (setq start (1- (length prefix)))
2919 (if (and (string-match "[^\\.]\\." (car groups) start)
2922 (concat "^" (substring (car groups) 0 (match-end 0))))
2923 (string-match prefix (cadr groups)))
2925 (setq prefixes (cons prefix prefixes))
2926 (message "Descend hierarchy %s? ([y]nsq): "
2927 (substring prefix 1 (1- (length prefix))))
2928 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2930 (message "Descend hierarchy %s? ([y]nsq): "
2931 (substring prefix 1 (1- (length prefix)))))
2934 (string-match prefix
2935 (setq group (car groups))))
2936 (setq gnus-killed-list
2937 (cons group gnus-killed-list))
2938 (gnus-sethash group group gnus-killed-hashtb)
2939 (setq groups (cdr groups)))
2940 (setq starts (cdr starts)))
2943 (string-match prefix
2944 (setq group (car groups))))
2945 (gnus-sethash group group gnus-killed-hashtb)
2946 (gnus-subscribe-alphabetically (car groups))
2947 (setq groups (cdr groups)))
2948 (setq starts (cdr starts)))
2951 (setq group (car groups))
2952 (setq gnus-killed-list (cons group gnus-killed-list))
2953 (gnus-sethash group group gnus-killed-hashtb)
2954 (setq groups (cdr groups))))
2956 (message "Subscribe %s? ([n]yq)" (car groups))
2957 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2959 (message "Subscribe %s? ([n]yq)" (car groups)))
2960 (setq group (car groups))
2962 (gnus-subscribe-alphabetically (car groups))
2963 (gnus-sethash group group gnus-killed-hashtb))
2966 (setq group (car groups))
2967 (setq gnus-killed-list (cons group gnus-killed-list))
2968 (gnus-sethash group group gnus-killed-hashtb)
2969 (setq groups (cdr groups))))
2971 (setq gnus-killed-list (cons group gnus-killed-list))
2972 (gnus-sethash group group gnus-killed-hashtb)))
2973 (setq groups (cdr groups)))))))
2975 (defun gnus-subscribe-randomly (newsgroup)
2976 "Subscribe new NEWSGROUP by making it the first newsgroup."
2977 (gnus-subscribe-newsgroup newsgroup))
2979 (defun gnus-subscribe-alphabetically (newgroup)
2980 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2981 (let ((groups (cdr gnus-newsrc-alist))
2983 (while (and (not before) groups)
2984 (if (string< newgroup (caar groups))
2985 (setq before (caar groups))
2986 (setq groups (cdr groups))))
2987 (gnus-subscribe-newsgroup newgroup before)))
2989 (defun gnus-subscribe-hierarchically (newgroup)
2990 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2991 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2993 (set-buffer (find-file-noselect gnus-current-startup-file))
2994 (let ((groupkey newgroup)
2996 (while (and (not before) groupkey)
2997 (goto-char (point-min))
2999 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3000 (while (and (re-search-forward groupkey-re nil t)
3002 (setq before (match-string 1))
3003 (string< before newgroup)))))
3004 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3006 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3007 (substring groupkey (match-beginning 1) (match-end 1)))))
3008 (gnus-subscribe-newsgroup newgroup before))))
3010 (defun gnus-subscribe-interactively (group)
3011 "Subscribe the new GROUP interactively.
3012 It is inserted in hierarchical newsgroup order if subscribed. If not,
3014 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3015 (gnus-subscribe-hierarchically group)
3016 (push group gnus-killed-list)))
3018 (defun gnus-subscribe-zombies (group)
3019 "Make the new GROUP into a zombie group."
3020 (push group gnus-zombie-list))
3022 (defun gnus-subscribe-killed (group)
3023 "Make the new GROUP a killed group."
3024 (push group gnus-killed-list))
3026 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3027 "Subscribe new NEWSGROUP.
3028 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3029 the first newsgroup."
3030 ;; We subscribe the group by changing its level to `subscribed'.
3031 (gnus-group-change-level
3032 newsgroup gnus-level-default-subscribed
3033 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3034 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3038 (defun gnus-newsgroup-directory-form (newsgroup)
3039 "Make hierarchical directory name from NEWSGROUP name."
3040 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3041 (len (length newsgroup))
3043 ;; If this is a foreign group, we don't want to translate the
3045 (if (setq idx (string-match ":" newsgroup))
3046 (aset newsgroup idx ?/)
3048 ;; Replace all occurrences of `.' with `/'.
3050 (if (= (aref newsgroup idx) ?.)
3051 (aset newsgroup idx ?/))
3052 (setq idx (1+ idx)))
3055 (defun gnus-newsgroup-savable-name (group)
3056 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3058 (nnheader-replace-chars-in-string group ?/ ?.))
3060 (defun gnus-make-directory (dir)
3061 "Make DIRECTORY recursively."
3062 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3063 ;; of the many mysteries of the universe.
3064 (let* ((dir (expand-file-name dir default-directory))
3066 (if (string-match "/$" dir)
3067 (setq dir (substring dir 0 (match-beginning 0))))
3068 ;; First go down the path until we find a directory that exists.
3069 (while (not (file-exists-p dir))
3070 (setq dirs (cons dir dirs))
3071 (string-match "/[^/]+$" dir)
3072 (setq dir (substring dir 0 (match-beginning 0))))
3073 ;; Then create all the subdirs.
3074 (while (and dirs (not err))
3076 (make-directory (car dirs))
3077 (error (setq err t)))
3078 (setq dirs (cdr dirs)))
3079 ;; We return whether we were successful or not.
3082 (defun gnus-capitalize-newsgroup (newsgroup)
3083 "Capitalize NEWSGROUP name."
3084 (and (not (zerop (length newsgroup)))
3085 (concat (char-to-string (upcase (aref newsgroup 0)))
3086 (substring newsgroup 1))))
3088 ;; Various... things.
3090 (defun gnus-simplify-subject (subject &optional re-only)
3091 "Remove `Re:' and words in parentheses.
3092 If RE-ONLY is non-nil, strip leading `Re:'s only."
3093 (let ((case-fold-search t)) ;Ignore case.
3094 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3095 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3096 (setq subject (substring subject (match-end 0))))
3097 ;; Remove uninteresting prefixes.
3098 (if (and (not re-only)
3099 gnus-simplify-ignored-prefixes
3100 (string-match gnus-simplify-ignored-prefixes subject))
3101 (setq subject (substring subject (match-end 0))))
3102 ;; Remove words in parentheses from end.
3104 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3105 (setq subject (substring subject 0 (match-beginning 0)))))
3106 ;; Return subject string.
3109 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3111 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3112 (defun gnus-simplify-buffer-fuzzy ()
3113 (goto-char (point-min))
3114 (while (search-forward "\t" nil t)
3115 (replace-match " " t t))
3116 (goto-char (point-min))
3117 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3118 (goto-char (match-beginning 0))
3120 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3121 (looking-at "^[[].*: .*[]]$"))
3122 (goto-char (point-min))
3123 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3125 (replace-match "" t t))
3126 (goto-char (point-min))
3127 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3128 (goto-char (match-end 0))
3131 (progn (goto-char (match-beginning 0)))
3132 (re-search-forward ":"))))
3133 (goto-char (point-min))
3134 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3135 (replace-match "" t t))
3136 (goto-char (point-min))
3137 (while (re-search-forward " +" nil t)
3138 (replace-match " " t t))
3139 (goto-char (point-min))
3140 (while (re-search-forward " $" nil t)
3141 (replace-match "" t t))
3142 (goto-char (point-min))
3143 (while (re-search-forward "^ +" nil t)
3144 (replace-match "" t t))
3145 (goto-char (point-min))
3146 (when gnus-simplify-subject-fuzzy-regexp
3147 (if (listp gnus-simplify-subject-fuzzy-regexp)
3148 (let ((list gnus-simplify-subject-fuzzy-regexp))
3150 (goto-char (point-min))
3151 (while (re-search-forward (car list) nil t)
3152 (replace-match "" t t))
3153 (setq list (cdr list))))
3154 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3155 (replace-match "" t t)))))
3157 (defun gnus-simplify-subject-fuzzy (subject)
3158 "Siplify a subject string fuzzily."
3160 (gnus-set-work-buffer)
3161 (let ((case-fold-search t))
3163 (inline (gnus-simplify-buffer-fuzzy))
3166 ;; Add the current buffer to the list of buffers to be killed on exit.
3167 (defun gnus-add-current-to-buffer-list ()
3168 (or (memq (current-buffer) gnus-buffer-list)
3169 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3171 (defun gnus-string> (s1 s2)
3172 (not (or (string< s1 s2)
3175 (defun gnus-read-active-file-p ()
3176 "Say whether the active file has been read from `gnus-select-method'."
3177 (memq gnus-select-method gnus-have-read-active-file))
3179 ;;; General various misc type functions.
3181 (defun gnus-clear-system ()
3182 "Clear all variables and buffers."
3183 ;; Clear Gnus variables.
3184 (let ((variables gnus-variable-list))
3186 (set (car variables) nil)
3187 (setq variables (cdr variables))))
3188 ;; Clear other internal variables.
3189 (setq gnus-list-of-killed-groups nil
3190 gnus-have-read-active-file nil
3191 gnus-newsrc-alist nil
3192 gnus-newsrc-hashtb nil
3193 gnus-killed-list nil
3194 gnus-zombie-list nil
3195 gnus-killed-hashtb nil
3196 gnus-active-hashtb nil
3197 gnus-moderated-list nil
3198 gnus-description-hashtb nil
3199 gnus-current-headers nil
3200 gnus-thread-indent-array nil
3201 gnus-newsgroup-headers nil
3202 gnus-newsgroup-name nil
3203 gnus-server-alist nil
3204 gnus-group-list-mode nil
3205 gnus-opened-servers nil
3206 gnus-current-select-method nil)
3207 (gnus-shutdown 'gnus)
3208 ;; Kill the startup file.
3209 (and gnus-current-startup-file
3210 (get-file-buffer gnus-current-startup-file)
3211 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3212 ;; Clear the dribble buffer.
3213 (gnus-dribble-clear)
3214 ;; Kill global KILL file buffer.
3215 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3216 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3217 (gnus-kill-buffer nntp-server-buffer)
3218 ;; Kill Gnus buffers.
3219 (while gnus-buffer-list
3220 (gnus-kill-buffer (pop gnus-buffer-list)))
3221 ;; Remove Gnus frames.
3222 (while gnus-created-frames
3223 (when (frame-live-p (car gnus-created-frames))
3224 ;; We slap a condition-case around this `delete-frame' to ensure
3225 ;; agains errors if we try do delete the single frame that's left.
3227 (delete-frame (car gnus-created-frames))
3229 (pop gnus-created-frames)))
3231 (defun gnus-windows-old-to-new (setting)
3232 ;; First we take care of the really, really old Gnus 3 actions.
3233 (when (symbolp setting)
3235 ;; Take care of ooold GNUS 3.x values.
3236 (cond ((eq setting 'SelectArticle) 'article)
3237 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3238 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3240 (if (or (listp setting)
3241 (not (and gnus-window-configuration
3242 (memq setting '(group summary article)))))
3244 (let* ((setting (if (eq setting 'group)
3245 (if (assq 'newsgroup gnus-window-configuration)
3247 'newsgroups) setting))
3248 (elem (cadr (assq setting gnus-window-configuration)))
3249 (total (apply '+ elem))
3250 (types '(group summary article))
3251 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3256 (or (not (numberp (nth i elem)))
3257 (zerop (nth i elem))
3259 (setq perc (/ (float (nth 0 elem)) total))
3260 (setq out (cons (if (eq pbuf (nth i types))
3261 (vector (nth i types) perc 'point)
3262 (vector (nth i types) perc))
3265 (list (nreverse out)))))
3268 (defun gnus-add-configuration (conf)
3269 "Add the window configuration CONF to `gnus-buffer-configuration'."
3270 (setq gnus-buffer-configuration
3271 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3272 gnus-buffer-configuration))))
3274 (defvar gnus-frame-list nil)
3276 (defun gnus-configure-frame (split &optional window)
3277 "Split WINDOW according to SPLIT."
3279 (setq window (get-buffer-window (current-buffer))))
3280 (select-window window)
3281 ;; This might be an old-stylee buffer config.
3282 (when (vectorp split)
3283 (setq split (append split nil)))
3284 (when (or (consp (car split))
3285 (vectorp (car split)))
3287 (push 'vertical split))
3288 ;; The SPLIT might be something that is to be evaled to
3289 ;; return a new SPLIT.
3290 (while (and (not (assq (car split) gnus-window-to-buffer))
3291 (gnus-functionp (car split)))
3292 (setq split (eval split)))
3293 (let* ((type (car split))
3295 (len (if (eq type 'horizontal) (window-width) (window-height)))
3297 (window-min-width (or gnus-window-min-width window-min-width))
3298 (window-min-height (or gnus-window-min-height window-min-height))
3299 s result new-win rest comp-subs size sub)
3301 ;; Nothing to do here.
3303 ;; Don't switch buffers.
3305 (and (memq 'point split) window))
3306 ;; This is a buffer to be selected.
3307 ((not (memq type '(frame horizontal vertical)))
3308 (let ((buffer (cond ((stringp type) type)
3309 (t (cdr (assq type gnus-window-to-buffer)))))
3312 (error "Illegal buffer type: %s" type))
3313 (unless (setq buf (get-buffer (if (symbolp buffer)
3314 (symbol-value buffer) buffer)))
3315 (setq buf (get-buffer-create (if (symbolp buffer)
3316 (symbol-value buffer) buffer))))
3317 (switch-to-buffer buf)
3318 ;; We return the window if it has the `point' spec.
3319 (and (memq 'point split) window)))
3320 ;; This is a frame split.
3322 (unless gnus-frame-list
3323 (setq gnus-frame-list (list (window-frame
3324 (get-buffer-window (current-buffer))))))
3326 params frame fresult)
3327 (while (< i (length subs))
3328 ;; Frame parameter is gotten from the sub-split.
3329 (setq params (cadr (elt subs i)))
3330 ;; It should be a list.
3331 (unless (listp params)
3333 ;; Create a new frame?
3334 (unless (setq frame (elt gnus-frame-list i))
3335 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3336 (push frame gnus-created-frames))
3337 ;; Is the old frame still alive?
3338 (unless (frame-live-p frame)
3339 (setcar (nthcdr i gnus-frame-list)
3340 (setq frame (make-frame params))))
3341 ;; Select the frame in question and do more splits there.
3342 (select-frame frame)
3343 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3345 ;; Select the frame that has the selected buffer.
3347 (select-frame (window-frame fresult)))))
3348 ;; This is a normal split.
3350 (when (> (length subs) 0)
3351 ;; First we have to compute the sizes of all new windows.
3353 (setq sub (append (pop subs) nil))
3354 (while (and (not (assq (car sub) gnus-window-to-buffer))
3355 (gnus-functionp (car sub)))
3356 (setq sub (eval sub)))
3358 (push sub comp-subs)
3359 (setq size (cadar comp-subs))
3360 (cond ((equal size 1.0)
3361 (setq rest (car comp-subs))
3364 (setq s (floor (* size len))))
3368 (error "Illegal size: %s" size)))
3369 ;; Try to make sure that we are inside the safe limits.
3371 ((eq type 'horizontal)
3372 (setq s (max s window-min-width)))
3373 ((eq type 'vertical)
3374 (setq s (max s window-min-height))))
3375 (setcar (cdar comp-subs) s)
3377 ;; Take care of the "1.0" spec.
3379 (setcar (cdr rest) (- len total))
3380 (error "No 1.0 specs in %s" split))
3381 ;; The we do the actual splitting in a nice recursive
3383 (setq comp-subs (nreverse comp-subs))
3385 (if (null (cdr comp-subs))
3386 (setq new-win window)
3388 (split-window window (cadar comp-subs)
3389 (eq type 'horizontal))))
3390 (setq result (or (gnus-configure-frame
3391 (car comp-subs) window) result))
3392 (select-window new-win)
3393 (setq window new-win)
3394 (setq comp-subs (cdr comp-subs))))
3395 ;; Return the proper window, if any.
3397 (select-window result))))))
3399 (defvar gnus-frame-split-p nil)
3401 (defun gnus-configure-windows (setting &optional force)
3402 (setq setting (gnus-windows-old-to-new setting))
3403 (let ((split (if (symbolp setting)
3404 (cadr (assq setting gnus-buffer-configuration))
3408 (setq gnus-frame-split-p nil)
3411 (error "No such setting: %s" setting))
3413 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3415 ;; All the windows mentioned are already visible, so we just
3416 ;; put point in the assigned buffer, and do not touch the
3418 (select-window all-visible)
3420 ;; Either remove all windows or just remove all Gnus windows.
3421 (let ((frame (selected-frame)))
3423 (if gnus-use-full-window
3424 ;; We want to remove all other windows.
3425 (if (not gnus-frame-split-p)
3426 ;; This is not a `frame' split, so we ignore the
3428 (delete-other-windows)
3429 ;; This is a `frame' split, so we delete all windows
3433 (unless (eq (cdr (assq 'minibuffer
3434 (frame-parameters frame)))
3436 (select-frame frame)
3437 (delete-other-windows)))
3439 ;; Just remove some windows.
3440 (gnus-remove-some-windows)
3441 (switch-to-buffer nntp-server-buffer))
3442 (select-frame frame)))
3444 (switch-to-buffer nntp-server-buffer)
3445 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3447 (defun gnus-all-windows-visible-p (split)
3448 "Say whether all buffers in SPLIT are currently visible.
3449 In particular, the value returned will be the window that
3451 (let ((stack (list split))
3453 type buffer win buf)
3454 (while (and (setq split (pop stack))
3456 ;; Be backwards compatible.
3457 (when (vectorp split)
3458 (setq split (append split nil)))
3459 (when (or (consp (car split))
3460 (vectorp (car split)))
3462 (push 'vertical split))
3463 ;; The SPLIT might be something that is to be evaled to
3464 ;; return a new SPLIT.
3465 (while (and (not (assq (car split) gnus-window-to-buffer))
3466 (gnus-functionp (car split)))
3467 (setq split (eval split)))
3469 (setq type (elt split 0))
3474 ((not (memq type '(horizontal vertical frame)))
3475 (setq buffer (cond ((stringp type) type)
3476 (t (cdr (assq type gnus-window-to-buffer)))))
3478 (error "Illegal buffer type: %s" type))
3479 (when (setq buf (get-buffer (if (symbolp buffer)
3480 (symbol-value buffer)
3482 (setq win (get-buffer-window buf t)))
3484 (when (memq 'point split)
3485 (setq all-visible win))
3486 (setq all-visible nil)))
3488 (when (eq type 'frame)
3489 (setq gnus-frame-split-p t))
3490 (setq stack (append (cddr split) stack)))))
3491 (unless (eq all-visible t)
3494 (defun gnus-window-top-edge (&optional window)
3495 (nth 1 (window-edges window)))
3497 (defun gnus-remove-some-windows ()
3498 (let ((buffers gnus-window-to-buffer)
3499 buf bufs lowest-buf lowest)
3501 ;; Remove windows on all known Gnus buffers.
3503 (setq buf (cdar buffers))
3505 (setq buf (and (boundp buf) (symbol-value buf))))
3507 (get-buffer-window buf)
3509 (setq bufs (cons buf bufs))
3511 (if (or (not lowest)
3512 (< (gnus-window-top-edge) lowest))
3514 (setq lowest (gnus-window-top-edge))
3515 (setq lowest-buf buf)))))
3516 (setq buffers (cdr buffers)))
3517 ;; Remove windows on *all* summary buffers.
3520 (let ((buf (window-buffer win)))
3521 (if (string-match "^\\*Summary" (buffer-name buf))
3523 (setq bufs (cons buf bufs))
3525 (if (or (not lowest)
3526 (< (gnus-window-top-edge) lowest))
3528 (setq lowest-buf buf)
3529 (setq lowest (gnus-window-top-edge)))))))))
3532 (pop-to-buffer lowest-buf)
3533 (switch-to-buffer nntp-server-buffer)))
3535 (and (not (eq (car bufs) lowest-buf))
3536 (delete-windows-on (car bufs)))
3537 (setq bufs (cdr bufs))))))
3539 (defun gnus-version (&optional arg)
3540 "Version number of this version of Gnus.
3541 If ARG, insert string at point."
3543 (let ((methods gnus-valid-select-methods)
3546 ;; Go through all the legal select methods and add their version
3547 ;; numbers to the total version string. Only the backends that are
3548 ;; currently in use will have their message numbers taken into
3551 (setq meth (intern (concat (caar methods) "-version")))
3553 (stringp (symbol-value meth))
3554 (setq mess (concat mess "; " (symbol-value meth))))
3555 (setq methods (cdr methods)))
3557 (insert (message mess))
3560 (defun gnus-info-find-node ()
3561 "Find Info documentation of Gnus."
3563 ;; Enlarge info window if needed.
3564 (let ((mode major-mode)
3566 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3567 (setq gnus-info-buffer (current-buffer))
3568 (gnus-configure-windows 'info)))
3570 (defun gnus-days-between (date1 date2)
3571 ;; Return the number of days between date1 and date2.
3572 (- (gnus-day-number date1) (gnus-day-number date2)))
3574 (defun gnus-day-number (date)
3575 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3576 (timezone-parse-date date))))
3577 (timezone-absolute-from-gregorian
3578 (nth 1 dat) (nth 2 dat) (car dat))))
3580 (defun gnus-encode-date (date)
3581 "Convert DATE to internal time."
3582 (let* ((parse (timezone-parse-date date))
3583 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3584 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3585 (encode-time (caddr time) (cadr time) (car time)
3586 (caddr date) (cadr date) (car date) (nth 4 date))))
3588 (defun gnus-time-minus (t1 t2)
3589 "Subtract two internal times."
3590 (let ((borrow (< (cadr t1) (cadr t2))))
3591 (list (- (car t1) (car t2) (if borrow 1 0))
3592 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3594 (defun gnus-file-newer-than (file date)
3595 (let ((fdate (nth 5 (file-attributes file))))
3596 (or (> (car fdate) (car date))
3597 (and (= (car fdate) (car date))
3598 (> (nth 1 fdate) (nth 1 date))))))
3600 (defmacro gnus-local-set-keys (&rest plist)
3601 "Set the keys in PLIST in the current keymap."
3602 `(gnus-define-keys-1 (current-local-map) ',plist))
3604 (defmacro gnus-define-keys (keymap &rest plist)
3605 "Define all keys in PLIST in KEYMAP."
3606 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3608 (put 'gnus-define-keys 'lisp-indent-function 1)
3609 (put 'gnus-define-keys 'lisp-indent-hook 1)
3610 (put 'gnus-define-keymap 'lisp-indent-function 1)
3611 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3613 (defmacro gnus-define-keymap (keymap &rest plist)
3614 "Define all keys in PLIST in KEYMAP."
3615 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3617 (defun gnus-define-keys-1 (keymap plist)
3619 (error "Can't set keys in a null keymap"))
3620 (cond ((symbolp keymap)
3621 (setq keymap (symbol-value keymap)))
3624 (set (car keymap) nil)
3625 (define-prefix-command (car keymap))
3626 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3627 (setq keymap (symbol-value (car keymap)))))
3630 (when (symbolp (setq key (pop plist)))
3631 (setq key (symbol-value key)))
3632 (define-key keymap key (pop plist)))))
3634 (defun gnus-group-read-only-p (&optional group)
3635 "Check whether GROUP supports editing or not.
3636 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3637 that that variable is buffer-local to the summary buffers."
3638 (let ((group (or group gnus-newsgroup-name)))
3639 (not (gnus-check-backend-function 'request-replace-article group))))
3641 (defun gnus-group-total-expirable-p (group)
3642 "Check whether GROUP is total-expirable or not."
3643 (let ((params (gnus-info-params (gnus-get-info group))))
3644 (or (memq 'total-expire params)
3645 (cdr (assq 'total-expire params)) ; (total-expire . t)
3646 (and gnus-total-expirable-newsgroups ; Check var.
3647 (string-match gnus-total-expirable-newsgroups group)))))
3649 (defun gnus-group-auto-expirable-p (group)
3650 "Check whether GROUP is total-expirable or not."
3651 (let ((params (gnus-info-params (gnus-get-info group))))
3652 (or (memq 'auto-expire params)
3653 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3654 (and gnus-auto-expirable-newsgroups ; Check var.
3655 (string-match gnus-auto-expirable-newsgroups group)))))
3657 (defun gnus-virtual-group-p (group)
3658 "Say whether GROUP is virtual or not."
3659 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3660 gnus-valid-select-methods)))
3662 (defun gnus-news-group-p (group &optional article)
3663 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3664 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3665 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3666 (eq (gnus-request-type group article) 'news))))
3668 (defsubst gnus-simplify-subject-fully (subject)
3669 "Simplify a subject string according to the user's wishes."
3671 ((null gnus-summary-gather-subject-limit)
3672 (gnus-simplify-subject-re subject))
3673 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3674 (gnus-simplify-subject-fuzzy subject))
3675 ((numberp gnus-summary-gather-subject-limit)
3676 (gnus-limit-string (gnus-simplify-subject-re subject)
3677 gnus-summary-gather-subject-limit))
3681 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3682 "Check whether two subjects are equal. If optional argument
3683 simple-first is t, first argument is already simplified."
3685 ((null simple-first)
3686 (equal (gnus-simplify-subject-fully s1)
3687 (gnus-simplify-subject-fully s2)))
3690 (gnus-simplify-subject-fully s2)))))
3692 ;; Returns a list of writable groups.
3693 (defun gnus-writable-groups ()
3694 (let ((alist gnus-newsrc-alist)
3696 (while (setq group (car (pop alist)))
3697 (unless (gnus-group-read-only-p group)
3698 (push group groups)))
3701 (defun gnus-completing-read (default prompt &rest args)
3702 ;; Like `completing-read', except that DEFAULT is the default argument.
3703 (let* ((prompt (if default
3704 (concat prompt " (default " default ") ")
3705 (concat prompt " ")))
3706 (answer (apply 'completing-read prompt args)))
3707 (if (or (null answer) (zerop (length answer)))
3711 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3713 (defun gnus-y-or-n-p (prompt)
3718 (defun gnus-yes-or-no-p (prompt)
3720 (yes-or-no-p prompt)
3723 ;; Check whether to use long file names.
3724 (defun gnus-use-long-file-name (symbol)
3725 ;; The variable has to be set...
3726 (and gnus-use-long-file-name
3727 ;; If it isn't a list, then we return t.
3728 (or (not (listp gnus-use-long-file-name))
3729 ;; If it is a list, and the list contains `symbol', we
3731 (not (memq symbol gnus-use-long-file-name)))))
3733 ;; I suspect there's a better way, but I haven't taken the time to do
3734 ;; it yet. -erik selberg@cs.washington.edu
3735 (defun gnus-dd-mmm (messy-date)
3736 "Return a string like DD-MMM from a big messy string"
3737 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3743 ;; Make sure leading zeroes are stripped.
3744 (number-to-string (string-to-number (aref datevec 2)))
3748 (nth (1- (string-to-number (aref datevec 1)))
3749 timezone-months-assoc))
3752 (defun gnus-mode-string-quote (string)
3753 "Quote all \"%\" in STRING."
3755 (gnus-set-work-buffer)
3757 (goto-char (point-min))
3758 (while (search-forward "%" nil t)
3762 ;; Make a hash table (default and minimum size is 255).
3763 ;; Optional argument HASHSIZE specifies the table size.
3764 (defun gnus-make-hashtable (&optional hashsize)
3765 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3767 ;; Make a number that is suitable for hashing; bigger than MIN and one
3769 (defun gnus-create-hash-size (min)
3775 ;; Show message if message has a lower level than `gnus-verbose'.
3776 ;; Guideline for numbers:
3777 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3778 ;; for things that take a long time, 7 - not very important messages
3779 ;; on stuff, 9 - messages inside loops.
3780 (defun gnus-message (level &rest args)
3781 (if (<= level gnus-verbose)
3782 (apply 'message args)
3783 ;; We have to do this format thingy here even if the result isn't
3784 ;; shown - the return value has to be the same as the return value
3786 (apply 'format args)))
3788 (defun gnus-error (level &rest args)
3789 "Beep an error if `gnus-verbose' is on LEVEL or less."
3790 (when (<= (floor level) gnus-verbose)
3791 (apply 'message args)
3794 (when (and (floatp level)
3795 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3796 (sit-for duration))))
3799 ;; Generate a unique new group name.
3800 (defun gnus-generate-new-group-name (leaf)
3803 (while (gnus-gethash name gnus-newsrc-hashtb)
3804 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3807 (defsubst gnus-hide-text (b e props)
3808 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3809 (gnus-add-text-properties b e props)
3810 (when (memq 'intangible props)
3811 (gnus-put-text-property (max (1- b) (point-min))
3812 b 'intangible (cddr (memq 'intangible props)))))
3814 (defsubst gnus-unhide-text (b e)
3815 "Remove hidden text properties from region between B and E."
3816 (remove-text-properties b e gnus-hidden-properties)
3817 (when (memq 'intangible gnus-hidden-properties)
3818 (gnus-put-text-property (max (1- b) (point-min))
3819 b 'intangible nil)))
3821 (defun gnus-hide-text-type (b e type)
3822 "Hide text of TYPE between B and E."
3823 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3825 (defun gnus-parent-headers (headers &optional generation)
3826 "Return the headers of the GENERATIONeth parent of HEADERS."
3828 (setq generation 1))
3829 (let (references parent)
3830 (while (and headers (not (zerop generation)))
3831 (setq references (mail-header-references headers))
3832 (when (and references
3833 (setq parent (gnus-parent-id references))
3834 (setq headers (car (gnus-id-to-thread parent))))
3838 (defun gnus-parent-id (references)
3839 "Return the last Message-ID in REFERENCES."
3840 (when (and references
3841 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3842 (substring references (match-beginning 1) (match-end 1))))
3844 (defun gnus-split-references (references)
3845 "Return a list of Message-IDs in REFERENCES."
3848 (while (string-match "<[^>]+>" references beg)
3849 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3853 (defun gnus-buffer-live-p (buffer)
3854 "Say whether BUFFER is alive or not."
3857 (buffer-name (get-buffer buffer))))
3859 (defun gnus-ephemeral-group-p (group)
3860 "Say whether GROUP is ephemeral or not."
3861 (gnus-group-get-parameter group 'quit-config))
3863 (defun gnus-group-quit-config (group)
3864 "Return the quit-config of GROUP."
3865 (gnus-group-get-parameter group 'quit-config))
3867 (defun gnus-simplify-mode-line ()
3868 "Make mode lines a bit simpler."
3869 (setq mode-line-modified "-- ")
3870 (when (listp mode-line-format)
3871 (make-local-variable 'mode-line-format)
3872 (setq mode-line-format (copy-sequence mode-line-format))
3873 (when (equal (nth 3 mode-line-format) " ")
3874 (setcar (nthcdr 3 mode-line-format) " "))))
3876 ;;; List and range functions
3878 (defun gnus-last-element (list)
3879 "Return last element of LIST."
3881 (setq list (cdr list)))
3884 (defun gnus-copy-sequence (list)
3885 "Do a complete, total copy of a list."
3886 (if (and (consp list) (not (consp (cdr list))))
3887 (cons (car list) (cdr list))
3888 (mapcar (lambda (elem) (if (consp elem)
3889 (if (consp (cdr elem))
3890 (gnus-copy-sequence elem)
3891 (cons (car elem) (cdr elem)))
3895 (defun gnus-set-difference (list1 list2)
3896 "Return a list of elements of LIST1 that do not appear in LIST2."
3897 (let ((list1 (copy-sequence list1)))
3899 (setq list1 (delq (car list2) list1))
3900 (setq list2 (cdr list2)))
3903 (defun gnus-sorted-complement (list1 list2)
3904 "Return a list of elements of LIST1 that do not appear in LIST2.
3905 Both lists have to be sorted over <."
3907 (if (or (null list1) (null list2))
3909 (while (and list1 list2)
3910 (cond ((= (car list1) (car list2))
3911 (setq list1 (cdr list1)
3913 ((< (car list1) (car list2))
3914 (setq out (cons (car list1) out))
3915 (setq list1 (cdr list1)))
3917 (setq out (cons (car list2) out))
3918 (setq list2 (cdr list2)))))
3919 (nconc (nreverse out) (or list1 list2)))))
3921 (defun gnus-intersection (list1 list2)
3924 (if (memq (car list2) list1)
3925 (setq result (cons (car list2) result)))
3926 (setq list2 (cdr list2)))
3929 (defun gnus-sorted-intersection (list1 list2)
3930 ;; LIST1 and LIST2 have to be sorted over <.
3932 (while (and list1 list2)
3933 (cond ((= (car list1) (car list2))
3934 (setq out (cons (car list1) out)
3937 ((< (car list1) (car list2))
3938 (setq list1 (cdr list1)))
3940 (setq list2 (cdr list2)))))
3943 (defun gnus-set-sorted-intersection (list1 list2)
3944 ;; LIST1 and LIST2 have to be sorted over <.
3945 ;; This function modifies LIST1.
3946 (let* ((top (cons nil list1))
3948 (while (and list1 list2)
3949 (cond ((= (car list1) (car list2))
3953 ((< (car list1) (car list2))
3954 (setcdr prev (cdr list1))
3955 (setq list1 (cdr list1)))
3957 (setq list2 (cdr list2)))))
3961 (defun gnus-compress-sequence (numbers &optional always-list)
3962 "Convert list of numbers to a list of ranges or a single range.
3963 If ALWAYS-LIST is non-nil, this function will always release a list of
3965 (let* ((first (car numbers))
3966 (last (car numbers))
3970 (if (not (listp (cdr numbers)))
3973 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3974 ((= (1+ last) (car numbers)) ;Still in sequence
3975 (setq last (car numbers)))
3976 (t ;End of one sequence
3978 (cons (if (= first last) first
3979 (cons first last)) result))
3980 (setq first (car numbers))
3981 (setq last (car numbers))))
3982 (setq numbers (cdr numbers)))
3983 (if (and (not always-list) (null result))
3984 (if (= first last) (list first) (cons first last))
3985 (nreverse (cons (if (= first last) first (cons first last))
3988 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3989 (defun gnus-uncompress-range (ranges)
3990 "Expand a list of ranges into a list of numbers.
3991 RANGES is either a single range on the form `(num . num)' or a list of
3993 (let (first last result)
3997 ((not (listp (cdr ranges)))
3998 (setq first (car ranges))
3999 (setq last (cdr ranges))
4000 (while (<= first last)
4001 (setq result (cons first result))
4002 (setq first (1+ first)))
4006 (if (atom (car ranges))
4007 (if (numberp (car ranges))
4008 (setq result (cons (car ranges) result)))
4009 (setq first (caar ranges))
4010 (setq last (cdar ranges))
4011 (while (<= first last)
4012 (setq result (cons first result))
4013 (setq first (1+ first))))
4014 (setq ranges (cdr ranges)))
4015 (nreverse result)))))
4017 (defun gnus-add-to-range (ranges list)
4018 "Return a list of ranges that has all articles from both RANGES and LIST.
4019 Note: LIST has to be sorted over `<'."
4021 (gnus-compress-sequence list t)
4022 (setq list (copy-sequence list))
4023 (or (listp (cdr ranges))
4024 (setq ranges (list ranges)))
4026 ilist lowest highest temp)
4027 (while (and ranges list)
4029 (setq lowest (or (and (atom (car ranges)) (car ranges))
4031 (while (and list (cdr list) (< (cadr list) lowest))
4032 (setq list (cdr list)))
4033 (if (< (car ilist) lowest)
4036 (setq list (cdr list))
4038 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4039 (setq highest (or (and (atom (car ranges)) (car ranges))
4041 (while (and list (<= (car list) highest))
4042 (setq list (cdr list)))
4043 (setq ranges (cdr ranges)))
4045 (setq out (nconc (gnus-compress-sequence list t) out)))
4046 (setq out (sort out (lambda (r1 r2)
4047 (< (or (and (atom r1) r1) (car r1))
4048 (or (and (atom r2) r2) (car r2))))))
4051 (if (atom (car ranges))
4053 (if (atom (cadr ranges))
4054 (if (= (1+ (car ranges)) (cadr ranges))
4056 (setcar ranges (cons (car ranges)
4058 (setcdr ranges (cddr ranges))))
4059 (if (= (1+ (car ranges)) (caadr ranges))
4061 (setcar (cadr ranges) (car ranges))
4062 (setcar ranges (cadr ranges))
4063 (setcdr ranges (cddr ranges))))))
4065 (if (atom (cadr ranges))
4066 (if (= (1+ (cdar ranges)) (cadr ranges))
4068 (setcdr (car ranges) (cadr ranges))
4069 (setcdr ranges (cddr ranges))))
4070 (if (= (1+ (cdar ranges)) (caadr ranges))
4072 (setcdr (car ranges) (cdadr ranges))
4073 (setcdr ranges (cddr ranges)))))))
4074 (setq ranges (cdr ranges)))
4077 (defun gnus-remove-from-range (ranges list)
4078 "Return a list of ranges that has all articles from LIST removed from RANGES.
4079 Note: LIST has to be sorted over `<'."
4080 ;; !!! This function shouldn't look like this, but I've got a headache.
4081 (gnus-compress-sequence
4082 (gnus-sorted-complement
4083 (gnus-uncompress-range ranges) list)))
4085 (defun gnus-member-of-range (number ranges)
4086 (if (not (listp (cdr ranges)))
4087 (and (>= number (car ranges))
4088 (<= number (cdr ranges)))
4091 (if (numberp (car ranges))
4092 (>= number (car ranges))
4093 (>= number (caar ranges)))
4095 (if (if (numberp (car ranges))
4096 (= number (car ranges))
4097 (and (>= number (caar ranges))
4098 (<= number (cdar ranges))))
4099 (setq not-stop nil))
4100 (setq ranges (cdr ranges)))
4103 (defun gnus-range-length (range)
4104 "Return the length RANGE would have if uncompressed."
4105 (length (gnus-uncompress-range range)))
4107 (defun gnus-sublist-p (list sublist)
4108 "Test whether all elements in SUBLIST are members of LIST."
4111 (unless (memq (pop sublist) list)
4121 (defvar gnus-group-mode-map nil)
4122 (put 'gnus-group-mode 'mode-class 'special)
4124 (unless gnus-group-mode-map
4125 (setq gnus-group-mode-map (make-keymap))
4126 (suppress-keymap gnus-group-mode-map)
4128 (gnus-define-keys gnus-group-mode-map
4129 " " gnus-group-read-group
4130 "=" gnus-group-select-group
4131 "\r" gnus-group-select-group
4132 "\M-\r" gnus-group-quick-select-group
4133 "j" gnus-group-jump-to-group
4134 "n" gnus-group-next-unread-group
4135 "p" gnus-group-prev-unread-group
4136 "\177" gnus-group-prev-unread-group
4137 [delete] gnus-group-prev-unread-group
4138 "N" gnus-group-next-group
4139 "P" gnus-group-prev-group
4140 "\M-n" gnus-group-next-unread-group-same-level
4141 "\M-p" gnus-group-prev-unread-group-same-level
4142 "," gnus-group-best-unread-group
4143 "." gnus-group-first-unread-group
4144 "u" gnus-group-unsubscribe-current-group
4145 "U" gnus-group-unsubscribe-group
4146 "c" gnus-group-catchup-current
4147 "C" gnus-group-catchup-current-all
4148 "l" gnus-group-list-groups
4149 "L" gnus-group-list-all-groups
4151 "g" gnus-group-get-new-news
4152 "\M-g" gnus-group-get-new-news-this-group
4153 "R" gnus-group-restart
4154 "r" gnus-group-read-init-file
4155 "B" gnus-group-browse-foreign-server
4156 "b" gnus-group-check-bogus-groups
4157 "F" gnus-find-new-newsgroups
4158 "\C-c\C-d" gnus-group-describe-group
4159 "\M-d" gnus-group-describe-all-groups
4160 "\C-c\C-a" gnus-group-apropos
4161 "\C-c\M-\C-a" gnus-group-description-apropos
4162 "a" gnus-group-post-news
4163 "\ek" gnus-group-edit-local-kill
4164 "\eK" gnus-group-edit-global-kill
4165 "\C-k" gnus-group-kill-group
4166 "\C-y" gnus-group-yank-group
4167 "\C-w" gnus-group-kill-region
4168 "\C-x\C-t" gnus-group-transpose-groups
4169 "\C-c\C-l" gnus-group-list-killed
4170 "\C-c\C-x" gnus-group-expire-articles
4171 "\C-c\M-\C-x" gnus-group-expire-all-groups
4173 "s" gnus-group-save-newsrc
4174 "z" gnus-group-suspend
4175 "Z" gnus-group-clear-dribble
4178 "?" gnus-group-describe-briefly
4179 "\C-c\C-i" gnus-info-find-node
4180 "\M-e" gnus-group-edit-group-method
4181 "^" gnus-group-enter-server-mode
4182 gnus-mouse-2 gnus-mouse-pick-group
4183 "<" beginning-of-buffer
4186 "\C-c\C-s" gnus-group-sort-groups
4188 "\C-c\M-g" gnus-activate-all-groups
4189 "\M-&" gnus-group-universal-argument
4190 "#" gnus-group-mark-group
4191 "\M-#" gnus-group-unmark-group)
4193 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4194 "m" gnus-group-mark-group
4195 "u" gnus-group-unmark-group
4196 "w" gnus-group-mark-region
4197 "m" gnus-group-mark-buffer
4198 "r" gnus-group-mark-regexp
4199 "U" gnus-group-unmark-all-groups)
4201 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4202 "d" gnus-group-make-directory-group
4203 "h" gnus-group-make-help-group
4204 "a" gnus-group-make-archive-group
4205 "k" gnus-group-make-kiboze-group
4206 "m" gnus-group-make-group
4207 "E" gnus-group-edit-group
4208 "e" gnus-group-edit-group-method
4209 "p" gnus-group-edit-group-parameters
4210 "v" gnus-group-add-to-virtual
4211 "V" gnus-group-make-empty-virtual
4212 "D" gnus-group-enter-directory
4213 "f" gnus-group-make-doc-group
4214 "r" gnus-group-rename-group
4215 "\177" gnus-group-delete-group
4216 [delete] gnus-group-delete-group)
4218 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4219 "b" gnus-group-brew-soup
4220 "w" gnus-soup-save-areas
4221 "s" gnus-soup-send-replies
4222 "p" gnus-soup-pack-packet
4223 "r" nnsoup-pack-replies)
4225 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4226 "s" gnus-group-sort-groups
4227 "a" gnus-group-sort-groups-by-alphabet
4228 "u" gnus-group-sort-groups-by-unread
4229 "l" gnus-group-sort-groups-by-level
4230 "v" gnus-group-sort-groups-by-score
4231 "r" gnus-group-sort-groups-by-rank
4232 "m" gnus-group-sort-groups-by-method)
4234 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4235 "k" gnus-group-list-killed
4236 "z" gnus-group-list-zombies
4237 "s" gnus-group-list-groups
4238 "u" gnus-group-list-all-groups
4239 "A" gnus-group-list-active
4240 "a" gnus-group-apropos
4241 "d" gnus-group-description-apropos
4242 "m" gnus-group-list-matching
4243 "M" gnus-group-list-all-matching
4244 "l" gnus-group-list-level)
4246 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4247 "f" gnus-score-flush-cache)
4249 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4250 "f" gnus-group-fetch-faq)
4252 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4253 "l" gnus-group-set-current-level
4254 "t" gnus-group-unsubscribe-current-group
4255 "s" gnus-group-unsubscribe-group
4256 "k" gnus-group-kill-group
4257 "y" gnus-group-yank-group
4258 "w" gnus-group-kill-region
4259 "\C-k" gnus-group-kill-level
4260 "z" gnus-group-kill-all-zombies))
4262 (defun gnus-group-mode ()
4263 "Major mode for reading news.
4265 All normal editing commands are switched off.
4266 \\<gnus-group-mode-map>
4267 The group buffer lists (some of) the groups available. For instance,
4268 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4269 lists all zombie groups.
4271 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4272 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4274 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4276 The following commands are available:
4278 \\{gnus-group-mode-map}"
4280 (when (and menu-bar-mode
4281 (gnus-visual-p 'group-menu 'menu))
4282 (gnus-group-make-menu-bar))
4283 (kill-all-local-variables)
4284 (gnus-simplify-mode-line)
4285 (setq major-mode 'gnus-group-mode)
4286 (setq mode-name "Group")
4287 (gnus-group-set-mode-line)
4288 (setq mode-line-process nil)
4289 (use-local-map gnus-group-mode-map)
4290 (buffer-disable-undo (current-buffer))
4291 (setq truncate-lines t)
4292 (setq buffer-read-only t)
4293 (gnus-make-local-hook 'post-command-hook)
4294 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4295 (run-hooks 'gnus-group-mode-hook))
4297 (defun gnus-clear-inboxes-moved ()
4298 (setq nnmail-moved-inboxes nil))
4300 (defun gnus-mouse-pick-group (e)
4301 "Enter the group under the mouse pointer."
4304 (gnus-group-read-group nil))
4306 ;; Look at LEVEL and find out what the level is really supposed to be.
4307 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4308 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4309 (defun gnus-group-default-level (&optional level number-or-nil)
4311 (gnus-group-use-permanent-levels
4312 (or (setq gnus-group-use-permanent-levels
4313 (or level (if (numberp gnus-group-use-permanent-levels)
4314 gnus-group-use-permanent-levels
4315 (or gnus-group-default-list-level
4316 gnus-level-subscribed))))
4317 gnus-group-default-list-level gnus-level-subscribed))
4321 (or level gnus-group-default-list-level gnus-level-subscribed))))
4324 (defun gnus-slave-no-server (&optional arg)
4325 "Read network news as a slave, without connecting to local server"
4327 (gnus-no-server arg t))
4330 (defun gnus-no-server (&optional arg slave)
4332 If ARG is a positive number, Gnus will use that as the
4333 startup level. If ARG is nil, Gnus will be started at level 2.
4334 If ARG is non-nil and not a positive number, Gnus will
4335 prompt the user for the name of an NNTP server to use.
4336 As opposed to `gnus', this command will not connect to the local server."
4338 (let ((val (or arg (1- gnus-level-default-subscribed))))
4340 (make-local-variable 'gnus-group-use-permanent-levels)
4341 (setq gnus-group-use-permanent-levels val)))
4344 (defun gnus-slave (&optional arg)
4345 "Read news as a slave."
4347 (gnus arg nil 'slave))
4350 (defun gnus-other-frame (&optional arg)
4351 "Pop up a frame to read news."
4353 (if (get-buffer gnus-group-buffer)
4354 (let ((pop-up-frames t))
4356 (select-frame (make-frame))
4360 (defun gnus (&optional arg dont-connect slave)
4362 If ARG is non-nil and a positive number, Gnus will use that as the
4363 startup level. If ARG is non-nil and not a positive number, Gnus will
4364 prompt the user for the name of an NNTP server to use."
4367 (if (get-buffer gnus-group-buffer)
4369 (switch-to-buffer gnus-group-buffer)
4370 (gnus-group-get-new-news))
4373 (nnheader-init-server-buffer)
4374 (gnus-read-init-file)
4375 (setq gnus-slave slave)
4377 (gnus-group-setup-buffer)
4378 (let ((buffer-read-only nil))
4380 (if (not gnus-inhibit-startup-message)
4382 (gnus-group-startup-message)
4385 (let ((level (and (numberp arg) (> arg 0) arg))
4391 (gnus-start-news-server (and arg (not level))))))
4392 (if (and (not dont-connect)
4395 (run-hooks 'gnus-startup-hook)
4396 ;; NNTP server is successfully open.
4398 ;; Find the current startup file name.
4399 (setq gnus-current-startup-file
4400 (gnus-make-newsrc-file gnus-startup-file))
4402 ;; Read the dribble file.
4403 (when (or gnus-slave gnus-use-dribble-file)
4404 (gnus-dribble-read-file))
4406 ;; Allow using GroupLens predictions.
4407 (when gnus-use-grouplens
4409 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4411 (gnus-summary-make-display-table)
4412 ;; Do the actual startup.
4413 (gnus-setup-news nil level dont-connect)
4414 ;; Generate the group buffer.
4415 (gnus-group-list-groups level)
4416 (gnus-group-first-unread-group)
4417 (gnus-configure-windows 'group)
4418 (gnus-group-set-mode-line))))))
4420 (defun gnus-unload ()
4421 "Unload all Gnus features."
4423 (or (boundp 'load-history)
4424 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4425 (let ((history load-history)
4428 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4429 (setq feature (cdr (assq 'provide (car history))))
4430 (unload-feature feature 'force))
4431 (setq history (cdr history)))))
4433 (defun gnus-compile ()
4434 "Byte-compile the user-defined format specs."
4436 (let ((entries gnus-format-specs)
4437 entry gnus-tmp-func)
4439 (gnus-message 7 "Compiling format specs...")
4442 (setq entry (pop entries))
4443 (if (eq (car entry) 'version)
4444 (setq gnus-format-specs (delq entry gnus-format-specs))
4445 (when (and (listp (caddr entry))
4446 (not (eq 'byte-code (caaddr entry))))
4447 (fset 'gnus-tmp-func
4448 `(lambda () ,(caddr entry)))
4449 (byte-compile 'gnus-tmp-func)
4450 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4452 (push (cons 'version emacs-version) gnus-format-specs)
4454 (gnus-message 7 "Compiling user specs...done"))))
4456 (defun gnus-indent-rigidly (start end arg)
4457 "Indent rigidly using only spaces and no tabs."
4460 (narrow-to-region start end)
4461 (indent-rigidly start end arg)
4462 (goto-char (point-min))
4463 (while (search-forward "\t" nil t)
4464 (replace-match " " t t)))))
4466 (defun gnus-group-startup-message (&optional x y)
4467 "Insert startup message in current buffer."
4468 ;; Insert the message.
4473 _ ___ __ ___ __ _ ___
4492 ;; And then hack it.
4493 (gnus-indent-rigidly (point-min) (point-max)
4494 (/ (max (- (window-width) (or x 46)) 0) 2))
4495 (goto-char (point-min))
4497 (let* ((pheight (count-lines (point-min) (point-max)))
4498 (wheight (window-height))
4499 (rest (- wheight pheight)))
4500 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4502 (goto-char (point-min))
4503 (and (search-forward "Praxis" nil t)
4504 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4505 (goto-char (point-min))
4506 (let* ((mode-string (gnus-group-set-mode-line)))
4507 (setq mode-line-buffer-identification
4508 (list (concat gnus-version (substring (car mode-string) 4))))
4509 (set-buffer-modified-p t)))
4511 (defun gnus-group-setup-buffer ()
4512 (or (get-buffer gnus-group-buffer)
4514 (switch-to-buffer gnus-group-buffer)
4515 (gnus-add-current-to-buffer-list)
4517 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4519 (defun gnus-group-list-groups (&optional level unread lowest)
4520 "List newsgroups with level LEVEL or lower that have unread articles.
4521 Default is all subscribed groups.
4522 If argument UNREAD is non-nil, groups with no unread articles are also
4524 (interactive (list (if current-prefix-arg
4525 (prefix-numeric-value current-prefix-arg)
4527 (gnus-group-default-level nil t)
4528 gnus-group-default-list-level
4529 gnus-level-subscribed))))
4531 (setq level (car gnus-group-list-mode)
4532 unread (cdr gnus-group-list-mode)))
4533 (setq level (gnus-group-default-level level))
4534 (gnus-group-setup-buffer) ;May call from out of group buffer
4535 (gnus-update-format-specifications)
4536 (let ((case-fold-search nil)
4537 (props (text-properties-at (gnus-point-at-bol)))
4538 (group (gnus-group-group-name)))
4539 (set-buffer gnus-group-buffer)
4540 (funcall gnus-group-prepare-function level unread lowest)
4541 (if (zerop (buffer-size))
4542 (gnus-message 5 gnus-no-groups-message)
4543 (goto-char (point-max))
4544 (when (or (not gnus-group-goto-next-group-function)
4545 (not (funcall gnus-group-goto-next-group-function
4548 ;; Go to the first group with unread articles.
4549 (gnus-group-search-forward t)
4550 ;; Find the right group to put point on. If the current group
4551 ;; has disappeared in the new listing, try to find the next
4552 ;; one. If no next one can be found, just leave point at the
4553 ;; first newsgroup in the buffer.
4554 (if (not (gnus-goto-char
4556 (point-min) (point-max)
4557 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4558 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4560 (not (gnus-goto-char
4562 (point-min) (point-max) 'gnus-group
4564 (caar newsrc) gnus-active-hashtb)))))
4565 (setq newsrc (cdr newsrc)))
4566 (or newsrc (progn (goto-char (point-max))
4567 (forward-line -1)))))))
4568 ;; Adjust cursor point.
4569 (gnus-group-position-point))))
4571 (defun gnus-group-list-level (level &optional all)
4572 "List groups on LEVEL.
4573 If ALL (the prefix), also list groups that have no unread articles."
4574 (interactive "nList groups on level: \nP")
4575 (gnus-group-list-groups level all level))
4577 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4578 "List all newsgroups with unread articles of level LEVEL or lower.
4579 If ALL is non-nil, list groups that have no unread articles.
4580 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4581 If REGEXP, only list groups matching REGEXP."
4582 (set-buffer gnus-group-buffer)
4583 (let ((buffer-read-only nil)
4584 (newsrc (cdr gnus-newsrc-alist))
4585 (lowest (or lowest 1))
4586 info clevel unread group params)
4588 (if (< lowest gnus-level-zombie)
4589 ;; List living groups.
4591 (setq info (car newsrc)
4592 group (gnus-info-group info)
4593 params (gnus-info-params info)
4595 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4596 (and unread ; This group might be bogus
4598 (string-match regexp group))
4599 (<= (setq clevel (gnus-info-level info)) level)
4601 (or all ; We list all groups?
4602 (if (eq unread t) ; Unactivated?
4603 gnus-group-list-inactive-groups ; We list unactivated
4604 (> unread 0)) ; We list groups with unread articles
4605 (and gnus-list-groups-with-ticked-articles
4606 (cdr (assq 'tick (gnus-info-marks info))))
4607 ; And groups with tickeds
4608 ;; Check for permanent visibility.
4609 (and gnus-permanently-visible-groups
4610 (string-match gnus-permanently-visible-groups
4612 (memq 'visible params)
4613 (cdr (assq 'visible params)))
4614 (gnus-group-insert-group-line
4615 group (gnus-info-level info)
4616 (gnus-info-marks info) unread (gnus-info-method info)))))
4618 ;; List dead groups.
4619 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4620 (gnus-group-prepare-flat-list-dead
4621 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4622 gnus-level-zombie ?Z
4624 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4625 (gnus-group-prepare-flat-list-dead
4626 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4627 gnus-level-killed ?K regexp))
4629 (gnus-group-set-mode-line)
4630 (setq gnus-group-list-mode (cons level all))
4631 (run-hooks 'gnus-group-prepare-hook)))
4633 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4634 ;; List zombies and killed lists somewhat faster, which was
4635 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4636 ;; this by ignoring the group format specification altogether.
4639 ;; This loop is used when listing groups that match some
4642 (setq group (pop groups))
4643 (when (string-match regexp group)
4644 (gnus-add-text-properties
4645 (point) (prog1 (1+ (point))
4646 (insert " " mark " *: " group "\n"))
4647 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4649 'gnus-level level))))
4650 ;; This loop is used when listing all groups.
4652 (gnus-add-text-properties
4653 (point) (prog1 (1+ (point))
4654 (insert " " mark " *: "
4655 (setq group (pop groups)) "\n"))
4656 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4658 'gnus-level level))))))
4660 (defmacro gnus-group-real-name (group)
4661 "Find the real name of a foreign newsgroup."
4662 `(let ((gname ,group))
4663 (if (string-match ":[^:]+$" gname)
4664 (substring gname (1+ (match-beginning 0)))
4667 (defsubst gnus-server-add-address (method)
4668 (let ((method-name (symbol-name (car method))))
4669 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4670 (not (assq (intern (concat method-name "-address")) method)))
4671 (append method (list (list (intern (concat method-name "-address"))
4675 (defsubst gnus-server-get-method (group method)
4676 ;; Input either a server name, and extended server name, or a
4677 ;; select method, and return a select method.
4678 (cond ((stringp method)
4679 (gnus-server-to-method method))
4680 ((equal method gnus-select-method)
4682 ((and (stringp (car method)) group)
4683 (gnus-server-extend-method group method))
4684 ((and method (not group)
4685 (equal (cadr method) ""))
4688 (gnus-server-add-address method))))
4690 (defun gnus-server-to-method (server)
4691 "Map virtual server names to select methods."
4693 ;; Is this a method, perhaps?
4694 (and server (listp server) server)
4695 ;; Perhaps this is the native server?
4696 (and (equal server "native") gnus-select-method)
4697 ;; It should be in the server alist.
4698 (cdr (assoc server gnus-server-alist))
4699 ;; If not, we look through all the opened server
4700 ;; to see whether we can find it there.
4701 (let ((opened gnus-opened-servers))
4703 (not (equal server (format "%s:%s" (caaar opened)
4708 (defmacro gnus-method-equal (ss1 ss2)
4709 "Say whether two servers are equal."
4713 (and (= (length s1) (length s2))
4715 (while (and s1 (member (car s1) s2))
4719 (defun gnus-server-equal (m1 m2)
4720 "Say whether two methods are equal."
4721 (let ((m1 (cond ((null m1) gnus-select-method)
4722 ((stringp m1) (gnus-server-to-method m1))
4724 (m2 (cond ((null m2) gnus-select-method)
4725 ((stringp m2) (gnus-server-to-method m2))
4727 (gnus-method-equal m1 m2)))
4729 (defun gnus-servers-using-backend (backend)
4730 "Return a list of known servers using BACKEND."
4731 (let ((opened gnus-opened-servers)
4734 (when (eq backend (caaar opened))
4735 (push (caar opened) out))
4739 (defun gnus-group-prefixed-name (group method)
4740 "Return the whole name from GROUP and METHOD."
4741 (and (stringp method) (setq method (gnus-server-to-method method)))
4742 (concat (format "%s" (car method))
4744 (or (assoc (format "%s" (car method))
4745 (gnus-methods-using 'address))
4746 (gnus-server-equal method gnus-message-archive-method))
4748 (not (string= (nth 1 method) "")))
4749 (concat "+" (nth 1 method)))
4752 (defun gnus-group-real-prefix (group)
4753 "Return the prefix of the current group name."
4754 (if (string-match "^[^:]+:" group)
4755 (substring group 0 (match-end 0))
4758 (defun gnus-group-method (group)
4759 "Return the server or method used for selecting GROUP."
4760 (let ((prefix (gnus-group-real-prefix group)))
4761 (if (equal prefix "")
4763 (let ((servers gnus-opened-servers)
4765 backend possible found)
4766 (if (string-match "^[^\\+]+\\+" prefix)
4767 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4768 server (substring prefix (match-end 0) (1- (length prefix))))
4769 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4771 (when (eq (caaar servers) backend)
4772 (setq possible (caar servers))
4773 (when (equal (cadaar servers) server)
4774 (setq found (caar servers))))
4776 (or (car (rassoc found gnus-server-alist))
4778 (car (rassoc possible gnus-server-alist))
4780 (list backend server))))))
4782 (defsubst gnus-secondary-method-p (method)
4783 "Return whether METHOD is a secondary select method."
4784 (let ((methods gnus-secondary-select-methods)
4785 (gmethod (gnus-server-get-method nil method)))
4787 (not (equal (gnus-server-get-method nil (car methods))
4789 (setq methods (cdr methods)))
4792 (defun gnus-group-foreign-p (group)
4793 "Say whether a group is foreign or not."
4794 (and (not (gnus-group-native-p group))
4795 (not (gnus-group-secondary-p group))))
4797 (defun gnus-group-native-p (group)
4798 "Say whether the group is native or not."
4799 (not (string-match ":" group)))
4801 (defun gnus-group-secondary-p (group)
4802 "Say whether the group is secondary or not."
4803 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4805 (defun gnus-group-get-parameter (group &optional symbol)
4806 "Returns the group parameters for GROUP.
4807 If SYMBOL, return the value of that symbol in the group parameters."
4808 (let ((params (gnus-info-params (gnus-get-info group))))
4810 (gnus-group-parameter-value params symbol)
4813 (defun gnus-group-parameter-value (params symbol)
4814 "Return the value of SYMBOL in group PARAMS."
4815 (or (car (memq symbol params)) ; It's either a simple symbol
4816 (cdr (assq symbol params)))) ; or a cons.
4818 (defun gnus-group-add-parameter (group param)
4819 "Add parameter PARAM to GROUP."
4820 (let ((info (gnus-get-info group)))
4822 () ; This is a dead group. We just ignore it.
4823 ;; Cons the new param to the old one and update.
4824 (gnus-group-set-info (cons param (gnus-info-params info))
4827 (defun gnus-group-set-parameter (group name value)
4828 "Set parameter NAME to VALUE in GROUP."
4829 (let ((info (gnus-get-info group)))
4831 () ; This is a dead group. We just ignore it.
4832 (let ((old-params (gnus-info-params info))
4833 (new-params (list (cons name value))))
4835 (if (or (not (listp (car old-params)))
4836 (not (eq (caar old-params) name)))
4837 (setq new-params (append new-params (list (car old-params)))))
4838 (setq old-params (cdr old-params)))
4839 (gnus-group-set-info new-params group 'params)))))
4841 (defun gnus-group-add-score (group &optional score)
4842 "Add SCORE to the GROUP score.
4843 If SCORE is nil, add 1 to the score of GROUP."
4844 (let ((info (gnus-get-info group)))
4846 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4848 (defun gnus-summary-bubble-group ()
4849 "Increase the score of the current group.
4850 This is a handy function to add to `gnus-summary-exit-hook' to
4851 increase the score of each group you read."
4852 (gnus-group-add-score gnus-newsgroup-name))
4854 (defun gnus-group-set-info (info &optional method-only-group part)
4855 (let* ((entry (gnus-gethash
4856 (or method-only-group (gnus-info-group info))
4857 gnus-newsrc-hashtb))
4859 (info (if method-only-group (nth 2 entry) info))
4861 (when method-only-group
4863 (error "Trying to change non-existent group %s" method-only-group))
4864 ;; We have received parts of the actual group info - either the
4865 ;; select method or the group parameters. We first check
4866 ;; whether we have to extend the info, and if so, do that.
4867 (let ((len (length info))
4868 (total (if (eq part 'method) 5 6)))
4870 (setcdr (nthcdr (1- len) info)
4871 (make-list (- total len) nil)))
4872 ;; Then we enter the new info.
4873 (setcar (nthcdr (1- total) info) part-info)))
4875 ;; This is a new group, so we just create it.
4877 (set-buffer gnus-group-buffer)
4878 (setq method (gnus-info-method info))
4879 (when (gnus-server-equal method "native")
4882 (set-buffer gnus-group-buffer)
4884 ;; It's a foreign group...
4885 (gnus-group-make-group
4886 (gnus-group-real-name (gnus-info-group info))
4887 (if (stringp method) method
4888 (prin1-to-string (car method)))
4890 (nth 1 (gnus-info-method info))))
4891 ;; It's a native group.
4892 (gnus-group-make-group (gnus-info-group info))))
4893 (gnus-message 6 "Note: New group created")
4895 (gnus-gethash (gnus-group-prefixed-name
4896 (gnus-group-real-name (gnus-info-group info))
4897 (or (gnus-info-method info) gnus-select-method))
4898 gnus-newsrc-hashtb))))
4899 ;; Whether it was a new group or not, we now have the entry, so we
4900 ;; can do the update.
4903 (setcar (nthcdr 2 entry) info)
4904 (when (and (not (eq (car entry) t))
4905 (gnus-active (gnus-info-group info)))
4906 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4907 (error "No such group: %s" (gnus-info-group info)))))
4909 (defun gnus-group-set-method-info (group select-method)
4910 (gnus-group-set-info select-method group 'method))
4912 (defun gnus-group-set-params-info (group params)
4913 (gnus-group-set-info params group 'params))
4915 (defun gnus-group-update-group-line ()
4916 "Update the current line in the group buffer."
4917 (let* ((buffer-read-only nil)
4918 (group (gnus-group-group-name))
4919 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4920 gnus-group-indentation)
4922 (not (gnus-ephemeral-group-p group))
4924 (concat "(gnus-group-set-info '"
4925 (prin1-to-string (nth 2 entry)) ")")))
4926 (setq gnus-group-indentation (gnus-group-group-indentation))
4928 (gnus-group-insert-group-line-info group)
4930 (gnus-group-position-point)))
4932 (defun gnus-group-insert-group-line-info (group)
4933 "Insert GROUP on the current line."
4934 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4938 ;; (Un)subscribed group.
4939 (setq info (nth 2 entry))
4940 (gnus-group-insert-group-line
4941 group (gnus-info-level info) (gnus-info-marks info)
4942 (or (car entry) t) (gnus-info-method info)))
4943 ;; This group is dead.
4944 (gnus-group-insert-group-line
4946 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4948 (if (setq active (gnus-active group))
4949 (- (1+ (cdr active)) (car active)) 0)
4952 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4953 gnus-tmp-marked number
4955 "Insert a group line in the group buffer."
4956 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4957 (gnus-tmp-number-total
4959 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4961 (gnus-tmp-number-of-unread
4962 (if (numberp number) (int-to-string (max 0 number))
4964 (gnus-tmp-number-of-read
4965 (if (numberp number)
4966 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4968 (gnus-tmp-subscribed
4969 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4970 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4971 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4973 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4974 (gnus-tmp-newsgroup-description
4975 (if gnus-description-hashtb
4976 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4979 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4980 (gnus-tmp-moderated-string
4981 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4983 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4984 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4985 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4986 (gnus-tmp-news-method-string
4988 (format "(%s:%s)" (car gnus-tmp-method)
4989 (cadr gnus-tmp-method)) ""))
4990 (gnus-tmp-marked-mark
4991 (if (and (numberp number)
4993 (cdr (assq 'tick gnus-tmp-marked)))
4995 (gnus-tmp-process-marked
4996 (if (member gnus-tmp-group gnus-group-marked)
4997 gnus-process-mark ? ))
4999 (or (and gnus-use-grouplens
5000 (bbb-grouplens-group-p gnus-tmp-group))
5002 (buffer-read-only nil)
5003 header gnus-tmp-header) ; passed as parameter to user-funcs.
5005 (gnus-add-text-properties
5009 (eval gnus-group-line-format-spec))
5010 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5011 gnus-unread ,(if (numberp number)
5012 (string-to-int gnus-tmp-number-of-unread)
5014 gnus-marked ,gnus-tmp-marked-mark
5015 gnus-indentation ,gnus-group-indentation
5016 gnus-level ,gnus-tmp-level))
5017 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5019 (run-hooks 'gnus-group-update-hook)
5021 ;; Allow XEmacs to remove front-sticky text properties.
5022 (gnus-group-remove-excess-properties)))
5024 (defun gnus-group-update-group (group &optional visible-only)
5025 "Update all lines where GROUP appear.
5026 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5029 (set-buffer gnus-group-buffer)
5030 ;; The buffer may be narrowed.
5033 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5035 found buffer-read-only)
5036 ;; Enter the current status into the dribble buffer.
5037 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5038 (if (and entry (not (gnus-ephemeral-group-p group)))
5040 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5042 ;; Find all group instances. If topics are in use, each group
5043 ;; may be listed in more than once.
5044 (while (setq loc (text-property-any
5045 loc (point-max) 'gnus-group ident))
5048 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5050 (gnus-group-insert-group-line-info group)
5053 (run-hooks 'gnus-group-update-group-hook)))
5054 (setq loc (1+ loc)))
5055 (unless (or found visible-only)
5056 ;; No such line in the buffer, find out where it's supposed to
5057 ;; go, and insert it there (or at the end of the buffer).
5058 (if gnus-goto-missing-group-function
5059 (funcall gnus-goto-missing-group-function group)
5060 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5061 (while (and entry (car entry)
5065 (point-min) (point-max)
5066 'gnus-group (gnus-intern-safe
5067 (caar entry) gnus-active-hashtb)))))
5068 (setq entry (cdr entry)))
5069 (or entry (goto-char (point-max)))))
5070 ;; Finally insert the line.
5071 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5072 (gnus-group-insert-group-line-info group)
5075 (run-hooks 'gnus-group-update-group-hook))))
5076 (gnus-group-set-mode-line)))))
5078 (defun gnus-group-set-mode-line ()
5079 "Update the mode line in the group buffer."
5080 (when (memq 'group gnus-updated-mode-lines)
5081 ;; Yes, we want to keep this mode line updated.
5083 (set-buffer gnus-group-buffer)
5084 (let* ((gformat (or gnus-group-mode-line-format-spec
5085 (setq gnus-group-mode-line-format-spec
5087 gnus-group-mode-line-format
5088 gnus-group-mode-line-format-alist))))
5089 (gnus-tmp-news-server (cadr gnus-select-method))
5090 (gnus-tmp-news-method (car gnus-select-method))
5091 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5093 gnus-tmp-header ;Dummy binding for user-defined formats
5094 ;; Get the resulting string.
5095 (mode-string (eval gformat)))
5096 ;; Say whether the dribble buffer has been modified.
5097 (setq mode-line-modified
5098 (if (and gnus-dribble-buffer
5099 (buffer-name gnus-dribble-buffer)
5100 (buffer-modified-p gnus-dribble-buffer)
5102 (set-buffer gnus-dribble-buffer)
5103 (not (zerop (buffer-size)))))
5105 ;; If the line is too long, we chop it off.
5106 (when (> (length mode-string) max-len)
5107 (setq mode-string (substring mode-string 0 (- max-len 4))))
5109 (setq mode-line-buffer-identification
5111 (set-buffer-modified-p t))))))
5113 (defun gnus-group-group-name ()
5114 "Get the name of the newsgroup on the current line."
5115 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5116 (and group (symbol-name group))))
5118 (defun gnus-group-group-level ()
5119 "Get the level of the newsgroup on the current line."
5120 (get-text-property (gnus-point-at-bol) 'gnus-level))
5122 (defun gnus-group-group-indentation ()
5123 "Get the indentation of the newsgroup on the current line."
5124 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5125 (and gnus-group-indentation-function
5126 (funcall gnus-group-indentation-function))
5129 (defun gnus-group-group-unread ()
5130 "Get the number of unread articles of the newsgroup on the current line."
5131 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5133 (defun gnus-group-search-forward (&optional backward all level first-too)
5134 "Find the next newsgroup with unread articles.
5135 If BACKWARD is non-nil, find the previous newsgroup instead.
5136 If ALL is non-nil, just find any newsgroup.
5137 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5139 If FIRST-TOO, the current line is also eligible as a target."
5140 (let ((way (if backward -1 1))
5141 (low gnus-level-killed)
5144 (if (and backward (progn (beginning-of-line)) (bobp))
5146 (or first-too (forward-line way))
5154 (get-text-property (point) 'gnus-unread)))
5155 (and (numberp unread) (> unread 0)))
5156 (setq lev (get-text-property (point)
5158 (<= lev gnus-level-subscribed)))
5160 (and (setq lev (get-text-property (point)
5169 (zerop (forward-line way)))))
5171 (progn (gnus-group-position-point) t)
5172 (goto-char (or pos beg))
5175 ;;; Gnus group mode commands
5179 (defun gnus-group-mark-group (n &optional unmark no-advance)
5180 "Mark the current group."
5182 (let ((buffer-read-only nil)
5186 (when (setq group (gnus-group-group-name))
5190 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5195 (setq gnus-group-marked (delete group gnus-group-marked)))
5197 (setq gnus-group-marked
5198 (cons group (delete group gnus-group-marked)))))
5199 (or no-advance (gnus-group-next-group 1))
5201 (gnus-summary-position-point)
5204 (defun gnus-group-unmark-group (n)
5205 "Remove the mark from the current group."
5207 (gnus-group-mark-group n 'unmark)
5208 (gnus-group-position-point))
5210 (defun gnus-group-unmark-all-groups ()
5211 "Unmark all groups."
5213 (let ((groups gnus-group-marked))
5216 (gnus-group-remove-mark (pop groups)))))
5217 (gnus-group-position-point))
5219 (defun gnus-group-mark-region (unmark beg end)
5220 "Mark all groups between point and mark.
5221 If UNMARK, remove the mark instead."
5222 (interactive "P\nr")
5223 (let ((num (count-lines beg end)))
5226 (- num (gnus-group-mark-group num unmark)))))
5228 (defun gnus-group-mark-buffer (&optional unmark)
5229 "Mark all groups in the buffer.
5230 If UNMARK, remove the mark instead."
5232 (gnus-group-mark-region unmark (point-min) (point-max)))
5234 (defun gnus-group-mark-regexp (regexp)
5235 "Mark all groups that match some regexp."
5236 (interactive "sMark (regexp): ")
5237 (let ((alist (cdr gnus-newsrc-alist))
5240 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5241 (gnus-group-set-mark group))))
5242 (gnus-group-position-point))
5244 (defun gnus-group-remove-mark (group)
5245 "Remove the process mark from GROUP and move point there.
5246 Return nil if the group isn't displayed."
5247 (if (gnus-group-goto-group group)
5249 (gnus-group-mark-group 1 'unmark t)
5251 (setq gnus-group-marked
5252 (delete group gnus-group-marked))
5255 (defun gnus-group-set-mark (group)
5256 "Set the process mark on GROUP."
5257 (if (gnus-group-goto-group group)
5259 (gnus-group-mark-group 1 nil t))
5260 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5262 (defun gnus-group-universal-argument (arg &optional groups func)
5263 "Perform any command on all groups accoring to the process/prefix convention."
5265 (let ((groups (or groups (gnus-group-process-prefix arg)))
5267 (if (eq (setq func (or func
5270 (substitute-command-keys
5271 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5273 (gnus-error 1 "Undefined key")
5275 (gnus-group-remove-mark (setq group (pop groups)))
5276 (command-execute func))))
5277 (gnus-group-position-point))
5279 (defun gnus-group-process-prefix (n)
5280 "Return a list of groups to work on.
5281 Take into consideration N (the prefix) and the list of marked groups."
5284 (setq n (prefix-numeric-value n))
5285 ;; There is a prefix, so we return a list of the N next
5287 (let ((way (if (< n 0) -1 1))
5292 (setq group (gnus-group-group-name)))
5293 (setq groups (cons group groups))
5295 (gnus-group-next-group way)))
5297 ((and (boundp 'transient-mark-mode)
5299 (boundp 'mark-active)
5301 ;; Work on the region between point and mark.
5302 (let ((max (max (point) (mark)))
5305 (goto-char (min (point) (mark)))
5308 (push (gnus-group-group-name) groups)
5309 (zerop (gnus-group-next-group 1))
5311 (nreverse groups))))
5313 ;; No prefix, but a list of marked articles.
5314 (reverse gnus-group-marked))
5316 ;; Neither marked articles or a prefix, so we return the
5318 (let ((group (gnus-group-group-name)))
5319 (and group (list group))))))
5321 ;; Selecting groups.
5323 (defun gnus-group-read-group (&optional all no-article group)
5324 "Read news in this newsgroup.
5325 If the prefix argument ALL is non-nil, already read articles become
5326 readable. IF ALL is a number, fetch this number of articles. If the
5327 optional argument NO-ARTICLE is non-nil, no article will be
5328 auto-selected upon group entry. If GROUP is non-nil, fetch that
5331 (let ((group (or group (gnus-group-group-name)))
5332 number active marked entry)
5333 (or group (error "No group on current line"))
5334 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5335 group gnus-newsrc-hashtb)))))
5336 ;; This group might be a dead group. In that case we have to get
5337 ;; the number of unread articles from `gnus-active-hashtb'.
5339 (cond ((numberp all) all)
5341 ((setq active (gnus-active group))
5342 (- (1+ (cdr active)) (car active)))))
5343 (gnus-summary-read-group
5344 group (or all (and (numberp number)
5345 (zerop (+ number (length (cdr (assq 'tick marked)))
5346 (length (cdr (assq 'dormant marked)))))))
5349 (defun gnus-group-select-group (&optional all)
5350 "Select this newsgroup.
5351 No article is selected automatically.
5352 If ALL is non-nil, already read articles become readable.
5353 If ALL is a number, fetch this number of articles."
5355 (gnus-group-read-group all t))
5357 (defun gnus-group-quick-select-group (&optional all)
5358 "Select the current group \"quickly\".
5359 This means that no highlighting or scoring will be performed."
5362 gnus-score-find-score-files-function
5363 gnus-apply-kill-hook
5364 gnus-summary-expunge-below)
5365 (gnus-group-read-group all t)))
5367 (defun gnus-group-visible-select-group (&optional all)
5368 "Select the current group without hiding any articles."
5370 (let ((gnus-inhibit-limiting t))
5371 (gnus-group-read-group all t)))
5374 (defun gnus-fetch-group (group)
5375 "Start Gnus if necessary and enter GROUP.
5376 Returns whether the fetching was successful or not."
5377 (interactive "sGroup name: ")
5378 (or (get-buffer gnus-group-buffer)
5380 (gnus-group-read-group nil nil group))
5382 ;; Enter a group that is not in the group buffer. Non-nil is returned
5383 ;; if selection was successful.
5384 (defun gnus-group-read-ephemeral-group
5385 (group method &optional activate quit-config)
5386 (let ((group (if (gnus-group-foreign-p group) group
5387 (gnus-group-prefixed-name group method))))
5390 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5391 ((quit-config . ,(if quit-config quit-config
5392 (cons (current-buffer) 'summary))))))
5394 (set-buffer gnus-group-buffer)
5395 (or (gnus-check-server method)
5396 (error "Unable to contact server: %s" (gnus-status-message method)))
5397 (if activate (or (gnus-request-group group)
5398 (error "Couldn't request group")))
5400 (gnus-group-read-group t t group)
5404 (defun gnus-group-jump-to-group (group)
5405 "Jump to newsgroup GROUP."
5407 (list (completing-read
5408 "Group: " gnus-active-hashtb nil
5409 (gnus-read-active-file-p)
5411 'gnus-group-history)))
5413 (when (equal group "")
5414 (error "Empty group name"))
5416 (when (string-match "[\000-\032]" group)
5417 (error "Control characters in group: %s" group))
5419 (let ((b (text-property-any
5420 (point-min) (point-max)
5421 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5422 (unless (gnus-ephemeral-group-p group)
5424 ;; Either go to the line in the group buffer...
5426 ;; ... or insert the line.
5429 (gnus-activate-group group)
5430 (error "%s error: %s" group (gnus-status-message group)))
5432 (gnus-group-update-group group)
5433 (goto-char (text-property-any
5434 (point-min) (point-max)
5435 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5436 ;; Adjust cursor point.
5437 (gnus-group-position-point)))
5439 (defun gnus-group-goto-group (group)
5440 "Goto to newsgroup GROUP."
5442 (let ((b (text-property-any (point-min) (point-max)
5443 'gnus-group (gnus-intern-safe
5444 group gnus-active-hashtb))))
5445 (and b (goto-char b)))))
5447 (defun gnus-group-next-group (n)
5448 "Go to next N'th newsgroup.
5449 If N is negative, search backward instead.
5450 Returns the difference between N and the number of skips actually
5453 (gnus-group-next-unread-group n t))
5455 (defun gnus-group-next-unread-group (n &optional all level)
5456 "Go to next N'th unread newsgroup.
5457 If N is negative, search backward instead.
5458 If ALL is non-nil, choose any newsgroup, unread or not.
5459 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5460 such group can be found, the next group with a level higher than
5462 Returns the difference between N and the number of skips actually
5465 (let ((backward (< n 0))
5468 (gnus-group-search-forward
5469 backward (or (not gnus-group-goto-unread) all) level))
5471 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5472 (if level " on this level or higher" "")))
5475 (defun gnus-group-prev-group (n)
5476 "Go to previous N'th newsgroup.
5477 Returns the difference between N and the number of skips actually
5480 (gnus-group-next-unread-group (- n) t))
5482 (defun gnus-group-prev-unread-group (n)
5483 "Go to previous N'th unread newsgroup.
5484 Returns the difference between N and the number of skips actually
5487 (gnus-group-next-unread-group (- n)))
5489 (defun gnus-group-next-unread-group-same-level (n)
5490 "Go to next N'th unread newsgroup on the same level.
5491 If N is negative, search backward instead.
5492 Returns the difference between N and the number of skips actually
5495 (gnus-group-next-unread-group n t (gnus-group-group-level))
5496 (gnus-group-position-point))
5498 (defun gnus-group-prev-unread-group-same-level (n)
5499 "Go to next N'th unread newsgroup on the same level.
5500 Returns the difference between N and the number of skips actually
5503 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5504 (gnus-group-position-point))
5506 (defun gnus-group-best-unread-group (&optional exclude-group)
5507 "Go to the group with the highest level.
5508 If EXCLUDE-GROUP, do not go to that group."
5510 (goto-char (point-min))
5514 (setq unread (get-text-property (point) 'gnus-unread))
5515 (if (and (numberp unread) (> unread 0))
5517 (if (and (get-text-property (point) 'gnus-level)
5518 (< (get-text-property (point) 'gnus-level) best)
5519 (or (not exclude-group)
5520 (not (equal exclude-group (gnus-group-group-name)))))
5522 (setq best (get-text-property (point) 'gnus-level))
5523 (setq best-point (point))))))
5525 (if best-point (goto-char best-point))
5526 (gnus-summary-position-point)
5527 (and best-point (gnus-group-group-name))))
5529 (defun gnus-group-first-unread-group ()
5530 "Go to the first group with unread articles."
5533 (let ((opoint (point))
5535 (goto-char (point-min))
5536 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5537 (and (numberp unread) ; Not a topic.
5538 (not (zerop unread))) ; Has unread articles.
5539 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5542 nil)) ; Not success.
5543 (gnus-group-position-point)))
5545 (defun gnus-group-enter-server-mode ()
5546 "Jump to the server buffer."
5548 (gnus-enter-server-buffer))
5550 (defun gnus-group-make-group (name &optional method address)
5551 "Add a new newsgroup.
5552 The user will be prompted for a NAME, for a select METHOD, and an
5556 (read-string "Group name: ")
5559 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5560 nil t nil 'gnus-method-history)))
5561 (cond ((assoc method gnus-valid-select-methods)
5563 (if (memq 'prompt-address
5564 (assoc method gnus-valid-select-methods))
5565 (read-string "Address: ")
5567 ((assoc method gnus-server-alist)
5570 (list method ""))))))
5572 (let* ((meth (and method (if address (list (intern method) address)
5574 (nname (if method (gnus-group-prefixed-name name meth) name))
5576 (when (gnus-gethash nname gnus-newsrc-hashtb)
5577 (error "Group %s already exists" nname))
5578 ;; Subscribe to the new group.
5579 (gnus-group-change-level
5580 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5581 gnus-level-default-subscribed gnus-level-killed
5582 (and (gnus-group-group-name)
5583 (gnus-gethash (gnus-group-group-name)
5584 gnus-newsrc-hashtb))
5587 (gnus-set-active nname (cons 1 0))
5588 (or (gnus-ephemeral-group-p name)
5590 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5592 (gnus-group-insert-group-line-info nname)
5594 (gnus-group-position-point)
5596 ;; Load the backend and try to make the backend create
5597 ;; the group as well.
5598 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5600 gnus-valid-select-methods)
5602 (gnus-check-server meth)
5603 (and (gnus-check-backend-function 'request-create-group nname)
5604 (gnus-request-create-group nname))
5607 (defun gnus-group-delete-group (group &optional force)
5608 "Delete the current group.
5609 If FORCE (the prefix) is non-nil, all the articles in the group will
5610 be deleted. This is \"deleted\" as in \"removed forever from the face
5611 of the Earth\". There is no undo."
5613 (list (gnus-group-group-name)
5614 current-prefix-arg))
5615 (or group (error "No group to rename"))
5616 (or (gnus-check-backend-function 'request-delete-group group)
5617 (error "This backend does not support group deletion"))
5619 (if (not (gnus-yes-or-no-p
5621 "Do you really want to delete %s%s? "
5622 group (if force " and all its contents" ""))))
5624 (gnus-message 6 "Deleting group %s..." group)
5625 (if (not (gnus-request-delete-group group force))
5626 (gnus-error 3 "Couldn't delete group %s" group)
5627 (gnus-message 6 "Deleting group %s...done" group)
5628 (gnus-group-goto-group group)
5629 (gnus-group-kill-group 1 t)
5630 (gnus-sethash group nil gnus-active-hashtb)
5632 (gnus-group-position-point)))
5634 (defun gnus-group-rename-group (group new-name)
5637 (gnus-group-group-name)
5639 (or (gnus-check-backend-function
5640 'request-rename-group (gnus-group-group-name))
5641 (error "This backend does not support renaming groups"))
5642 (read-string "New group name: "))))
5644 (or (gnus-check-backend-function 'request-rename-group group)
5645 (error "This backend does not support renaming groups"))
5647 (or group (error "No group to rename"))
5648 (and (string-match "^[ \t]*$" new-name)
5649 (error "Not a valid group name"))
5651 ;; We find the proper prefixed name.
5653 (gnus-group-prefixed-name
5654 (gnus-group-real-name new-name)
5655 (gnus-info-method (gnus-get-info group))))
5657 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5659 (if (not (gnus-request-rename-group group new-name))
5660 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5661 ;; We rename the group internally by killing it...
5662 (gnus-group-goto-group group)
5663 (gnus-group-kill-group)
5664 ;; ... changing its name ...
5665 (setcar (cdar gnus-list-of-killed-groups) new-name)
5666 ;; ... and then yanking it. Magic!
5667 (gnus-group-yank-group)
5668 (gnus-set-active new-name (gnus-active group))
5669 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5671 (gnus-group-position-point)))
5673 (defun gnus-group-edit-group (group &optional part)
5674 "Edit the group on the current line."
5675 (interactive (list (gnus-group-group-name)))
5676 (let* ((part (or part 'info))
5677 (done-func `(lambda ()
5678 "Exit editing mode and update the information."
5680 (gnus-group-edit-group-done ',part ,group)))
5681 (winconf (current-window-configuration))
5683 (or group (error "No group on current line"))
5684 (or (setq info (gnus-get-info group))
5685 (error "Killed group; can't be edited"))
5686 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5687 (gnus-configure-windows 'edit-group)
5688 (gnus-add-current-to-buffer-list)
5690 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5691 (use-local-map (copy-keymap emacs-lisp-mode-map))
5692 (local-set-key "\C-c\C-c" done-func)
5693 (make-local-variable 'gnus-prev-winconf)
5694 (setq gnus-prev-winconf winconf)
5699 ";; Type `C-c C-c' after editing the select method.\n\n")
5701 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5703 ";; Type `C-c C-c' after editing the group info.\n\n")))
5706 (cond ((eq part 'method)
5707 (or (gnus-info-method info) "native"))
5709 (gnus-info-params info))
5713 (defun gnus-group-edit-group-method (group)
5714 "Edit the select method of GROUP."
5715 (interactive (list (gnus-group-group-name)))
5716 (gnus-group-edit-group group 'method))
5718 (defun gnus-group-edit-group-parameters (group)
5719 "Edit the group parameters of GROUP."
5720 (interactive (list (gnus-group-group-name)))
5721 (gnus-group-edit-group group 'params))
5723 (defun gnus-group-edit-group-done (part group)
5724 "Get info from buffer, update variables and jump to the group buffer."
5725 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5726 (goto-char (point-min))
5727 (let* ((form (read (current-buffer)))
5728 (winconf gnus-prev-winconf)
5729 (method (cond ((eq part 'info) (nth 4 form))
5730 ((eq part 'method) form)
5732 (info (cond ((eq part 'info) form)
5733 ((eq part 'method) (gnus-get-info group))
5736 (if (or (not method)
5738 gnus-select-method method))
5739 (gnus-group-real-name (car info))
5740 (gnus-group-prefixed-name
5741 (gnus-group-real-name (car info)) method))
5743 (when (and new-group
5744 (not (equal new-group group)))
5745 (when (gnus-group-goto-group group)
5746 (gnus-group-kill-group 1))
5747 (gnus-activate-group new-group))
5749 (if (and info new-group)
5751 (setq info (gnus-copy-sequence info))
5752 (setcar info new-group)
5753 (unless (gnus-server-equal method "native")
5754 (unless (nthcdr 3 info)
5755 (nconc info (list nil nil)))
5756 (unless (nthcdr 4 info)
5757 (nconc info (list nil)))
5758 (gnus-info-set-method info method))
5759 (gnus-group-set-info info))
5760 (gnus-group-set-info form (or new-group group) part))
5761 (kill-buffer (current-buffer))
5762 (and winconf (set-window-configuration winconf))
5763 (set-buffer gnus-group-buffer)
5764 (gnus-group-update-group (or new-group group))
5765 (gnus-group-position-point)))
5767 (defun gnus-group-make-help-group ()
5768 "Create the Gnus documentation group."
5770 (let ((path load-path)
5771 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5773 (and (gnus-gethash name gnus-newsrc-hashtb)
5774 (error "Documentation group already exists"))
5776 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5778 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5780 (setq file (concat (file-name-directory
5781 (directory-file-name dir))
5782 "etc/gnus-tut.txt"))))
5785 (gnus-message 1 "Couldn't find doc group")
5786 (gnus-group-make-group
5787 (gnus-group-real-name name)
5788 (list 'nndoc "gnus-help"
5789 (list 'nndoc-address file)
5790 (list 'nndoc-article-type 'mbox)))))
5791 (gnus-group-position-point))
5793 (defun gnus-group-make-doc-group (file type)
5794 "Create a group that uses a single file as the source."
5796 (list (read-file-name "File name: ")
5797 (and current-prefix-arg 'ask)))
5798 (when (eq type 'ask)
5803 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5805 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5806 ((= char ?b) 'babyl)
5807 ((= char ?d) 'digest)
5808 ((= char ?f) 'forward)
5810 (t (setq err (format "%c unknown. " char))
5813 (let* ((file (expand-file-name file))
5814 (name (gnus-generate-new-group-name
5815 (gnus-group-prefixed-name
5816 (file-name-nondirectory file) '(nndoc "")))))
5817 (gnus-group-make-group
5818 (gnus-group-real-name name)
5819 (list 'nndoc (file-name-nondirectory file)
5820 (list 'nndoc-address file)
5821 (list 'nndoc-article-type (or type 'guess))))))
5823 (defun gnus-group-make-archive-group (&optional all)
5824 "Create the (ding) Gnus archive group of the most recent articles.
5825 Given a prefix, create a full group."
5827 (let ((group (gnus-group-prefixed-name
5828 (if all "ding.archives" "ding.recent") '(nndir ""))))
5829 (and (gnus-gethash group gnus-newsrc-hashtb)
5830 (error "Archive group already exists"))
5831 (gnus-group-make-group
5832 (gnus-group-real-name group)
5833 (list 'nndir (if all "hpc" "edu")
5834 (list 'nndir-directory
5835 (if all gnus-group-archive-directory
5836 gnus-group-recent-archive-directory))))))
5838 (defun gnus-group-make-directory-group (dir)
5839 "Create an nndir group.
5840 The user will be prompted for a directory. The contents of this
5841 directory will be used as a newsgroup. The directory should contain
5842 mail messages or news articles in files that have numeric names."
5844 (list (read-file-name "Create group from directory: ")))
5845 (or (file-exists-p dir) (error "No such directory"))
5846 (or (file-directory-p dir) (error "Not a directory"))
5850 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5852 (gnus-group-prefixed-name
5853 (concat (file-name-as-directory (directory-file-name dir))
5856 (setq ext (format "<%d>" (setq i (1+ i)))))
5857 (gnus-group-make-group
5858 (gnus-group-real-name group)
5859 (list 'nndir group (list 'nndir-directory dir)))))
5861 (defun gnus-group-make-kiboze-group (group address scores)
5862 "Create an nnkiboze group.
5863 The user will be prompted for a name, a regexp to match groups, and
5864 score file entries for articles to include in the group."
5867 (read-string "nnkiboze group name: ")
5868 (read-string "Source groups (regexp): ")
5869 (let ((headers (mapcar (lambda (group) (list group))
5870 '("subject" "from" "number" "date" "message-id"
5871 "references" "chars" "lines" "xref"
5872 "followup" "all" "body" "head")))
5873 scores header regexp regexps)
5874 (while (not (equal "" (setq header (completing-read
5875 "Match on header: " headers nil t))))
5877 (while (not (equal "" (setq regexp (read-string
5878 (format "Match on %s (string): "
5880 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5881 (setq scores (cons (cons header regexps) scores)))
5883 (gnus-group-make-group group "nnkiboze" address)
5884 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5885 (let (emacs-lisp-mode-hook)
5886 (pp scores (current-buffer)))))
5888 (defun gnus-group-add-to-virtual (n vgroup)
5889 "Add the current group to a virtual group."
5891 (list current-prefix-arg
5892 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5894 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5895 (error "%s is not an nnvirtual group" vgroup))
5896 (let* ((groups (gnus-group-process-prefix n))
5897 (method (gnus-info-method (gnus-get-info vgroup))))
5898 (setcar (cdr method)
5900 (nth 1 method) "\\|"
5903 (gnus-group-remove-mark s)
5904 (concat "\\(^" (regexp-quote s) "$\\)"))
5906 (gnus-group-position-point))
5908 (defun gnus-group-make-empty-virtual (group)
5909 "Create a new, fresh, empty virtual group."
5910 (interactive "sCreate new, empty virtual group: ")
5911 (let* ((method (list 'nnvirtual "^$"))
5912 (pgroup (gnus-group-prefixed-name group method)))
5913 ;; Check whether it exists already.
5914 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5915 (error "Group %s already exists." pgroup))
5916 ;; Subscribe the new group after the group on the current line.
5917 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5918 (gnus-group-update-group pgroup)
5920 (gnus-group-position-point)))
5922 (defun gnus-group-enter-directory (dir)
5923 "Enter an ephemeral nneething group."
5924 (interactive "DDirectory to read: ")
5925 (let* ((method (list 'nneething dir))
5926 (leaf (gnus-group-prefixed-name
5927 (file-name-nondirectory (directory-file-name dir))
5929 (name (gnus-generate-new-group-name leaf)))
5930 (let ((nneething-read-only t))
5931 (or (gnus-group-read-ephemeral-group
5933 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5935 (error "Couldn't enter %s" dir)))))
5937 ;; Group sorting commands
5938 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5940 (defun gnus-group-sort-groups (func &optional reverse)
5941 "Sort the group buffer according to FUNC.
5942 If REVERSE, reverse the sorting order."
5943 (interactive (list gnus-group-sort-function
5944 current-prefix-arg))
5946 ((not (listp func)) func)
5948 ((= 1 (length func)) (car func))
5950 ,(gnus-make-sort-function
5951 (reverse func)))))))
5952 ;; We peel off the dummy group from the alist.
5954 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5955 (pop gnus-newsrc-alist))
5957 (setq gnus-newsrc-alist
5958 (sort gnus-newsrc-alist func))
5960 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5961 ;; Regenerate the hash table.
5962 (gnus-make-hashtable-from-newsrc-alist)
5963 (gnus-group-list-groups))))
5965 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5966 "Sort the group buffer alphabetically by group name.
5967 If REVERSE, sort in reverse order."
5969 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5971 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5972 "Sort the group buffer by number of unread articles.
5973 If REVERSE, sort in reverse order."
5975 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5977 (defun gnus-group-sort-groups-by-level (&optional reverse)
5978 "Sort the group buffer by group level.
5979 If REVERSE, sort in reverse order."
5981 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5983 (defun gnus-group-sort-groups-by-score (&optional reverse)
5984 "Sort the group buffer by group score.
5985 If REVERSE, sort in reverse order."
5987 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5989 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5990 "Sort the group buffer by group rank.
5991 If REVERSE, sort in reverse order."
5993 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5995 (defun gnus-group-sort-groups-by-method (&optional reverse)
5996 "Sort the group buffer alphabetically by backend name.
5997 If REVERSE, sort in reverse order."
5999 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6001 (defun gnus-group-sort-by-alphabet (info1 info2)
6002 "Sort alphabetically."
6003 (string< (gnus-info-group info1) (gnus-info-group info2)))
6005 (defun gnus-group-sort-by-unread (info1 info2)
6006 "Sort by number of unread articles."
6007 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6008 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6009 (< (or (and (numberp n1) n1) 0)
6010 (or (and (numberp n2) n2) 0))))
6012 (defun gnus-group-sort-by-level (info1 info2)
6014 (< (gnus-info-level info1) (gnus-info-level info2)))
6016 (defun gnus-group-sort-by-method (info1 info2)
6017 "Sort alphabetically by backend name."
6018 (string< (symbol-name (car (gnus-find-method-for-group
6019 (gnus-info-group info1) info1)))
6020 (symbol-name (car (gnus-find-method-for-group
6021 (gnus-info-group info2) info2)))))
6023 (defun gnus-group-sort-by-score (info1 info2)
6024 "Sort by group score."
6025 (< (gnus-info-score info1) (gnus-info-score info2)))
6027 (defun gnus-group-sort-by-rank (info1 info2)
6028 "Sort by level and score."
6029 (let ((level1 (gnus-info-level info1))
6030 (level2 (gnus-info-level info2)))
6031 (or (< level1 level2)
6032 (and (= level1 level2)
6033 (> (gnus-info-score info1) (gnus-info-score info2))))))
6035 ;; Group catching up.
6037 (defun gnus-group-clear-data (n)
6038 "Clear all marks and read ranges from the current group."
6040 (let ((groups (gnus-group-process-prefix n))
6042 (while (setq group (pop groups))
6043 (setq info (gnus-get-info group))
6044 (gnus-info-set-read info nil)
6045 (when (gnus-info-marks info)
6046 (gnus-info-set-marks info nil))
6047 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6048 (when (gnus-group-goto-group group)
6049 (gnus-group-remove-mark group)
6050 (gnus-group-update-group-line)))))
6052 (defun gnus-group-catchup-current (&optional n all)
6053 "Mark all articles not marked as unread in current newsgroup as read.
6054 If prefix argument N is numeric, the ARG next newsgroups will be
6055 caught up. If ALL is non-nil, marked articles will also be marked as
6056 read. Cross references (Xref: header) of articles are ignored.
6057 The difference between N and actual number of newsgroups that were
6058 caught up is returned."
6060 (unless (gnus-group-group-name)
6061 (error "No group on the current line"))
6062 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6066 "Do you really want to mark all articles as read? "
6067 "Mark all unread articles as read? "))))
6069 (let ((groups (gnus-group-process-prefix n))
6072 ;; Virtual groups have to be given special treatment.
6073 (let ((method (gnus-find-method-for-group (car groups))))
6074 (if (eq 'nnvirtual (car method))
6075 (nnvirtual-catchup-group
6076 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6077 (gnus-group-remove-mark (car groups))
6078 (if (>= (gnus-group-group-level) gnus-level-zombie)
6079 (gnus-message 2 "Dead groups can't be caught up")
6081 (gnus-group-goto-group (car groups))
6082 (gnus-group-catchup (car groups) all))
6083 (gnus-group-update-group-line)
6084 (setq ret (1+ ret))))
6085 (setq groups (cdr groups)))
6086 (gnus-group-next-unread-group 1)
6089 (defun gnus-group-catchup-current-all (&optional n)
6090 "Mark all articles in current newsgroup as read.
6091 Cross references (Xref: header) of articles are ignored."
6093 (gnus-group-catchup-current n 'all))
6095 (defun gnus-group-catchup (group &optional all)
6096 "Mark all articles in GROUP as read.
6097 If ALL is non-nil, all articles are marked as read.
6098 The return value is the number of articles that were marked as read,
6099 or nil if no action could be taken."
6100 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6102 ;; Do the updating only if the newsgroup isn't killed.
6103 (if (not (numberp (car entry)))
6104 (gnus-message 1 "Can't catch up; non-active group")
6105 ;; Do auto-expirable marks if that's required.
6106 (when (gnus-group-auto-expirable-p group)
6107 (gnus-add-marked-articles
6108 group 'expire (gnus-list-of-unread-articles group))
6110 (let ((marks (nth 3 (nth 2 entry))))
6111 (gnus-add-marked-articles
6112 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6113 (gnus-add-marked-articles
6114 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6116 (gnus-update-read-articles group nil)
6117 ;; Also nix out the lists of marks and dormants.
6119 (gnus-add-marked-articles group 'tick nil nil 'force)
6120 (gnus-add-marked-articles group 'dormant nil nil 'force))
6121 (run-hooks 'gnus-group-catchup-group-hook)
6124 (defun gnus-group-expire-articles (&optional n)
6125 "Expire all expirable articles in the current newsgroup."
6127 (let ((groups (gnus-group-process-prefix n))
6130 (error "No groups to expire"))
6131 (while (setq group (pop groups))
6132 (gnus-group-remove-mark group)
6133 (when (gnus-check-backend-function 'request-expire-articles group)
6134 (gnus-message 6 "Expiring articles in %s..." group)
6135 (let* ((info (gnus-get-info group))
6136 (expirable (if (gnus-group-total-expirable-p group)
6137 (cons nil (gnus-list-of-read-articles group))
6138 (assq 'expire (gnus-info-marks info))))
6139 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6143 (gnus-compress-sequence
6145 ;; We set the expiry variables to the groupp
6147 (let ((nnmail-expiry-wait-function nil)
6148 (nnmail-expiry-wait expiry-wait))
6149 (gnus-request-expire-articles
6150 (gnus-uncompress-sequence (cdr expirable)) group))
6151 ;; Just expire using the normal expiry values.
6152 (gnus-request-expire-articles
6153 (gnus-uncompress-sequence (cdr expirable)) group)))))
6154 (gnus-message 6 "Expiring articles in %s...done" group)))
6155 (gnus-group-position-point))))
6157 (defun gnus-group-expire-all-groups ()
6158 "Expire all expirable articles in all newsgroups."
6161 (gnus-message 5 "Expiring...")
6162 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6163 (cdr gnus-newsrc-alist))))
6164 (gnus-group-expire-articles nil)))
6165 (gnus-group-position-point)
6166 (gnus-message 5 "Expiring...done"))
6168 (defun gnus-group-set-current-level (n level)
6169 "Set the level of the next N groups to LEVEL."
6174 (let ((s (read-string
6175 (format "Level (default %s): "
6176 (or (gnus-group-group-level)
6177 gnus-level-default-subscribed)))))
6178 (if (string-match "^\\s-*$" s)
6179 (int-to-string (or (gnus-group-group-level)
6180 gnus-level-default-subscribed))
6182 (or (and (>= level 1) (<= level gnus-level-killed))
6183 (error "Illegal level: %d" level))
6184 (let ((groups (gnus-group-process-prefix n))
6186 (while (setq group (pop groups))
6187 (gnus-group-remove-mark group)
6188 (gnus-message 6 "Changed level of %s from %d to %d"
6189 group (or (gnus-group-group-level) gnus-level-killed)
6191 (gnus-group-change-level
6192 group level (or (gnus-group-group-level) gnus-level-killed))
6193 (gnus-group-update-group-line)))
6194 (gnus-group-position-point))
6196 (defun gnus-group-unsubscribe-current-group (&optional n)
6197 "Toggle subscription of the current group.
6198 If given numerical prefix, toggle the N next groups."
6200 (let ((groups (gnus-group-process-prefix n))
6203 (setq group (car groups)
6204 groups (cdr groups))
6205 (gnus-group-remove-mark group)
6206 (gnus-group-unsubscribe-group
6207 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6208 gnus-level-default-unsubscribed
6209 gnus-level-default-subscribed) t)
6210 (gnus-group-update-group-line))
6211 (gnus-group-next-group 1)))
6213 (defun gnus-group-unsubscribe-group (group &optional level silent)
6214 "Toggle subscription to GROUP.
6215 Killed newsgroups are subscribed. If SILENT, don't try to update the
6218 (list (completing-read
6219 "Group: " gnus-active-hashtb nil
6220 (gnus-read-active-file-p)
6222 'gnus-group-history)))
6223 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6225 ((string-match "^[ \t]$" group)
6226 (error "Empty group name"))
6228 ;; Toggle subscription flag.
6229 (gnus-group-change-level
6230 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6231 gnus-level-subscribed)
6232 (1+ gnus-level-subscribed)
6233 gnus-level-default-subscribed)))
6235 (gnus-group-update-group group)))
6236 ((and (stringp group)
6237 (or (not (gnus-read-active-file-p))
6238 (gnus-active group)))
6239 ;; Add new newsgroup.
6240 (gnus-group-change-level
6242 (if level level gnus-level-default-subscribed)
6243 (or (and (member group gnus-zombie-list)
6246 (and (gnus-group-group-name)
6247 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6249 (gnus-group-update-group group)))
6250 (t (error "No such newsgroup: %s" group)))
6251 (gnus-group-position-point)))
6253 (defun gnus-group-transpose-groups (n)
6254 "Move the current newsgroup up N places.
6255 If given a negative prefix, move down instead. The difference between
6256 N and the number of steps taken is returned."
6258 (or (gnus-group-group-name)
6259 (error "No group on current line"))
6260 (gnus-group-kill-group 1)
6262 (forward-line (- n))
6263 (gnus-group-yank-group)
6264 (gnus-group-position-point)))
6266 (defun gnus-group-kill-all-zombies ()
6267 "Kill all zombie newsgroups."
6269 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6270 (setq gnus-zombie-list nil)
6271 (gnus-group-list-groups))
6273 (defun gnus-group-kill-region (begin end)
6274 "Kill newsgroups in current region (excluding current point).
6275 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6290 (beginning-of-line) ;Important when LINES < 1
6291 (gnus-group-kill-group lines)))
6293 (defun gnus-group-kill-group (&optional n discard)
6294 "Kill the next N groups.
6295 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6296 However, only groups that were alive can be yanked; already killed
6297 groups or zombie groups can't be yanked.
6298 The return value is the name of the group that was killed, or a list
6301 (let ((buffer-read-only nil)
6302 (groups (gnus-group-process-prefix n))
6303 group entry level out)
6304 (if (< (length groups) 10)
6305 ;; This is faster when there are few groups.
6307 (push (setq group (pop groups)) out)
6308 (gnus-group-remove-mark group)
6309 (setq level (gnus-group-group-level))
6311 (when (and (not discard)
6312 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6313 (push (cons (car entry) (nth 2 entry))
6314 gnus-list-of-killed-groups))
6315 (gnus-group-change-level
6316 (if entry entry group) gnus-level-killed (if entry nil level)))
6317 ;; If there are lots and lots of groups to be killed, we use
6318 ;; this thing instead.
6320 (setq groups (nreverse groups))
6322 (gnus-group-remove-mark (setq group (pop groups)))
6325 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6326 (push (cons (car entry) (nth 2 entry))
6327 gnus-list-of-killed-groups)
6328 (setcdr (cdr entry) (cdddr entry)))
6329 ((member group gnus-zombie-list)
6330 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6331 (gnus-make-hashtable-from-newsrc-alist)))
6333 (gnus-group-position-point)
6334 (if (< (length out) 2) (car out) (nreverse out))))
6336 (defun gnus-group-yank-group (&optional arg)
6337 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6338 inserting it before the current newsgroup. The numeric ARG specifies
6339 how many newsgroups are to be yanked. The name of the newsgroup yanked
6340 is returned, or (if several groups are yanked) a list of yanked groups
6343 (setq arg (or arg 1))
6344 (let (info group prev out)
6345 (while (>= (decf arg) 0)
6346 (if (not (setq info (pop gnus-list-of-killed-groups)))
6347 (error "No more newsgroups to yank"))
6348 (push (setq group (nth 1 info)) out)
6349 ;; Find which newsgroup to insert this one before - search
6350 ;; backward until something suitable is found. If there are no
6351 ;; other newsgroups in this buffer, just make this newsgroup the
6353 (setq prev (gnus-group-group-name))
6354 (gnus-group-change-level
6355 info (gnus-info-level (cdr info)) gnus-level-killed
6356 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6358 (gnus-group-insert-group-line-info group))
6360 (gnus-group-position-point)
6361 (if (< (length out) 2) (car out) (nreverse out))))
6363 (defun gnus-group-kill-level (level)
6364 "Kill all groups that is on a certain LEVEL."
6365 (interactive "nKill all groups on level: ")
6367 ((= level gnus-level-zombie)
6368 (setq gnus-killed-list
6369 (nconc gnus-zombie-list gnus-killed-list))
6370 (setq gnus-zombie-list nil))
6371 ((and (< level gnus-level-zombie)
6373 (or gnus-expert-user
6376 "Do you really want to kill all groups on level %d? "
6378 (let* ((prev gnus-newsrc-alist)
6381 (if (= (gnus-info-level level) level)
6382 (setcdr prev (cdr alist))
6384 (setq alist (cdr alist)))
6385 (gnus-make-hashtable-from-newsrc-alist)
6386 (gnus-group-list-groups)))
6388 (error "Can't kill; illegal level: %d" level))))
6390 (defun gnus-group-list-all-groups (&optional arg)
6391 "List all newsgroups with level ARG or lower.
6392 Default is gnus-level-unsubscribed, which lists all subscribed and most
6393 unsubscribed groups."
6395 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6397 ;; Redefine this to list ALL killed groups if prefix arg used.
6398 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6399 (defun gnus-group-list-killed (&optional arg)
6400 "List all killed newsgroups in the group buffer.
6401 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6402 entail asking the server for the groups."
6404 ;; Find all possible killed newsgroups if arg.
6406 (gnus-get-killed-groups))
6407 (if (not gnus-killed-list)
6408 (gnus-message 6 "No killed groups")
6409 (let (gnus-group-list-mode)
6410 (funcall gnus-group-prepare-function
6411 gnus-level-killed t gnus-level-killed))
6412 (goto-char (point-min)))
6413 (gnus-group-position-point))
6415 (defun gnus-group-list-zombies ()
6416 "List all zombie newsgroups in the group buffer."
6418 (if (not gnus-zombie-list)
6419 (gnus-message 6 "No zombie groups")
6420 (let (gnus-group-list-mode)
6421 (funcall gnus-group-prepare-function
6422 gnus-level-zombie t gnus-level-zombie))
6423 (goto-char (point-min)))
6424 (gnus-group-position-point))
6426 (defun gnus-group-list-active ()
6427 "List all groups that are available from the server(s)."
6429 ;; First we make sure that we have really read the active file.
6430 (unless (gnus-read-active-file-p)
6431 (let ((gnus-read-active-file t))
6432 (gnus-read-active-file)))
6433 ;; Find all groups and sort them.
6441 (setq list (cons (symbol-name sym) list))))
6445 (buffer-read-only nil))
6448 (gnus-group-insert-group-line-info (pop groups)))
6449 (goto-char (point-min))))
6451 (defun gnus-activate-all-groups (level)
6452 "Activate absolutely all groups."
6453 (interactive (list 7))
6454 (let ((gnus-activate-level level)
6455 (gnus-activate-foreign-newsgroups level))
6456 (gnus-group-get-new-news)))
6458 (defun gnus-group-get-new-news (&optional arg)
6459 "Get newly arrived articles.
6460 If ARG is a number, it specifies which levels you are interested in
6461 re-scanning. If ARG is non-nil and not a number, this will force
6462 \"hard\" re-reading of the active files from all servers."
6464 (run-hooks 'gnus-get-new-news-hook)
6465 ;; We might read in new NoCeM messages here.
6466 (when (and gnus-use-nocem
6468 (gnus-nocem-scan-groups))
6469 ;; If ARG is not a number, then we read the active file.
6470 (when (and arg (not (numberp arg)))
6471 (let ((gnus-read-active-file t))
6472 (gnus-read-active-file))
6475 (setq arg (gnus-group-default-level arg t))
6476 (if (and gnus-read-active-file (not arg))
6478 (gnus-read-active-file)
6479 (gnus-get-unread-articles arg))
6480 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6481 (gnus-get-unread-articles arg)))
6482 (run-hooks 'gnus-after-getting-new-news-hook)
6483 (gnus-group-list-groups))
6485 (defun gnus-group-get-new-news-this-group (&optional n)
6486 "Check for newly arrived news in the current group (and the N-1 next groups).
6487 The difference between N and the number of newsgroup checked is returned.
6488 If N is negative, this group and the N-1 previous groups will be checked."
6490 (let* ((groups (gnus-group-process-prefix n))
6491 (ret (if (numberp n) (- n (length groups)) 0))
6492 (beg (unless n (point)))
6494 (while (setq group (pop groups))
6495 (gnus-group-remove-mark group)
6496 (if (gnus-activate-group group 'scan)
6498 (gnus-get-unread-articles-in-group
6499 (gnus-get-info group) (gnus-active group) t)
6500 (unless (gnus-virtual-group-p group)
6501 (gnus-close-group group))
6502 (gnus-group-update-group group))
6503 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6504 (when beg (goto-char beg))
6505 (when gnus-goto-next-group-when-activating
6506 (gnus-group-next-unread-group 1 t))
6507 (gnus-summary-position-point)
6510 (defun gnus-group-fetch-faq (group &optional faq-dir)
6511 "Fetch the FAQ for the current group."
6514 (gnus-group-real-name (gnus-group-group-name))
6515 (cond (current-prefix-arg
6517 "Faq dir: " (and (listp gnus-group-faq-directory)
6518 (mapcar (lambda (file) (list file))
6519 gnus-group-faq-directory)))))))
6521 (setq faq-dir (if (listp gnus-group-faq-directory)
6522 (car gnus-group-faq-directory)
6523 gnus-group-faq-directory)))
6524 (or group (error "No group name given"))
6525 (let ((file (concat (file-name-as-directory faq-dir)
6526 (gnus-group-real-name group))))
6527 (if (not (file-exists-p file))
6528 (error "No such file: %s" file)
6531 (defun gnus-group-describe-group (force &optional group)
6532 "Display a description of the current newsgroup."
6533 (interactive (list current-prefix-arg (gnus-group-group-name)))
6534 (and force (setq gnus-description-hashtb nil))
6535 (let ((method (gnus-find-method-for-group group))
6537 (or group (error "No group name given"))
6538 (and (or (and gnus-description-hashtb
6539 ;; We check whether this group's method has been
6540 ;; queried for a description file.
6542 (gnus-group-prefixed-name "" method)
6543 gnus-description-hashtb))
6544 (setq desc (gnus-group-get-description group))
6545 (gnus-read-descriptions-file method))
6547 (or desc (gnus-gethash group gnus-description-hashtb)
6548 "No description available")))))
6550 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6551 (defun gnus-group-describe-all-groups (&optional force)
6552 "Pop up a buffer with descriptions of all newsgroups."
6554 (and force (setq gnus-description-hashtb nil))
6555 (if (not (or gnus-description-hashtb
6556 (gnus-read-all-descriptions-files)))
6557 (error "Couldn't request descriptions file"))
6558 (let ((buffer-read-only nil)
6564 (insert (format " *: %-20s %s\n" (symbol-name group)
6565 (symbol-value group)))
6566 (gnus-add-text-properties
6567 b (1+ b) (list 'gnus-group group
6568 'gnus-unread t 'gnus-marked nil
6569 'gnus-level (1+ gnus-level-subscribed))))
6570 gnus-description-hashtb)
6571 (goto-char (point-min))
6572 (gnus-group-position-point)))
6574 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6575 (defun gnus-group-apropos (regexp &optional search-description)
6576 "List all newsgroups that have names that match a regexp."
6577 (interactive "sGnus apropos (regexp): ")
6579 (obuf (current-buffer))
6581 ;; Go through all newsgroups that are known to Gnus.
6584 (and (symbol-name group)
6585 (string-match regexp (symbol-name group))
6586 (setq groups (cons (symbol-name group) groups))))
6588 ;; Also go through all descriptions that are known to Gnus.
6589 (when search-description
6592 (and (string-match regexp (symbol-value group))
6593 (gnus-active (symbol-name group))
6594 (setq groups (cons (symbol-name group) groups))))
6595 gnus-description-hashtb))
6597 (gnus-message 3 "No groups matched \"%s\"." regexp)
6598 ;; Print out all the groups.
6600 (pop-to-buffer "*Gnus Help*")
6601 (buffer-disable-undo (current-buffer))
6603 (setq groups (sort groups 'string<))
6605 ;; Groups may be entered twice into the list of groups.
6606 (if (not (string= (car groups) prev))
6608 (insert (setq prev (car groups)) "\n")
6609 (if (and gnus-description-hashtb
6610 (setq des (gnus-gethash (car groups)
6611 gnus-description-hashtb)))
6612 (insert " " des "\n"))))
6613 (setq groups (cdr groups)))
6614 (goto-char (point-min))))
6615 (pop-to-buffer obuf)))
6617 (defun gnus-group-description-apropos (regexp)
6618 "List all newsgroups that have names or descriptions that match a regexp."
6619 (interactive "sGnus description apropos (regexp): ")
6620 (if (not (or gnus-description-hashtb
6621 (gnus-read-all-descriptions-files)))
6622 (error "Couldn't request descriptions file"))
6623 (gnus-group-apropos regexp t))
6625 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6626 (defun gnus-group-list-matching (level regexp &optional all lowest)
6627 "List all groups with unread articles that match REGEXP.
6628 If the prefix LEVEL is non-nil, it should be a number that says which
6629 level to cut off listing groups.
6630 If ALL, also list groups with no unread articles.
6631 If LOWEST, don't list groups with level lower than LOWEST.
6633 This command may read the active file."
6634 (interactive "P\nsList newsgroups matching: ")
6635 ;; First make sure active file has been read.
6637 (> (prefix-numeric-value level) gnus-level-killed))
6638 (gnus-get-killed-groups))
6639 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6640 all (or lowest 1) regexp)
6641 (goto-char (point-min))
6642 (gnus-group-position-point))
6644 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6645 "List all groups that match REGEXP.
6646 If the prefix LEVEL is non-nil, it should be a number that says which
6647 level to cut off listing groups.
6648 If LOWEST, don't list groups with level lower than LOWEST."
6649 (interactive "P\nsList newsgroups matching: ")
6650 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6652 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6653 (defun gnus-group-save-newsrc (&optional force)
6654 "Save the Gnus startup files.
6655 If FORCE, force saving whether it is necessary or not."
6657 (gnus-save-newsrc-file force))
6659 (defun gnus-group-restart (&optional arg)
6660 "Force Gnus to read the .newsrc file."
6662 (when (gnus-yes-or-no-p
6663 (format "Are you sure you want to read %s? "
6664 gnus-current-startup-file))
6665 (gnus-save-newsrc-file)
6666 (gnus-setup-news 'force)
6667 (gnus-group-list-groups arg)))
6669 (defun gnus-group-read-init-file ()
6670 "Read the Gnus elisp init file."
6672 (gnus-read-init-file))
6674 (defun gnus-group-check-bogus-groups (&optional silent)
6675 "Check bogus newsgroups.
6676 If given a prefix, don't ask for confirmation before removing a bogus
6679 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6680 (gnus-group-list-groups))
6682 (defun gnus-group-edit-global-kill (&optional article group)
6683 "Edit the global kill file.
6684 If GROUP, edit that local kill file instead."
6686 (setq gnus-current-kill-article article)
6687 (gnus-kill-file-edit-file group)
6690 (substitute-command-keys
6691 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6692 (if group "local" "global")))))
6694 (defun gnus-group-edit-local-kill (article group)
6695 "Edit a local kill file."
6696 (interactive (list nil (gnus-group-group-name)))
6697 (gnus-group-edit-global-kill article group))
6699 (defun gnus-group-force-update ()
6700 "Update `.newsrc' file."
6702 (gnus-save-newsrc-file))
6704 (defun gnus-group-suspend ()
6705 "Suspend the current Gnus session.
6706 In fact, cleanup buffers except for group mode buffer.
6707 The hook gnus-suspend-gnus-hook is called before actually suspending."
6709 (run-hooks 'gnus-suspend-gnus-hook)
6710 ;; Kill Gnus buffers except for group mode buffer.
6711 (let ((group-buf (get-buffer gnus-group-buffer)))
6712 ;; Do this on a separate list in case the user does a ^G before we finish
6713 (let ((gnus-buffer-list
6714 (delq group-buf (delq gnus-dribble-buffer
6715 (append gnus-buffer-list nil)))))
6716 (while gnus-buffer-list
6717 (gnus-kill-buffer (car gnus-buffer-list))
6718 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6721 (setq gnus-buffer-list (list group-buf))
6722 (bury-buffer group-buf)
6723 (delete-windows-on group-buf t)))))
6725 (defun gnus-group-clear-dribble ()
6726 "Clear all information from the dribble buffer."
6728 (gnus-dribble-clear)
6729 (gnus-message 7 "Cleared dribble buffer"))
6731 (defun gnus-group-exit ()
6732 "Quit reading news after updating .newsrc.eld and .newsrc.
6733 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6736 (or noninteractive ;For gnus-batch-kill
6737 (not gnus-interactive-exit) ;Without confirmation
6739 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6740 (run-hooks 'gnus-exit-gnus-hook)
6741 ;; Offer to save data from non-quitted summary buffers.
6742 (gnus-offer-save-summaries)
6743 ;; Save the newsrc file(s).
6744 (gnus-save-newsrc-file)
6746 (gnus-close-backends)
6747 ;; Reset everything.
6749 ;; Allow the user to do things after cleaning up.
6750 (run-hooks 'gnus-after-exiting-gnus-hook)))
6752 (defun gnus-close-backends ()
6753 ;; Send a close request to all backends that support such a request.
6754 (let ((methods gnus-valid-select-methods)
6757 (if (fboundp (setq func (intern (concat (caar methods)
6758 "-request-close"))))
6760 (setq methods (cdr methods)))))
6762 (defun gnus-group-quit ()
6763 "Quit reading news without updating .newsrc.eld or .newsrc.
6764 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6766 (when (or noninteractive ;For gnus-batch-kill
6767 (zerop (buffer-size))
6768 (not (gnus-server-opened gnus-select-method))
6770 (not gnus-current-startup-file)
6772 (format "Quit reading news without saving %s? "
6773 (file-name-nondirectory gnus-current-startup-file))))
6774 (run-hooks 'gnus-exit-gnus-hook)
6775 (if gnus-use-full-window
6776 (delete-other-windows)
6777 (gnus-remove-some-windows))
6779 (gnus-close-backends)
6781 ;; Allow the user to do things after cleaning up.
6782 (run-hooks 'gnus-after-exiting-gnus-hook)))
6784 (defun gnus-offer-save-summaries ()
6785 "Offer to save all active summary buffers."
6787 (let ((buflist (buffer-list))
6789 ;; Go through all buffers and find all summaries.
6791 (and (setq bufname (buffer-name (car buflist)))
6792 (string-match "Summary" bufname)
6794 (set-buffer bufname)
6795 ;; We check that this is, indeed, a summary buffer.
6796 (and (eq major-mode 'gnus-summary-mode)
6797 ;; Also make sure this isn't bogus.
6798 gnus-newsgroup-prepared))
6799 (push bufname buffers))
6800 (setq buflist (cdr buflist)))
6801 ;; Go through all these summary buffers and offer to save them.
6804 "Update summary buffer %s? "
6805 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6808 (defun gnus-group-describe-briefly ()
6809 "Give a one line description of the group mode commands."
6811 (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")))
6813 (defun gnus-group-browse-foreign-server (method)
6814 "Browse a foreign news server.
6815 If called interactively, this function will ask for a select method
6816 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6817 If not, METHOD should be a list where the first element is the method
6818 and the second element is the address."
6820 (list (let ((how (completing-read
6822 (append gnus-valid-select-methods gnus-server-alist)
6823 nil t (cons "nntp" 0) 'gnus-method-history)))
6824 ;; We either got a backend name or a virtual server name.
6825 ;; If the first, we also need an address.
6826 (if (assoc how gnus-valid-select-methods)
6828 ;; Suggested by mapjph@bath.ac.uk.
6831 (mapcar (lambda (server) (list server))
6832 gnus-secondary-servers)))
6833 ;; We got a server name, so we find the method.
6834 (gnus-server-to-method how)))))
6835 (gnus-browse-foreign-server method))
6839 ;;; Gnus summary mode
6842 (defvar gnus-summary-mode-map nil)
6844 (put 'gnus-summary-mode 'mode-class 'special)
6846 (unless gnus-summary-mode-map
6847 (setq gnus-summary-mode-map (make-keymap))
6848 (suppress-keymap gnus-summary-mode-map)
6850 ;; Non-orthogonal keys
6852 (gnus-define-keys gnus-summary-mode-map
6853 " " gnus-summary-next-page
6854 "\177" gnus-summary-prev-page
6855 [delete] gnus-summary-prev-page
6856 "\r" gnus-summary-scroll-up
6857 "n" gnus-summary-next-unread-article
6858 "p" gnus-summary-prev-unread-article
6859 "N" gnus-summary-next-article
6860 "P" gnus-summary-prev-article
6861 "\M-\C-n" gnus-summary-next-same-subject
6862 "\M-\C-p" gnus-summary-prev-same-subject
6863 "\M-n" gnus-summary-next-unread-subject
6864 "\M-p" gnus-summary-prev-unread-subject
6865 "." gnus-summary-first-unread-article
6866 "," gnus-summary-best-unread-article
6867 "\M-s" gnus-summary-search-article-forward
6868 "\M-r" gnus-summary-search-article-backward
6869 "<" gnus-summary-beginning-of-article
6870 ">" gnus-summary-end-of-article
6871 "j" gnus-summary-goto-article
6872 "^" gnus-summary-refer-parent-article
6873 "\M-^" gnus-summary-refer-article
6874 "u" gnus-summary-tick-article-forward
6875 "!" gnus-summary-tick-article-forward
6876 "U" gnus-summary-tick-article-backward
6877 "d" gnus-summary-mark-as-read-forward
6878 "D" gnus-summary-mark-as-read-backward
6879 "E" gnus-summary-mark-as-expirable
6880 "\M-u" gnus-summary-clear-mark-forward
6881 "\M-U" gnus-summary-clear-mark-backward
6882 "k" gnus-summary-kill-same-subject-and-select
6883 "\C-k" gnus-summary-kill-same-subject
6884 "\M-\C-k" gnus-summary-kill-thread
6885 "\M-\C-l" gnus-summary-lower-thread
6886 "e" gnus-summary-edit-article
6887 "#" gnus-summary-mark-as-processable
6888 "\M-#" gnus-summary-unmark-as-processable
6889 "\M-\C-t" gnus-summary-toggle-threads
6890 "\M-\C-s" gnus-summary-show-thread
6891 "\M-\C-h" gnus-summary-hide-thread
6892 "\M-\C-f" gnus-summary-next-thread
6893 "\M-\C-b" gnus-summary-prev-thread
6894 "\M-\C-u" gnus-summary-up-thread
6895 "\M-\C-d" gnus-summary-down-thread
6896 "&" gnus-summary-execute-command
6897 "c" gnus-summary-catchup-and-exit
6898 "\C-w" gnus-summary-mark-region-as-read
6899 "\C-t" gnus-summary-toggle-truncation
6900 "?" gnus-summary-mark-as-dormant
6901 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6902 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6903 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6904 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6905 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6906 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6907 "=" gnus-summary-expand-window
6908 "\C-x\C-s" gnus-summary-reselect-current-group
6909 "\M-g" gnus-summary-rescan-group
6910 "w" gnus-summary-stop-page-breaking
6911 "\C-c\C-r" gnus-summary-caesar-message
6912 "\M-t" gnus-summary-toggle-mime
6913 "f" gnus-summary-followup
6914 "F" gnus-summary-followup-with-original
6915 "C" gnus-summary-cancel-article
6916 "r" gnus-summary-reply
6917 "R" gnus-summary-reply-with-original
6918 "\C-c\C-f" gnus-summary-mail-forward
6919 "o" gnus-summary-save-article
6920 "\C-o" gnus-summary-save-article-mail
6921 "|" gnus-summary-pipe-output
6922 "\M-k" gnus-summary-edit-local-kill
6923 "\M-K" gnus-summary-edit-global-kill
6925 "\C-c\C-d" gnus-summary-describe-group
6926 "q" gnus-summary-exit
6927 "Q" gnus-summary-exit-no-update
6928 "\C-c\C-i" gnus-info-find-node
6929 gnus-mouse-2 gnus-mouse-pick-article
6930 "m" gnus-summary-mail-other-window
6931 "a" gnus-summary-post-news
6932 "x" gnus-summary-limit-to-unread
6933 "s" gnus-summary-isearch-article
6934 "t" gnus-article-hide-headers
6935 "g" gnus-summary-show-article
6936 "l" gnus-summary-goto-last-article
6937 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6938 "\C-d" gnus-summary-enter-digest-group
6940 "*" gnus-cache-enter-article
6941 "\M-*" gnus-cache-remove-article
6942 "\M-&" gnus-summary-universal-argument
6943 "\C-l" gnus-recenter
6944 "I" gnus-summary-increase-score
6945 "L" gnus-summary-lower-score
6947 "V" gnus-summary-score-map
6948 "X" gnus-uu-extract-map
6949 "S" gnus-summary-send-map)
6951 ;; Sort of orthogonal keymap
6952 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6953 "t" gnus-summary-tick-article-forward
6954 "!" gnus-summary-tick-article-forward
6955 "d" gnus-summary-mark-as-read-forward
6956 "r" gnus-summary-mark-as-read-forward
6957 "c" gnus-summary-clear-mark-forward
6958 " " gnus-summary-clear-mark-forward
6959 "e" gnus-summary-mark-as-expirable
6960 "x" gnus-summary-mark-as-expirable
6961 "?" gnus-summary-mark-as-dormant
6962 "b" gnus-summary-set-bookmark
6963 "B" gnus-summary-remove-bookmark
6964 "#" gnus-summary-mark-as-processable
6965 "\M-#" gnus-summary-unmark-as-processable
6966 "S" gnus-summary-limit-include-expunged
6967 "C" gnus-summary-catchup
6968 "H" gnus-summary-catchup-to-here
6969 "\C-c" gnus-summary-catchup-all
6970 "k" gnus-summary-kill-same-subject-and-select
6971 "K" gnus-summary-kill-same-subject
6972 "P" gnus-uu-mark-map)
6974 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6975 "c" gnus-summary-clear-above
6976 "u" gnus-summary-tick-above
6977 "m" gnus-summary-mark-above
6978 "k" gnus-summary-kill-below)
6980 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6981 "/" gnus-summary-limit-to-subject
6982 "n" gnus-summary-limit-to-articles
6983 "w" gnus-summary-pop-limit
6984 "s" gnus-summary-limit-to-subject
6985 "a" gnus-summary-limit-to-author
6986 "u" gnus-summary-limit-to-unread
6987 "m" gnus-summary-limit-to-marks
6988 "v" gnus-summary-limit-to-score
6989 "D" gnus-summary-limit-include-dormant
6990 "d" gnus-summary-limit-exclude-dormant
6991 ;; "t" gnus-summary-limit-exclude-thread
6992 "E" gnus-summary-limit-include-expunged
6993 "c" gnus-summary-limit-exclude-childless-dormant
6994 "C" gnus-summary-limit-mark-excluded-as-read)
6996 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6997 "n" gnus-summary-next-unread-article
6998 "p" gnus-summary-prev-unread-article
6999 "N" gnus-summary-next-article
7000 "P" gnus-summary-prev-article
7001 "\C-n" gnus-summary-next-same-subject
7002 "\C-p" gnus-summary-prev-same-subject
7003 "\M-n" gnus-summary-next-unread-subject
7004 "\M-p" gnus-summary-prev-unread-subject
7005 "f" gnus-summary-first-unread-article
7006 "b" gnus-summary-best-unread-article
7007 "j" gnus-summary-goto-article
7008 "g" gnus-summary-goto-subject
7009 "l" gnus-summary-goto-last-article
7010 "p" gnus-summary-pop-article)
7012 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7013 "k" gnus-summary-kill-thread
7014 "l" gnus-summary-lower-thread
7015 "i" gnus-summary-raise-thread
7016 "T" gnus-summary-toggle-threads
7017 "t" gnus-summary-rethread-current
7018 "^" gnus-summary-reparent-thread
7019 "s" gnus-summary-show-thread
7020 "S" gnus-summary-show-all-threads
7021 "h" gnus-summary-hide-thread
7022 "H" gnus-summary-hide-all-threads
7023 "n" gnus-summary-next-thread
7024 "p" gnus-summary-prev-thread
7025 "u" gnus-summary-up-thread
7026 "o" gnus-summary-top-thread
7027 "d" gnus-summary-down-thread
7028 "#" gnus-uu-mark-thread
7029 "\M-#" gnus-uu-unmark-thread)
7031 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7032 "c" gnus-summary-catchup-and-exit
7033 "C" gnus-summary-catchup-all-and-exit
7034 "E" gnus-summary-exit-no-update
7035 "Q" gnus-summary-exit
7036 "Z" gnus-summary-exit
7037 "n" gnus-summary-catchup-and-goto-next-group
7038 "R" gnus-summary-reselect-current-group
7039 "G" gnus-summary-rescan-group
7040 "N" gnus-summary-next-group
7041 "P" gnus-summary-prev-group)
7043 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7044 " " gnus-summary-next-page
7045 "n" gnus-summary-next-page
7046 "\177" gnus-summary-prev-page
7047 [delete] gnus-summary-prev-page
7048 "p" gnus-summary-prev-page
7049 "\r" gnus-summary-scroll-up
7050 "<" gnus-summary-beginning-of-article
7051 ">" gnus-summary-end-of-article
7052 "b" gnus-summary-beginning-of-article
7053 "e" gnus-summary-end-of-article
7054 "^" gnus-summary-refer-parent-article
7055 "r" gnus-summary-refer-parent-article
7056 "R" gnus-summary-refer-references
7057 "g" gnus-summary-show-article
7058 "s" gnus-summary-isearch-article)
7060 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7061 "b" gnus-article-add-buttons
7062 "B" gnus-article-add-buttons-to-head
7063 "o" gnus-article-treat-overstrike
7064 ;; "w" gnus-article-word-wrap
7065 "w" gnus-article-fill-cited-article
7066 "c" gnus-article-remove-cr
7067 "L" gnus-article-remove-trailing-blank-lines
7068 "q" gnus-article-de-quoted-unreadable
7069 "f" gnus-article-display-x-face
7070 "l" gnus-summary-stop-page-breaking
7071 "r" gnus-summary-caesar-message
7072 "t" gnus-article-hide-headers
7073 "v" gnus-summary-verbose-headers
7074 "m" gnus-summary-toggle-mime)
7076 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7077 "a" gnus-article-hide
7078 "h" gnus-article-hide-headers
7079 "b" gnus-article-hide-boring-headers
7080 "s" gnus-article-hide-signature
7081 "c" gnus-article-hide-citation
7082 "p" gnus-article-hide-pgp
7083 "\C-c" gnus-article-hide-citation-maybe)
7085 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7086 "a" gnus-article-highlight
7087 "h" gnus-article-highlight-headers
7088 "c" gnus-article-highlight-citation
7089 "s" gnus-article-highlight-signature)
7091 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7092 "z" gnus-article-date-ut
7093 "u" gnus-article-date-ut
7094 "l" gnus-article-date-local
7095 "e" gnus-article-date-lapsed
7096 "o" gnus-article-date-original)
7098 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7100 "f" gnus-summary-fetch-faq
7101 "d" gnus-summary-describe-group
7102 "h" gnus-summary-describe-briefly
7103 "i" gnus-info-find-node)
7105 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7106 "e" gnus-summary-expire-articles
7107 "\M-\C-e" gnus-summary-expire-articles-now
7108 "\177" gnus-summary-delete-article
7109 [delete] gnus-summary-delete-article
7110 "m" gnus-summary-move-article
7111 "r" gnus-summary-respool-article
7112 "w" gnus-summary-edit-article
7113 "c" gnus-summary-copy-article
7114 "B" gnus-summary-crosspost-article
7115 "q" gnus-summary-respool-query
7116 "i" gnus-summary-import-article)
7118 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7119 "o" gnus-summary-save-article
7120 "m" gnus-summary-save-article-mail
7121 "r" gnus-summary-save-article-rmail
7122 "f" gnus-summary-save-article-file
7123 "b" gnus-summary-save-article-body-file
7124 "h" gnus-summary-save-article-folder
7125 "v" gnus-summary-save-article-vm
7126 "p" gnus-summary-pipe-output
7127 "s" gnus-soup-add-article)
7132 (defun gnus-summary-mode (&optional group)
7133 "Major mode for reading articles.
7135 All normal editing commands are switched off.
7136 \\<gnus-summary-mode-map>
7137 Each line in this buffer represents one article. To read an
7138 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7139 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7142 You can also post articles and send mail from this buffer. To
7143 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7144 of an article, type `\\[gnus-summary-reply]'.
7146 There are approx. one gazillion commands you can execute in this
7147 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7149 The following commands are available:
7151 \\{gnus-summary-mode-map}"
7153 (when (and menu-bar-mode
7154 (gnus-visual-p 'summary-menu 'menu))
7155 (gnus-summary-make-menu-bar))
7156 (kill-all-local-variables)
7157 (gnus-summary-make-local-variables)
7158 (gnus-make-thread-indent-array)
7159 (gnus-simplify-mode-line)
7160 (setq major-mode 'gnus-summary-mode)
7161 (setq mode-name "Summary")
7162 (make-local-variable 'minor-mode-alist)
7163 (use-local-map gnus-summary-mode-map)
7164 (buffer-disable-undo (current-buffer))
7165 (setq buffer-read-only t) ;Disable modification
7166 (setq truncate-lines t)
7167 (setq selective-display t)
7168 (setq selective-display-ellipses t) ;Display `...'
7169 (setq buffer-display-table gnus-summary-display-table)
7170 (setq gnus-newsgroup-name group)
7171 (make-local-variable 'gnus-summary-line-format)
7172 (make-local-variable 'gnus-summary-line-format-spec)
7173 (make-local-variable 'gnus-summary-mark-positions)
7174 (run-hooks 'gnus-summary-mode-hook))
7176 (defun gnus-summary-make-local-variables ()
7177 "Make all the local summary buffer variables."
7178 (let ((locals gnus-summary-local-variables)
7180 (while (setq local (pop locals))
7183 (if (eq (cdr local) 'global)
7184 ;; Copy the global value of the variable.
7185 (setq global (symbol-value (car local)))
7186 ;; Use the value from the list.
7187 (setq global (eval (cdr local))))
7188 (make-local-variable (car local))
7189 (set (car local) global))
7190 ;; Simple nil-valued local variable.
7191 (make-local-variable local)
7194 (defun gnus-summary-make-display-table ()
7195 ;; Change the display table. Odd characters have a tendency to mess
7196 ;; up nicely formatted displays - we make all possible glyphs
7197 ;; display only a single character.
7199 ;; We start from the standard display table, if any.
7200 (setq gnus-summary-display-table
7201 (or (copy-sequence standard-display-table)
7202 (make-display-table)))
7203 ;; Nix out all the control chars...
7205 (while (>= (setq i (1- i)) 0)
7206 (aset gnus-summary-display-table i [??])))
7207 ;; ... but not newline and cr, of course. (cr is necessary for the
7208 ;; selective display).
7209 (aset gnus-summary-display-table ?\n nil)
7210 (aset gnus-summary-display-table ?\r nil)
7211 ;; We nix out any glyphs over 126 that are not set already.
7213 (while (>= (setq i (1- i)) 127)
7214 ;; Only modify if the entry is nil.
7215 (or (aref gnus-summary-display-table i)
7216 (aset gnus-summary-display-table i [??])))))
7218 (defun gnus-summary-clear-local-variables ()
7219 (let ((locals gnus-summary-local-variables))
7221 (if (consp (car locals))
7222 (and (vectorp (caar locals))
7223 (set (caar locals) nil))
7224 (and (vectorp (car locals))
7225 (set (car locals) nil)))
7226 (setq locals (cdr locals)))))
7228 ;; Summary data functions.
7230 (defmacro gnus-data-number (data)
7233 (defmacro gnus-data-set-number (data number)
7234 `(setcar ,data ,number))
7236 (defmacro gnus-data-mark (data)
7239 (defmacro gnus-data-set-mark (data mark)
7240 `(setcar (nthcdr 1 ,data) ,mark))
7242 (defmacro gnus-data-pos (data)
7245 (defmacro gnus-data-set-pos (data pos)
7246 `(setcar (nthcdr 2 ,data) ,pos))
7248 (defmacro gnus-data-header (data)
7251 (defmacro gnus-data-level (data)
7254 (defmacro gnus-data-unread-p (data)
7255 `(= (nth 1 ,data) gnus-unread-mark))
7257 (defmacro gnus-data-pseudo-p (data)
7258 `(consp (nth 3 ,data)))
7260 (defmacro gnus-data-find (number)
7261 `(assq ,number gnus-newsgroup-data))
7263 (defmacro gnus-data-find-list (number &optional data)
7264 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7265 (memq (assq ,number bdata)
7268 (defmacro gnus-data-make (number mark pos header level)
7269 `(list ,number ,mark ,pos ,header ,level))
7271 (defun gnus-data-enter (after-article number mark pos header level offset)
7272 (let ((data (gnus-data-find-list after-article)))
7273 (or data (error "No such article: %d" after-article))
7274 (setcdr data (cons (gnus-data-make number mark pos header level)
7276 (setq gnus-newsgroup-data-reverse nil)
7277 (gnus-data-update-list (cddr data) offset)))
7279 (defun gnus-data-enter-list (after-article list &optional offset)
7281 (let ((data (and after-article (gnus-data-find-list after-article)))
7283 (or data (not after-article) (error "No such article: %d" after-article))
7284 ;; Find the last element in the list to be spliced into the main
7287 (setq list (cdr list)))
7290 (setcdr list gnus-newsgroup-data)
7291 (setq gnus-newsgroup-data ilist)
7292 (and offset (gnus-data-update-list (cdr list) offset)))
7293 (setcdr list (cdr data))
7295 (and offset (gnus-data-update-list (cdr data) offset)))
7296 (setq gnus-newsgroup-data-reverse nil))))
7298 (defun gnus-data-remove (article &optional offset)
7299 (let ((data gnus-newsgroup-data))
7300 (if (= (gnus-data-number (car data)) article)
7301 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7302 gnus-newsgroup-data-reverse nil)
7304 (and (= (gnus-data-number (cadr data)) article)
7306 (setcdr data (cddr data))
7307 (and offset (gnus-data-update-list (cdr data) offset))
7309 gnus-newsgroup-data-reverse nil)))
7310 (setq data (cdr data))))))
7312 (defmacro gnus-data-list (backward)
7314 (or gnus-newsgroup-data-reverse
7315 (setq gnus-newsgroup-data-reverse
7316 (reverse gnus-newsgroup-data)))
7317 gnus-newsgroup-data))
7319 (defun gnus-data-update-list (data offset)
7320 "Add OFFSET to the POS of all data entries in DATA."
7322 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7323 (setq data (cdr data))))
7325 (defun gnus-data-compute-positions ()
7326 "Compute the positions of all articles."
7327 (let ((data gnus-newsgroup-data)
7330 (when (setq pos (text-property-any
7331 (point-min) (point-max)
7332 'gnus-number (gnus-data-number (car data))))
7333 (gnus-data-set-pos (car data) (+ pos 3)))
7334 (setq data (cdr data)))))
7336 (defun gnus-summary-article-pseudo-p (article)
7337 "Say whether this article is a pseudo article or not."
7338 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7340 (defun gnus-article-parent-p (number)
7341 "Say whether this article is a parent or not."
7342 (let ((data (gnus-data-find-list number)))
7343 (and (cdr data) ; There has to be an article after...
7344 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7345 (gnus-data-level (nth 1 data))))))
7347 (defun gnus-article-children (number)
7348 "Return a list of all children to NUMBER."
7349 (let* ((data (gnus-data-find-list number))
7350 (level (gnus-data-level (car data)))
7352 (setq data (cdr data))
7354 (= (gnus-data-level (car data)) (1+ level)))
7355 (push (gnus-data-number (car data)) children)
7356 (setq data (cdr data)))
7359 (defmacro gnus-summary-skip-intangible ()
7360 "If the current article is intangible, then jump to a different article."
7361 '(let ((to (get-text-property (point) 'gnus-intangible)))
7362 (and to (gnus-summary-goto-subject to))))
7364 (defmacro gnus-summary-article-intangible-p ()
7365 "Say whether this article is intangible or not."
7366 '(get-text-property (point) 'gnus-intangible))
7368 ;; Some summary mode macros.
7370 (defmacro gnus-summary-article-number ()
7371 "The article number of the article on the current line.
7372 If there isn's an article number here, then we return the current
7375 (gnus-summary-skip-intangible)
7376 (or (get-text-property (point) 'gnus-number)
7377 (gnus-summary-last-subject))))
7379 (defmacro gnus-summary-article-header (&optional number)
7380 `(gnus-data-header (gnus-data-find
7381 ,(or number '(gnus-summary-article-number)))))
7383 (defmacro gnus-summary-thread-level (&optional number)
7384 `(if (and (eq gnus-summary-make-false-root 'dummy)
7385 (get-text-property (point) 'gnus-intangible))
7387 (gnus-data-level (gnus-data-find
7388 ,(or number '(gnus-summary-article-number))))))
7390 (defmacro gnus-summary-article-mark (&optional number)
7391 `(gnus-data-mark (gnus-data-find
7392 ,(or number '(gnus-summary-article-number)))))
7394 (defmacro gnus-summary-article-pos (&optional number)
7395 `(gnus-data-pos (gnus-data-find
7396 ,(or number '(gnus-summary-article-number)))))
7398 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7399 (defmacro gnus-summary-article-subject (&optional number)
7400 "Return current subject string or nil if nothing."
7403 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7404 '(gnus-data-header (assq (gnus-summary-article-number)
7405 gnus-newsgroup-data)))))
7408 (mail-header-subject headers))))
7410 (defmacro gnus-summary-article-score (&optional number)
7411 "Return current article score."
7412 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7413 gnus-newsgroup-scored))
7414 gnus-summary-default-score 0))
7416 (defun gnus-summary-article-children (&optional number)
7417 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7418 (level (gnus-data-level (car data)))
7420 (while (and (setq data (cdr data))
7421 (> (setq l (gnus-data-level (car data))) level))
7422 (and (= (1+ level) l)
7423 (setq children (cons (gnus-data-number (car data))
7425 (nreverse children)))
7427 (defun gnus-summary-article-parent (&optional number)
7428 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7429 (gnus-data-list t)))
7430 (level (gnus-data-level (car data))))
7432 () ; This is a root.
7433 ;; We search until we find an article with a level less than
7434 ;; this one. That function has to be the parent.
7435 (while (and (setq data (cdr data))
7436 (not (< (gnus-data-level (car data)) level))))
7437 (and data (gnus-data-number (car data))))))
7439 (defun gnus-unread-mark-p (mark)
7440 "Say whether MARK is the unread mark."
7441 (= mark gnus-unread-mark))
7443 (defun gnus-read-mark-p (mark)
7444 "Say whether MARK is one of the marks that mark as read.
7445 This is all marks except unread, ticked, dormant, and expirable."
7446 (not (or (= mark gnus-unread-mark)
7447 (= mark gnus-ticked-mark)
7448 (= mark gnus-dormant-mark)
7449 (= mark gnus-expirable-mark))))
7451 ;; Saving hidden threads.
7453 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7454 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7455 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7457 (defmacro gnus-save-hidden-threads (&rest forms)
7458 "Save hidden threads, eval FORMS, and restore the hidden threads."
7459 (let ((config (make-symbol "config")))
7460 `(let ((,config (gnus-hidden-threads-configuration)))
7464 (gnus-restore-hidden-threads-configuration ,config)))))
7466 (defun gnus-hidden-threads-configuration ()
7467 "Return the current hidden threads configuration."
7470 (goto-char (point-min))
7471 (while (search-forward "\r" nil t)
7472 (push (1- (point)) config))
7475 (defun gnus-restore-hidden-threads-configuration (config)
7476 "Restore hidden threads configuration from CONFIG."
7477 (let (point buffer-read-only)
7478 (while (setq point (pop config))
7479 (when (and (< point (point-max))
7481 (= (following-char) ?\n))
7482 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7484 ;; Various summary mode internalish functions.
7486 (defun gnus-mouse-pick-article (e)
7489 (gnus-summary-next-page nil t))
7491 (defun gnus-summary-setup-buffer (group)
7492 "Initialize summary buffer."
7493 (let ((buffer (concat "*Summary " group "*")))
7494 (if (get-buffer buffer)
7497 (setq gnus-summary-buffer (current-buffer))
7498 (not gnus-newsgroup-prepared))
7499 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7500 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7501 (gnus-add-current-to-buffer-list)
7502 (gnus-summary-mode group)
7504 (gnus-carpal-setup-buffer 'summary))
7505 (unless gnus-single-article-buffer
7506 (make-local-variable 'gnus-article-buffer)
7507 (make-local-variable 'gnus-article-current)
7508 (make-local-variable 'gnus-original-article-buffer))
7509 (setq gnus-newsgroup-name group)
7512 (defun gnus-set-global-variables ()
7513 ;; Set the global equivalents of the summary buffer-local variables
7514 ;; to the latest values they had. These reflect the summary buffer
7515 ;; that was in action when the last article was fetched.
7516 (when (eq major-mode 'gnus-summary-mode)
7517 (setq gnus-summary-buffer (current-buffer))
7518 (let ((name gnus-newsgroup-name)
7519 (marked gnus-newsgroup-marked)
7520 (unread gnus-newsgroup-unreads)
7521 (headers gnus-current-headers)
7522 (data gnus-newsgroup-data)
7523 (summary gnus-summary-buffer)
7524 (article-buffer gnus-article-buffer)
7525 (original gnus-original-article-buffer)
7526 (gac gnus-article-current)
7527 (score-file gnus-current-score-file))
7529 (set-buffer gnus-group-buffer)
7530 (setq gnus-newsgroup-name name)
7531 (setq gnus-newsgroup-marked marked)
7532 (setq gnus-newsgroup-unreads unread)
7533 (setq gnus-current-headers headers)
7534 (setq gnus-newsgroup-data data)
7535 (setq gnus-article-current gac)
7536 (setq gnus-summary-buffer summary)
7537 (setq gnus-article-buffer article-buffer)
7538 (setq gnus-original-article-buffer original)
7539 (setq gnus-current-score-file score-file)))))
7541 (defun gnus-summary-last-article-p (&optional article)
7542 "Return whether ARTICLE is the last article in the buffer."
7543 (if (not (setq article (or article (gnus-summary-article-number))))
7544 t ; All non-existant numbers are the last article. :-)
7545 (not (cdr (gnus-data-find-list article)))))
7547 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7548 "Insert a dummy root in the summary buffer."
7550 (gnus-add-text-properties
7551 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7552 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7554 (defun gnus-make-thread-indent-array ()
7556 (unless (and gnus-thread-indent-array
7557 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7558 (setq gnus-thread-indent-array (make-vector 201 "")
7559 gnus-thread-indent-array-level gnus-thread-indent-level)
7561 (aset gnus-thread-indent-array n
7562 (make-string (* n gnus-thread-indent-level) ? ))
7565 (defun gnus-summary-insert-line
7566 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7567 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7568 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7569 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7570 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7571 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7572 (gnus-tmp-score-char
7573 (if (or (null gnus-summary-default-score)
7574 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7575 gnus-summary-zcore-fuzz)) ?
7576 (if (< gnus-tmp-score gnus-summary-default-score)
7577 gnus-score-below-mark gnus-score-over-mark)))
7578 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7579 ((memq gnus-tmp-current gnus-newsgroup-cached)
7581 (gnus-tmp-replied gnus-replied-mark)
7582 ((memq gnus-tmp-current gnus-newsgroup-saved)
7584 (t gnus-unread-mark)))
7585 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7588 ((string-match "(.+)" gnus-tmp-from)
7589 (substring gnus-tmp-from
7590 (1+ (match-beginning 0)) (1- (match-end 0))))
7591 ((string-match "<[^>]+> *$" gnus-tmp-from)
7592 (let ((beg (match-beginning 0)))
7593 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7594 (substring gnus-tmp-from (1+ (match-beginning 0))
7595 (1- (match-end 0))))
7596 (substring gnus-tmp-from 0 beg))))
7598 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7599 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7600 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7601 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7602 (buffer-read-only nil))
7603 (when (string= gnus-tmp-name "")
7604 (setq gnus-tmp-name gnus-tmp-from))
7605 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7606 (gnus-put-text-property
7608 (progn (eval gnus-summary-line-format-spec) (point))
7609 'gnus-number gnus-tmp-number)
7610 (when (gnus-visual-p 'summary-highlight 'highlight)
7612 (run-hooks 'gnus-summary-update-hook)
7615 (defun gnus-summary-update-line (&optional dont-update)
7616 ;; Update summary line after change.
7617 (when (and gnus-summary-default-score
7618 (not gnus-summary-inhibit-highlight))
7619 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7620 (article (gnus-summary-article-number))
7621 (score (gnus-summary-article-score article)))
7623 (if (and gnus-summary-mark-below
7624 (< (gnus-summary-article-score)
7625 gnus-summary-mark-below))
7626 ;; This article has a low score, so we mark it as read.
7627 (when (memq article gnus-newsgroup-unreads)
7628 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7629 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7630 ;; This article was previously marked as read on account
7631 ;; of a low score, but now it has risen, so we mark it as
7633 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7634 (gnus-summary-update-mark
7635 (if (or (null gnus-summary-default-score)
7636 (<= (abs (- score gnus-summary-default-score))
7637 gnus-summary-zcore-fuzz)) ?
7638 (if (< score gnus-summary-default-score)
7639 gnus-score-below-mark gnus-score-over-mark)) 'score))
7640 ;; Do visual highlighting.
7641 (when (gnus-visual-p 'summary-highlight 'highlight)
7642 (run-hooks 'gnus-summary-update-hook)))))
7644 (defvar gnus-tmp-new-adopts nil)
7646 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7647 ;; Sum up all elements (and sub-elements) in a list.
7649 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7651 ((and (consp thread) (cdr thread))
7654 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7657 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7660 (when (and level (zerop level) gnus-tmp-new-adopts)
7663 'gnus-summary-number-of-articles-in-thread
7664 gnus-tmp-new-adopts))))
7666 (if (> number 1) gnus-not-empty-thread-mark
7667 gnus-empty-thread-mark)
7670 (defun gnus-summary-set-local-parameters (group)
7671 "Go through the local params of GROUP and set all variable specs in that list."
7672 (let ((params (gnus-info-params (gnus-get-info group)))
7675 (setq elem (car params)
7676 params (cdr params))
7677 (and (consp elem) ; Has to be a cons.
7678 (consp (cdr elem)) ; The cdr has to be a list.
7679 (symbolp (car elem)) ; Has to be a symbol in there.
7680 (not (memq (car elem)
7681 '(quit-config to-address to-list to-group)))
7682 (progn ; So we set it.
7683 (make-local-variable (car elem))
7684 (set (car elem) (eval (nth 1 elem))))))))
7686 (defun gnus-summary-read-group (group &optional show-all no-article
7687 kill-buffer no-display)
7688 "Start reading news in newsgroup GROUP.
7689 If SHOW-ALL is non-nil, already read articles are also listed.
7690 If NO-ARTICLE is non-nil, no article is selected initially.
7691 If NO-DISPLAY, don't generate a summary buffer."
7692 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7693 (let* ((new-group (gnus-summary-setup-buffer group))
7694 (quit-config (gnus-group-quit-config group))
7695 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7697 ;; This summary buffer exists already, so we just select it.
7699 (gnus-set-global-variables)
7701 (gnus-kill-or-deaden-summary kill-buffer))
7702 (gnus-configure-windows 'summary 'force)
7703 (gnus-set-mode-line 'summary)
7704 (gnus-summary-position-point)
7707 ;; We couldn't select this group.
7709 (when (and (eq major-mode 'gnus-summary-mode)
7710 (not (equal (current-buffer) kill-buffer)))
7711 (kill-buffer (current-buffer))
7712 (if (not quit-config)
7714 (set-buffer gnus-group-buffer)
7715 (gnus-group-jump-to-group group)
7716 (gnus-group-next-unread-group 1))
7717 (if (not (buffer-name (car quit-config)))
7718 (gnus-configure-windows 'group 'force)
7719 (set-buffer (car quit-config))
7720 (and (eq major-mode 'gnus-summary-mode)
7721 (gnus-set-global-variables))
7722 (gnus-configure-windows (cdr quit-config)))))
7723 (gnus-message 3 "Can't select group")
7725 ;; The user did a `C-g' while prompting for number of articles,
7726 ;; so we exit this group.
7727 ((eq did-select 'quit)
7728 (and (eq major-mode 'gnus-summary-mode)
7729 (not (equal (current-buffer) kill-buffer))
7730 (kill-buffer (current-buffer)))
7732 (gnus-kill-or-deaden-summary kill-buffer))
7733 (if (not quit-config)
7735 (set-buffer gnus-group-buffer)
7736 (gnus-group-jump-to-group group)
7737 (gnus-group-next-unread-group 1)
7738 (gnus-configure-windows 'group 'force))
7739 (if (not (buffer-name (car quit-config)))
7740 (gnus-configure-windows 'group 'force)
7741 (set-buffer (car quit-config))
7742 (and (eq major-mode 'gnus-summary-mode)
7743 (gnus-set-global-variables))
7744 (gnus-configure-windows (cdr quit-config))))
7745 ;; Finally signal the quit.
7747 ;; The group was successfully selected.
7749 (gnus-set-global-variables)
7750 ;; Save the active value in effect when the group was entered.
7751 (setq gnus-newsgroup-active
7753 (gnus-active gnus-newsgroup-name)))
7754 ;; You can change the summary buffer in some way with this hook.
7755 (run-hooks 'gnus-select-group-hook)
7756 ;; Set any local variables in the group parameters.
7757 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7758 (gnus-update-format-specifications)
7759 ;; Do score processing.
7760 (when gnus-use-scoring
7761 (gnus-possibly-score-headers))
7762 ;; Check whether to fill in the gaps in the threads.
7763 (when gnus-build-sparse-threads
7764 (gnus-build-sparse-threads))
7765 ;; Find the initial limit.
7766 (if gnus-show-threads
7768 (let ((gnus-newsgroup-dormant nil))
7769 (gnus-summary-initial-limit show-all))
7770 (gnus-summary-initial-limit show-all))
7771 (setq gnus-newsgroup-limit
7773 (lambda (header) (mail-header-number header))
7774 gnus-newsgroup-headers)))
7775 ;; Generate the summary buffer.
7777 (gnus-summary-prepare))
7778 (when gnus-use-trees
7779 (gnus-tree-open group)
7780 (setq gnus-summary-highlight-line-function
7781 'gnus-tree-highlight-article))
7782 ;; If the summary buffer is empty, but there are some low-scored
7783 ;; articles or some excluded dormants, we include these in the
7785 (when (and (zerop (buffer-size))
7787 (cond (gnus-newsgroup-dormant
7788 (gnus-summary-limit-include-dormant))
7789 ((and gnus-newsgroup-scored show-all)
7790 (gnus-summary-limit-include-expunged))))
7791 ;; Function `gnus-apply-kill-file' must be called in this hook.
7792 (run-hooks 'gnus-apply-kill-hook)
7793 (if (and (zerop (buffer-size))
7796 ;; This newsgroup is empty.
7797 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7798 (gnus-message 6 "No unread news")
7800 (gnus-kill-or-deaden-summary kill-buffer))
7801 ;; Return nil from this function.
7803 ;; Hide conversation thread subtrees. We cannot do this in
7804 ;; gnus-summary-prepare-hook since kill processing may not
7805 ;; work with hidden articles.
7806 (and gnus-show-threads
7807 gnus-thread-hide-subtree
7808 (gnus-summary-hide-all-threads))
7809 ;; Show first unread article if requested.
7810 (if (and (not no-article)
7812 gnus-newsgroup-unreads
7813 gnus-auto-select-first)
7814 (unless (if (eq gnus-auto-select-first 'best)
7815 (gnus-summary-best-unread-article)
7816 (gnus-summary-first-unread-article))
7817 (gnus-configure-windows 'summary))
7818 ;; Don't select any articles, just move point to the first
7819 ;; article in the group.
7820 (goto-char (point-min))
7821 (gnus-summary-position-point)
7822 (gnus-set-mode-line 'summary)
7823 (gnus-configure-windows 'summary 'force))
7824 ;; If we are in async mode, we send some info to the backend.
7825 (when gnus-newsgroup-async
7826 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7828 (gnus-kill-or-deaden-summary kill-buffer))
7829 (when (get-buffer-window gnus-group-buffer t)
7830 ;; Gotta use windows, because recenter does wierd stuff if
7831 ;; the current buffer ain't the displayed window.
7832 (let ((owin (selected-window)))
7833 (select-window (get-buffer-window gnus-group-buffer t))
7834 (when (gnus-group-goto-group group)
7836 (select-window owin))))
7837 ;; Mark this buffer as "prepared".
7838 (setq gnus-newsgroup-prepared t)
7841 (defun gnus-summary-prepare ()
7842 "Generate the summary buffer."
7843 (let ((buffer-read-only nil))
7845 (setq gnus-newsgroup-data nil
7846 gnus-newsgroup-data-reverse nil)
7847 (run-hooks 'gnus-summary-generate-hook)
7848 ;; Generate the buffer, either with threads or without.
7849 (when gnus-newsgroup-headers
7850 (gnus-summary-prepare-threads
7851 (if gnus-show-threads
7852 (gnus-sort-gathered-threads
7853 (funcall gnus-summary-thread-gathering-function
7855 (gnus-cut-threads (gnus-make-threads)))))
7856 ;; Unthreaded display.
7857 (gnus-sort-articles gnus-newsgroup-headers))))
7858 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7859 ;; Call hooks for modifying summary buffer.
7860 (goto-char (point-min))
7861 (run-hooks 'gnus-summary-prepare-hook)))
7863 (defun gnus-gather-threads-by-subject (threads)
7864 "Gather threads by looking at Subject headers."
7865 (if (not gnus-summary-make-false-root)
7867 (let ((hashtb (gnus-make-hashtable 1023))
7870 subject hthread whole-subject)
7872 (setq whole-subject (mail-header-subject (caar threads)))
7875 ;; Truncate the subject.
7876 ((numberp gnus-summary-gather-subject-limit)
7877 (setq subject (gnus-simplify-subject-re whole-subject))
7878 (if (> (length subject) gnus-summary-gather-subject-limit)
7879 (substring subject 0 gnus-summary-gather-subject-limit)
7881 ;; Fuzzily simplify it.
7882 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7883 (gnus-simplify-subject-fuzzy whole-subject))
7884 ;; Just remove the leading "Re:".
7886 (gnus-simplify-subject-re whole-subject))))
7888 (if (and gnus-summary-gather-exclude-subject
7889 (string-match gnus-summary-gather-exclude-subject
7891 () ; We don't want to do anything with this article.
7892 ;; We simplify the subject before looking it up in the
7895 (if (setq hthread (gnus-gethash subject hashtb))
7897 ;; We enter a dummy root into the thread, if we
7898 ;; haven't done that already.
7899 (unless (stringp (caar hthread))
7900 (setcar hthread (list whole-subject (car hthread))))
7901 ;; We add this new gathered thread to this gathered
7903 (setcdr (car hthread)
7904 (nconc (cdar hthread) (list (car threads))))
7905 ;; Remove it from the list of threads.
7906 (setcdr prev (cdr threads))
7907 (setq threads prev))
7908 ;; Enter this thread into the hash table.
7909 (gnus-sethash subject threads hashtb)))
7911 (setq threads (cdr threads)))
7914 (defun gnus-gather-threads-by-references (threads)
7915 "Gather threads by looking at References headers."
7916 (let ((idhashtb (gnus-make-hashtable 1023))
7917 (thhashtb (gnus-make-hashtable 1023))
7920 ids references id gthread gid entered)
7922 (when (setq references (mail-header-references (caar threads)))
7923 (setq id (mail-header-id (caar threads)))
7924 (setq ids (gnus-split-references references))
7927 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7929 (gnus-sethash (car ids) id idhashtb)
7930 (gnus-sethash id threads thhashtb))
7931 (setq gthread (gnus-gethash gid thhashtb))
7933 ;; We enter a dummy root into the thread, if we
7934 ;; haven't done that already.
7935 (unless (stringp (caar gthread))
7936 (setcar gthread (list (mail-header-subject (caar gthread))
7938 ;; We add this new gathered thread to this gathered
7940 (setcdr (car gthread)
7941 (nconc (cdar gthread) (list (car threads)))))
7942 ;; Add it into the thread hash table.
7943 (gnus-sethash id gthread thhashtb)
7945 ;; Remove it from the list of threads.
7946 (setcdr prev (cdr threads))
7947 (setq threads prev))
7948 (setq ids (cdr ids))))
7950 (setq threads (cdr threads)))
7953 (defun gnus-sort-gathered-threads (threads)
7954 "Sort subtreads inside each gathered thread by article number."
7955 (let ((result threads))
7957 (when (stringp (caar threads))
7958 (setcdr (car threads)
7959 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7960 (setq threads (cdr threads)))
7963 (defun gnus-make-threads ()
7964 "Go through the dependency hashtb and find the roots. Return all threads."
7968 (unless (car (symbol-value refs))
7969 ;; These threads do not refer back to any other articles,
7970 ;; so they're roots.
7971 (setq threads (append (cdr (symbol-value refs)) threads))))
7972 gnus-newsgroup-dependencies)
7975 (defun gnus-build-sparse-threads ()
7976 (let ((headers gnus-newsgroup-headers)
7977 (deps gnus-newsgroup-dependencies)
7978 header references generation relations
7979 cthread subject child end pthread relation)
7980 ;; First we create an alist of generations/relations, where
7981 ;; generations is how much we trust the ralation, and the relation
7983 (gnus-message 7 "Making sparse threads...")
7985 (nnheader-set-temp-buffer " *gnus sparse threads*")
7986 (while (setq header (pop headers))
7987 (when (and (setq references (mail-header-references header))
7988 (not (string= references "")))
7990 (setq child (mail-header-id header)
7991 subject (mail-header-subject header))
7993 (while (search-backward ">" nil t)
7994 (setq end (1+ (point)))
7995 (when (search-backward "<" nil t)
7996 (push (list (incf generation)
7997 child (setq child (buffer-substring (point) end))
8000 (push (list (1+ generation) child nil subject) relations)
8002 (kill-buffer (current-buffer)))
8003 ;; Sort over trustworthiness.
8004 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8005 (while (setq relation (pop relations))
8006 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8007 (unless (car (symbol-value cthread))
8008 ;; Make this article the parent of these threads.
8009 (setcar (symbol-value cthread)
8010 (vector gnus-reffed-article-number
8014 (or (caddr relation) "") 0 0 "")))
8015 (set cthread (list (vector gnus-reffed-article-number
8017 "" "" (cadr relation)
8018 (or (caddr relation) "") 0 0 ""))))
8019 (push gnus-reffed-article-number gnus-newsgroup-limit)
8020 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8021 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8022 gnus-newsgroup-reads)
8023 (decf gnus-reffed-article-number)
8024 ;; Make this new thread the child of its parent.
8025 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8026 (setcdr (symbol-value pthread)
8027 (nconc (cdr (symbol-value pthread))
8028 (list (symbol-value cthread))))
8029 (set pthread (list nil (symbol-value cthread))))))
8030 (gnus-message 7 "Making sparse threads...done")))
8032 (defun gnus-build-old-threads ()
8033 ;; Look at all the articles that refer back to old articles, and
8034 ;; fetch the headers for the articles that aren't there. This will
8035 ;; build complete threads - if the roots haven't been expired by the
8040 (when (not (car (symbol-value refs)))
8041 (setq heads (cdr (symbol-value refs)))
8043 (if (memq (mail-header-number (caar heads))
8044 gnus-newsgroup-dormant)
8045 (setq heads (cdr heads))
8046 (setq id (symbol-name refs))
8047 (while (and (setq id (gnus-build-get-header id))
8048 (not (car (gnus-gethash
8049 id gnus-newsgroup-dependencies)))))
8050 (setq heads nil)))))
8051 gnus-newsgroup-dependencies)))
8053 (defun gnus-build-get-header (id)
8054 ;; Look through the buffer of NOV lines and find the header to
8055 ;; ID. Enter this line into the dependencies hash table, and return
8056 ;; the id of the parent article (if any).
8057 (let ((deps gnus-newsgroup-dependencies)
8061 (set-buffer nntp-server-buffer)
8062 (goto-char (point-min))
8063 (while (and (not found) (search-forward id nil t))
8065 (setq found (looking-at
8066 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8067 (regexp-quote id))))
8068 (or found (beginning-of-line 2)))
8072 (setq header (gnus-nov-parse-line
8073 (read (current-buffer)) deps))
8074 (gnus-parent-id (mail-header-references header)))))
8076 (let ((number (mail-header-number header)))
8077 (push number gnus-newsgroup-limit)
8078 (push header gnus-newsgroup-headers)
8079 (if (memq number gnus-newsgroup-unselected)
8081 (push number gnus-newsgroup-unreads)
8082 (setq gnus-newsgroup-unselected
8083 (delq number gnus-newsgroup-unselected)))
8084 (push number gnus-newsgroup-ancient)))))))
8086 (defun gnus-summary-update-article (article &optional iheader)
8087 "Update ARTICLE in the summary buffer."
8088 (set-buffer gnus-summary-buffer)
8089 (let* ((header (or iheader (gnus-summary-article-header article)))
8090 (id (mail-header-id header))
8091 (data (gnus-data-find article))
8092 (thread (gnus-id-to-thread id))
8093 (references (mail-header-references header))
8098 (not (equal "" references)))
8101 (buffer-read-only nil)
8103 (number (mail-header-number header))
8106 ;; !!! Should this be in or not?
8108 (setcar thread nil))
8110 (delq thread parent))
8111 (if (gnus-summary-insert-subject id header iheader)
8112 ;; Set the (possibly) new article number in the data structure.
8113 (gnus-data-set-number data (gnus-id-to-article id))
8117 (defun gnus-rebuild-thread (id)
8118 "Rebuild the thread containing ID."
8119 (let ((buffer-read-only nil)
8120 current thread data)
8121 (if (not gnus-show-threads)
8122 (setq thread (list (car (gnus-id-to-thread id))))
8123 ;; Get the thread this article is part of.
8124 (setq thread (gnus-remove-thread id)))
8125 (setq current (save-excursion
8126 (and (zerop (forward-line -1))
8127 (gnus-summary-article-number))))
8128 ;; If this is a gathered thread, we have to go some re-gathering.
8129 (when (stringp (car thread))
8130 (let ((subject (car thread))
8132 (setq thread (cdr thread))
8134 (unless (memq (setq thr (gnus-id-to-thread
8136 (mail-header-id (caar thread)))))
8139 (setq thread (cdr thread)))
8140 ;; We now have all (unique) roots.
8141 (if (= (length roots) 1)
8142 ;; All the loose roots are now one solid root.
8143 (setq thread (car roots))
8144 (setq thread (cons subject (gnus-sort-threads roots))))))
8146 ;; We then insert this thread into the summary buffer.
8147 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8148 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8149 (setq data (nreverse gnus-newsgroup-data))
8150 (setq threads gnus-newsgroup-threads))
8151 ;; We splice the new data into the data structure.
8152 (gnus-data-enter-list current data)
8153 (gnus-data-compute-positions)
8154 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8156 (defun gnus-number-to-header (number)
8157 "Return the header for article NUMBER."
8158 (let ((headers gnus-newsgroup-headers))
8160 (not (= number (mail-header-number (car headers)))))
8165 (defun gnus-id-to-thread (id)
8166 "Return the (sub-)thread where ID appears."
8167 (gnus-gethash id gnus-newsgroup-dependencies))
8169 (defun gnus-id-to-article (id)
8170 "Return the article number of ID."
8171 (let ((thread (gnus-id-to-thread id)))
8174 (mail-header-number (car thread)))))
8176 (defun gnus-id-to-header (id)
8177 "Return the article headers of ID."
8178 (car (gnus-id-to-thread id)))
8180 (defun gnus-article-displayed-root-p (article)
8181 "Say whether ARTICLE is a root(ish) article."
8182 (let ((level (gnus-summary-thread-level article))
8183 (refs (mail-header-references (gnus-summary-article-header article)))
8189 ((null (gnus-parent-id refs)) t)
8191 (null (setq particle (gnus-id-to-article
8192 (gnus-parent-id refs))))
8193 (null (gnus-summary-thread-level particle)))))))
8195 (defun gnus-root-id (id)
8196 "Return the id of the root of the thread where ID appears."
8198 (while (and id (setq prev (car (gnus-gethash
8199 id gnus-newsgroup-dependencies))))
8201 id (gnus-parent-id (mail-header-references prev))))
8204 (defun gnus-remove-thread (id &optional dont-remove)
8205 "Remove the thread that has ID in it."
8206 (let ((dep gnus-newsgroup-dependencies)
8207 headers thread last-id)
8208 ;; First go up in this thread until we find the root.
8209 (setq last-id (gnus-root-id id))
8210 (setq headers (list (car (gnus-id-to-thread last-id))
8211 (caadr (gnus-id-to-thread last-id))))
8212 ;; We have now found the real root of this thread. It might have
8213 ;; been gathered into some loose thread, so we have to search
8214 ;; through the threads to find the thread we wanted.
8215 (let ((threads gnus-newsgroup-threads)
8218 (setq sub (car threads))
8219 (if (stringp (car sub))
8220 ;; This is a gathered threads, so we look at the roots
8221 ;; below it to find whether this article in in this
8224 (setq sub (cdr sub))
8226 (when (member (caar sub) headers)
8227 (setq thread (car threads)
8230 (setq sub (cdr sub))))
8231 ;; It's an ordinary thread, so we check it.
8232 (when (eq (car sub) (car headers))
8235 (setq threads (cdr threads)))
8236 ;; If this article is in no thread, then it's a root.
8239 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8240 (setq thread (gnus-gethash last-id dep)))
8243 thread ; We return this thread.
8245 (if (stringp (car thread))
8247 ;; If we use dummy roots, then we have to remove the
8248 ;; dummy root as well.
8249 (when (eq gnus-summary-make-false-root 'dummy)
8252 (setq thread (cdr thread))
8254 (gnus-remove-thread-1 (car thread))
8255 (setq thread (cdr thread))))
8256 (gnus-remove-thread-1 thread))))))))
8258 (defun gnus-remove-thread-1 (thread)
8259 "Remove the thread THREAD recursively."
8260 (let ((number (mail-header-number (car thread)))
8262 (when (setq pos (text-property-any
8263 (point-min) (point-max) 'gnus-number number))
8266 (gnus-data-remove number))
8267 (setq thread (cdr thread))
8269 (gnus-remove-thread-1 (pop thread)))))
8271 (defun gnus-sort-threads (threads)
8273 (if (not gnus-thread-sort-functions)
8275 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8276 (car gnus-thread-sort-functions)
8278 ,(gnus-make-sort-function
8279 (reverse gnus-thread-sort-functions))))))
8280 (gnus-message 7 "Sorting threads...")
8283 (gnus-message 7 "Sorting threads...done")))))
8285 (defun gnus-sort-articles (articles)
8287 (when gnus-article-sort-functions
8288 (let ((func (if (= 1 (length gnus-article-sort-functions))
8289 (car gnus-article-sort-functions)
8291 ,(gnus-make-sort-function
8292 (reverse gnus-article-sort-functions))))))
8293 (gnus-message 7 "Sorting articles...")
8295 (setq gnus-newsgroup-headers (sort articles func))
8296 (gnus-message 7 "Sorting articles...done")))))
8298 (defun gnus-make-sort-function (funs)
8299 "Return a composite sort condition based on the functions in FUNC."
8301 `(or (,(car funs) t1 t2)
8302 (and (not (,(car funs) t2 t1))
8303 ,(gnus-make-sort-function (cdr funs))))
8304 `(,(car funs) t1 t2)))
8306 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8307 (defmacro gnus-thread-header (thread)
8308 ;; Return header of first article in THREAD.
8309 ;; Note that THREAD must never, ever be anything else than a variable -
8310 ;; using some other form will lead to serious barfage.
8311 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8312 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8313 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8316 (defsubst gnus-article-sort-by-number (h1 h2)
8317 "Sort articles by article number."
8318 (< (mail-header-number h1)
8319 (mail-header-number h2)))
8321 (defun gnus-thread-sort-by-number (h1 h2)
8322 "Sort threads by root article number."
8323 (gnus-article-sort-by-number
8324 (gnus-thread-header h1) (gnus-thread-header h2)))
8326 (defsubst gnus-article-sort-by-author (h1 h2)
8327 "Sort articles by root author."
8329 (let ((extract (funcall
8330 gnus-extract-address-components
8331 (mail-header-from h1))))
8332 (or (car extract) (cdr extract)))
8333 (let ((extract (funcall
8334 gnus-extract-address-components
8335 (mail-header-from h2))))
8336 (or (car extract) (cdr extract)))))
8338 (defun gnus-thread-sort-by-author (h1 h2)
8339 "Sort threads by root author."
8340 (gnus-article-sort-by-author
8341 (gnus-thread-header h1) (gnus-thread-header h2)))
8343 (defsubst gnus-article-sort-by-subject (h1 h2)
8344 "Sort articles by root subject."
8346 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8347 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8349 (defun gnus-thread-sort-by-subject (h1 h2)
8350 "Sort threads by root subject."
8351 (gnus-article-sort-by-subject
8352 (gnus-thread-header h1) (gnus-thread-header h2)))
8354 (defsubst gnus-article-sort-by-date (h1 h2)
8355 "Sort articles by root article date."
8357 (inline (gnus-sortable-date (mail-header-date h1)))
8358 (inline (gnus-sortable-date (mail-header-date h2)))))
8360 (defun gnus-thread-sort-by-date (h1 h2)
8361 "Sort threads by root article date."
8362 (gnus-article-sort-by-date
8363 (gnus-thread-header h1) (gnus-thread-header h2)))
8365 (defsubst gnus-article-sort-by-score (h1 h2)
8366 "Sort articles by root article score.
8367 Unscored articles will be counted as having a score of zero."
8368 (> (or (cdr (assq (mail-header-number h1)
8369 gnus-newsgroup-scored))
8370 gnus-summary-default-score 0)
8371 (or (cdr (assq (mail-header-number h2)
8372 gnus-newsgroup-scored))
8373 gnus-summary-default-score 0)))
8375 (defun gnus-thread-sort-by-score (h1 h2)
8376 "Sort threads by root article score."
8377 (gnus-article-sort-by-score
8378 (gnus-thread-header h1) (gnus-thread-header h2)))
8380 (defun gnus-thread-sort-by-total-score (h1 h2)
8381 "Sort threads by the sum of all scores in the thread.
8382 Unscored articles will be counted as having a score of zero."
8383 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8385 (defun gnus-thread-total-score (thread)
8386 ;; This function find the total score of THREAD.
8387 (cond ((null thread)
8390 (if (stringp (car thread))
8391 (apply gnus-thread-score-function 0
8392 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8393 (gnus-thread-total-score-1 thread)))
8395 (gnus-thread-total-score-1 (list thread)))))
8397 (defun gnus-thread-total-score-1 (root)
8398 ;; This function find the total score of the thread below ROOT.
8399 (setq root (car root))
8400 (apply gnus-thread-score-function
8401 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8402 gnus-summary-default-score 0)
8403 (mapcar 'gnus-thread-total-score
8404 (cdr (gnus-gethash (mail-header-id root)
8405 gnus-newsgroup-dependencies)))))
8407 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8408 (defvar gnus-tmp-prev-subject nil)
8409 (defvar gnus-tmp-false-parent nil)
8410 (defvar gnus-tmp-root-expunged nil)
8411 (defvar gnus-tmp-dummy-line nil)
8413 (defun gnus-summary-prepare-threads (threads)
8414 "Prepare summary buffer from THREADS and indentation LEVEL.
8415 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8416 or a straight list of headers."
8417 (gnus-message 7 "Generating summary...")
8419 (setq gnus-newsgroup-threads threads)
8422 (let ((gnus-tmp-level 0)
8423 (default-score (or gnus-summary-default-score 0))
8424 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8425 thread number subject stack state gnus-tmp-gathered beg-match
8426 new-roots gnus-tmp-new-adopts thread-end
8427 gnus-tmp-header gnus-tmp-unread
8428 gnus-tmp-replied gnus-tmp-subject-or-nil
8429 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8430 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8431 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8433 (setq gnus-tmp-prev-subject nil)
8435 (if (vectorp (car threads))
8436 ;; If this is a straight (sic) list of headers, then a
8437 ;; threaded summary display isn't required, so we just create
8438 ;; an unthreaded one.
8439 (gnus-summary-prepare-unthreaded threads)
8441 ;; Do the threaded display.
8443 (while (or threads stack gnus-tmp-new-adopts new-roots)
8445 (if (and (= gnus-tmp-level 0)
8446 (not (setq gnus-tmp-dummy-line nil))
8449 (not gnus-tmp-false-parent)
8450 (or gnus-tmp-new-adopts new-roots))
8451 (if gnus-tmp-new-adopts
8452 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8453 thread (list (car gnus-tmp-new-adopts))
8454 gnus-tmp-header (caar thread)
8455 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8457 (setq thread (list (car new-roots))
8458 gnus-tmp-header (caar thread)
8459 new-roots (cdr new-roots))))
8462 ;; If there are some threads, we do them before the
8463 ;; threads on the stack.
8464 (setq thread threads
8465 gnus-tmp-header (caar thread))
8466 ;; There were no current threads, so we pop something off
8468 (setq state (car stack)
8469 gnus-tmp-level (car state)
8472 gnus-tmp-header (caar thread))))
8474 (setq gnus-tmp-false-parent nil)
8475 (setq gnus-tmp-root-expunged nil)
8476 (setq thread-end nil)
8478 (if (stringp gnus-tmp-header)
8479 ;; The header is a dummy root.
8481 ((eq gnus-summary-make-false-root 'adopt)
8482 ;; We let the first article adopt the rest.
8483 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8485 (setq gnus-tmp-gathered
8487 (lambda (h) (mail-header-number (car h)))
8490 (setq thread (cons (list (caar thread)
8493 (setq gnus-tmp-level -1
8494 gnus-tmp-false-parent t))
8495 ((eq gnus-summary-make-false-root 'empty)
8496 ;; We print adopted articles with empty subject fields.
8497 (setq gnus-tmp-gathered
8499 (lambda (h) (mail-header-number (car h)))
8502 (setq gnus-tmp-level -1))
8503 ((eq gnus-summary-make-false-root 'dummy)
8504 ;; We remember that we probably want to output a dummy
8506 (setq gnus-tmp-dummy-line gnus-tmp-header)
8507 (setq gnus-tmp-prev-subject gnus-tmp-header))
8509 ;; We do not make a root for the gathered
8510 ;; sub-threads at all.
8511 (setq gnus-tmp-level -1)))
8513 (setq number (mail-header-number gnus-tmp-header)
8514 subject (mail-header-subject gnus-tmp-header))
8517 ;; If the thread has changed subject, we might want to make
8518 ;; this subthread into a root.
8519 ((and (null gnus-thread-ignore-subject)
8520 (not (zerop gnus-tmp-level))
8521 gnus-tmp-prev-subject
8523 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8524 (setq new-roots (nconc new-roots (list (car thread)))
8526 gnus-tmp-header nil))
8527 ;; If the article lies outside the current limit,
8528 ;; then we do not display it.
8529 ((and (not (memq number gnus-newsgroup-limit))
8530 (not gnus-tmp-dummy-line))
8531 (setq gnus-tmp-gathered
8533 (lambda (h) (mail-header-number (car h)))
8536 (setq gnus-tmp-new-adopts (if (cdar thread)
8537 (append gnus-tmp-new-adopts
8539 gnus-tmp-new-adopts)
8541 gnus-tmp-header nil)
8542 (when (zerop gnus-tmp-level)
8543 (setq gnus-tmp-root-expunged t)))
8544 ;; Perhaps this article is to be marked as read?
8545 ((and gnus-summary-mark-below
8546 (< (or (cdr (assq number gnus-newsgroup-scored))
8548 gnus-summary-mark-below)
8549 ;; Don't touch sparse articles.
8550 (not (memq number gnus-newsgroup-sparse))
8551 (not (memq number gnus-newsgroup-ancient)))
8552 (setq gnus-newsgroup-unreads
8553 (delq number gnus-newsgroup-unreads))
8554 (if gnus-newsgroup-auto-expire
8555 (push number gnus-newsgroup-expirable)
8556 (push (cons number gnus-low-score-mark)
8557 gnus-newsgroup-reads))))
8559 (when gnus-tmp-header
8560 ;; We may have an old dummy line to output before this
8562 (when gnus-tmp-dummy-line
8563 (gnus-summary-insert-dummy-line
8564 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8565 (setq gnus-tmp-dummy-line nil))
8567 ;; Compute the mark.
8571 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8572 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8573 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8574 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8575 (t (or (cdr (assq number gnus-newsgroup-reads))
8576 gnus-ancient-mark))))
8578 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8579 gnus-tmp-header gnus-tmp-level)
8580 gnus-newsgroup-data)
8582 ;; Actually insert the line.
8584 gnus-tmp-subject-or-nil
8586 ((and gnus-thread-ignore-subject
8587 gnus-tmp-prev-subject
8588 (not (inline (gnus-subject-equal
8589 gnus-tmp-prev-subject subject))))
8591 ((zerop gnus-tmp-level)
8592 (if (and (eq gnus-summary-make-false-root 'empty)
8593 (memq number gnus-tmp-gathered)
8594 gnus-tmp-prev-subject
8595 (inline (gnus-subject-equal
8596 gnus-tmp-prev-subject subject)))
8597 gnus-summary-same-subject
8599 (t gnus-summary-same-subject)))
8600 (if (and (eq gnus-summary-make-false-root 'adopt)
8601 (= gnus-tmp-level 1)
8602 (memq number gnus-tmp-gathered))
8603 (setq gnus-tmp-opening-bracket ?\<
8604 gnus-tmp-closing-bracket ?\>)
8605 (setq gnus-tmp-opening-bracket ?\[
8606 gnus-tmp-closing-bracket ?\]))
8608 gnus-tmp-indentation
8609 (aref gnus-thread-indent-array gnus-tmp-level)
8610 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8611 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8612 gnus-summary-default-score 0)
8614 (if (or (null gnus-summary-default-score)
8615 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8616 gnus-summary-zcore-fuzz)) ?
8617 (if (< gnus-tmp-score gnus-summary-default-score)
8618 gnus-score-below-mark gnus-score-over-mark))
8620 (cond ((memq number gnus-newsgroup-processable)
8622 ((memq number gnus-newsgroup-cached)
8624 ((memq number gnus-newsgroup-replied)
8626 (t gnus-unread-mark))
8627 gnus-tmp-from (mail-header-from gnus-tmp-header)
8630 ((string-match "(.+)" gnus-tmp-from)
8631 (substring gnus-tmp-from
8632 (1+ (match-beginning 0)) (1- (match-end 0))))
8633 ((string-match "<[^>]+> *$" gnus-tmp-from)
8634 (setq beg-match (match-beginning 0))
8635 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8636 (substring gnus-tmp-from (1+ (match-beginning 0))
8637 (1- (match-end 0))))
8638 (substring gnus-tmp-from 0 beg-match)))
8640 (when (string= gnus-tmp-name "")
8641 (setq gnus-tmp-name gnus-tmp-from))
8642 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8643 (gnus-put-text-property
8645 (progn (eval gnus-summary-line-format-spec) (point))
8646 'gnus-number number)
8649 (run-hooks 'gnus-summary-update-hook)
8652 (setq gnus-tmp-prev-subject subject)))
8654 (when (nth 1 thread)
8655 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8656 (incf gnus-tmp-level)
8657 (setq threads (if thread-end nil (cdar thread)))
8659 (setq gnus-tmp-level 0)))))
8660 (gnus-message 7 "Generating summary...done"))
8662 (defun gnus-summary-prepare-unthreaded (headers)
8663 "Generate an unthreaded summary buffer based on HEADERS."
8664 (let (header number mark)
8667 ;; We may have to root out some bad articles...
8668 (when (memq (setq number (mail-header-number
8669 (setq header (pop headers))))
8670 gnus-newsgroup-limit)
8671 ;; Mark article as read when it has a low score.
8672 (when (and gnus-summary-mark-below
8673 (< (or (cdr (assq number gnus-newsgroup-scored))
8674 gnus-summary-default-score 0)
8675 gnus-summary-mark-below)
8676 (not (memq number gnus-newsgroup-ancient)))
8677 (setq gnus-newsgroup-unreads
8678 (delq number gnus-newsgroup-unreads))
8679 (if gnus-newsgroup-auto-expire
8680 (push number gnus-newsgroup-expirable)
8681 (push (cons number gnus-low-score-mark)
8682 gnus-newsgroup-reads)))
8686 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8687 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8688 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8689 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8690 (t (or (cdr (assq number gnus-newsgroup-reads))
8691 gnus-ancient-mark))))
8692 (setq gnus-newsgroup-data
8693 (cons (gnus-data-make number mark (1+ (point)) header 0)
8694 gnus-newsgroup-data))
8695 (gnus-summary-insert-line
8696 header 0 nil mark (memq number gnus-newsgroup-replied)
8697 (memq number gnus-newsgroup-expirable)
8698 (mail-header-subject header) nil
8699 (cdr (assq number gnus-newsgroup-scored))
8700 (memq number gnus-newsgroup-processable))))))
8702 (defun gnus-select-newsgroup (group &optional read-all)
8703 "Select newsgroup GROUP.
8704 If READ-ALL is non-nil, all articles in the group are selected."
8705 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8706 (info (nth 2 entry))
8707 articles fetched-articles cached)
8709 (or (gnus-check-server
8710 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8711 (error "Couldn't open server"))
8713 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8714 (gnus-activate-group group) ; Or we can activate it...
8715 (progn ; Or we bug out.
8716 (when (equal major-mode 'gnus-summary-mode)
8717 (kill-buffer (current-buffer)))
8718 (error "Couldn't request group %s: %s"
8719 group (gnus-status-message group))))
8721 (unless (gnus-request-group group t)
8722 (when (equal major-mode 'gnus-summary-mode)
8723 (kill-buffer (current-buffer)))
8724 (error "Couldn't request group %s: %s"
8725 group (gnus-status-message group)))
8727 (setq gnus-newsgroup-name group)
8728 (setq gnus-newsgroup-unselected nil)
8729 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8731 (and gnus-asynchronous
8732 (gnus-check-backend-function
8733 'request-asynchronous gnus-newsgroup-name)
8734 (setq gnus-newsgroup-async
8735 (gnus-request-asynchronous gnus-newsgroup-name)))
8737 ;; Adjust and set lists of article marks.
8739 (gnus-adjust-marked-articles info))
8741 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8742 (when (gnus-virtual-group-p group)
8743 (setq cached gnus-newsgroup-cached))
8745 (setq gnus-newsgroup-unreads
8746 (gnus-set-difference
8747 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8748 gnus-newsgroup-dormant))
8750 (setq gnus-newsgroup-processable nil)
8752 (setq articles (gnus-articles-to-read group read-all))
8756 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8758 ((eq articles 0) nil)
8760 ;; Init the dependencies hash table.
8761 (setq gnus-newsgroup-dependencies
8762 (gnus-make-hashtable (length articles)))
8763 ;; Retrieve the headers and read them in.
8764 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8765 (setq gnus-newsgroup-headers
8767 (setq gnus-headers-retrieved-by
8768 (gnus-retrieve-headers
8769 articles gnus-newsgroup-name
8770 ;; We might want to fetch old headers, but
8771 ;; not if there is only 1 article.
8772 (and gnus-fetch-old-headers
8774 (not (eq gnus-fetch-old-headers 'some))
8775 (not (numberp gnus-fetch-old-headers)))
8776 (> (length articles) 1))))))
8777 (gnus-get-newsgroup-headers-xover articles)
8778 (gnus-get-newsgroup-headers)))
8779 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8781 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8783 (setq gnus-newsgroup-cached cached))
8785 ;; Set the initial limit.
8786 (setq gnus-newsgroup-limit (copy-sequence articles))
8787 ;; Remove canceled articles from the list of unread articles.
8788 (setq gnus-newsgroup-unreads
8789 (gnus-set-sorted-intersection
8790 gnus-newsgroup-unreads
8791 (setq fetched-articles
8792 (mapcar (lambda (headers) (mail-header-number headers))
8793 gnus-newsgroup-headers))))
8794 ;; Removed marked articles that do not exist.
8795 (gnus-update-missing-marks
8796 (gnus-sorted-complement fetched-articles articles))
8797 ;; We might want to build some more threads first.
8798 (and gnus-fetch-old-headers
8799 (eq gnus-headers-retrieved-by 'nov)
8800 (gnus-build-old-threads))
8801 ;; Check whether auto-expire is to be done in this group.
8802 (setq gnus-newsgroup-auto-expire
8803 (gnus-group-auto-expirable-p group))
8804 ;; Set up the article buffer now, if necessary.
8805 (unless gnus-single-article-buffer
8806 (gnus-article-setup-buffer))
8807 ;; First and last article in this newsgroup.
8808 (when gnus-newsgroup-headers
8809 (setq gnus-newsgroup-begin
8810 (mail-header-number (car gnus-newsgroup-headers))
8813 (gnus-last-element gnus-newsgroup-headers))))
8814 (setq gnus-reffed-article-number -1)
8815 ;; GROUP is successfully selected.
8816 (or gnus-newsgroup-headers t)))))
8818 (defun gnus-articles-to-read (group read-all)
8819 ;; Find out what articles the user wants to read.
8821 ;; Select all articles if `read-all' is non-nil, or if there
8822 ;; are no unread articles.
8824 (and (zerop (length gnus-newsgroup-marked))
8825 (zerop (length gnus-newsgroup-unreads))))
8826 (gnus-uncompress-range (gnus-active group))
8827 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8828 (copy-sequence gnus-newsgroup-unreads))
8830 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8831 (scored (length scored-list))
8832 (number (length articles))
8833 (marked (+ (length gnus-newsgroup-marked)
8834 (length gnus-newsgroup-dormant)))
8842 ((and (or (<= scored marked) (= scored number))
8843 (numberp gnus-large-newsgroup)
8844 (> number gnus-large-newsgroup))
8848 "How many articles from %s (default %d): "
8849 gnus-newsgroup-name number))))
8850 (if (string-match "^[ \t]*$" input) number input)))
8851 ((and (> scored marked) (< scored number))
8854 (format "%s %s (%d scored, %d total): "
8855 "How many articles from"
8856 group scored number))))
8857 (if (string-match "^[ \t]*$" input)
8861 (setq select (if (stringp select) (string-to-number select) select))
8862 (if (or (null select) (zerop select))
8864 (if (and (not (zerop scored)) (<= (abs select) scored))
8866 (setq articles (sort scored-list '<))
8867 (setq number (length articles)))
8868 (setq articles (copy-sequence articles)))
8870 (if (< (abs select) number)
8872 ;; Select the N oldest articles.
8873 (setcdr (nthcdr (1- (abs select)) articles) nil)
8874 ;; Select the N most recent articles.
8875 (setq articles (nthcdr (- number select) articles))))
8876 (setq gnus-newsgroup-unselected
8877 (gnus-sorted-intersection
8878 gnus-newsgroup-unreads
8879 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8882 (defun gnus-killed-articles (killed articles)
8885 (if (inline (gnus-member-of-range (car articles) killed))
8886 (setq out (cons (car articles) out)))
8887 (setq articles (cdr articles)))
8890 (defun gnus-uncompress-marks (marks)
8891 "Uncompress the mark ranges in MARKS."
8892 (let ((uncompressed '(score bookmark))
8895 (if (memq (caar marks) uncompressed)
8896 (push (car marks) out)
8897 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8898 (setq marks (cdr marks)))
8901 (defun gnus-adjust-marked-articles (info)
8902 "Set all article lists and remove all marks that are no longer legal."
8903 (let* ((marked-lists (gnus-info-marks info))
8904 (active (gnus-active (gnus-info-group info)))
8907 (types gnus-article-mark-lists)
8908 (uncompressed '(score bookmark))
8909 marks var articles article mark)
8912 (setq marks (pop marked-lists))
8913 (set (setq var (intern (format "gnus-newsgroup-%s"
8914 (car (rassq (setq mark (car marks))
8916 (if (memq (car marks) uncompressed) (cdr marks)
8917 (gnus-uncompress-range (cdr marks))))
8919 (setq articles (symbol-value var))
8921 ;; All articles have to be subsets of the active articles.
8923 ;; Adjust "simple" lists.
8924 ((memq mark '(tick dormant expirable reply killed save))
8926 (when (or (< (setq article (pop articles)) min) (> article max))
8927 (set var (delq article (symbol-value var))))))
8929 ((memq mark '(score bookmark))
8931 (when (or (< (car (setq article (pop articles))) min)
8932 (> (car article) max))
8933 (set var (delq article (symbol-value var))))))))))
8935 (defun gnus-update-missing-marks (missing)
8936 "Go through the list of MISSING articles and remove them mark lists."
8938 (let ((types gnus-article-mark-lists)
8940 ;; Go through all types.
8942 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8943 (when (symbol-value var)
8944 ;; This list has articles. So we delete all missing articles
8948 (set var (delq (pop m) (symbol-value var)))))))))
8950 (defun gnus-update-marks ()
8951 "Enter the various lists of marked articles into the newsgroup info list."
8952 (let ((types gnus-article-mark-lists)
8953 (info (gnus-get-info gnus-newsgroup-name))
8954 (uncompressed '(score bookmark killed))
8955 type list newmarked symbol)
8957 ;; Add all marks lists that are non-nil to the list of marks lists.
8959 (setq type (pop types))
8960 (when (setq list (symbol-value
8962 (intern (format "gnus-newsgroup-%s"
8964 (push (cons (cdr type)
8965 (if (memq (cdr type) uncompressed) list
8966 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8969 ;; Enter these new marks into the info of the group.
8971 (setcar (nthcdr 3 info) newmarked)
8972 ;; Add the marks lists to the end of the info.
8974 (setcdr (nthcdr 2 info) (list newmarked))))
8976 ;; Cut off the end of the info if there's nothing else there.
8980 (when (nthcdr (decf i) info)
8981 (setcdr (nthcdr i info) nil)))))))
8983 (defun gnus-add-marked-articles (group type articles &optional info force)
8984 ;; Add ARTICLES of TYPE to the info of GROUP.
8985 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8986 ;; add, but replace marked articles of TYPE with ARTICLES.
8987 (let ((info (or info (gnus-get-info group)))
8988 (uncompressed '(score bookmark killed))
8991 (and (not (setq marked (nthcdr 3 info)))
8993 (setcdr (nthcdr 2 info)
8994 (list (list (cons type (gnus-compress-sequence
8996 (and (not (setq m (assq type (car marked))))
8999 (cons (cons type (gnus-compress-sequence articles t) )
9003 (setcar (nthcdr 3 info)
9004 (delq (assq type (car marked)) (car marked)))
9005 (setcdr m (gnus-compress-sequence articles t)))
9006 (setcdr m (gnus-compress-sequence
9007 (sort (nconc (gnus-uncompress-range (cdr m))
9008 (copy-sequence articles)) '<) t))))))
9010 (defun gnus-set-mode-line (where)
9011 "This function sets the mode line of the article or summary buffers.
9012 If WHERE is `summary', the summary mode line format will be used."
9013 ;; Is this mode line one we keep updated?
9014 (when (memq where gnus-updated-mode-lines)
9017 ;; We evaluate this in the summary buffer since these
9018 ;; variables are buffer-local to that buffer.
9019 (set-buffer gnus-summary-buffer)
9020 ;; We bind all these variables that are used in the `eval' form
9022 (let* ((mformat (symbol-value
9024 (format "gnus-%s-mode-line-format-spec" where))))
9025 (gnus-tmp-group-name gnus-newsgroup-name)
9026 (gnus-tmp-article-number (or gnus-current-article 0))
9027 (gnus-tmp-unread gnus-newsgroup-unreads)
9028 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9029 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9030 (gnus-tmp-unread-and-unselected
9031 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9032 (zerop gnus-tmp-unselected)) "")
9033 ((zerop gnus-tmp-unselected)
9034 (format "{%d more}" gnus-tmp-unread-and-unticked))
9035 (t (format "{%d(+%d) more}"
9036 gnus-tmp-unread-and-unticked
9037 gnus-tmp-unselected))))
9039 (if (and gnus-current-headers
9040 (vectorp gnus-current-headers))
9041 (gnus-mode-string-quote
9042 (mail-header-subject gnus-current-headers)) ""))
9044 gnus-tmp-header);; passed as argument to any user-format-funcs
9045 (setq mode-string (eval mformat))
9046 (setq max-len (max 4 (if gnus-mode-non-string-length
9048 gnus-mode-non-string-length)
9049 (length mode-string))))
9050 ;; We might have to chop a bit of the string off...
9051 (when (> (length mode-string) max-len)
9053 (concat (gnus-truncate-string mode-string (- max-len 3))
9055 ;; Pad the mode string a bit.
9056 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9057 ;; Update the mode line.
9058 (setq mode-line-buffer-identification (list mode-string))
9059 (set-buffer-modified-p t))))
9061 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9062 "Go through the HEADERS list and add all Xrefs to a hash table.
9063 The resulting hash table is returned, or nil if no Xrefs were found."
9064 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9065 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9066 (xref-hashtb (make-vector 63 0))
9067 start group entry number xrefs header)
9069 (setq header (pop headers))
9070 (when (and (setq xrefs (mail-header-xref header))
9071 (not (memq (setq number (mail-header-number header))
9074 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9075 (setq start (match-end 0))
9076 (setq group (if prefix
9077 (concat prefix (substring xrefs (match-beginning 1)
9079 (substring xrefs (match-beginning 1) (match-end 1))))
9081 (string-to-int (substring xrefs (match-beginning 2)
9083 (if (setq entry (gnus-gethash group xref-hashtb))
9084 (setcdr entry (cons number (cdr entry)))
9085 (gnus-sethash group (cons number nil) xref-hashtb)))))
9086 (and start xref-hashtb)))
9088 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9089 "Look through all the headers and mark the Xrefs as read."
9090 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9091 name entry info xref-hashtb idlist method nth4)
9093 (set-buffer gnus-group-buffer)
9094 (when (setq xref-hashtb
9095 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9098 (unless (string= from-newsgroup (setq name (symbol-name group)))
9099 (setq idlist (symbol-value group))
9100 ;; Dead groups are not updated.
9102 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9104 (if (stringp (setq nth4 (gnus-info-method info)))
9105 (setq nth4 (gnus-server-to-method nth4))))
9106 ;; Only do the xrefs if the group has the same
9107 ;; select method as the group we have just read.
9108 (or (gnus-methods-equal-p
9109 nth4 (gnus-find-method-for-group from-newsgroup))
9111 (equal nth4 (setq method (gnus-find-method-for-group
9113 (and (equal (car nth4) (car method))
9114 (equal (nth 1 nth4) (nth 1 method))))
9115 gnus-use-cross-reference
9116 (or (not (eq gnus-use-cross-reference t))
9118 ;; Only do cross-references on subscribed
9119 ;; groups, if that is what is wanted.
9120 (<= (gnus-info-level info) gnus-level-subscribed))
9121 (gnus-group-make-articles-read name idlist))))
9124 (defun gnus-group-make-articles-read (group articles)
9126 (entry (gnus-gethash group gnus-newsrc-hashtb))
9127 (info (nth 2 entry))
9128 (active (gnus-active group))
9130 ;; First peel off all illegal article numbers.
9132 (let ((ids articles)
9136 (if (and first (> id (cdr active)))
9138 ;; We'll end up in this situation in one particular
9139 ;; obscure situation. If you re-scan a group and get
9140 ;; a new article that is cross-posted to a different
9141 ;; group that has not been re-scanned, you might get
9142 ;; crossposted article that has a higher number than
9143 ;; Gnus believes possible. So we re-activate this
9144 ;; group as well. This might mean doing the
9145 ;; crossposting thingy will *increase* the number
9146 ;; of articles in some groups. Tsk, tsk.
9147 (setq active (or (gnus-activate-group group) active))))
9148 (if (or (> id (cdr active))
9149 (< id (car active)))
9150 (setq articles (delq id articles)))
9151 (setq ids (cdr ids)))))
9152 ;; If the read list is nil, we init it.
9154 (null (gnus-info-read info))
9156 (gnus-info-set-read info (cons 1 (1- (car active)))))
9157 ;; Then we add the read articles to the range.
9162 (gnus-info-read info) (setq articles (sort articles '<)))))
9163 ;; Then we have to re-compute how many unread
9164 ;; articles there are in this group.
9169 (setq num (- (1+ (cdr active)) (car active))))
9170 ((not (listp (cdr range)))
9171 (setq num (- (cdr active) (- (1+ (cdr range))
9175 (if (numberp (car range))
9177 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9178 (setq range (cdr range)))
9179 (setq num (- (cdr active) num))))
9180 ;; Update the number of unread articles.
9182 ;; Update the group buffer.
9183 (gnus-group-update-group group t)))))
9185 (defun gnus-methods-equal-p (m1 m2)
9186 (let ((m1 (or m1 gnus-select-method))
9187 (m2 (or m2 gnus-select-method)))
9189 (and (eq (car m1) (car m2))
9190 (or (not (memq 'address (assoc (symbol-name (car m1))
9191 gnus-valid-select-methods)))
9192 (equal (nth 1 m1) (nth 1 m2)))))))
9194 (defsubst gnus-header-value ()
9197 (if (re-search-forward "^[^ \t]" nil t)
9201 (gnus-point-at-eol))))
9203 (defvar gnus-newsgroup-none-id 0)
9205 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9206 (let ((cur nntp-server-buffer)
9209 (save-excursion (set-buffer gnus-summary-buffer)
9210 gnus-newsgroup-dependencies)))
9211 headers id id-dep ref-dep end ref)
9213 (set-buffer nntp-server-buffer)
9214 (run-hooks 'gnus-parse-headers-hook)
9215 (let ((case-fold-search t)
9216 in-reply-to header p lines)
9217 (goto-char (point-min))
9218 ;; Search to the beginning of the next header. Error messages
9219 ;; do not begin with 2 or 3.
9220 (while (re-search-forward "^[23][0-9]+ " nil t)
9223 ;; This implementation of this function, with nine
9224 ;; search-forwards instead of the one re-search-forward and
9225 ;; a case (which basically was the old function) is actually
9226 ;; about twice as fast, even though it looks messier. You
9227 ;; can't have everything, I guess. Speed and elegance
9228 ;; doesn't always go hand in hand.
9237 (narrow-to-region (point)
9238 (or (and (search-forward "\n.\n" nil t)
9244 (if (search-forward "\nsubject: " nil t)
9245 (gnus-header-value) "(none)"))
9249 (if (search-forward "\nfrom: " nil t)
9250 (gnus-header-value) "(nobody)"))
9254 (if (search-forward "\ndate: " nil t)
9255 (gnus-header-value) ""))
9259 (if (search-forward "\nmessage-id: " nil t)
9260 (setq id (gnus-header-value))
9261 ;; If there was no message-id, we just fake one to make
9262 ;; subsequent routines simpler.
9263 (setq id (concat "none+"
9265 (setq gnus-newsgroup-none-id
9266 (1+ gnus-newsgroup-none-id)))))))
9270 (if (search-forward "\nreferences: " nil t)
9279 (search-backward ">" end t)
9282 (search-backward "<" end t)
9284 ;; Get the references from the in-reply-to header if there
9285 ;; were no references and the in-reply-to header looks
9287 (if (and (search-forward "\nin-reply-to: " nil t)
9288 (setq in-reply-to (gnus-header-value))
9289 (string-match "<[^>]+>" in-reply-to))
9290 (setq ref (substring in-reply-to (match-beginning 0)
9298 (if (search-forward "\nlines: " nil t)
9299 (if (numberp (setq lines (read cur)))
9305 (and (search-forward "\nxref: " nil t)
9306 (gnus-header-value)))))
9307 ;; We do the threading while we read the headers. The
9308 ;; message-id and the last reference are both entered into
9309 ;; the same hash table. Some tippy-toeing around has to be
9310 ;; done in case an article has arrived before the article
9311 ;; which it refers to.
9312 (if (boundp (setq id-dep (intern id dependencies)))
9313 (if (and (car (symbol-value id-dep))
9315 ;; An article with this Message-ID has already
9316 ;; been seen, so we ignore this one, except we add
9317 ;; any additional Xrefs (in case the two articles
9318 ;; came from different servers).
9320 (mail-header-set-xref
9321 (car (symbol-value id-dep))
9322 (concat (or (mail-header-xref
9323 (car (symbol-value id-dep))) "")
9324 (or (mail-header-xref header) "")))
9326 (setcar (symbol-value id-dep) header))
9327 (set id-dep (list header)))
9329 (if (boundp (setq ref-dep (intern ref dependencies)))
9330 (setcdr (symbol-value ref-dep)
9331 (nconc (cdr (symbol-value ref-dep))
9332 (list (symbol-value id-dep))))
9333 (set ref-dep (list nil (symbol-value id-dep))))
9334 (setq headers (cons header headers)))
9335 (goto-char (point-max))
9337 (nreverse headers)))))
9339 ;; The following macros and functions were written by Felix Lee
9340 ;; <flee@cse.psu.edu>.
9342 (defmacro gnus-nov-read-integer ()
9344 (if (= (following-char) ?\t)
9346 (let ((num (condition-case nil (read buffer) (error nil))))
9347 (if (numberp num) num 0)))
9348 (or (eobp) (forward-char 1))))
9350 (defmacro gnus-nov-skip-field ()
9351 '(search-forward "\t" eol 'move))
9353 (defmacro gnus-nov-field ()
9354 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9356 ;; Goes through the xover lines and returns a list of vectors
9357 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9358 force-new dependencies)
9359 "Parse the news overview data in the server buffer, and return a
9360 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9361 ;; Get the Xref when the users reads the articles since most/some
9362 ;; NNTP servers do not include Xrefs when using XOVER.
9363 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9364 (let ((cur nntp-server-buffer)
9365 (dependencies (or dependencies gnus-newsgroup-dependencies))
9366 number headers header)
9368 (set-buffer nntp-server-buffer)
9369 ;; Allow the user to mangle the headers before parsing them.
9370 (run-hooks 'gnus-parse-headers-hook)
9371 (goto-char (point-min))
9372 (while (and sequence (not (eobp)))
9373 (setq number (read cur))
9374 (while (and sequence (< (car sequence) number))
9375 (setq sequence (cdr sequence)))
9377 (eq number (car sequence))
9379 (setq sequence (cdr sequence))
9381 (inline (gnus-nov-parse-line
9382 number dependencies force-new)))
9383 (setq headers (cons header headers)))))
9385 (setq headers (nreverse headers)))
9388 ;; This function has to be called with point after the article number
9389 ;; on the beginning of the line.
9390 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9392 (eol (gnus-point-at-eol))
9393 (buffer (current-buffer))
9394 header ref id id-dep ref-dep)
9396 ;; overview: [num subject from date id refs chars lines misc]
9397 (narrow-to-region (point) eol)
9398 (or (eobp) (forward-char))
9404 (gnus-nov-field) ; subject
9405 (gnus-nov-field) ; from
9406 (gnus-nov-field) ; date
9407 (setq id (or (gnus-nov-field)
9410 (setq none (1+ none)))))) ; id
9413 (let ((beg (point)))
9414 (search-forward "\t" eol)
9415 (if (search-backward ">" beg t)
9419 (search-backward "<" beg t)))
9421 (gnus-nov-field)) ; refs
9422 (gnus-nov-read-integer) ; chars
9423 (gnus-nov-read-integer) ; lines
9424 (if (= (following-char) ?\n)
9426 (gnus-nov-field)) ; misc
9429 (gnus-error 4 "Strange nov line")
9435 ;; We build the thread tree.
9437 (if (boundp (setq id-dep (intern id dependencies)))
9438 (if (and (car (symbol-value id-dep))
9440 ;; An article with this Message-ID has already been seen,
9441 ;; so we ignore this one, except we add any additional
9442 ;; Xrefs (in case the two articles came from different
9445 (mail-header-set-xref
9446 (car (symbol-value id-dep))
9447 (concat (or (mail-header-xref
9448 (car (symbol-value id-dep))) "")
9449 (or (mail-header-xref header) "")))
9451 (setcar (symbol-value id-dep) header))
9452 (set id-dep (list header))))
9454 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9455 (setcdr (symbol-value ref-dep)
9456 (nconc (cdr (symbol-value ref-dep))
9457 (list (symbol-value id-dep))))
9458 (set ref-dep (list nil (symbol-value id-dep)))))
9461 (defun gnus-article-get-xrefs ()
9462 "Fill in the Xref value in `gnus-current-headers', if necessary.
9463 This is meant to be called in `gnus-article-internal-prepare-hook'."
9464 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9465 gnus-current-headers)))
9466 (or (not gnus-use-cross-reference)
9468 (and (mail-header-xref headers)
9469 (not (string= (mail-header-xref headers) "")))
9470 (let ((case-fold-search t)
9473 (nnheader-narrow-to-headers)
9474 (goto-char (point-min))
9475 (if (or (and (eq (downcase (following-char)) ?x)
9476 (looking-at "Xref:"))
9477 (search-forward "\nXref:" nil t))
9479 (goto-char (1+ (match-end 0)))
9480 (setq xref (buffer-substring (point)
9481 (progn (end-of-line) (point))))
9482 (mail-header-set-xref headers xref))))))))
9484 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9485 "Find article ID and insert the summary line for that article."
9486 (let ((header (if (and old-header use-old-header)
9487 old-header (gnus-read-header id)))
9488 (number (and (numberp id) id))
9491 ;; Rebuild the thread that this article is part of and go to the
9492 ;; article we have fetched.
9493 (when (and (not gnus-show-threads)
9495 (when (setq pos (text-property-any
9496 (point-min) (point-max) 'gnus-number
9497 (mail-header-number old-header)))
9500 (gnus-data-remove (mail-header-number old-header))))
9502 (mail-header-set-number header (mail-header-number old-header)))
9503 (setq gnus-newsgroup-sparse
9504 (delq (setq number (mail-header-number header))
9505 gnus-newsgroup-sparse))
9506 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9507 (gnus-rebuild-thread (mail-header-id header))
9508 (gnus-summary-goto-subject number nil t))
9509 (when (and (numberp number)
9511 ;; We have to update the boundaries even if we can't fetch the
9512 ;; article if ID is a number -- so that the next `P' or `N'
9513 ;; command will fetch the previous (or next) article even
9514 ;; if the one we tried to fetch this time has been canceled.
9515 (and (> number gnus-newsgroup-end)
9516 (setq gnus-newsgroup-end number))
9517 (and (< number gnus-newsgroup-begin)
9518 (setq gnus-newsgroup-begin number))
9519 (setq gnus-newsgroup-unselected
9520 (delq number gnus-newsgroup-unselected)))
9521 ;; Report back a success?
9522 (and header (mail-header-number header))))
9524 (defun gnus-summary-work-articles (n)
9525 "Return a list of articles to be worked upon. The prefix argument,
9526 the list of process marked articles, and the current article will be
9527 taken into consideration."
9529 ((and n (numberp n))
9530 ;; A numerical prefix has been given.
9531 (let ((backward (< n 0))
9537 (push (setq article (gnus-summary-article-number))
9540 (gnus-summary-find-prev nil article)
9541 (gnus-summary-find-next nil article)))
9543 (nreverse articles)))
9544 ((and (boundp 'transient-mark-mode)
9547 ;; Work on the region between point and mark.
9548 (let ((max (max (point) (mark)))
9551 (goto-char (min (point) (mark)))
9554 (push (setq article (gnus-summary-article-number)) articles)
9555 (gnus-summary-find-next nil article)
9557 (nreverse articles))))
9558 (gnus-newsgroup-processable
9559 ;; There are process-marked articles present.
9560 (reverse gnus-newsgroup-processable))
9562 ;; Just return the current article.
9563 (list (gnus-summary-article-number)))))
9565 (defun gnus-summary-search-group (&optional backward use-level)
9566 "Search for next unread newsgroup.
9567 If optional argument BACKWARD is non-nil, search backward instead."
9569 (set-buffer gnus-group-buffer)
9570 (if (gnus-group-search-forward
9571 backward nil (if use-level (gnus-group-group-level) nil))
9572 (gnus-group-group-name))))
9574 (defun gnus-summary-best-group (&optional exclude-group)
9575 "Find the name of the best unread group.
9576 If EXCLUDE-GROUP, do not go to this group."
9578 (set-buffer gnus-group-buffer)
9580 (gnus-group-best-unread-group exclude-group))))
9582 (defun gnus-summary-find-next (&optional unread article backward)
9583 (if backward (gnus-summary-find-prev)
9584 (let* ((dummy (gnus-summary-article-intangible-p))
9585 (article (or article (gnus-summary-article-number)))
9586 (arts (gnus-data-find-list article))
9588 (when (and (not dummy)
9589 (or (not gnus-summary-check-current)
9591 (not (gnus-data-unread-p (car arts)))))
9592 (setq arts (cdr arts)))
9597 (when (gnus-data-unread-p (car arts))
9598 (setq result (car arts)
9600 (setq arts (cdr arts)))
9603 (goto-char (gnus-data-pos result))
9604 (gnus-data-number result)))))
9606 (defun gnus-summary-find-prev (&optional unread article)
9607 (let* ((eobp (eobp))
9608 (article (or article (gnus-summary-article-number)))
9609 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9611 (when (and (not eobp)
9612 (or (not gnus-summary-check-current)
9614 (not (gnus-data-unread-p (car arts)))))
9615 (setq arts (cdr arts)))
9620 (and (gnus-data-unread-p (car arts))
9621 (setq result (car arts)
9623 (setq arts (cdr arts)))
9627 (goto-char (gnus-data-pos result))
9628 (gnus-data-number result)))))
9630 (defun gnus-summary-find-subject (subject &optional unread backward article)
9631 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9632 (article (or article (gnus-summary-article-number)))
9633 (articles (gnus-data-list backward))
9634 (arts (gnus-data-find-list article articles))
9636 (when (or (not gnus-summary-check-current)
9638 (not (gnus-data-unread-p (car arts))))
9639 (setq arts (cdr arts)))
9641 (and (or (not unread)
9642 (gnus-data-unread-p (car arts)))
9643 (vectorp (gnus-data-header (car arts)))
9645 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9646 (setq result (car arts)
9648 (setq arts (cdr arts)))
9650 (goto-char (gnus-data-pos result))
9651 (gnus-data-number result))))
9653 (defun gnus-summary-search-forward (&optional unread subject backward)
9654 "Search forward for an article.
9655 If UNREAD, look for unread articles. If SUBJECT, look for
9656 articles with that subject. If BACKWARD, search backward instead."
9657 (cond (subject (gnus-summary-find-subject subject unread backward))
9658 (backward (gnus-summary-find-prev unread))
9659 (t (gnus-summary-find-next unread))))
9661 (defun gnus-recenter (&optional n)
9662 "Center point in window and redisplay frame.
9663 Also do horizontal recentering."
9665 (when (and gnus-auto-center-summary
9666 (not (eq gnus-auto-center-summary 'vertical)))
9667 (gnus-horizontal-recenter))
9670 (defun gnus-summary-recenter ()
9671 "Center point in the summary window.
9672 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9673 displayed, no centering will be performed."
9674 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9675 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9676 (let* ((top (cond ((< (window-height) 4) 0)
9677 ((< (window-height) 7) 1)
9679 (height (1- (window-height)))
9680 (bottom (save-excursion (goto-char (point-max))
9681 (forward-line (- height))
9683 (window (get-buffer-window (current-buffer))))
9684 ;; The user has to want it.
9685 (when gnus-auto-center-summary
9686 (when (get-buffer-window gnus-article-buffer)
9687 ;; Only do recentering when the article buffer is displayed,
9688 ;; Set the window start to either `bottom', which is the biggest
9689 ;; possible valid number, or the second line from the top,
9690 ;; whichever is the least.
9692 window (min bottom (save-excursion
9693 (forward-line (- top)) (point)))))
9694 ;; Do horizontal recentering while we're at it.
9695 (when (and (get-buffer-window (current-buffer) t)
9696 (not (eq gnus-auto-center-summary 'vertical)))
9697 (let ((selected (selected-window)))
9698 (select-window (get-buffer-window (current-buffer) t))
9699 (gnus-summary-position-point)
9700 (gnus-horizontal-recenter)
9701 (select-window selected))))))
9703 (defun gnus-horizontal-recenter ()
9704 "Recenter the current buffer horizontally."
9705 (if (< (current-column) (/ (window-width) 2))
9706 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9707 (let* ((orig (point))
9708 (end (window-end (get-buffer-window (current-buffer) t)))
9710 ;; Find the longest line currently displayed in the window.
9711 (goto-char (window-start))
9712 (while (and (not (eobp))
9715 (setq max (max max (current-column)))
9718 ;; Scroll horizontally to center (sort of) the point.
9719 (if (> max (window-width))
9721 (get-buffer-window (current-buffer) t)
9722 (min (- (current-column) (/ (window-width) 3))
9723 (+ 2 (- max (window-width)))))
9724 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9727 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9728 (defun gnus-short-group-name (group &optional levels)
9729 "Collapse GROUP name LEVELS."
9736 (while (string-match "\\." group skip)
9737 (setq skip (match-end 0)
9740 (if (string-match ":" group)
9741 (setq foreign (substring group 0 (match-end 0))
9742 group (substring group (match-end 0))))
9744 (if (and (string-match "\\." group)
9745 (> levels (- gnus-group-uncollapsed-levels 1)))
9746 (setq name (concat name (substring group 0 1))
9747 group (substring group (match-end 0))
9749 name (concat name "."))
9750 (setq name (concat foreign name group)
9754 (defun gnus-summary-jump-to-group (newsgroup)
9755 "Move point to NEWSGROUP in group mode buffer."
9756 ;; Keep update point of group mode buffer if visible.
9757 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9758 (save-window-excursion
9759 ;; Take care of tree window mode.
9760 (if (get-buffer-window gnus-group-buffer)
9761 (pop-to-buffer gnus-group-buffer))
9762 (gnus-group-jump-to-group newsgroup))
9764 ;; Take care of tree window mode.
9765 (if (get-buffer-window gnus-group-buffer)
9766 (pop-to-buffer gnus-group-buffer)
9767 (set-buffer gnus-group-buffer))
9768 (gnus-group-jump-to-group newsgroup))))
9770 ;; This function returns a list of article numbers based on the
9771 ;; difference between the ranges of read articles in this group and
9772 ;; the range of active articles.
9773 (defun gnus-list-of-unread-articles (group)
9774 (let* ((read (gnus-info-read (gnus-get-info group)))
9775 (active (gnus-active group))
9778 ;; If none are read, then all are unread.
9780 (setq first (car active))
9781 ;; If the range of read articles is a single range, then the
9782 ;; first unread article is the article after the last read
9783 ;; article. Sounds logical, doesn't it?
9784 (if (not (listp (cdr read)))
9785 (setq first (1+ (cdr read)))
9786 ;; `read' is a list of ranges.
9787 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9792 (while (< first nlast)
9793 (setq unread (cons first unread))
9794 (setq first (1+ first))))
9795 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9796 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9797 (setq read (cdr read)))))
9798 ;; And add the last unread articles.
9799 (while (<= first last)
9800 (setq unread (cons first unread))
9801 (setq first (1+ first)))
9802 ;; Return the list of unread articles.
9805 (defun gnus-list-of-read-articles (group)
9806 "Return a list of unread, unticked and non-dormant articles."
9807 (let* ((info (gnus-get-info group))
9808 (marked (gnus-info-marks info))
9809 (active (gnus-active group)))
9811 (gnus-set-difference
9812 (gnus-sorted-complement
9813 (gnus-uncompress-range active)
9814 (gnus-list-of-unread-articles group))
9816 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9817 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9819 ;; Various summary commands
9821 (defun gnus-summary-universal-argument (arg)
9822 "Perform any operation on all articles that are process/prefixed."
9824 (gnus-set-global-variables)
9825 (let ((articles (gnus-summary-work-articles arg))
9832 (substitute-command-keys
9833 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9836 (gnus-error 1 "Undefined key")
9839 (gnus-summary-goto-subject (setq article (pop articles)))
9840 (command-execute func)
9841 (gnus-summary-remove-process-mark article)))))
9842 (gnus-summary-position-point))
9844 (defun gnus-summary-toggle-truncation (&optional arg)
9845 "Toggle truncation of summary lines.
9846 With arg, turn line truncation on iff arg is positive."
9848 (setq truncate-lines
9849 (if (null arg) (not truncate-lines)
9850 (> (prefix-numeric-value arg) 0)))
9853 (defun gnus-summary-reselect-current-group (&optional all rescan)
9854 "Exit and then reselect the current newsgroup.
9855 The prefix argument ALL means to select all articles."
9857 (gnus-set-global-variables)
9858 (let ((current-subject (gnus-summary-article-number))
9859 (group gnus-newsgroup-name))
9860 (setq gnus-newsgroup-begin nil)
9862 ;; We have to adjust the point of group mode buffer because the
9863 ;; current point was moved to the next unread newsgroup by
9865 (gnus-summary-jump-to-group group)
9868 (gnus-group-get-new-news-this-group 1)))
9869 (gnus-group-read-group all t)
9870 (gnus-summary-goto-subject current-subject)))
9872 (defun gnus-summary-rescan-group (&optional all)
9873 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9875 (gnus-summary-reselect-current-group all t))
9877 (defun gnus-summary-update-info ()
9878 (let* ((group gnus-newsgroup-name))
9879 (when gnus-newsgroup-kill-headers
9880 (setq gnus-newsgroup-killed
9881 (gnus-compress-sequence
9883 (gnus-set-sorted-intersection
9884 (gnus-uncompress-range gnus-newsgroup-killed)
9885 (setq gnus-newsgroup-unselected
9886 (sort gnus-newsgroup-unselected '<)))
9887 (setq gnus-newsgroup-unreads
9888 (sort gnus-newsgroup-unreads '<))) t)))
9889 (unless (listp (cdr gnus-newsgroup-killed))
9890 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9891 (let ((headers gnus-newsgroup-headers))
9892 (run-hooks 'gnus-exit-group-hook)
9893 (unless gnus-save-score
9894 (setq gnus-newsgroup-scored nil))
9895 ;; Set the new ranges of read articles.
9896 (gnus-update-read-articles
9897 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9898 ;; Set the current article marks.
9900 ;; Do the cross-ref thing.
9901 (when gnus-use-cross-reference
9902 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9903 ;; Do adaptive scoring, and possibly save score files.
9904 (when gnus-newsgroup-adaptive
9905 (gnus-score-adaptive))
9906 (when gnus-use-scoring
9908 ;; Do not switch windows but change the buffer to work.
9909 (set-buffer gnus-group-buffer)
9910 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9911 (gnus-group-update-group group)))))
9913 (defun gnus-summary-exit (&optional temporary)
9914 "Exit reading current newsgroup, and then return to group selection mode.
9915 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9917 (gnus-set-global-variables)
9918 (gnus-kill-save-kill-buffer)
9919 (let* ((group gnus-newsgroup-name)
9920 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9922 (buf (current-buffer)))
9923 (run-hooks 'gnus-summary-prepare-exit-hook)
9924 ;; If we have several article buffers, we kill them at exit.
9925 (unless gnus-single-article-buffer
9926 (gnus-kill-buffer gnus-original-article-buffer)
9927 (setq gnus-article-current nil))
9928 (when gnus-use-cache
9929 (gnus-cache-possibly-remove-articles)
9930 (gnus-cache-save-buffers))
9931 (when gnus-use-trees
9932 (gnus-tree-close group))
9933 ;; Make all changes in this group permanent.
9935 (gnus-summary-update-info))
9936 (gnus-close-group group)
9937 ;; Make sure where I was, and go to next newsgroup.
9938 (set-buffer gnus-group-buffer)
9940 (gnus-group-jump-to-group group))
9941 (run-hooks 'gnus-summary-exit-hook)
9943 (gnus-group-next-unread-group 1))
9946 ;; If we have several article buffers, we kill them at exit.
9947 (unless gnus-single-article-buffer
9948 (gnus-kill-buffer gnus-article-buffer)
9949 (gnus-kill-buffer gnus-original-article-buffer)
9950 (setq gnus-article-current nil))
9952 (if (not gnus-kill-summary-on-exit)
9953 (gnus-deaden-summary)
9954 ;; We set all buffer-local variables to nil. It is unclear why
9955 ;; this is needed, but if we don't, buffer-local variables are
9956 ;; not garbage-collected, it seems. This would the lead to en
9957 ;; ever-growing Emacs.
9958 (gnus-summary-clear-local-variables)
9959 (when (get-buffer gnus-article-buffer)
9960 (bury-buffer gnus-article-buffer))
9961 ;; We clear the global counterparts of the buffer-local
9962 ;; variables as well, just to be on the safe side.
9963 (gnus-configure-windows 'group 'force)
9964 (gnus-summary-clear-local-variables)
9965 ;; Return to group mode buffer.
9966 (if (eq mode 'gnus-summary-mode)
9967 (gnus-kill-buffer buf)))
9968 (setq gnus-current-select-method gnus-select-method)
9969 (pop-to-buffer gnus-group-buffer)
9970 ;; Clear the current group name.
9971 (if (not quit-config)
9973 (gnus-group-jump-to-group group)
9974 (gnus-group-next-unread-group 1)
9975 (gnus-configure-windows 'group 'force))
9976 (if (not (buffer-name (car quit-config)))
9977 (gnus-configure-windows 'group 'force)
9978 (set-buffer (car quit-config))
9979 (and (eq major-mode 'gnus-summary-mode)
9980 (gnus-set-global-variables))
9981 (gnus-configure-windows (cdr quit-config))))
9983 (setq gnus-newsgroup-name nil)))))
9985 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9986 (defun gnus-summary-exit-no-update (&optional no-questions)
9987 "Quit reading current newsgroup without updating read article info."
9989 (gnus-set-global-variables)
9990 (let* ((group gnus-newsgroup-name)
9991 (quit-config (gnus-group-quit-config group)))
9992 (when (or no-questions
9994 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9995 ;; If we have several article buffers, we kill them at exit.
9996 (unless gnus-single-article-buffer
9997 (gnus-kill-buffer gnus-article-buffer)
9998 (gnus-kill-buffer gnus-original-article-buffer)
9999 (setq gnus-article-current nil))
10000 (if (not gnus-kill-summary-on-exit)
10001 (gnus-deaden-summary)
10002 (gnus-close-group group)
10003 (gnus-summary-clear-local-variables)
10004 (set-buffer gnus-group-buffer)
10005 (gnus-summary-clear-local-variables)
10006 (when (get-buffer gnus-summary-buffer)
10007 (kill-buffer gnus-summary-buffer)))
10008 (unless gnus-single-article-buffer
10009 (setq gnus-article-current nil))
10010 (when gnus-use-trees
10011 (gnus-tree-close group))
10012 (when (get-buffer gnus-article-buffer)
10013 (bury-buffer gnus-article-buffer))
10014 ;; Return to the group buffer.
10015 (gnus-configure-windows 'group 'force)
10016 ;; Clear the current group name.
10017 (setq gnus-newsgroup-name nil)
10018 (when (equal (gnus-group-group-name) group)
10019 (gnus-group-next-unread-group 1))
10021 (if (not (buffer-name (car quit-config)))
10022 (gnus-configure-windows 'group 'force)
10023 (set-buffer (car quit-config))
10024 (when (eq major-mode 'gnus-summary-mode)
10025 (gnus-set-global-variables))
10026 (gnus-configure-windows (cdr quit-config)))))))
10028 ;;; Dead summaries.
10030 (defvar gnus-dead-summary-mode-map nil)
10032 (if gnus-dead-summary-mode-map
10034 (setq gnus-dead-summary-mode-map (make-keymap))
10035 (suppress-keymap gnus-dead-summary-mode-map)
10036 (substitute-key-definition
10037 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10038 (let ((keys '("\C-d" "\r" "\177")))
10040 (define-key gnus-dead-summary-mode-map
10041 (pop keys) 'gnus-summary-wake-up-the-dead))))
10043 (defvar gnus-dead-summary-mode nil
10044 "Minor mode for Gnus summary buffers.")
10046 (defun gnus-dead-summary-mode (&optional arg)
10047 "Minor mode for Gnus summary buffers."
10049 (when (eq major-mode 'gnus-summary-mode)
10050 (make-local-variable 'gnus-dead-summary-mode)
10051 (setq gnus-dead-summary-mode
10052 (if (null arg) (not gnus-dead-summary-mode)
10053 (> (prefix-numeric-value arg) 0)))
10054 (when gnus-dead-summary-mode
10055 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10056 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10057 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10058 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10059 minor-mode-map-alist)))))
10061 (defun gnus-deaden-summary ()
10062 "Make the current summary buffer into a dead summary buffer."
10063 ;; Kill any previous dead summary buffer.
10064 (when (and gnus-dead-summary
10065 (buffer-name gnus-dead-summary))
10067 (set-buffer gnus-dead-summary)
10068 (when gnus-dead-summary-mode
10069 (kill-buffer (current-buffer)))))
10070 ;; Make this the current dead summary.
10071 (setq gnus-dead-summary (current-buffer))
10072 (gnus-dead-summary-mode 1)
10073 (let ((name (buffer-name)))
10074 (when (string-match "Summary" name)
10076 (concat (substring name 0 (match-beginning 0)) "Dead "
10077 (substring name (match-beginning 0))) t))))
10079 (defun gnus-kill-or-deaden-summary (buffer)
10080 "Kill or deaden the summary BUFFER."
10081 (when (and (buffer-name buffer)
10082 (not gnus-single-article-buffer))
10084 (set-buffer buffer)
10085 (gnus-kill-buffer gnus-article-buffer)
10086 (gnus-kill-buffer gnus-original-article-buffer)))
10087 (cond (gnus-kill-summary-on-exit
10088 (when (and gnus-use-trees
10089 (and (get-buffer buffer)
10090 (buffer-name (get-buffer buffer))))
10092 (set-buffer (get-buffer buffer))
10093 (gnus-tree-close gnus-newsgroup-name)))
10094 (gnus-kill-buffer buffer))
10095 ((and (get-buffer buffer)
10096 (buffer-name (get-buffer buffer)))
10098 (set-buffer buffer)
10099 (gnus-deaden-summary)))))
10101 (defun gnus-summary-wake-up-the-dead (&rest args)
10102 "Wake up the dead summary buffer."
10104 (gnus-dead-summary-mode -1)
10105 (let ((name (buffer-name)))
10106 (when (string-match "Dead " name)
10108 (concat (substring name 0 (match-beginning 0))
10109 (substring name (match-end 0))) t)))
10110 (gnus-message 3 "This dead summary is now alive again"))
10112 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10113 (defun gnus-summary-fetch-faq (&optional faq-dir)
10114 "Fetch the FAQ for the current group.
10115 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10119 (if current-prefix-arg
10121 "Faq dir: " (and (listp gnus-group-faq-directory)
10122 gnus-group-faq-directory)))))
10123 (let (gnus-faq-buffer)
10124 (and (setq gnus-faq-buffer
10125 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10126 (gnus-configure-windows 'summary-faq))))
10128 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10129 (defun gnus-summary-describe-group (&optional force)
10130 "Describe the current newsgroup."
10132 (gnus-group-describe-group force gnus-newsgroup-name))
10134 (defun gnus-summary-describe-briefly ()
10135 "Describe summary mode commands briefly."
10138 (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")))
10140 ;; Walking around group mode buffer from summary mode.
10142 (defun gnus-summary-next-group (&optional no-article target-group backward)
10143 "Exit current newsgroup and then select next unread newsgroup.
10144 If prefix argument NO-ARTICLE is non-nil, no article is selected
10145 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10146 previous group instead."
10148 (gnus-set-global-variables)
10149 (let ((current-group gnus-newsgroup-name)
10150 (current-buffer (current-buffer))
10152 ;; First we semi-exit this group to update Xrefs and all variables.
10153 ;; We can't do a real exit, because the window conf must remain
10154 ;; the same in case the user is prompted for info, and we don't
10155 ;; want the window conf to change before that...
10156 (gnus-summary-exit t)
10157 (while (not entered)
10158 ;; Then we find what group we are supposed to enter.
10159 (set-buffer gnus-group-buffer)
10160 (gnus-group-jump-to-group current-group)
10163 (if (eq gnus-keep-same-level 'best)
10164 (gnus-summary-best-group gnus-newsgroup-name)
10165 (gnus-summary-search-group backward gnus-keep-same-level))))
10166 (if (not target-group)
10167 ;; There are no further groups, so we return to the group
10170 (gnus-message 5 "Returning to the group buffer")
10172 (set-buffer current-buffer)
10173 (gnus-summary-exit))
10174 ;; We try to enter the target group.
10175 (gnus-group-jump-to-group target-group)
10176 (let ((unreads (gnus-group-group-unread)))
10177 (if (and (or (eq t unreads)
10178 (and unreads (not (zerop unreads))))
10179 (gnus-summary-read-group
10180 target-group nil no-article current-buffer))
10182 (setq current-group target-group
10183 target-group nil)))))))
10185 (defun gnus-summary-prev-group (&optional no-article)
10186 "Exit current newsgroup and then select previous unread newsgroup.
10187 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10189 (gnus-summary-next-group no-article nil t))
10191 ;; Walking around summary lines.
10193 (defun gnus-summary-first-subject (&optional unread)
10194 "Go to the first unread subject.
10195 If UNREAD is non-nil, go to the first unread article.
10196 Returns the article selected or nil if there are no unread articles."
10201 ((null gnus-newsgroup-data)
10202 (gnus-message 3 "No articles in the group")
10204 ;; Pick the first article.
10206 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10207 (gnus-data-number (car gnus-newsgroup-data)))
10208 ;; No unread articles.
10209 ((null gnus-newsgroup-unreads)
10210 (gnus-message 3 "No more unread articles")
10212 ;; Find the first unread article.
10214 (let ((data gnus-newsgroup-data))
10216 (not (gnus-data-unread-p (car data))))
10217 (setq data (cdr data)))
10220 (goto-char (gnus-data-pos (car data)))
10221 (gnus-data-number (car data)))))))
10222 (gnus-summary-position-point)))
10224 (defun gnus-summary-next-subject (n &optional unread dont-display)
10225 "Go to next N'th summary line.
10226 If N is negative, go to the previous N'th subject line.
10227 If UNREAD is non-nil, only unread articles are selected.
10228 The difference between N and the actual number of steps taken is
10231 (let ((backward (< n 0))
10233 (while (and (> n 0)
10235 (gnus-summary-find-prev unread)
10236 (gnus-summary-find-next unread)))
10238 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10239 (if unread " unread" "")))
10240 (unless dont-display
10241 (gnus-summary-recenter)
10242 (gnus-summary-position-point))
10245 (defun gnus-summary-next-unread-subject (n)
10246 "Go to next N'th unread summary line."
10248 (gnus-summary-next-subject n t))
10250 (defun gnus-summary-prev-subject (n &optional unread)
10251 "Go to previous N'th summary line.
10252 If optional argument UNREAD is non-nil, only unread article is selected."
10254 (gnus-summary-next-subject (- n) unread))
10256 (defun gnus-summary-prev-unread-subject (n)
10257 "Go to previous N'th unread summary line."
10259 (gnus-summary-next-subject (- n) t))
10261 (defun gnus-summary-goto-subject (article &optional force silent)
10262 "Go the subject line of ARTICLE.
10263 If FORCE, also allow jumping to articles not currently shown."
10265 (data (gnus-data-find article)))
10266 ;; We read in the article if we have to.
10269 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10270 (setq data (gnus-data-find article)))
10275 (gnus-message 3 "Can't find article %d" article))
10277 (goto-char (gnus-data-pos data))
10280 ;; Walking around summary lines with displaying articles.
10282 (defun gnus-summary-expand-window (&optional arg)
10283 "Make the summary buffer take up the entire Emacs frame.
10284 Given a prefix, will force an `article' buffer configuration."
10286 (gnus-set-global-variables)
10288 (gnus-configure-windows 'article 'force)
10289 (gnus-configure-windows 'summary 'force)))
10291 (defun gnus-summary-display-article (article &optional all-header)
10292 "Display ARTICLE in article buffer."
10293 (gnus-set-global-variables)
10297 (if gnus-summary-display-article-function
10298 (funcall gnus-summary-display-article-function article all-header)
10299 (gnus-article-prepare article all-header))
10300 (run-hooks 'gnus-select-article-hook)
10301 (unless (zerop gnus-current-article)
10302 (gnus-summary-goto-subject gnus-current-article))
10303 (gnus-summary-recenter)
10304 (when gnus-use-trees
10305 (gnus-possibly-generate-tree article)
10306 (gnus-highlight-selected-tree article))
10307 ;; Successfully display article.
10308 (gnus-article-set-window-start
10309 (cdr (assq article gnus-newsgroup-bookmarks))))))
10311 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10312 "Select the current article.
10313 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10314 non-nil, the article will be re-fetched even if it already present in
10315 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10317 ;; Make sure we are in the summary buffer to work around bbdb bug.
10318 (unless (eq major-mode 'gnus-summary-mode)
10319 (set-buffer gnus-summary-buffer))
10320 (let ((article (or article (gnus-summary-article-number)))
10321 (all-headers (not (not all-headers))) ;Must be T or NIL.
10322 gnus-summary-display-article-function
10325 (gnus-summary-article-pseudo-p article)
10326 (error "This is a pseudo-article."))
10329 (set-buffer gnus-summary-buffer)
10330 (if (or (and gnus-single-article-buffer
10331 (or (null gnus-current-article)
10332 (null gnus-article-current)
10333 (null (get-buffer gnus-article-buffer))
10334 (not (eq article (cdr gnus-article-current)))
10335 (not (equal (car gnus-article-current)
10336 gnus-newsgroup-name))))
10337 (and (not gnus-single-article-buffer)
10338 (or (null gnus-current-article)
10339 (not (eq gnus-current-article article))))
10341 ;; The requested article is different from the current article.
10343 (gnus-summary-display-article article all-headers)
10344 (setq did article))
10345 (if (or all-headers gnus-show-all-headers)
10346 (gnus-article-show-all-headers))
10349 (gnus-article-set-window-start
10350 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10352 (defun gnus-summary-set-current-mark (&optional current-mark)
10353 "Obsolete function."
10356 (defun gnus-summary-next-article (&optional unread subject backward push)
10357 "Select the next article.
10358 If UNREAD, only unread articles are selected.
10359 If SUBJECT, only articles with SUBJECT are selected.
10360 If BACKWARD, the previous article is selected instead of the next."
10362 (gnus-set-global-variables)
10364 ;; Is there such an article?
10365 ((and (gnus-summary-search-forward unread subject backward)
10366 (or (gnus-summary-display-article (gnus-summary-article-number))
10367 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10368 (gnus-summary-position-point))
10369 ;; If not, we try the first unread, if that is wanted.
10371 gnus-auto-select-same
10372 (or (gnus-summary-first-unread-article)
10373 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10374 (gnus-summary-position-point)
10375 (gnus-message 6 "Wrapped"))
10376 ;; Try to get next/previous article not displayed in this group.
10377 ((and gnus-auto-extend-newsgroup
10378 (not unread) (not subject))
10379 (gnus-summary-goto-article
10380 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10382 ;; Go to next/previous group.
10384 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10385 (gnus-summary-jump-to-group gnus-newsgroup-name))
10386 (let ((cmd last-command-char)
10388 (if (eq gnus-keep-same-level 'best)
10389 (gnus-summary-best-group gnus-newsgroup-name)
10390 (gnus-summary-search-group backward gnus-keep-same-level))))
10391 ;; For some reason, the group window gets selected. We change
10393 (select-window (get-buffer-window (current-buffer)))
10394 ;; Select next unread newsgroup automagically.
10396 ((not gnus-auto-select-next)
10397 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10398 ((or (eq gnus-auto-select-next 'quietly)
10399 (and (eq gnus-auto-select-next 'slightly-quietly)
10401 (and (eq gnus-auto-select-next 'almost-quietly)
10402 (gnus-summary-last-article-p)))
10404 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10405 (gnus-summary-exit)
10406 (gnus-message 7 "No more%s articles (%s)..."
10407 (if unread " unread" "")
10408 (if group (concat "selecting " group)
10410 (gnus-summary-next-group nil group backward)))
10412 (gnus-summary-walk-group-buffer
10413 gnus-newsgroup-name cmd unread backward)))))))
10415 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10416 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10417 (?\C-p (gnus-group-prev-unread-group 1))))
10418 keve key group ended)
10420 (set-buffer gnus-group-buffer)
10421 (gnus-summary-jump-to-group from-group)
10423 (if (eq gnus-keep-same-level 'best)
10424 (gnus-summary-best-group gnus-newsgroup-name)
10425 (gnus-summary-search-group backward gnus-keep-same-level))))
10428 5 "No more%s articles%s" (if unread " unread" "")
10430 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10431 (format " (Type %s for %s [%s])"
10432 (single-key-description cmd) group
10433 (car (gnus-gethash group gnus-newsrc-hashtb)))
10434 (format " (Type %s to exit %s)"
10435 (single-key-description cmd)
10436 gnus-newsgroup-name)))
10437 ;; Confirm auto selection.
10438 (setq key (car (setq keve (gnus-read-event-char))))
10441 ((assq key keystrokes)
10442 (let ((obuf (current-buffer)))
10443 (switch-to-buffer gnus-group-buffer)
10445 (gnus-group-jump-to-group group))
10446 (eval (cadr (assq key keystrokes)))
10447 (setq group (gnus-group-group-name))
10448 (switch-to-buffer obuf))
10451 (if (or (not group)
10452 (gnus-ephemeral-group-p gnus-newsgroup-name))
10453 (gnus-summary-exit)
10454 (gnus-summary-next-group nil group backward)))
10456 (push (cdr keve) unread-command-events))))))
10458 (defun gnus-read-event-char ()
10459 "Get the next event."
10460 (let ((event (read-event)))
10461 (cons (and (numberp event) event) event)))
10463 (defun gnus-summary-next-unread-article ()
10464 "Select unread article after current one."
10466 (gnus-summary-next-article t (and gnus-auto-select-same
10467 (gnus-summary-article-subject))))
10469 (defun gnus-summary-prev-article (&optional unread subject)
10470 "Select the article after the current one.
10471 If UNREAD is non-nil, only unread articles are selected."
10473 (gnus-summary-next-article unread subject t))
10475 (defun gnus-summary-prev-unread-article ()
10476 "Select unred article before current one."
10478 (gnus-summary-prev-article t (and gnus-auto-select-same
10479 (gnus-summary-article-subject))))
10481 (defun gnus-summary-next-page (&optional lines circular)
10482 "Show next page of the selected article.
10483 If at the end of the current article, select the next article.
10484 LINES says how many lines should be scrolled up.
10486 If CIRCULAR is non-nil, go to the start of the article instead of
10487 selecting the next article when reaching the end of the current
10490 (setq gnus-summary-buffer (current-buffer))
10491 (gnus-set-global-variables)
10492 (let ((article (gnus-summary-article-number))
10494 (gnus-configure-windows 'article)
10495 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10496 (if (and (eq gnus-summary-goto-unread 'never)
10497 (not (gnus-summary-last-article-p article)))
10498 (gnus-summary-next-article)
10499 (gnus-summary-next-unread-article))
10500 (if (or (null gnus-current-article)
10501 (null gnus-article-current)
10502 (/= article (cdr gnus-article-current))
10503 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10504 ;; Selected subject is different from current article's.
10505 (gnus-summary-display-article article)
10506 (gnus-eval-in-buffer-window gnus-article-buffer
10507 (setq endp (gnus-article-next-page lines)))
10510 (gnus-summary-beginning-of-article))
10512 (gnus-message 3 "End of message"))
10514 (if (and (eq gnus-summary-goto-unread 'never)
10515 (not (gnus-summary-last-article-p article)))
10516 (gnus-summary-next-article)
10517 (gnus-summary-next-unread-article)))))))
10518 (gnus-summary-recenter)
10519 (gnus-summary-position-point)))
10521 (defun gnus-summary-prev-page (&optional lines)
10522 "Show previous page of selected article.
10523 Argument LINES specifies lines to be scrolled down."
10525 (gnus-set-global-variables)
10526 (let ((article (gnus-summary-article-number)))
10527 (gnus-configure-windows 'article)
10528 (if (or (null gnus-current-article)
10529 (null gnus-article-current)
10530 (/= article (cdr gnus-article-current))
10531 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10532 ;; Selected subject is different from current article's.
10533 (gnus-summary-display-article article)
10534 (gnus-summary-recenter)
10535 (gnus-eval-in-buffer-window gnus-article-buffer
10536 (gnus-article-prev-page lines))))
10537 (gnus-summary-position-point))
10539 (defun gnus-summary-scroll-up (lines)
10540 "Scroll up (or down) one line current article.
10541 Argument LINES specifies lines to be scrolled up (or down if negative)."
10543 (gnus-set-global-variables)
10544 (gnus-configure-windows 'article)
10545 (gnus-summary-show-thread)
10546 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10547 (gnus-eval-in-buffer-window gnus-article-buffer
10549 (if (gnus-article-next-page lines)
10550 (gnus-message 3 "End of message")))
10552 (gnus-article-prev-page (- lines))))))
10553 (gnus-summary-recenter)
10554 (gnus-summary-position-point))
10556 (defun gnus-summary-next-same-subject ()
10557 "Select next article which has the same subject as current one."
10559 (gnus-set-global-variables)
10560 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10562 (defun gnus-summary-prev-same-subject ()
10563 "Select previous article which has the same subject as current one."
10565 (gnus-set-global-variables)
10566 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10568 (defun gnus-summary-next-unread-same-subject ()
10569 "Select next unread article which has the same subject as current one."
10571 (gnus-set-global-variables)
10572 (gnus-summary-next-article t (gnus-summary-article-subject)))
10574 (defun gnus-summary-prev-unread-same-subject ()
10575 "Select previous unread article which has the same subject as current one."
10577 (gnus-set-global-variables)
10578 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10580 (defun gnus-summary-first-unread-article ()
10581 "Select the first unread article.
10582 Return nil if there are no unread articles."
10584 (gnus-set-global-variables)
10586 (if (gnus-summary-first-subject t)
10588 (gnus-summary-show-thread)
10589 (gnus-summary-first-subject t)
10590 (gnus-summary-display-article (gnus-summary-article-number))))
10591 (gnus-summary-position-point)))
10593 (defun gnus-summary-best-unread-article ()
10594 "Select the unread article with the highest score."
10596 (gnus-set-global-variables)
10597 (let ((best -1000000)
10598 (data gnus-newsgroup-data)
10601 (and (gnus-data-unread-p (car data))
10603 (gnus-summary-article-score (gnus-data-number (car data))))
10606 article (gnus-data-number (car data))))
10607 (setq data (cdr data)))
10610 (gnus-summary-goto-article article)
10611 (error "No unread articles"))
10612 (gnus-summary-position-point))))
10614 (defun gnus-summary-last-subject ()
10615 "Go to the last displayed subject line in the group."
10616 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10618 (gnus-summary-goto-subject article))))
10620 (defun gnus-summary-goto-article (article &optional all-headers force)
10621 "Fetch ARTICLE and display it if it exists.
10622 If ALL-HEADERS is non-nil, no header lines are hidden."
10628 (mapcar (lambda (number) (list (int-to-string number)))
10629 gnus-newsgroup-limit)))
10633 (if (gnus-summary-goto-subject article force)
10634 (gnus-summary-display-article article all-headers)
10635 (gnus-message 4 "Couldn't go to article %s" article) nil)
10636 (gnus-summary-position-point)))
10638 (defun gnus-summary-goto-last-article ()
10639 "Go to the previously read article."
10642 (and gnus-last-article
10643 (gnus-summary-goto-article gnus-last-article))
10644 (gnus-summary-position-point)))
10646 (defun gnus-summary-pop-article (number)
10647 "Pop one article off the history and go to the previous.
10648 NUMBER articles will be popped off."
10651 (setq gnus-newsgroup-history
10652 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10654 (gnus-summary-goto-article (car to))
10655 (error "Article history empty")))
10656 (gnus-summary-position-point))
10658 ;; Summary commands and functions for limiting the summary buffer.
10660 (defun gnus-summary-limit-to-articles (n)
10661 "Limit the summary buffer to the next N articles.
10662 If not given a prefix, use the process marked articles instead."
10664 (gnus-set-global-variables)
10666 (let ((articles (gnus-summary-work-articles n)))
10667 (setq gnus-newsgroup-processable nil)
10668 (gnus-summary-limit articles))
10669 (gnus-summary-position-point)))
10671 (defun gnus-summary-pop-limit (&optional total)
10672 "Restore the previous limit.
10673 If given a prefix, remove all limits."
10675 (gnus-set-global-variables)
10677 (setq gnus-newsgroup-limits
10678 (list (mapcar (lambda (h) (mail-header-number h))
10679 gnus-newsgroup-headers))))
10680 (unless gnus-newsgroup-limits
10681 (error "No limit to pop"))
10683 (gnus-summary-limit nil 'pop)
10684 (gnus-summary-position-point)))
10686 (defun gnus-summary-limit-to-subject (subject &optional header)
10687 "Limit the summary buffer to articles that have subjects that match a regexp."
10688 (interactive "sRegexp: ")
10690 (setq header "subject"))
10691 (when (not (equal "" subject))
10693 (let ((articles (gnus-summary-find-matching
10694 (or header "subject") subject 'all)))
10695 (or articles (error "Found no matches for \"%s\"" subject))
10696 (gnus-summary-limit articles))
10697 (gnus-summary-position-point))))
10699 (defun gnus-summary-limit-to-author (from)
10700 "Limit the summary buffer to articles that have authors that match a regexp."
10701 (interactive "sRegexp: ")
10702 (gnus-summary-limit-to-subject from "from"))
10704 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10706 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10708 (defun gnus-summary-limit-to-unread (&optional all)
10709 "Limit the summary buffer to articles that are not marked as read.
10710 If ALL is non-nil, limit strictly to unread articles."
10713 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10714 (gnus-summary-limit-to-marks
10715 ;; Concat all the marks that say that an article is read and have
10717 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10718 gnus-killed-mark gnus-kill-file-mark
10719 gnus-low-score-mark gnus-expirable-mark
10720 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10723 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10724 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10726 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10727 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10728 If REVERSE, limit the summary buffer to articles that are not marked
10729 with MARKS. MARKS can either be a string of marks or a list of marks.
10730 Returns how many articles were removed."
10731 (interactive "sMarks: ")
10732 (gnus-set-global-variables)
10734 (let ((data gnus-newsgroup-data)
10735 (marks (if (listp marks) marks
10736 (append marks nil))) ; Transform to list.
10739 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10740 (memq (gnus-data-mark (car data)) marks))
10741 (setq articles (cons (gnus-data-number (car data)) articles)))
10742 (setq data (cdr data)))
10743 (gnus-summary-limit articles))
10744 (gnus-summary-position-point)))
10746 (defun gnus-summary-limit-to-score (&optional score)
10747 "Limit to articles with score at or above SCORE."
10749 (gnus-set-global-variables)
10750 (setq score (if score
10751 (prefix-numeric-value score)
10752 (or gnus-summary-default-score 0)))
10753 (let ((data gnus-newsgroup-data)
10756 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10758 (push (gnus-data-number (car data)) articles))
10759 (setq data (cdr data)))
10761 (gnus-summary-limit articles)
10762 (gnus-summary-position-point))))
10764 (defun gnus-summary-limit-include-dormant ()
10765 "Display all the hidden articles that are marked as dormant."
10767 (gnus-set-global-variables)
10768 (or gnus-newsgroup-dormant
10769 (error "There are no dormant articles in this group"))
10771 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10772 (gnus-summary-position-point)))
10774 (defun gnus-summary-limit-exclude-dormant ()
10775 "Hide all dormant articles."
10777 (gnus-set-global-variables)
10779 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10780 (gnus-summary-position-point)))
10782 (defun gnus-summary-limit-exclude-childless-dormant ()
10783 "Hide all dormant articles that have no children."
10785 (gnus-set-global-variables)
10786 (let ((data (gnus-data-list t))
10787 articles d children)
10788 ;; Find all articles that are either not dormant or have
10790 (while (setq d (pop data))
10791 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10792 (and (setq children
10793 (gnus-article-children (gnus-data-number d)))
10796 (when (memq (car children) articles)
10801 (push (gnus-data-number d) articles)))
10802 ;; Do the limiting.
10804 (gnus-summary-limit articles)
10805 (gnus-summary-position-point))))
10807 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10808 "Mark all unread excluded articles as read.
10809 If ALL, mark even excluded ticked and dormants as read."
10811 (let ((articles (gnus-sorted-complement
10813 (mapcar (lambda (h) (mail-header-number h))
10814 gnus-newsgroup-headers)
10816 (sort gnus-newsgroup-limit '<)))
10818 (setq gnus-newsgroup-unreads nil)
10820 (setq gnus-newsgroup-dormant nil
10821 gnus-newsgroup-marked nil
10822 gnus-newsgroup-reads
10824 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10825 gnus-newsgroup-reads))
10826 (while (setq article (pop articles))
10827 (unless (or (memq article gnus-newsgroup-dormant)
10828 (memq article gnus-newsgroup-marked))
10829 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10831 (defun gnus-summary-limit (articles &optional pop)
10833 ;; We pop the previous limit off the stack and use that.
10834 (setq articles (car gnus-newsgroup-limits)
10835 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10836 ;; We use the new limit, so we push the old limit on the stack.
10837 (setq gnus-newsgroup-limits
10838 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10840 (setq gnus-newsgroup-limit articles)
10841 (let ((total (length gnus-newsgroup-data))
10842 (data (gnus-data-find-list (gnus-summary-article-number)))
10844 ;; This will do all the work of generating the new summary buffer
10845 ;; according to the new limit.
10846 (gnus-summary-prepare)
10847 ;; Hide any threads, possibly.
10848 (and gnus-show-threads
10849 gnus-thread-hide-subtree
10850 (gnus-summary-hide-all-threads))
10851 ;; Try to return to the article you were at, or one in the
10854 ;; We try to find some article after the current one.
10856 (and (gnus-summary-goto-subject
10857 (gnus-data-number (car data)) nil t)
10860 (setq data (cdr data))))
10862 ;; If there is no data, that means that we were after the last
10863 ;; article. The same goes when we can't find any articles
10864 ;; after the current one.
10866 (goto-char (point-max))
10867 (gnus-summary-find-prev)))
10868 ;; We return how many articles were removed from the summary
10869 ;; buffer as a result of the new limit.
10870 (- total (length gnus-newsgroup-data))))
10872 (defsubst gnus-invisible-cut-children (threads)
10875 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10880 (defsubst gnus-cut-thread (thread)
10881 "Go forwards in the thread until we find an article that we want to display."
10882 (when (or (eq gnus-fetch-old-headers 'some)
10883 (eq gnus-build-sparse-threads 'some)
10884 (eq gnus-build-sparse-threads 'more))
10885 ;; Deal with old-fetched headers and sparse threads.
10889 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10890 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10891 (or (<= (length (cdr thread)) 1)
10892 (gnus-invisible-cut-children (cdr thread))))
10893 (setq thread (cadr thread))))
10896 (defun gnus-cut-threads (threads)
10897 "Cut off all uninteresting articles from the beginning of threads."
10898 (when (or (eq gnus-fetch-old-headers 'some)
10899 (eq gnus-build-sparse-threads 'some)
10900 (eq gnus-build-sparse-threads 'more))
10901 (let ((th threads))
10903 (setcar th (gnus-cut-thread (car th)))
10904 (setq th (cdr th)))))
10905 ;; Remove nixed out threads.
10906 (delq nil threads))
10908 (defun gnus-summary-initial-limit (&optional show-if-empty)
10909 "Figure out what the initial limit is supposed to be on group entry.
10910 This entails weeding out unwanted dormants, low-scored articles,
10911 fetch-old-headers verbiage, and so on."
10912 ;; Most groups have nothing to remove.
10913 (if (or gnus-inhibit-limiting
10914 (and (null gnus-newsgroup-dormant)
10915 (not (eq gnus-fetch-old-headers 'some))
10916 (null gnus-summary-expunge-below)
10917 (not (eq gnus-build-sparse-threads 'some))
10918 (not (eq gnus-build-sparse-threads 'more))
10919 (null gnus-thread-expunge-below)
10920 (not gnus-use-nocem)))
10922 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10923 (setq gnus-newsgroup-limit nil)
10926 (unless (car (symbol-value node))
10927 ;; These threads have no parents -- they are roots.
10928 (let ((nodes (cdr (symbol-value node)))
10931 (if (and gnus-thread-expunge-below
10932 (< (gnus-thread-total-score (car nodes))
10933 gnus-thread-expunge-below))
10934 (gnus-expunge-thread (pop nodes))
10935 (setq thread (pop nodes))
10936 (gnus-summary-limit-children thread))))))
10937 gnus-newsgroup-dependencies)
10938 ;; If this limitation resulted in an empty group, we might
10939 ;; pop the previous limit and use it instead.
10940 (when (and (not gnus-newsgroup-limit)
10942 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10943 gnus-newsgroup-limit))
10945 (defun gnus-summary-limit-children (thread)
10946 "Return 1 if this subthread is visible and 0 if it is not."
10947 ;; First we get the number of visible children to this thread. This
10948 ;; is done by recursing down the thread using this function, so this
10949 ;; will really go down to a leaf article first, before slowly
10950 ;; working its way up towards the root.
10954 (apply '+ (mapcar 'gnus-summary-limit-children
10957 (number (mail-header-number (car thread)))
10960 ;; If this article is dormant and has absolutely no visible
10961 ;; children, then this article isn't visible.
10962 (and (memq number gnus-newsgroup-dormant)
10964 ;; If this is "fetch-old-headered" and there is only one
10965 ;; visible child (or less), then we don't want this article.
10966 (and (eq gnus-fetch-old-headers 'some)
10967 (memq number gnus-newsgroup-ancient)
10969 ;; If this is a sparsely inserted article with no children,
10970 ;; we don't want it.
10971 (and (eq gnus-build-sparse-threads 'some)
10972 (memq number gnus-newsgroup-sparse)
10974 ;; If we use expunging, and this article is really
10975 ;; low-scored, then we don't want this article.
10976 (when (and gnus-summary-expunge-below
10978 (or (cdr (assq number gnus-newsgroup-scored))
10979 gnus-summary-default-score))
10980 gnus-summary-expunge-below))
10981 ;; We increase the expunge-tally here, but that has
10982 ;; nothing to do with the limits, really.
10983 (incf gnus-newsgroup-expunged-tally)
10984 ;; We also mark as read here, if that's wanted.
10985 (when (and gnus-summary-mark-below
10986 (< score gnus-summary-mark-below))
10987 (setq gnus-newsgroup-unreads
10988 (delq number gnus-newsgroup-unreads))
10989 (if gnus-newsgroup-auto-expire
10990 (push number gnus-newsgroup-expirable)
10991 (push (cons number gnus-low-score-mark)
10992 gnus-newsgroup-reads)))
10994 (and gnus-use-nocem
10995 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10996 ;; Nope, invisible article.
10998 ;; Ok, this article is to be visible, so we add it to the limit
11000 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11003 (defun gnus-expunge-thread (thread)
11004 "Mark all articles in THREAD as read."
11005 (let* ((number (mail-header-number (car thread))))
11006 (incf gnus-newsgroup-expunged-tally)
11007 ;; We also mark as read here, if that's wanted.
11008 (setq gnus-newsgroup-unreads
11009 (delq number gnus-newsgroup-unreads))
11010 (if gnus-newsgroup-auto-expire
11011 (push number gnus-newsgroup-expirable)
11012 (push (cons number gnus-low-score-mark)
11013 gnus-newsgroup-reads)))
11014 ;; Go recursively through all subthreads.
11015 (mapcar 'gnus-expunge-thread (cdr thread)))
11017 ;; Summary article oriented commands
11019 (defun gnus-summary-refer-parent-article (n)
11020 "Refer parent article N times.
11021 The difference between N and the number of articles fetched is returned."
11023 (gnus-set-global-variables)
11027 (let* ((header (gnus-summary-article-header))
11029 ;; If we try to find the parent of the currently
11030 ;; displayed article, then we take a look at the actual
11031 ;; References header, since this is slightly more
11032 ;; reliable than the References field we got from the
11034 (if (and (eq (mail-header-number header)
11035 (cdr gnus-article-current))
11036 (equal gnus-newsgroup-name
11037 (car gnus-article-current)))
11039 (set-buffer gnus-original-article-buffer)
11040 (nnheader-narrow-to-headers)
11042 (message-fetch-field "references")
11044 ;; It's not the current article, so we take a bet on
11045 ;; the value we got from the server.
11046 (mail-header-references header))))
11047 (if (setq ref (or ref (mail-header-references header)))
11048 (or (gnus-summary-refer-article (gnus-parent-id ref))
11049 (gnus-message 1 "Couldn't find parent"))
11050 (gnus-message 1 "No references in article %d"
11051 (gnus-summary-article-number))
11054 (gnus-summary-position-point)
11057 (defun gnus-summary-refer-references ()
11058 "Fetch all articles mentioned in the References header.
11059 Return how many articles were fetched."
11061 (gnus-set-global-variables)
11062 (let ((ref (mail-header-references (gnus-summary-article-header)))
11063 (current (gnus-summary-article-number))
11065 ;; For each Message-ID in the References header...
11066 (while (string-match "<[^>]*>" ref)
11068 ;; ... fetch that article.
11069 (gnus-summary-refer-article
11070 (prog1 (match-string 0 ref)
11071 (setq ref (substring ref (match-end 0))))))
11072 (gnus-summary-goto-subject current)
11073 (gnus-summary-position-point)
11076 (defun gnus-summary-refer-article (message-id)
11077 "Fetch an article specified by MESSAGE-ID."
11078 (interactive "sMessage-ID: ")
11079 (when (and (stringp message-id)
11080 (not (zerop (length message-id))))
11081 ;; Construct the correct Message-ID if necessary.
11082 ;; Suggested by tale@pawl.rpi.edu.
11083 (unless (string-match "^<" message-id)
11084 (setq message-id (concat "<" message-id)))
11085 (unless (string-match ">$" message-id)
11086 (setq message-id (concat message-id ">")))
11087 (let* ((header (gnus-id-to-header message-id))
11088 (sparse (and header
11089 (memq (mail-header-number header)
11090 gnus-newsgroup-sparse))))
11093 ;; The article is present in the buffer, to we just go to it.
11094 (gnus-summary-goto-article
11095 (mail-header-number header) nil header)
11097 (gnus-summary-update-article (mail-header-number header))))
11098 ;; We fetch the article
11099 (let ((gnus-override-method
11100 (and (gnus-news-group-p gnus-newsgroup-name)
11101 gnus-refer-article-method))
11103 ;; Start the special refer-article method, if necessary.
11104 (when (and gnus-refer-article-method
11105 (gnus-news-group-p gnus-newsgroup-name))
11106 (gnus-check-server gnus-refer-article-method))
11107 ;; Fetch the header, and display the article.
11108 (if (setq number (gnus-summary-insert-subject message-id))
11109 (gnus-summary-select-article nil nil nil number)
11110 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11112 (defun gnus-summary-enter-digest-group (&optional force)
11113 "Enter a digest group based on the current article."
11115 (gnus-set-global-variables)
11116 (gnus-summary-select-article)
11117 (let ((name (format "%s-%d"
11118 (gnus-group-prefixed-name
11119 gnus-newsgroup-name (list 'nndoc ""))
11120 gnus-current-article))
11121 (ogroup gnus-newsgroup-name)
11122 (case-fold-search t)
11123 (buf (current-buffer))
11126 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11127 (insert-buffer-substring gnus-original-article-buffer)
11129 (goto-char (point-min))
11130 (or (search-forward "\n\n" nil t) (point)))
11131 (goto-char (point-min))
11132 (delete-matching-lines "^\\(Path\\):\\|^From ")
11135 (if (gnus-group-read-ephemeral-group
11136 name `(nndoc ,name (nndoc-address
11138 (nndoc-article-type ,(if force 'digest 'guess))) t)
11139 ;; Make all postings to this group go to the parent group.
11140 (nconc (gnus-info-params (gnus-get-info name))
11141 (list (cons 'to-group ogroup)))
11142 ;; Couldn't select this doc group.
11143 (switch-to-buffer buf)
11144 (gnus-set-global-variables)
11145 (gnus-configure-windows 'summary)
11146 (gnus-message 3 "Article couldn't be entered?"))
11147 (kill-buffer dig))))
11149 (defun gnus-summary-isearch-article (&optional regexp-p)
11150 "Do incremental search forward on the current article.
11151 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11153 (gnus-set-global-variables)
11154 (gnus-summary-select-article)
11155 (gnus-configure-windows 'article)
11156 (gnus-eval-in-buffer-window gnus-article-buffer
11157 (goto-char (point-min))
11158 (isearch-forward regexp-p)))
11160 (defun gnus-summary-search-article-forward (regexp &optional backward)
11161 "Search for an article containing REGEXP forward.
11162 If BACKWARD, search backward instead."
11165 (format "Search article %s (regexp%s): "
11166 (if current-prefix-arg "backward" "forward")
11167 (if gnus-last-search-regexp
11168 (concat ", default " gnus-last-search-regexp)
11170 current-prefix-arg))
11171 (gnus-set-global-variables)
11172 (if (string-equal regexp "")
11173 (setq regexp (or gnus-last-search-regexp ""))
11174 (setq gnus-last-search-regexp regexp))
11175 (unless (gnus-summary-search-article regexp backward)
11176 (error "Search failed: \"%s\"" regexp)))
11178 (defun gnus-summary-search-article-backward (regexp)
11179 "Search for an article containing REGEXP backward."
11182 (format "Search article backward (regexp%s): "
11183 (if gnus-last-search-regexp
11184 (concat ", default " gnus-last-search-regexp)
11186 (gnus-summary-search-article-forward regexp 'backward))
11188 (defun gnus-summary-search-article (regexp &optional backward)
11189 "Search for an article containing REGEXP.
11190 Optional argument BACKWARD means do search for backward.
11191 `gnus-select-article-hook' is not called during the search."
11192 (let ((gnus-select-article-hook nil) ;Disable hook.
11193 (gnus-article-display-hook nil)
11194 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11197 're-search-backward 're-search-forward))
11198 (sum (current-buffer))
11200 (gnus-save-hidden-threads
11201 (gnus-summary-select-article)
11202 (set-buffer gnus-article-buffer)
11204 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11206 (re-search-backward regexp nil t)
11207 (re-search-forward regexp nil t))
11208 ;; We found the regexp.
11210 (setq found 'found)
11211 (beginning-of-line)
11213 (get-buffer-window (current-buffer))
11217 ;; We didn't find it, so we go to the next article.
11219 (if (not (if backward (gnus-summary-find-prev)
11220 (gnus-summary-find-next)))
11221 ;; No more articles.
11223 ;; Select the next article and adjust point.
11224 (gnus-summary-select-article)
11225 (set-buffer gnus-article-buffer)
11227 (goto-char (if backward (point-max) (point-min))))))
11228 (gnus-message 7 ""))
11229 ;; Return whether we found the regexp.
11230 (when (eq found 'found)
11231 (gnus-summary-show-thread)
11232 (gnus-summary-goto-subject gnus-current-article)
11233 (gnus-summary-position-point)
11236 (defun gnus-summary-find-matching (header regexp &optional backward unread
11238 "Return a list of all articles that match REGEXP on HEADER.
11239 The search stars on the current article and goes forwards unless
11240 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11241 If UNREAD is non-nil, only unread articles will
11242 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11243 in the comparisons."
11244 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11245 (gnus-data-find-list
11246 (gnus-summary-article-number) (gnus-data-list backward))))
11247 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11248 (case-fold-search (not not-case-fold))
11250 (or (fboundp (intern (concat "mail-header-" header)))
11251 (error "%s is not a valid header" header))
11253 (setq d (car data))
11254 (and (or (not unread) ; We want all articles...
11255 (gnus-data-unread-p d)) ; Or just unreads.
11256 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11257 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11258 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11259 (setq data (cdr data)))
11260 (nreverse articles)))
11262 (defun gnus-summary-execute-command (header regexp command &optional backward)
11263 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11264 If HEADER is an empty string (or nil), the match is done on the entire
11265 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11267 (list (let ((completion-ignore-case t))
11270 (mapcar (lambda (string) (list string))
11271 '("Number" "Subject" "From" "Lines" "Date"
11272 "Message-ID" "Xref" "References" "Body"))
11273 nil 'require-match))
11274 (read-string "Regexp: ")
11275 (read-key-sequence "Command: ")
11276 current-prefix-arg))
11277 (when (equal header "Body")
11279 (gnus-set-global-variables)
11280 ;; Hidden thread subtrees must be searched as well.
11281 (gnus-summary-show-all-threads)
11282 ;; We don't want to change current point nor window configuration.
11284 (save-window-excursion
11285 (gnus-message 6 "Executing %s..." (key-description command))
11286 ;; We'd like to execute COMMAND interactively so as to give arguments.
11287 (gnus-execute header regexp
11288 `(lambda () (call-interactively ',(key-binding command)))
11290 (gnus-message 6 "Executing %s...done" (key-description command)))))
11292 (defun gnus-summary-beginning-of-article ()
11293 "Scroll the article back to the beginning."
11295 (gnus-set-global-variables)
11296 (gnus-summary-select-article)
11297 (gnus-configure-windows 'article)
11298 (gnus-eval-in-buffer-window gnus-article-buffer
11300 (goto-char (point-min))
11301 (and gnus-break-pages (gnus-narrow-to-page))))
11303 (defun gnus-summary-end-of-article ()
11304 "Scroll to the end of the article."
11306 (gnus-set-global-variables)
11307 (gnus-summary-select-article)
11308 (gnus-configure-windows 'article)
11309 (gnus-eval-in-buffer-window gnus-article-buffer
11311 (goto-char (point-max))
11313 (and gnus-break-pages (gnus-narrow-to-page))))
11315 (defun gnus-summary-show-article (&optional arg)
11316 "Force re-fetching of the current article.
11317 If ARG (the prefix) is non-nil, show the raw article without any
11318 article massaging functions being run."
11320 (gnus-set-global-variables)
11322 ;; Select the article the normal way.
11323 (gnus-summary-select-article nil 'force)
11324 ;; Bind the article treatment functions to nil.
11325 (let ((gnus-have-all-headers t)
11326 gnus-article-display-hook
11327 gnus-article-prepare-hook
11330 (gnus-summary-select-article nil 'force)))
11331 (gnus-summary-goto-subject gnus-current-article)
11332 ; (gnus-configure-windows 'article)
11333 (gnus-summary-position-point))
11335 (defun gnus-summary-verbose-headers (&optional arg)
11336 "Toggle permanent full header display.
11337 If ARG is a positive number, turn header display on.
11338 If ARG is a negative number, turn header display off."
11340 (gnus-set-global-variables)
11341 (gnus-summary-toggle-header arg)
11342 (setq gnus-show-all-headers
11343 (cond ((or (not (numberp arg))
11345 (not gnus-show-all-headers))
11349 (defun gnus-summary-toggle-header (&optional arg)
11350 "Show the headers if they are hidden, or hide them if they are shown.
11351 If ARG is a positive number, show the entire header.
11352 If ARG is a negative number, hide the unwanted header lines."
11354 (gnus-set-global-variables)
11356 (set-buffer gnus-article-buffer)
11357 (let* ((buffer-read-only nil)
11358 (inhibit-point-motion-hooks t)
11359 (hidden (text-property-any
11360 (goto-char (point-min)) (search-forward "\n\n")
11363 (goto-char (point-min))
11364 (when (search-forward "\n\n" nil t)
11365 (delete-region (point-min) (1- (point))))
11366 (goto-char (point-min))
11368 (set-buffer gnus-original-article-buffer)
11369 (goto-char (point-min))
11370 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11371 (insert-buffer-substring gnus-original-article-buffer 1 e)
11372 (let ((gnus-inhibit-hiding t))
11373 (run-hooks 'gnus-article-display-hook))
11374 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11375 (gnus-article-hide-headers)))))
11377 (defun gnus-summary-show-all-headers ()
11378 "Make all header lines visible."
11380 (gnus-set-global-variables)
11381 (gnus-article-show-all-headers))
11383 (defun gnus-summary-toggle-mime (&optional arg)
11384 "Toggle MIME processing.
11385 If ARG is a positive number, turn MIME processing on."
11387 (gnus-set-global-variables)
11388 (setq gnus-show-mime
11389 (if (null arg) (not gnus-show-mime)
11390 (> (prefix-numeric-value arg) 0)))
11391 (gnus-summary-select-article t 'force))
11393 (defun gnus-summary-caesar-message (&optional arg)
11394 "Caesar rotate the current article by 13.
11395 The numerical prefix specifies how manu places to rotate each letter
11398 (gnus-set-global-variables)
11399 (gnus-summary-select-article)
11400 (let ((mail-header-separator ""))
11401 (gnus-eval-in-buffer-window gnus-article-buffer
11404 (let ((start (window-start))
11406 (message-caesar-buffer-body arg)
11407 (set-window-start (get-buffer-window (current-buffer)) start))))))
11409 (defun gnus-summary-stop-page-breaking ()
11410 "Stop page breaking in the current article."
11412 (gnus-set-global-variables)
11413 (gnus-summary-select-article)
11414 (gnus-eval-in-buffer-window gnus-article-buffer
11417 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11418 "Move the current article to a different newsgroup.
11419 If N is a positive number, move the N next articles.
11420 If N is a negative number, move the N previous articles.
11421 If N is nil and any articles have been marked with the process mark,
11422 move those articles instead.
11423 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11424 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11425 re-spool using this method.
11427 For this function to work, both the current newsgroup and the
11428 newsgroup that you want to move to have to support the `request-move'
11429 and `request-accept' functions."
11431 (unless action (setq action 'move))
11432 (gnus-set-global-variables)
11433 ;; Check whether the source group supports the required functions.
11434 (cond ((and (eq action 'move)
11435 (not (gnus-check-backend-function
11436 'request-move-article gnus-newsgroup-name)))
11437 (error "The current group does not support article moving"))
11438 ((and (eq action 'crosspost)
11439 (not (gnus-check-backend-function
11440 'request-replace-article gnus-newsgroup-name)))
11441 (error "The current group does not support article editing")))
11442 (let ((articles (gnus-summary-work-articles n))
11443 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11444 (names '((move "Move" "Moving")
11445 (copy "Copy" "Copying")
11446 (crosspost "Crosspost" "Crossposting")))
11447 (copy-buf (save-excursion
11448 (nnheader-set-temp-buffer " *copy article*")))
11449 art-group to-method new-xref article to-groups)
11450 (unless (assq action names)
11451 (error "Unknown action %s" action))
11452 ;; Read the newsgroup name.
11453 (when (and (not to-newsgroup)
11454 (not select-method))
11456 (gnus-read-move-group-name
11457 (cadr (assq action names))
11458 (symbol-value (intern (format "gnus-current-%s-group" action)))
11460 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11461 (setq to-method (or select-method
11462 (gnus-find-method-for-group to-newsgroup)))
11463 ;; Check the method we are to move this article to...
11464 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11465 (error "%s does not support article copying" (car to-method)))
11466 (or (gnus-check-server to-method)
11467 (error "Can't open server %s" (car to-method)))
11468 (gnus-message 6 "%s to %s: %s..."
11469 (caddr (assq action names))
11470 (or (car select-method) to-newsgroup) articles)
11472 (setq article (pop articles))
11476 ;; Move the article.
11478 (gnus-request-move-article
11479 article ; Article to move
11480 gnus-newsgroup-name ; From newsgrouo
11481 (nth 1 (gnus-find-method-for-group
11482 gnus-newsgroup-name)) ; Server
11483 (list 'gnus-request-accept-article
11484 to-newsgroup (list 'quote select-method)
11485 (not articles)) ; Accept form
11486 (not articles))) ; Only save nov last time
11487 ;; Copy the article.
11490 (set-buffer copy-buf)
11491 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11492 (gnus-request-accept-article
11493 to-newsgroup select-method (not articles))))
11494 ;; Crosspost the article.
11495 ((eq action 'crosspost)
11496 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11497 (setq new-xref (concat gnus-newsgroup-name ":" article))
11498 (if (and xref (not (string= xref "")))
11500 (when (string-match "^Xref: " xref)
11501 (setq xref (substring xref (match-end 0))))
11502 (setq new-xref (concat xref " " new-xref)))
11503 (setq new-xref (concat (system-name) " " new-xref)))
11505 (set-buffer copy-buf)
11506 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11507 (nnheader-replace-header "xref" new-xref)
11508 (gnus-request-accept-article
11509 to-newsgroup select-method (not articles)))))))
11510 (if (not art-group)
11511 (gnus-message 1 "Couldn't %s article %s"
11512 (cadr (assq action names)) article)
11515 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11517 (gnus-group-prefixed-name
11520 (gnus-find-method-for-group to-newsgroup)))
11521 gnus-newsrc-hashtb)))
11522 (info (nth 2 entry))
11523 (to-group (gnus-info-group info)))
11524 ;; Update the group that has been moved to.
11526 (memq action '(move copy)))
11527 (unless (member to-group to-groups)
11528 (push to-group to-groups))
11530 (unless (memq article gnus-newsgroup-unreads)
11531 (gnus-info-set-read
11532 info (gnus-add-to-range (gnus-info-read info)
11533 (list (cdr art-group)))))
11535 ;; Copy any marks over to the new group.
11536 (let ((marks gnus-article-mark-lists)
11537 (to-article (cdr art-group)))
11539 ;; See whether the article is to be put in the cache.
11540 (when gnus-use-cache
11541 (gnus-cache-possibly-enter-article
11542 to-group to-article
11543 (let ((header (copy-sequence
11544 (gnus-summary-article-header article))))
11545 (mail-header-set-number header to-article)
11547 (memq article gnus-newsgroup-marked)
11548 (memq article gnus-newsgroup-dormant)
11549 (memq article gnus-newsgroup-unreads)))
11552 (when (memq article (symbol-value
11553 (intern (format "gnus-newsgroup-%s"
11555 ;; If the other group is the same as this group,
11556 ;; then we have to add the mark to the list.
11557 (when (equal to-group gnus-newsgroup-name)
11558 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11561 (intern (format "gnus-newsgroup-%s"
11563 ;; Copy mark to other group.
11564 (gnus-add-marked-articles
11565 to-group (cdar marks) (list to-article) info))
11566 (setq marks (cdr marks)))))
11568 ;; Update the Xref header in this article to point to
11569 ;; the new crossposted article we have just created.
11570 (when (eq action 'crosspost)
11572 (set-buffer copy-buf)
11573 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11574 (nnheader-replace-header
11575 "xref" (concat new-xref " " (gnus-group-prefixed-name
11576 (car art-group) to-method)
11577 ":" (cdr art-group)))
11578 (gnus-request-replace-article
11579 article gnus-newsgroup-name (current-buffer)))))
11581 (gnus-summary-goto-subject article)
11582 (when (eq action 'move)
11583 (gnus-summary-mark-article article gnus-canceled-mark)))
11584 (gnus-summary-remove-process-mark article))
11585 ;; Re-activate all groups that have been moved to.
11587 (gnus-activate-group (pop to-groups)))
11589 (gnus-kill-buffer copy-buf)
11590 (gnus-summary-position-point)
11591 (gnus-set-mode-line 'summary)))
11593 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11594 "Move the current article to a different newsgroup.
11595 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11596 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11597 re-spool using this method."
11599 (gnus-summary-move-article n nil select-method 'copy))
11601 (defun gnus-summary-crosspost-article (&optional n)
11602 "Crosspost the current article to some other group."
11604 (gnus-summary-move-article n nil nil 'crosspost))
11606 (defvar gnus-summary-respool-default-method nil
11607 "Default method for respooling an article.
11608 If nil, use to the current newsgroup method.")
11610 (defun gnus-summary-respool-article (&optional n method)
11611 "Respool the current article.
11612 The article will be squeezed through the mail spooling process again,
11613 which means that it will be put in some mail newsgroup or other
11614 depending on `nnmail-split-methods'.
11615 If N is a positive number, respool the N next articles.
11616 If N is a negative number, respool the N previous articles.
11617 If N is nil and any articles have been marked with the process mark,
11618 respool those articles instead.
11620 Respooling can be done both from mail groups and \"real\" newsgroups.
11621 In the former case, the articles in question will be moved from the
11622 current group into whatever groups they are destined to. In the
11623 latter case, they will be copied into the relevant groups."
11625 (list current-prefix-arg
11626 (let* ((methods (gnus-methods-using 'respool))
11628 (symbol-name (or gnus-summary-respool-default-method
11629 (car (gnus-find-method-for-group
11630 gnus-newsgroup-name)))))
11632 (gnus-completing-read
11633 methname "What backend do you want to use when? "
11634 methods nil t nil 'gnus-method-history))
11637 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11638 (list (intern method) ""))
11642 (cdr (completing-read
11644 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11645 (gnus-set-global-variables)
11647 (error "No method given for respooling"))
11648 (if (assoc (symbol-name
11649 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11650 (gnus-methods-using 'respool))
11651 (gnus-summary-move-article n nil method)
11652 (gnus-summary-copy-article n nil method)))
11654 (defun gnus-summary-import-article (file)
11655 "Import a random file into a mail newsgroup."
11656 (interactive "fImport file: ")
11657 (gnus-set-global-variables)
11658 (let ((group gnus-newsgroup-name)
11659 (now (current-time))
11661 (or (gnus-check-backend-function 'request-accept-article group)
11662 (error "%s does not support article importing" group))
11663 (or (file-readable-p file)
11664 (not (file-regular-p file))
11665 (error "Can't read %s" file))
11667 (set-buffer (get-buffer-create " *import file*"))
11668 (buffer-disable-undo (current-buffer))
11670 (insert-file-contents file)
11671 (goto-char (point-min))
11672 (unless (nnheader-article-p)
11673 ;; This doesn't look like an article, so we fudge some headers.
11674 (setq atts (file-attributes file)
11675 lines (count-lines (point-min) (point-max)))
11676 (insert "From: " (read-string "From: ") "\n"
11677 "Subject: " (read-string "Subject: ") "\n"
11678 "Date: " (timezone-make-date-arpa-standard
11679 (current-time-string (nth 5 atts))
11680 (current-time-zone now)
11681 (current-time-zone now)) "\n"
11682 "Message-ID: " (gnus-inews-message-id) "\n"
11683 "Lines: " (int-to-string lines) "\n"
11684 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11685 (gnus-request-accept-article group nil t)
11686 (kill-buffer (current-buffer)))))
11688 (defun gnus-summary-expire-articles (&optional now)
11689 "Expire all articles that are marked as expirable in the current group."
11691 (gnus-set-global-variables)
11692 (when (gnus-check-backend-function
11693 'request-expire-articles gnus-newsgroup-name)
11694 ;; This backend supports expiry.
11695 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11696 (expirable (if total
11697 (gnus-list-of-read-articles gnus-newsgroup-name)
11698 (setq gnus-newsgroup-expirable
11699 (sort gnus-newsgroup-expirable '<))))
11700 (expiry-wait (if now 'immediate
11701 (gnus-group-get-parameter
11702 gnus-newsgroup-name 'expiry-wait)))
11705 ;; There are expirable articles in this group, so we run them
11706 ;; through the expiry process.
11707 (gnus-message 6 "Expiring articles...")
11708 ;; The list of articles that weren't expired is returned.
11710 (let ((nnmail-expiry-wait-function nil)
11711 (nnmail-expiry-wait expiry-wait))
11712 (setq es (gnus-request-expire-articles
11713 expirable gnus-newsgroup-name)))
11714 (setq es (gnus-request-expire-articles
11715 expirable gnus-newsgroup-name)))
11716 (or total (setq gnus-newsgroup-expirable es))
11717 ;; We go through the old list of expirable, and mark all
11718 ;; really expired articles as nonexistent.
11719 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11720 (let ((gnus-use-cache nil))
11722 (unless (memq (car expirable) es)
11723 (when (gnus-data-find (car expirable))
11724 (gnus-summary-mark-article
11725 (car expirable) gnus-canceled-mark)))
11726 (setq expirable (cdr expirable)))))
11727 (gnus-message 6 "Expiring articles...done")))))
11729 (defun gnus-summary-expire-articles-now ()
11730 "Expunge all expirable articles in the current group.
11731 This means that *all* articles that are marked as expirable will be
11732 deleted forever, right now."
11734 (gnus-set-global-variables)
11735 (or gnus-expert-user
11737 "Are you really, really, really sure you want to delete all these messages? ")
11739 (gnus-summary-expire-articles t))
11741 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11742 (defun gnus-summary-delete-article (&optional n)
11743 "Delete the N next (mail) articles.
11744 This command actually deletes articles. This is not a marking
11745 command. The article will disappear forever from your life, never to
11747 If N is negative, delete backwards.
11748 If N is nil and articles have been marked with the process mark,
11749 delete these instead."
11751 (gnus-set-global-variables)
11752 (or (gnus-check-backend-function 'request-expire-articles
11753 gnus-newsgroup-name)
11754 (error "The current newsgroup does not support article deletion."))
11755 ;; Compute the list of articles to delete.
11756 (let ((articles (gnus-summary-work-articles n))
11758 (if (and gnus-novice-user
11759 (not (gnus-y-or-n-p
11760 (format "Do you really want to delete %s forever? "
11761 (if (> (length articles) 1)
11762 (format "these %s articles" (length articles))
11763 "this article")))))
11765 ;; Delete the articles.
11766 (setq not-deleted (gnus-request-expire-articles
11767 articles gnus-newsgroup-name 'force))
11769 (gnus-summary-remove-process-mark (car articles))
11770 ;; The backend might not have been able to delete the article
11772 (or (memq (car articles) not-deleted)
11773 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11774 (setq articles (cdr articles))))
11775 (gnus-summary-position-point)
11776 (gnus-set-mode-line 'summary)
11779 (defun gnus-summary-edit-article (&optional force)
11780 "Enter into a buffer and edit the current article.
11781 This will have permanent effect only in mail groups.
11782 If FORCE is non-nil, allow editing of articles even in read-only
11786 (set-buffer gnus-summary-buffer)
11787 (gnus-set-global-variables)
11788 (when (and (not force)
11789 (gnus-group-read-only-p))
11790 (error "The current newsgroup does not support article editing."))
11791 (gnus-summary-select-article t nil t)
11792 (gnus-configure-windows 'article)
11793 (select-window (get-buffer-window gnus-article-buffer))
11794 (gnus-message 6 "C-c C-c to end edits")
11795 (setq buffer-read-only nil)
11797 (use-local-map (copy-keymap (current-local-map)))
11798 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11799 (buffer-enable-undo)
11801 (goto-char (point-min))
11802 (search-forward "\n\n" nil t)))
11804 (defun gnus-summary-edit-article-done ()
11805 "Make edits to the current article permanent."
11807 (if (gnus-group-read-only-p)
11809 (gnus-summary-edit-article-postpone)
11811 1 "The current newsgroup does not support article editing."))
11812 (let ((buf (format "%s" (buffer-string))))
11815 (if (not (gnus-request-replace-article
11816 (cdr gnus-article-current) (car gnus-article-current)
11818 (error "Couldn't replace article.")
11819 (gnus-article-mode)
11820 (use-local-map gnus-article-mode-map)
11821 (setq buffer-read-only t)
11822 (buffer-disable-undo (current-buffer))
11823 (gnus-configure-windows 'summary)
11824 (gnus-summary-update-article (cdr gnus-article-current))
11825 (when gnus-use-cache
11826 (gnus-cache-update-article
11827 (cdr gnus-article-current) (car gnus-article-current)))
11828 (when gnus-keep-backlog
11829 (gnus-backlog-remove-article
11830 (car gnus-article-current) (cdr gnus-article-current))))
11832 (when (get-buffer gnus-original-article-buffer)
11833 (set-buffer gnus-original-article-buffer)
11834 (setq gnus-original-article nil)))
11835 (setq gnus-article-current nil
11836 gnus-current-article nil)
11837 (run-hooks 'gnus-article-display-hook)
11838 (and (gnus-visual-p 'summary-highlight 'highlight)
11839 (run-hooks 'gnus-visual-mark-article-hook)))))
11841 (defun gnus-summary-edit-article-postpone ()
11842 "Postpone changes to the current article."
11844 (gnus-article-mode)
11845 (use-local-map gnus-article-mode-map)
11846 (setq buffer-read-only t)
11847 (buffer-disable-undo (current-buffer))
11848 (gnus-configure-windows 'summary)
11849 (and (gnus-visual-p 'summary-highlight 'highlight)
11850 (run-hooks 'gnus-visual-mark-article-hook)))
11852 (defun gnus-summary-respool-query ()
11853 "Query where the respool algorithm would put this article."
11855 (gnus-set-global-variables)
11856 (gnus-summary-select-article)
11858 (set-buffer gnus-article-buffer)
11860 (goto-char (point-min))
11861 (search-forward "\n\n")
11862 (narrow-to-region (point-min) (point))
11863 (pp-eval-expression
11864 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11866 ;; Summary marking commands.
11868 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11869 "Mark articles which has the same subject as read, and then select the next.
11870 If UNMARK is positive, remove any kind of mark.
11871 If UNMARK is negative, tick articles."
11873 (gnus-set-global-variables)
11875 (setq unmark (prefix-numeric-value unmark)))
11877 (gnus-summary-mark-same-subject
11878 (gnus-summary-article-subject) unmark)))
11879 ;; Select next unread article. If auto-select-same mode, should
11880 ;; select the first unread article.
11881 (gnus-summary-next-article t (and gnus-auto-select-same
11882 (gnus-summary-article-subject)))
11883 (gnus-message 7 "%d article%s marked as %s"
11884 count (if (= count 1) " is" "s are")
11885 (if unmark "unread" "read"))))
11887 (defun gnus-summary-kill-same-subject (&optional unmark)
11888 "Mark articles which has the same subject as read.
11889 If UNMARK is positive, remove any kind of mark.
11890 If UNMARK is negative, tick articles."
11892 (gnus-set-global-variables)
11894 (setq unmark (prefix-numeric-value unmark)))
11896 (gnus-summary-mark-same-subject
11897 (gnus-summary-article-subject) unmark)))
11898 ;; If marked as read, go to next unread subject.
11900 ;; Go to next unread subject.
11901 (gnus-summary-next-subject 1 t))
11902 (gnus-message 7 "%d articles are marked as %s"
11903 count (if unmark "unread" "read"))))
11905 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11906 "Mark articles with same SUBJECT as read, and return marked number.
11907 If optional argument UNMARK is positive, remove any kinds of marks.
11908 If optional argument UNMARK is negative, mark articles as unread instead."
11912 ((null unmark) ; Mark as read.
11915 (gnus-summary-mark-article-as-read gnus-killed-mark)
11916 (gnus-summary-show-thread) t)
11917 (gnus-summary-find-subject subject))
11918 (setq count (1+ count))))
11919 ((> unmark 0) ; Tick.
11922 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11923 (gnus-summary-show-thread) t)
11924 (gnus-summary-find-subject subject))
11925 (setq count (1+ count))))
11926 (t ; Mark as unread.
11929 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11930 (gnus-summary-show-thread) t)
11931 (gnus-summary-find-subject subject))
11932 (setq count (1+ count)))))
11933 (gnus-set-mode-line 'summary)
11934 ;; Return the number of marked articles.
11937 (defun gnus-summary-mark-as-processable (n &optional unmark)
11938 "Set the process mark on the next N articles.
11939 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11940 the process mark instead. The difference between N and the actual
11941 number of articles marked is returned."
11943 (gnus-set-global-variables)
11944 (let ((backward (< n 0))
11949 (gnus-summary-remove-process-mark
11950 (gnus-summary-article-number))
11951 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11952 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11954 (if (/= 0 n) (gnus-message 7 "No more articles"))
11955 (gnus-summary-recenter)
11956 (gnus-summary-position-point)
11959 (defun gnus-summary-unmark-as-processable (n)
11960 "Remove the process mark from the next N articles.
11961 If N is negative, mark backward instead. The difference between N and
11962 the actual number of articles marked is returned."
11964 (gnus-set-global-variables)
11965 (gnus-summary-mark-as-processable n t))
11967 (defun gnus-summary-unmark-all-processable ()
11968 "Remove the process mark from all articles."
11970 (gnus-set-global-variables)
11972 (while gnus-newsgroup-processable
11973 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11974 (gnus-summary-position-point))
11976 (defun gnus-summary-mark-as-expirable (n)
11977 "Mark N articles forward as expirable.
11978 If N is negative, mark backward instead. The difference between N and
11979 the actual number of articles marked is returned."
11981 (gnus-set-global-variables)
11982 (gnus-summary-mark-forward n gnus-expirable-mark))
11984 (defun gnus-summary-mark-article-as-replied (article)
11985 "Mark ARTICLE replied and update the summary line."
11986 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11987 (let ((buffer-read-only nil))
11988 (when (gnus-summary-goto-subject article)
11989 (gnus-summary-update-secondary-mark article))))
11991 (defun gnus-summary-set-bookmark (article)
11992 "Set a bookmark in current article."
11993 (interactive (list (gnus-summary-article-number)))
11994 (gnus-set-global-variables)
11995 (if (or (not (get-buffer gnus-article-buffer))
11996 (not gnus-current-article)
11997 (not gnus-article-current)
11998 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11999 (error "No current article selected"))
12000 ;; Remove old bookmark, if one exists.
12001 (let ((old (assq article gnus-newsgroup-bookmarks)))
12002 (if old (setq gnus-newsgroup-bookmarks
12003 (delq old gnus-newsgroup-bookmarks))))
12004 ;; Set the new bookmark, which is on the form
12005 ;; (article-number . line-number-in-body).
12006 (setq gnus-newsgroup-bookmarks
12010 (set-buffer gnus-article-buffer)
12014 (goto-char (point-min))
12015 (search-forward "\n\n" nil t)
12018 gnus-newsgroup-bookmarks))
12019 (gnus-message 6 "A bookmark has been added to the current article."))
12021 (defun gnus-summary-remove-bookmark (article)
12022 "Remove the bookmark from the current article."
12023 (interactive (list (gnus-summary-article-number)))
12024 (gnus-set-global-variables)
12025 ;; Remove old bookmark, if one exists.
12026 (let ((old (assq article gnus-newsgroup-bookmarks)))
12029 (setq gnus-newsgroup-bookmarks
12030 (delq old gnus-newsgroup-bookmarks))
12031 (gnus-message 6 "Removed bookmark."))
12032 (gnus-message 6 "No bookmark in current article."))))
12034 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12035 (defun gnus-summary-mark-as-dormant (n)
12036 "Mark N articles forward as dormant.
12037 If N is negative, mark backward instead. The difference between N and
12038 the actual number of articles marked is returned."
12040 (gnus-set-global-variables)
12041 (gnus-summary-mark-forward n gnus-dormant-mark))
12043 (defun gnus-summary-set-process-mark (article)
12044 "Set the process mark on ARTICLE and update the summary line."
12045 (setq gnus-newsgroup-processable
12047 (delq article gnus-newsgroup-processable)))
12048 (when (gnus-summary-goto-subject article)
12049 (gnus-summary-show-thread)
12050 (gnus-summary-update-secondary-mark article)))
12052 (defun gnus-summary-remove-process-mark (article)
12053 "Remove the process mark from ARTICLE and update the summary line."
12054 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12055 (when (gnus-summary-goto-subject article)
12056 (gnus-summary-show-thread)
12057 (gnus-summary-update-secondary-mark article)))
12059 (defun gnus-summary-set-saved-mark (article)
12060 "Set the process mark on ARTICLE and update the summary line."
12061 (push article gnus-newsgroup-saved)
12062 (when (gnus-summary-goto-subject article)
12063 (gnus-summary-update-secondary-mark article)))
12065 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12066 "Mark N articles as read forwards.
12067 If N is negative, mark backwards instead.
12068 Mark with MARK. If MARK is ? , ?! or ??, articles will be
12070 The difference between N and the actual number of articles marked is
12073 (gnus-set-global-variables)
12074 (let ((backward (< n 0))
12075 (gnus-summary-goto-unread
12076 (and gnus-summary-goto-unread
12077 (not (eq gnus-summary-goto-unread 'never))
12078 (not (memq mark (list gnus-unread-mark
12079 gnus-ticked-mark gnus-dormant-mark)))))
12081 (mark (or mark gnus-del-mark)))
12082 (while (and (> n 0)
12083 (gnus-summary-mark-article nil mark no-expire)
12084 (zerop (gnus-summary-next-subject
12086 (and gnus-summary-goto-unread
12087 (not (eq gnus-summary-goto-unread 'never)))
12090 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12091 (gnus-summary-recenter)
12092 (gnus-summary-position-point)
12093 (gnus-set-mode-line 'summary)
12096 (defun gnus-summary-mark-article-as-read (mark)
12097 "Mark the current article quickly as read with MARK."
12098 (let ((article (gnus-summary-article-number)))
12099 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12100 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12101 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12102 (setq gnus-newsgroup-reads
12103 (cons (cons article mark) gnus-newsgroup-reads))
12104 ;; Possibly remove from cache, if that is used.
12105 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12106 ;; Allow the backend to change the mark.
12107 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12108 ;; Check for auto-expiry.
12109 (when (and gnus-newsgroup-auto-expire
12110 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12111 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12112 (= mark gnus-ancient-mark)
12113 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12114 (setq mark gnus-expirable-mark)
12115 (push article gnus-newsgroup-expirable))
12116 ;; Set the mark in the buffer.
12117 (gnus-summary-update-mark mark 'unread)
12120 (defun gnus-summary-mark-article-as-unread (mark)
12121 "Mark the current article quickly as unread with MARK."
12122 (let ((article (gnus-summary-article-number)))
12123 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12124 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12125 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12126 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12127 (cond ((= mark gnus-ticked-mark)
12128 (push article gnus-newsgroup-marked))
12129 ((= mark gnus-dormant-mark)
12130 (push article gnus-newsgroup-dormant))
12132 (push article gnus-newsgroup-unreads)))
12133 (setq gnus-newsgroup-reads
12134 (delq (assq article gnus-newsgroup-reads)
12135 gnus-newsgroup-reads))
12137 ;; See whether the article is to be put in the cache.
12138 (and gnus-use-cache
12139 (vectorp (gnus-summary-article-header article))
12141 (gnus-cache-possibly-enter-article
12142 gnus-newsgroup-name article
12143 (gnus-summary-article-header article)
12144 (= mark gnus-ticked-mark)
12145 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12148 (gnus-summary-update-mark mark 'unread)
12151 (defun gnus-summary-mark-article (&optional article mark no-expire)
12152 "Mark ARTICLE with MARK. MARK can be any character.
12153 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12154 `??' (dormant) and `?E' (expirable).
12155 If MARK is nil, then the default character `?D' is used.
12156 If ARTICLE is nil, then the article on the current line will be
12158 ;; The mark might be a string.
12159 (and (stringp mark)
12160 (setq mark (aref mark 0)))
12161 ;; If no mark is given, then we check auto-expiring.
12162 (and (not no-expire)
12163 gnus-newsgroup-auto-expire
12165 (and (numberp mark)
12166 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12167 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12168 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12169 (setq mark gnus-expirable-mark))
12170 (let* ((mark (or mark gnus-del-mark))
12171 (article (or article (gnus-summary-article-number))))
12172 (or article (error "No article on current line"))
12173 (if (or (= mark gnus-unread-mark)
12174 (= mark gnus-ticked-mark)
12175 (= mark gnus-dormant-mark))
12176 (gnus-mark-article-as-unread article mark)
12177 (gnus-mark-article-as-read article mark))
12179 ;; See whether the article is to be put in the cache.
12180 (and gnus-use-cache
12181 (not (= mark gnus-canceled-mark))
12182 (vectorp (gnus-summary-article-header article))
12184 (gnus-cache-possibly-enter-article
12185 gnus-newsgroup-name article
12186 (gnus-summary-article-header article)
12187 (= mark gnus-ticked-mark)
12188 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12190 (if (gnus-summary-goto-subject article nil t)
12191 (let ((buffer-read-only nil))
12192 (gnus-summary-show-thread)
12194 (gnus-summary-update-mark mark 'unread)
12197 (defun gnus-summary-update-secondary-mark (article)
12198 "Update the secondary (read, process, cache) mark."
12199 (gnus-summary-update-mark
12200 (cond ((memq article gnus-newsgroup-processable)
12202 ((memq article gnus-newsgroup-cached)
12204 ((memq article gnus-newsgroup-replied)
12206 ((memq article gnus-newsgroup-saved)
12208 (t gnus-unread-mark))
12210 (when (gnus-visual-p 'summary-highlight 'highlight)
12211 (run-hooks 'gnus-summary-update-hook))
12214 (defun gnus-summary-update-mark (mark type)
12215 (beginning-of-line)
12216 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12217 (buffer-read-only nil))
12219 (<= (+ forward (point)) (point-max)))
12220 ;; Go to the right position on the line.
12221 (goto-char (+ forward (point)))
12222 ;; Replace the old mark with the new mark.
12223 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12224 ;; Optionally update the marks by some user rule.
12225 (when (eq type 'unread)
12226 (gnus-data-set-mark
12227 (gnus-data-find (gnus-summary-article-number)) mark)
12228 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12230 (defun gnus-mark-article-as-read (article &optional mark)
12231 "Enter ARTICLE in the pertinent lists and remove it from others."
12232 ;; Make the article expirable.
12233 (let ((mark (or mark gnus-del-mark)))
12234 (if (= mark gnus-expirable-mark)
12235 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12236 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12237 ;; Remove from unread and marked lists.
12238 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12239 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12240 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12241 (push (cons article mark) gnus-newsgroup-reads)
12242 ;; Possibly remove from cache, if that is used.
12243 (when gnus-use-cache
12244 (gnus-cache-enter-remove-article article))))
12246 (defun gnus-mark-article-as-unread (article &optional mark)
12247 "Enter ARTICLE in the pertinent lists and remove it from others."
12248 (let ((mark (or mark gnus-ticked-mark)))
12249 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12250 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12251 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12252 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12253 (cond ((= mark gnus-ticked-mark)
12254 (push article gnus-newsgroup-marked))
12255 ((= mark gnus-dormant-mark)
12256 (push article gnus-newsgroup-dormant))
12258 (push article gnus-newsgroup-unreads)))
12259 (setq gnus-newsgroup-reads
12260 (delq (assq article gnus-newsgroup-reads)
12261 gnus-newsgroup-reads))))
12263 (defalias 'gnus-summary-mark-as-unread-forward
12264 'gnus-summary-tick-article-forward)
12265 (make-obsolete 'gnus-summary-mark-as-unread-forward
12266 'gnus-summary-tick-article-forward)
12267 (defun gnus-summary-tick-article-forward (n)
12268 "Tick N articles forwards.
12269 If N is negative, tick backwards instead.
12270 The difference between N and the number of articles ticked is returned."
12272 (gnus-summary-mark-forward n gnus-ticked-mark))
12274 (defalias 'gnus-summary-mark-as-unread-backward
12275 'gnus-summary-tick-article-backward)
12276 (make-obsolete 'gnus-summary-mark-as-unread-backward
12277 'gnus-summary-tick-article-backward)
12278 (defun gnus-summary-tick-article-backward (n)
12279 "Tick N articles backwards.
12280 The difference between N and the number of articles ticked is returned."
12282 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12284 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12285 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12286 (defun gnus-summary-tick-article (&optional article clear-mark)
12287 "Mark current article as unread.
12288 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12289 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12291 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12292 gnus-ticked-mark)))
12294 (defun gnus-summary-mark-as-read-forward (n)
12295 "Mark N articles as read forwards.
12296 If N is negative, mark backwards instead.
12297 The difference between N and the actual number of articles marked is
12300 (gnus-summary-mark-forward n gnus-del-mark t))
12302 (defun gnus-summary-mark-as-read-backward (n)
12303 "Mark the N articles as read backwards.
12304 The difference between N and the actual number of articles marked is
12307 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12309 (defun gnus-summary-mark-as-read (&optional article mark)
12310 "Mark current article as read.
12311 ARTICLE specifies the article to be marked as read.
12312 MARK specifies a string to be inserted at the beginning of the line."
12313 (gnus-summary-mark-article article mark))
12315 (defun gnus-summary-clear-mark-forward (n)
12316 "Clear marks from N articles forward.
12317 If N is negative, clear backward instead.
12318 The difference between N and the number of marks cleared is returned."
12320 (gnus-summary-mark-forward n gnus-unread-mark))
12322 (defun gnus-summary-clear-mark-backward (n)
12323 "Clear marks from N articles backward.
12324 The difference between N and the number of marks cleared is returned."
12326 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12328 (defun gnus-summary-mark-unread-as-read ()
12329 "Intended to be used by `gnus-summary-mark-article-hook'."
12330 (when (memq gnus-current-article gnus-newsgroup-unreads)
12331 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12333 (defun gnus-summary-mark-read-and-unread-as-read ()
12334 "Intended to be used by `gnus-summary-mark-article-hook'."
12335 (let ((mark (gnus-summary-article-mark)))
12336 (when (or (gnus-unread-mark-p mark)
12337 (gnus-read-mark-p mark))
12338 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12340 (defun gnus-summary-mark-region-as-read (point mark all)
12341 "Mark all unread articles between point and mark as read.
12342 If given a prefix, mark all articles between point and mark as read,
12343 even ticked and dormant ones."
12344 (interactive "r\nP")
12348 (beginning-of-line)
12353 (memq (setq article (gnus-summary-article-number))
12354 gnus-newsgroup-unreads))
12355 (gnus-summary-mark-article article gnus-del-mark))
12357 (gnus-summary-find-next))))))
12359 (defun gnus-summary-mark-below (score mark)
12360 "Mark articles with score less than SCORE with MARK."
12361 (interactive "P\ncMark: ")
12362 (gnus-set-global-variables)
12363 (setq score (if score
12364 (prefix-numeric-value score)
12365 (or gnus-summary-default-score 0)))
12367 (set-buffer gnus-summary-buffer)
12368 (goto-char (point-min))
12371 (and (< (gnus-summary-article-score) score)
12372 (gnus-summary-mark-article nil mark))
12373 (gnus-summary-find-next)))))
12375 (defun gnus-summary-kill-below (&optional score)
12376 "Mark articles with score below SCORE as read."
12378 (gnus-set-global-variables)
12379 (gnus-summary-mark-below score gnus-killed-mark))
12381 (defun gnus-summary-clear-above (&optional score)
12382 "Clear all marks from articles with score above SCORE."
12384 (gnus-set-global-variables)
12385 (gnus-summary-mark-above score gnus-unread-mark))
12387 (defun gnus-summary-tick-above (&optional score)
12388 "Tick all articles with score above SCORE."
12390 (gnus-set-global-variables)
12391 (gnus-summary-mark-above score gnus-ticked-mark))
12393 (defun gnus-summary-mark-above (score mark)
12394 "Mark articles with score over SCORE with MARK."
12395 (interactive "P\ncMark: ")
12396 (gnus-set-global-variables)
12397 (setq score (if score
12398 (prefix-numeric-value score)
12399 (or gnus-summary-default-score 0)))
12401 (set-buffer gnus-summary-buffer)
12402 (goto-char (point-min))
12404 (if (> (gnus-summary-article-score) score)
12405 (gnus-summary-mark-article nil mark))
12407 (gnus-summary-find-next)))))
12409 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12410 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12411 (defun gnus-summary-limit-include-expunged ()
12412 "Display all the hidden articles that were expunged for low scores."
12414 (gnus-set-global-variables)
12415 (let ((buffer-read-only nil))
12416 (let ((scored gnus-newsgroup-scored)
12419 (or (gnus-summary-goto-subject (caar scored))
12420 (and (setq h (gnus-summary-article-header (caar scored)))
12421 (< (cdar scored) gnus-summary-expunge-below)
12422 (setq headers (cons h headers))))
12423 (setq scored (cdr scored)))
12424 (or headers (error "No expunged articles hidden."))
12425 (goto-char (point-min))
12426 (gnus-summary-prepare-unthreaded (nreverse headers)))
12427 (goto-char (point-min))
12428 (gnus-summary-position-point)))
12430 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12431 "Mark all articles not marked as unread in this newsgroup as read.
12432 If prefix argument ALL is non-nil, all articles are marked as read.
12433 If QUIETLY is non-nil, no questions will be asked.
12434 If TO-HERE is non-nil, it should be a point in the buffer. All
12435 articles before this point will be marked as read.
12436 The number of articles marked as read is returned."
12438 (gnus-set-global-variables)
12441 (not gnus-interactive-catchup) ;Without confirmation?
12445 "Mark absolutely all articles as read? "
12446 "Mark all unread articles as read? ")))
12448 (not gnus-newsgroup-adaptive)
12449 (not gnus-newsgroup-auto-expire))
12452 (setq gnus-newsgroup-marked nil
12453 gnus-newsgroup-dormant nil))
12454 (setq gnus-newsgroup-unreads nil))
12455 ;; We actually mark all articles as canceled, which we
12456 ;; have to do when using auto-expiry or adaptive scoring.
12457 (gnus-summary-show-all-threads)
12458 (if (gnus-summary-first-subject (not all))
12460 (if to-here (< (point) to-here) t)
12461 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12462 (gnus-summary-find-next (not all)))))
12464 (setq gnus-newsgroup-unreads nil))
12465 (gnus-set-mode-line 'summary)))
12466 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12467 (if (and (not to-here) (eq 'nnvirtual (car method)))
12468 (nnvirtual-catchup-group
12469 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12470 (gnus-summary-position-point)))
12472 (defun gnus-summary-catchup-to-here (&optional all)
12473 "Mark all unticked articles before the current one as read.
12474 If ALL is non-nil, also mark ticked and dormant articles as read."
12476 (gnus-set-global-variables)
12478 (gnus-save-hidden-threads
12479 (let ((beg (point)))
12480 ;; We check that there are unread articles.
12481 (when (or all (gnus-summary-find-prev))
12482 (gnus-summary-catchup all t beg)))))
12483 (gnus-summary-position-point))
12485 (defun gnus-summary-catchup-all (&optional quietly)
12486 "Mark all articles in this newsgroup as read."
12488 (gnus-set-global-variables)
12489 (gnus-summary-catchup t quietly))
12491 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12492 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12493 If prefix argument ALL is non-nil, all articles are marked as read."
12495 (gnus-set-global-variables)
12496 (gnus-summary-catchup all quietly nil 'fast)
12497 ;; Select next newsgroup or exit.
12498 (if (eq gnus-auto-select-next 'quietly)
12499 (gnus-summary-next-group nil)
12500 (gnus-summary-exit)))
12502 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12503 "Mark all articles in this newsgroup as read, and then exit."
12505 (gnus-set-global-variables)
12506 (gnus-summary-catchup-and-exit t quietly))
12508 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12509 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12510 "Mark all articles in this group as read and select the next group.
12511 If given a prefix, mark all articles, unread as well as ticked, as
12514 (gnus-set-global-variables)
12516 (gnus-summary-catchup all))
12517 (gnus-summary-next-article t nil nil t))
12519 ;; Thread-based commands.
12521 (defun gnus-summary-articles-in-thread (&optional article)
12522 "Return a list of all articles in the current thread.
12523 If ARTICLE is non-nil, return all articles in the thread that starts
12524 with that article."
12525 (let* ((article (or article (gnus-summary-article-number)))
12526 (data (gnus-data-find-list article))
12527 (top-level (gnus-data-level (car data)))
12529 (cond ((null gnus-thread-operation-ignore-subject)
12530 (gnus-simplify-subject-re
12531 (mail-header-subject (gnus-data-header (car data)))))
12532 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12533 (gnus-simplify-subject-fuzzy
12534 (mail-header-subject (gnus-data-header (car data)))))
12536 (end-point (save-excursion
12537 (if (gnus-summary-go-to-next-thread)
12538 (point) (point-max))))
12541 (< (gnus-data-pos (car data)) end-point))
12542 (when (or (not top-subject)
12543 (string= top-subject
12544 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12545 (gnus-simplify-subject-fuzzy
12546 (mail-header-subject
12547 (gnus-data-header (car data))))
12548 (gnus-simplify-subject-re
12549 (mail-header-subject
12550 (gnus-data-header (car data)))))))
12551 (push (gnus-data-number (car data)) articles))
12552 (unless (and (setq data (cdr data))
12553 (> (gnus-data-level (car data)) top-level))
12555 ;; Return the list of articles.
12556 (nreverse articles)))
12558 (defun gnus-summary-rethread-current ()
12559 "Rethread the thread the current article is part of."
12561 (gnus-set-global-variables)
12562 (let* ((gnus-show-threads t)
12563 (article (gnus-summary-article-number))
12564 (id (mail-header-id (gnus-summary-article-header)))
12565 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12567 (error "No article on the current line"))
12568 (gnus-rebuild-thread id)
12569 (gnus-summary-goto-subject article)))
12571 (defun gnus-summary-reparent-thread ()
12572 "Make current article child of the marked (or previous) article.
12574 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12575 is non-nil or the Subject: of both articles are the same."
12577 (or (not (gnus-group-read-only-p))
12578 (error "The current newsgroup does not support article editing."))
12579 (or (<= (length gnus-newsgroup-processable) 1)
12580 (error "No more than one article may be marked."))
12581 (save-window-excursion
12582 (let ((gnus-article-buffer " *reparent*")
12583 (current-article (gnus-summary-article-number))
12584 ; first grab the marked article, otherwise one line up.
12585 (parent-article (if (not (null gnus-newsgroup-processable))
12586 (car gnus-newsgroup-processable)
12588 (if (eq (forward-line -1) 0)
12589 (gnus-summary-article-number)
12590 (error "Beginning of summary buffer."))))))
12591 (or (not (eq current-article parent-article))
12592 (error "An article may not be self-referential."))
12593 (let ((message-id (mail-header-id
12594 (gnus-summary-article-header parent-article))))
12595 (or (and message-id (not (equal message-id "")))
12596 (error "No message-id in desired parent."))
12597 (gnus-summary-select-article t t nil current-article)
12598 (set-buffer gnus-article-buffer)
12599 (setq buffer-read-only nil)
12600 (let ((buf (format "%s" (buffer-string))))
12603 (goto-char (point-min))
12604 (if (search-forward-regexp "^References: " nil t)
12605 (insert message-id " " )
12606 (insert "References: " message-id "\n"))
12607 (or (gnus-request-replace-article current-article
12608 (car gnus-article-current)
12609 gnus-article-buffer)
12610 (error "Couldn't replace article."))
12611 (set-buffer gnus-summary-buffer)
12612 (gnus-summary-unmark-all-processable)
12613 (gnus-summary-rethread-current)
12614 (gnus-message 3 "Article %d is now the child of article %d."
12615 current-article parent-article)))))
12617 (defun gnus-summary-toggle-threads (&optional arg)
12618 "Toggle showing conversation threads.
12619 If ARG is positive number, turn showing conversation threads on."
12621 (gnus-set-global-variables)
12622 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12623 (setq gnus-show-threads
12624 (if (null arg) (not gnus-show-threads)
12625 (> (prefix-numeric-value arg) 0)))
12626 (gnus-summary-prepare)
12627 (gnus-summary-goto-subject current)
12628 (gnus-summary-position-point)))
12630 (defun gnus-summary-show-all-threads ()
12631 "Show all threads."
12633 (gnus-set-global-variables)
12635 (let ((buffer-read-only nil))
12636 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12637 (gnus-summary-position-point))
12639 (defun gnus-summary-show-thread ()
12640 "Show thread subtrees.
12641 Returns nil if no thread was there to be shown."
12643 (gnus-set-global-variables)
12644 (let ((buffer-read-only nil)
12646 ;; first goto end then to beg, to have point at beg after let
12647 (end (progn (end-of-line) (point)))
12648 (beg (progn (beginning-of-line) (point))))
12650 ;; Any hidden lines here?
12651 (search-forward "\r" end t)
12652 (subst-char-in-region beg end ?\^M ?\n t)
12654 (gnus-summary-position-point))))
12656 (defun gnus-summary-hide-all-threads ()
12657 "Hide all thread subtrees."
12659 (gnus-set-global-variables)
12661 (goto-char (point-min))
12662 (gnus-summary-hide-thread)
12663 (while (zerop (gnus-summary-next-thread 1 t))
12664 (gnus-summary-hide-thread)))
12665 (gnus-summary-position-point))
12667 (defun gnus-summary-hide-thread ()
12668 "Hide thread subtrees.
12669 Returns nil if no threads were there to be hidden."
12671 (gnus-set-global-variables)
12672 (let ((buffer-read-only nil)
12674 (article (gnus-summary-article-number)))
12676 ;; Go forward until either the buffer ends or the subthread
12678 (when (and (not (eobp))
12679 (or (zerop (gnus-summary-next-thread 1 t))
12680 (goto-char (point-max))))
12682 (if (and (> (point) start)
12683 (search-backward "\n" start t))
12685 (subst-char-in-region start (point) ?\n ?\^M)
12686 (gnus-summary-goto-subject article))
12689 ;;(gnus-summary-position-point)
12692 (defun gnus-summary-go-to-next-thread (&optional previous)
12693 "Go to the same level (or less) next thread.
12694 If PREVIOUS is non-nil, go to previous thread instead.
12695 Return the article number moved to, or nil if moving was impossible."
12696 (let ((level (gnus-summary-thread-level))
12697 (way (if previous -1 1))
12700 (while (and (not (eobp))
12701 (< level (gnus-summary-thread-level)))
12702 (forward-line way))
12709 (gnus-summary-article-number)
12710 (goto-char beg)))))
12712 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12713 "Go to the same level (or less) next thread.
12714 If PREVIOUS is non-nil, go to previous thread instead.
12715 Return the article number moved to, or nil if moving was impossible."
12716 (if (and (eq gnus-summary-make-false-root 'dummy)
12717 (gnus-summary-article-intangible-p))
12718 (let ((beg (point)))
12719 (while (and (zerop (forward-line 1))
12720 (not (gnus-summary-article-intangible-p))
12721 (not (zerop (save-excursion
12722 (gnus-summary-thread-level))))))
12728 (let* ((level (gnus-summary-thread-level))
12729 (article (gnus-summary-article-number))
12730 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12733 (if (<= (gnus-data-level (car data)) level)
12734 (setq oart (gnus-data-number (car data))
12736 (setq data (cdr data))))
12738 (gnus-summary-goto-subject oart)))))
12740 (defun gnus-summary-next-thread (n &optional silent)
12741 "Go to the same level next N'th thread.
12742 If N is negative, search backward instead.
12743 Returns the difference between N and the number of skips actually
12746 If SILENT, don't output messages."
12748 (gnus-set-global-variables)
12749 (let ((backward (< n 0))
12752 (while (and (> n 0)
12753 (gnus-summary-go-to-next-thread backward))
12756 (gnus-summary-position-point))
12757 (when (and (not silent) (/= 0 n))
12758 (gnus-message 7 "No more threads"))
12761 (defun gnus-summary-prev-thread (n)
12762 "Go to the same level previous N'th thread.
12763 Returns the difference between N and the number of skips actually
12766 (gnus-set-global-variables)
12767 (gnus-summary-next-thread (- n)))
12769 (defun gnus-summary-go-down-thread ()
12770 "Go down one level in the current thread."
12771 (let ((children (gnus-summary-article-children)))
12773 (gnus-summary-goto-subject (car children)))))
12775 (defun gnus-summary-go-up-thread ()
12776 "Go up one level in the current thread."
12777 (let ((parent (gnus-summary-article-parent)))
12779 (gnus-summary-goto-subject parent))))
12781 (defun gnus-summary-down-thread (n)
12782 "Go down thread N steps.
12783 If N is negative, go up instead.
12784 Returns the difference between N and how many steps down that were
12787 (gnus-set-global-variables)
12790 (while (and (> n 0)
12791 (if up (gnus-summary-go-up-thread)
12792 (gnus-summary-go-down-thread)))
12794 (gnus-summary-position-point)
12795 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12798 (defun gnus-summary-up-thread (n)
12799 "Go up thread N steps.
12800 If N is negative, go up instead.
12801 Returns the difference between N and how many steps down that were
12804 (gnus-set-global-variables)
12805 (gnus-summary-down-thread (- n)))
12807 (defun gnus-summary-top-thread ()
12808 "Go to the top of the thread."
12810 (gnus-set-global-variables)
12811 (while (gnus-summary-go-up-thread))
12812 (gnus-summary-article-number))
12814 (defun gnus-summary-kill-thread (&optional unmark)
12815 "Mark articles under current thread as read.
12816 If the prefix argument is positive, remove any kinds of marks.
12817 If the prefix argument is negative, tick articles instead."
12819 (gnus-set-global-variables)
12821 (setq unmark (prefix-numeric-value unmark)))
12822 (let ((articles (gnus-summary-articles-in-thread)))
12824 ;; Expand the thread.
12825 (gnus-summary-show-thread)
12826 ;; Mark all the articles.
12828 (gnus-summary-goto-subject (car articles))
12829 (cond ((null unmark)
12830 (gnus-summary-mark-article-as-read gnus-killed-mark))
12832 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12834 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12835 (setq articles (cdr articles))))
12836 ;; Hide killed subtrees.
12838 gnus-thread-hide-killed
12839 (gnus-summary-hide-thread))
12840 ;; If marked as read, go to next unread subject.
12842 ;; Go to next unread subject.
12843 (gnus-summary-next-subject 1 t)))
12844 (gnus-set-mode-line 'summary))
12846 ;; Summary sorting commands
12848 (defun gnus-summary-sort-by-number (&optional reverse)
12849 "Sort summary buffer by article number.
12850 Argument REVERSE means reverse order."
12852 (gnus-summary-sort 'number reverse))
12854 (defun gnus-summary-sort-by-author (&optional reverse)
12855 "Sort summary buffer by author name alphabetically.
12856 If case-fold-search is non-nil, case of letters is ignored.
12857 Argument REVERSE means reverse order."
12859 (gnus-summary-sort 'author reverse))
12861 (defun gnus-summary-sort-by-subject (&optional reverse)
12862 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12863 If case-fold-search is non-nil, case of letters is ignored.
12864 Argument REVERSE means reverse order."
12866 (gnus-summary-sort 'subject reverse))
12868 (defun gnus-summary-sort-by-date (&optional reverse)
12869 "Sort summary buffer by date.
12870 Argument REVERSE means reverse order."
12872 (gnus-summary-sort 'date reverse))
12874 (defun gnus-summary-sort-by-score (&optional reverse)
12875 "Sort summary buffer by score.
12876 Argument REVERSE means reverse order."
12878 (gnus-summary-sort 'score reverse))
12880 (defun gnus-summary-sort (predicate reverse)
12881 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12882 (gnus-set-global-variables)
12883 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12884 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12885 (gnus-thread-sort-functions
12890 (,thread t2 t1)))))
12891 (gnus-article-sort-functions
12896 (,article t2 t1)))))
12898 (gnus-summary-prepare-hook nil))
12899 ;; We do the sorting by regenerating the threads.
12900 (gnus-summary-prepare)
12901 ;; Hide subthreads if needed.
12902 (when (and gnus-show-threads gnus-thread-hide-subtree)
12903 (gnus-summary-hide-all-threads)))
12904 ;; If in async mode, we send some info to the backend.
12905 (when gnus-newsgroup-async
12906 (gnus-request-asynchronous
12907 gnus-newsgroup-name gnus-newsgroup-data)))
12909 (defun gnus-sortable-date (date)
12910 "Make sortable string by string-lessp from DATE.
12911 Timezone package is used."
12914 (setq date (inline (timezone-fix-time
12916 (aref (inline (timezone-parse-date date)) 4))))
12918 (timezone-make-sortable-date
12919 (aref date 0) (aref date 1) (aref date 2)
12921 (timezone-make-time-string
12922 (aref date 3) (aref date 4) (aref date 5))))))
12925 ;; Summary saving commands.
12927 (defun gnus-summary-save-article (&optional n not-saved)
12928 "Save the current article using the default saver function.
12929 If N is a positive number, save the N next articles.
12930 If N is a negative number, save the N previous articles.
12931 If N is nil and any articles have been marked with the process mark,
12932 save those articles instead.
12933 The variable `gnus-default-article-saver' specifies the saver function."
12935 (gnus-set-global-variables)
12936 (let ((articles (gnus-summary-work-articles n))
12937 (save-buffer (save-excursion
12938 (nnheader-set-temp-buffer " *Gnus Save*")))
12939 file header article)
12941 (setq header (gnus-summary-article-header
12942 (setq article (pop articles))))
12943 (if (not (vectorp header))
12944 ;; This is a pseudo-article.
12945 (if (assq 'name header)
12946 (gnus-copy-file (cdr (assq 'name header)))
12947 (gnus-message 1 "Article %d is unsaveable" article))
12948 ;; This is a real article.
12949 (save-window-excursion
12950 (gnus-summary-select-article t nil nil article))
12952 (set-buffer save-buffer)
12953 (insert-buffer-substring gnus-original-article-buffer))
12954 (unless gnus-save-all-headers
12955 ;; Remove headers accoring to `gnus-saved-headers'.
12956 (let ((gnus-visible-headers
12957 (or gnus-saved-headers gnus-visible-headers))
12958 (gnus-article-buffer save-buffer))
12959 (gnus-article-hide-headers 1 t)))
12960 (save-window-excursion
12961 (if (not gnus-default-article-saver)
12962 (error "No default saver is defined.")
12963 ;; !!! Magic! The saving functions all save
12964 ;; `gnus-original-article-buffer' (or so they think),
12965 ;; but we bind that variable to out save-buffer.
12966 (set-buffer gnus-article-buffer)
12967 (let ((gnus-original-article-buffer save-buffer))
12968 (setq file (funcall
12969 gnus-default-article-saver
12971 ((not gnus-prompt-before-saving)
12973 ((eq gnus-prompt-before-saving 'always)
12976 (gnus-summary-remove-process-mark article)
12978 (gnus-summary-set-saved-mark article))))
12979 (gnus-kill-buffer save-buffer)
12980 (gnus-summary-position-point)
12983 (defun gnus-summary-pipe-output (&optional arg)
12984 "Pipe the current article to a subprocess.
12985 If N is a positive number, pipe the N next articles.
12986 If N is a negative number, pipe the N previous articles.
12987 If N is nil and any articles have been marked with the process mark,
12988 pipe those articles instead."
12990 (gnus-set-global-variables)
12991 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12992 (gnus-summary-save-article arg t))
12993 (gnus-configure-windows 'pipe))
12995 (defun gnus-summary-save-article-mail (&optional arg)
12996 "Append the current article to an mail file.
12997 If N is a positive number, save the N next articles.
12998 If N is a negative number, save the N previous articles.
12999 If N is nil and any articles have been marked with the process mark,
13000 save those articles instead."
13002 (gnus-set-global-variables)
13003 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13004 (gnus-summary-save-article arg)))
13006 (defun gnus-summary-save-article-rmail (&optional arg)
13007 "Append the current article to an rmail file.
13008 If N is a positive number, save the N next articles.
13009 If N is a negative number, save the N previous articles.
13010 If N is nil and any articles have been marked with the process mark,
13011 save those articles instead."
13013 (gnus-set-global-variables)
13014 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13015 (gnus-summary-save-article arg)))
13017 (defun gnus-summary-save-article-file (&optional arg)
13018 "Append the current article to a file.
13019 If N is a positive number, save the N next articles.
13020 If N is a negative number, save the N previous articles.
13021 If N is nil and any articles have been marked with the process mark,
13022 save those articles instead."
13024 (gnus-set-global-variables)
13025 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13026 (gnus-summary-save-article arg)))
13028 (defun gnus-summary-save-article-body-file (&optional arg)
13029 "Append the current article body to a file.
13030 If N is a positive number, save the N next articles.
13031 If N is a negative number, save the N previous articles.
13032 If N is nil and any articles have been marked with the process mark,
13033 save those articles instead."
13035 (gnus-set-global-variables)
13036 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13037 (gnus-summary-save-article arg)))
13039 (defun gnus-get-split-value (methods)
13040 "Return a value based on the split METHODS."
13041 (let (split-name method result match)
13044 (set-buffer gnus-original-article-buffer)
13046 (nnheader-narrow-to-headers)
13048 (goto-char (point-min))
13049 (setq method (pop methods))
13050 (setq match (car method))
13053 ;; Regular expression.
13055 (re-search-forward match nil t)
13057 ((gnus-functionp match)
13061 (setq result (funcall match gnus-newsgroup-name))))
13066 (setq result (eval match)))))
13067 (setq split-name (append (cdr method) split-name))
13068 (cond ((stringp result)
13069 (push result split-name))
13071 (setq split-name (append result split-name)))))))))
13074 (defun gnus-read-move-group-name (prompt default articles prefix)
13075 "Read a group name."
13076 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13077 (minibuffer-confirm-incomplete nil) ; XEmacs
13084 (assoc (symbol-name
13085 (car (gnus-find-method-for-group
13087 gnus-valid-select-methods))
13088 (push (list (symbol-name g)) group-map)))
13089 gnus-active-hashtb))
13091 (format "%s %s to:"
13093 (if (> (length articles) 1)
13094 (format "these %d articles" (length articles))
13099 (gnus-completing-read default prom
13100 group-map nil nil prefix
13101 'gnus-group-history))
13102 ((= 1 (length split-name))
13103 (gnus-completing-read (car split-name) prom group-map
13105 'gnus-group-history))
13107 (gnus-completing-read nil prom
13108 (mapcar (lambda (el) (list el))
13109 (nreverse split-name))
13111 'gnus-group-history)))))
13113 (if (or (string= to-newsgroup "")
13114 (string= to-newsgroup prefix))
13115 (setq to-newsgroup (or default "")))
13116 (or (gnus-active to-newsgroup)
13117 (gnus-activate-group to-newsgroup)
13118 (error "No such group: %s" to-newsgroup)))
13121 (defun gnus-read-save-file-name (prompt default-name)
13122 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13124 ;; Let the split methods have their say.
13126 ;; No split name was found.
13129 (concat prompt " (default "
13130 (file-name-nondirectory default-name) ") ")
13131 (file-name-directory default-name)
13133 ;; A single split name was found
13134 ((= 1 (length split-name))
13136 (concat prompt " (default " (car split-name) ") ")
13137 gnus-article-save-directory
13138 (concat gnus-article-save-directory (car split-name))))
13139 ;; A list of splits was found.
13141 (setq split-name (nreverse split-name))
13143 (let ((file-name-history (nconc split-name file-name-history)))
13146 (concat prompt " (`M-p' for defaults) ")
13147 gnus-article-save-directory
13148 (car split-name))))
13149 (car (push result file-name-history)))))))
13150 ;; If we have read a directory, we append the default file name.
13151 (when (file-directory-p file)
13152 (setq file (concat (file-name-as-directory file)
13153 (file-name-nondirectory default-name))))
13154 ;; Possibly translate some charaters.
13155 (nnheader-translate-file-chars file)))
13157 (defun gnus-article-archive-name (group)
13158 "Return the first instance of an \"Archive-name\" in the current buffer."
13159 (let ((case-fold-search t))
13160 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13161 (match-string 1))))
13163 (defun gnus-summary-save-in-rmail (&optional filename)
13164 "Append this article to Rmail file.
13165 Optional argument FILENAME specifies file name.
13166 Directory to save to is default to `gnus-article-save-directory'."
13168 (gnus-set-global-variables)
13169 (let ((default-name
13170 (funcall gnus-rmail-save-name gnus-newsgroup-name
13171 gnus-current-headers gnus-newsgroup-last-rmail)))
13173 (cond ((eq filename 'default)
13175 (filename filename)
13176 (t (gnus-read-save-file-name
13177 "Save in rmail file:" default-name))))
13178 (gnus-make-directory (file-name-directory filename))
13179 (gnus-eval-in-buffer-window gnus-original-article-buffer
13183 (gnus-output-to-rmail filename))))
13184 ;; Remember the directory name to save articles
13185 (setq gnus-newsgroup-last-rmail filename)))
13187 (defun gnus-summary-save-in-mail (&optional filename)
13188 "Append this article to Unix mail file.
13189 Optional argument FILENAME specifies file name.
13190 Directory to save to is default to `gnus-article-save-directory'."
13192 (gnus-set-global-variables)
13193 (let ((default-name
13194 (funcall gnus-mail-save-name gnus-newsgroup-name
13195 gnus-current-headers gnus-newsgroup-last-mail)))
13197 (cond ((eq filename 'default)
13199 (filename filename)
13200 (t (gnus-read-save-file-name
13201 "Save in Unix mail file:" default-name))))
13203 (expand-file-name filename
13205 (file-name-directory default-name))))
13206 (gnus-make-directory (file-name-directory filename))
13207 (gnus-eval-in-buffer-window gnus-original-article-buffer
13211 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13212 (gnus-output-to-rmail filename)
13213 (let ((mail-use-rfc822 t))
13214 (rmail-output filename 1 t t))))))
13215 ;; Remember the directory name to save articles.
13216 (setq gnus-newsgroup-last-mail filename)))
13218 (defun gnus-summary-save-in-file (&optional filename)
13219 "Append this article to file.
13220 Optional argument FILENAME specifies file name.
13221 Directory to save to is default to `gnus-article-save-directory'."
13223 (gnus-set-global-variables)
13224 (let ((default-name
13225 (funcall gnus-file-save-name gnus-newsgroup-name
13226 gnus-current-headers gnus-newsgroup-last-file)))
13228 (cond ((eq filename 'default)
13230 (filename filename)
13231 (t (gnus-read-save-file-name
13232 "Save in file:" default-name))))
13233 (gnus-make-directory (file-name-directory filename))
13234 (gnus-eval-in-buffer-window gnus-original-article-buffer
13238 (gnus-output-to-file filename))))
13239 ;; Remember the directory name to save articles.
13240 (setq gnus-newsgroup-last-file filename)))
13242 (defun gnus-summary-save-body-in-file (&optional filename)
13243 "Append this article body to a file.
13244 Optional argument FILENAME specifies file name.
13245 The directory to save in defaults to `gnus-article-save-directory'."
13247 (gnus-set-global-variables)
13248 (let ((default-name
13249 (funcall gnus-file-save-name gnus-newsgroup-name
13250 gnus-current-headers gnus-newsgroup-last-file)))
13252 (cond ((eq filename 'default)
13254 (filename filename)
13255 (t (gnus-read-save-file-name
13256 "Save body in file:" default-name))))
13257 (gnus-make-directory (file-name-directory filename))
13258 (gnus-eval-in-buffer-window gnus-article-buffer
13262 (goto-char (point-min))
13263 (and (search-forward "\n\n" nil t)
13264 (narrow-to-region (point) (point-max)))
13265 (gnus-output-to-file filename))))
13266 ;; Remember the directory name to save articles.
13267 (setq gnus-newsgroup-last-file filename)))
13269 (defun gnus-summary-save-in-pipe (&optional command)
13270 "Pipe this article to subprocess."
13272 (gnus-set-global-variables)
13274 (cond ((eq command 'default)
13275 gnus-last-shell-command)
13277 (t (read-string "Shell command on article: "
13278 gnus-last-shell-command))))
13279 (if (string-equal command "")
13280 (setq command gnus-last-shell-command))
13281 (gnus-eval-in-buffer-window gnus-article-buffer
13284 (shell-command-on-region (point-min) (point-max) command nil)))
13285 (setq gnus-last-shell-command command))
13287 ;; Summary extract commands
13289 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13290 (let ((buffer-read-only nil)
13291 (article (gnus-summary-article-number))
13293 (or (gnus-summary-goto-subject article)
13294 (error (format "No such article: %d" article)))
13295 (gnus-summary-position-point)
13296 ;; If all commands are to be bunched up on one line, we collect
13298 (if gnus-view-pseudos-separately
13300 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13303 (setq action (cdr (assq 'action (car ps))))
13304 (setq files (list (cdr (assq 'name (car ps)))))
13305 (while (and ps (cdr ps)
13306 (string= (or action "1")
13307 (or (cdr (assq 'action (cadr ps))) "2")))
13308 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13309 (setcdr ps (cddr ps)))
13312 (if (not (string-match "%s" action))
13313 (setq files (cons " " files)))
13314 (setq files (cons " " files))
13315 (and (assq 'execute (car ps))
13316 (setcdr (assq 'execute (car ps))
13317 (funcall (if (string-match "%s" action)
13320 (mapconcat (lambda (f) f) files " ")))))
13321 (setq ps (cdr ps)))))
13322 (if (and gnus-view-pseudos (not not-view))
13324 (and (assq 'execute (car pslist))
13325 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13326 (eq gnus-view-pseudos 'not-confirm)))
13327 (setq pslist (cdr pslist)))
13330 (setq after-article (or (cdr (assq 'article (car pslist)))
13331 (gnus-summary-article-number)))
13332 (gnus-summary-goto-subject after-article)
13335 (insert " " (file-name-nondirectory
13336 (cdr (assq 'name (car pslist))))
13337 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13339 (forward-line -1) ; back to `b'
13340 (gnus-add-text-properties
13341 b (1- e) (list 'gnus-number gnus-reffed-article-number
13342 gnus-mouse-face-prop gnus-mouse-face))
13344 after-article gnus-reffed-article-number
13345 gnus-unread-mark b (car pslist) 0 (- e b))
13346 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13347 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13348 (setq pslist (cdr pslist)))))))
13350 (defun gnus-pseudos< (p1 p2)
13351 (let ((c1 (cdr (assq 'action p1)))
13352 (c2 (cdr (assq 'action p2))))
13353 (and c1 c2 (string< c1 c2))))
13355 (defun gnus-request-pseudo-article (props)
13356 (cond ((assq 'execute props)
13357 (gnus-execute-command (cdr (assq 'execute props)))))
13358 (let ((gnus-current-article (gnus-summary-article-number)))
13359 (run-hooks 'gnus-mark-article-hook)))
13361 (defun gnus-execute-command (command &optional automatic)
13363 (gnus-article-setup-buffer)
13364 (set-buffer gnus-article-buffer)
13365 (setq buffer-read-only nil)
13366 (let ((command (if automatic command (read-string "Command: " command)))
13367 ;; Just binding this here doesn't help, because there might
13368 ;; be output from the process after exiting the scope of
13370 ;; (buffer-read-only nil)
13373 (insert "$ " command "\n\n")
13374 (if gnus-view-pseudo-asynchronously
13375 (start-process "gnus-execute" nil "sh" "-c" command)
13376 (call-process "sh" nil t nil "-c" command)))))
13378 (defun gnus-copy-file (file &optional to)
13381 (list (read-file-name "Copy file: " default-directory)
13382 (read-file-name "Copy file to: " default-directory)))
13383 (gnus-set-global-variables)
13384 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13385 (and (file-directory-p to)
13386 (setq to (concat (file-name-as-directory to)
13387 (file-name-nondirectory file))))
13388 (copy-file file to))
13390 ;; Summary kill commands.
13392 (defun gnus-summary-edit-global-kill (article)
13393 "Edit the \"global\" kill file."
13394 (interactive (list (gnus-summary-article-number)))
13395 (gnus-set-global-variables)
13396 (gnus-group-edit-global-kill article))
13398 (defun gnus-summary-edit-local-kill ()
13399 "Edit a local kill file applied to the current newsgroup."
13401 (gnus-set-global-variables)
13402 (setq gnus-current-headers (gnus-summary-article-header))
13403 (gnus-set-global-variables)
13404 (gnus-group-edit-local-kill
13405 (gnus-summary-article-number) gnus-newsgroup-name))
13409 ;;; Gnus article mode
13412 (put 'gnus-article-mode 'mode-class 'special)
13414 (if gnus-article-mode-map
13416 (setq gnus-article-mode-map (make-keymap))
13417 (suppress-keymap gnus-article-mode-map)
13419 (gnus-define-keys gnus-article-mode-map
13420 " " gnus-article-goto-next-page
13421 "\177" gnus-article-goto-prev-page
13422 [delete] gnus-article-goto-prev-page
13423 "\C-c^" gnus-article-refer-article
13424 "h" gnus-article-show-summary
13425 "s" gnus-article-show-summary
13426 "\C-c\C-m" gnus-article-mail
13427 "?" gnus-article-describe-briefly
13428 gnus-mouse-2 gnus-article-push-button
13429 "\r" gnus-article-press-button
13430 "\t" gnus-article-next-button
13431 "\M-\t" gnus-article-prev-button
13432 "\C-c\C-b" gnus-bug)
13434 (substitute-key-definition
13435 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13437 (defun gnus-article-mode ()
13438 "Major mode for displaying an article.
13440 All normal editing commands are switched off.
13442 The following commands are available:
13444 \\<gnus-article-mode-map>
13445 \\[gnus-article-next-page]\t Scroll the article one page forwards
13446 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13447 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13448 \\[gnus-article-show-summary]\t Display the summary buffer
13449 \\[gnus-article-mail]\t Send a reply to the address near point
13450 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13451 \\[gnus-info-find-node]\t Go to the Gnus info node"
13453 (when (and menu-bar-mode
13454 (gnus-visual-p 'article-menu 'menu))
13455 (gnus-article-make-menu-bar))
13456 (kill-all-local-variables)
13457 (gnus-simplify-mode-line)
13458 (setq mode-name "Article")
13459 (setq major-mode 'gnus-article-mode)
13460 (make-local-variable 'minor-mode-alist)
13461 (or (assq 'gnus-show-mime minor-mode-alist)
13462 (setq minor-mode-alist
13463 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13464 (use-local-map gnus-article-mode-map)
13465 (make-local-variable 'page-delimiter)
13466 (setq page-delimiter gnus-page-delimiter)
13467 (buffer-disable-undo (current-buffer))
13468 (setq buffer-read-only t) ;Disable modification
13469 (run-hooks 'gnus-article-mode-hook))
13471 (defun gnus-article-setup-buffer ()
13472 "Initialize the article buffer."
13473 (let* ((name (if gnus-single-article-buffer "*Article*"
13474 (concat "*Article " gnus-newsgroup-name "*")))
13476 (progn (string-match "\\*Article" name)
13477 (concat " *Original Article"
13478 (substring name (match-end 0))))))
13479 (setq gnus-article-buffer name)
13480 (setq gnus-original-article-buffer original)
13481 ;; This might be a variable local to the summary buffer.
13482 (unless gnus-single-article-buffer
13484 (set-buffer gnus-summary-buffer)
13485 (setq gnus-article-buffer name)
13486 (setq gnus-original-article-buffer original)
13487 (gnus-set-global-variables))
13488 (make-local-variable 'gnus-summary-buffer))
13489 ;; Init original article buffer.
13491 (set-buffer (get-buffer-create gnus-original-article-buffer))
13492 (buffer-disable-undo (current-buffer))
13493 (setq major-mode 'gnus-original-article-mode)
13494 (make-local-variable 'gnus-original-article))
13495 (if (get-buffer name)
13498 (buffer-disable-undo (current-buffer))
13499 (setq buffer-read-only t)
13500 (gnus-add-current-to-buffer-list)
13501 (or (eq major-mode 'gnus-article-mode)
13502 (gnus-article-mode))
13505 (set-buffer (get-buffer-create name))
13506 (gnus-add-current-to-buffer-list)
13507 (gnus-article-mode)
13508 (current-buffer)))))
13510 ;; Set article window start at LINE, where LINE is the number of lines
13511 ;; from the head of the article.
13512 (defun gnus-article-set-window-start (&optional line)
13514 (get-buffer-window gnus-article-buffer t)
13516 (set-buffer gnus-article-buffer)
13517 (goto-char (point-min))
13520 (gnus-message 6 "Moved to bookmark")
13521 (search-forward "\n\n" nil t)
13522 (forward-line line)
13525 (defun gnus-kill-all-overlays ()
13526 "Delete all overlays in the current buffer."
13527 (when (fboundp 'overlay-lists)
13528 (let* ((overlayss (overlay-lists))
13529 (buffer-read-only nil)
13530 (overlays (nconc (car overlayss) (cdr overlayss))))
13532 (delete-overlay (pop overlays))))))
13534 (defun gnus-request-article-this-buffer (article group)
13535 "Get an article and insert it into this buffer."
13536 (let (do-update-line)
13540 (gnus-kill-all-overlays)
13541 (setq group (or group gnus-newsgroup-name))
13543 ;; Open server if it has closed.
13544 (gnus-check-server (gnus-find-method-for-group group))
13546 ;; Using `gnus-request-article' directly will insert the article into
13547 ;; `nntp-server-buffer' - so we'll save some time by not having to
13548 ;; copy it from the server buffer into the article buffer.
13550 ;; We only request an article by message-id when we do not have the
13551 ;; headers for it, so we'll have to get those.
13552 (when (stringp article)
13553 (let ((gnus-override-method gnus-refer-article-method))
13554 (gnus-read-header article)))
13556 ;; If the article number is negative, that means that this article
13557 ;; doesn't belong in this newsgroup (possibly), so we find its
13558 ;; message-id and request it by id instead of number.
13559 (when (and (numberp article)
13560 gnus-summary-buffer
13561 (get-buffer gnus-summary-buffer)
13562 (buffer-name (get-buffer gnus-summary-buffer)))
13564 (set-buffer gnus-summary-buffer)
13565 (let ((header (gnus-summary-article-header article)))
13568 ((memq article gnus-newsgroup-sparse)
13569 ;; This is a sparse gap article.
13570 (setq do-update-line article)
13571 (setq article (mail-header-id header))
13572 (let ((gnus-override-method gnus-refer-article-method))
13573 (gnus-read-header article))
13574 (setq gnus-newsgroup-sparse
13575 (delq article gnus-newsgroup-sparse)))
13577 ;; It's a real article.
13578 (setq article (mail-header-id header)))
13580 ;; It is an extracted pseudo-article.
13581 (setq article 'pseudo)
13582 (gnus-request-pseudo-article header))))
13584 (let ((method (gnus-find-method-for-group
13585 gnus-newsgroup-name)))
13586 (if (not (eq (car method) 'nneething))
13588 (let ((dir (concat (file-name-as-directory (nth 1 method))
13589 (mail-header-subject header))))
13590 (if (file-directory-p dir)
13592 (setq article 'nneething)
13593 (gnus-group-enter-directory dir)))))))))
13596 ;; Refuse to select canceled articles.
13597 ((and (numberp article)
13598 gnus-summary-buffer
13599 (get-buffer gnus-summary-buffer)
13600 (buffer-name (get-buffer gnus-summary-buffer))
13601 (eq (cdr (save-excursion
13602 (set-buffer gnus-summary-buffer)
13603 (assq article gnus-newsgroup-reads)))
13604 gnus-canceled-mark))
13606 ;; We first check `gnus-original-article-buffer'.
13607 ((and (get-buffer gnus-original-article-buffer)
13610 (set-buffer gnus-original-article-buffer)
13611 (and (equal (car gnus-original-article) group)
13612 (eq (cdr gnus-original-article) article))))
13613 (insert-buffer-substring gnus-original-article-buffer)
13615 ;; Check the backlog.
13616 ((and gnus-keep-backlog
13617 (gnus-backlog-request-article group article (current-buffer)))
13619 ;; Check the cache.
13620 ((and gnus-use-cache
13622 (gnus-cache-request-article article group))
13624 ;; Get the article and put into the article buffer.
13625 ((or (stringp article) (numberp article))
13626 (let ((gnus-override-method
13627 (and (stringp article) gnus-refer-article-method))
13628 (buffer-read-only nil))
13630 (gnus-kill-all-overlays)
13631 (if (gnus-request-article article group (current-buffer))
13633 (and gnus-keep-backlog
13635 (gnus-backlog-enter-article
13636 group article (current-buffer)))
13638 ;; It was a pseudo.
13641 ;; Take the article from the original article buffer
13642 ;; and place it in the buffer it's supposed to be in.
13643 (when (and (get-buffer gnus-article-buffer)
13644 ;;(numberp article)
13645 (equal (buffer-name (current-buffer))
13646 (buffer-name (get-buffer gnus-article-buffer))))
13648 (if (get-buffer gnus-original-article-buffer)
13649 (set-buffer (get-buffer gnus-original-article-buffer))
13650 (set-buffer (get-buffer-create gnus-original-article-buffer))
13651 (buffer-disable-undo (current-buffer))
13652 (setq major-mode 'gnus-original-article-mode)
13653 (setq buffer-read-only t)
13654 (gnus-add-current-to-buffer-list))
13655 (let (buffer-read-only)
13657 (insert-buffer-substring gnus-article-buffer))
13658 (setq gnus-original-article (cons group article))))
13660 ;; Update sparse articles.
13661 (when (and do-update-line
13662 (or (numberp article)
13663 (stringp article)))
13664 (let ((buf (current-buffer)))
13665 (set-buffer gnus-summary-buffer)
13666 (gnus-summary-update-article do-update-line)
13667 (gnus-summary-goto-subject do-update-line nil t)
13668 (set-window-point (get-buffer-window (current-buffer) t)
13670 (set-buffer buf))))))
13672 (defun gnus-read-header (id &optional header)
13673 "Read the headers of article ID and enter them into the Gnus system."
13674 (let ((group gnus-newsgroup-name)
13675 (gnus-override-method
13676 (and (gnus-news-group-p gnus-newsgroup-name)
13677 gnus-refer-article-method))
13679 ;; First we check to see whether the header in question is already
13682 ;; This is a Message-ID.
13683 (setq header (or header (gnus-id-to-header id)))
13684 ;; This is an article number.
13685 (setq header (or header (gnus-summary-article-header id))))
13687 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13688 ;; We have found the header.
13690 ;; We have to really fetch the header to this article.
13692 (if (gnus-check-backend-function 'request-head group)
13693 (gnus-request-head id group)
13694 (gnus-request-article id group)))
13696 (set-buffer nntp-server-buffer)
13697 (and (search-forward "\n\n" nil t)
13698 (delete-region (1- (point)) (point-max)))
13699 (goto-char (point-max))
13701 (goto-char (point-min))
13705 ((cdr where) (cdr where))
13706 (header (mail-header-number header))
13707 (t gnus-reffed-article-number))
13709 (insert " Article retrieved.\n"))
13711 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13712 ; (setcar (gnus-id-to-thread id) nil))
13713 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13714 () ; Malformed head.
13715 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13716 (if (and (stringp id)
13717 (not (string= (gnus-group-real-name group)
13719 ;; If we fetched by Message-ID and the article came
13720 ;; from a different group, we fudge some bogus article
13721 ;; numbers for this article.
13722 (mail-header-set-number header gnus-reffed-article-number))
13723 (decf gnus-reffed-article-number)
13724 (gnus-remove-header (mail-header-number header))
13725 (push header gnus-newsgroup-headers)
13726 (setq gnus-current-headers header)
13727 (push (mail-header-number header) gnus-newsgroup-limit))
13730 (defun gnus-remove-header (number)
13731 "Remove header NUMBER from `gnus-newsgroup-headers'."
13732 (if (and gnus-newsgroup-headers
13733 (= number (mail-header-number (car gnus-newsgroup-headers))))
13734 (pop gnus-newsgroup-headers)
13735 (let ((headers gnus-newsgroup-headers))
13736 (while (and (cdr headers)
13737 (not (= number (mail-header-number (cadr headers)))))
13739 (when (cdr headers)
13740 (setcdr headers (cddr headers))))))
13742 (defun gnus-article-prepare (article &optional all-headers header)
13743 "Prepare ARTICLE in article mode buffer.
13744 ARTICLE should either be an article number or a Message-ID.
13745 If ARTICLE is an id, HEADER should be the article headers.
13746 If ALL-HEADERS is non-nil, no headers are hidden."
13748 ;; Make sure we start in a summary buffer.
13749 (unless (eq major-mode 'gnus-summary-mode)
13750 (set-buffer gnus-summary-buffer))
13751 (setq gnus-summary-buffer (current-buffer))
13752 ;; Make sure the connection to the server is alive.
13753 (unless (gnus-server-opened
13754 (gnus-find-method-for-group gnus-newsgroup-name))
13755 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13756 (gnus-request-group gnus-newsgroup-name t))
13757 (let* ((article (if header (mail-header-number header) article))
13758 (summary-buffer (current-buffer))
13759 (internal-hook gnus-article-internal-prepare-hook)
13760 (group gnus-newsgroup-name)
13763 (gnus-article-setup-buffer)
13764 (set-buffer gnus-article-buffer)
13765 ;; Deactivate active regions.
13766 (when (and (boundp 'transient-mark-mode)
13767 transient-mark-mode)
13768 (setq mark-active nil))
13769 (if (not (setq result (let ((buffer-read-only nil))
13770 (gnus-request-article-this-buffer
13772 ;; There is no such article.
13774 (when (and (numberp article)
13775 (not (memq article gnus-newsgroup-sparse)))
13776 (setq gnus-article-current
13777 (cons gnus-newsgroup-name article))
13778 (set-buffer gnus-summary-buffer)
13779 (setq gnus-current-article article)
13780 (gnus-summary-mark-article article gnus-canceled-mark))
13781 (unless (memq article gnus-newsgroup-sparse)
13783 1 "No such article (may have expired or been canceled)")))
13784 (if (or (eq result 'pseudo) (eq result 'nneething))
13787 (set-buffer summary-buffer)
13788 (setq gnus-last-article gnus-current-article
13789 gnus-newsgroup-history (cons gnus-current-article
13790 gnus-newsgroup-history)
13791 gnus-current-article 0
13792 gnus-current-headers nil
13793 gnus-article-current nil)
13794 (if (eq result 'nneething)
13795 (gnus-configure-windows 'summary)
13796 (gnus-configure-windows 'article))
13797 (gnus-set-global-variables))
13798 (gnus-set-mode-line 'article))
13799 ;; The result from the `request' was an actual article -
13800 ;; or at least some text that is now displayed in the
13802 (if (and (numberp article)
13803 (not (eq article gnus-current-article)))
13804 ;; Seems like a new article has been selected.
13805 ;; `gnus-current-article' must be an article number.
13807 (set-buffer summary-buffer)
13808 (setq gnus-last-article gnus-current-article
13809 gnus-newsgroup-history (cons gnus-current-article
13810 gnus-newsgroup-history)
13811 gnus-current-article article
13812 gnus-current-headers
13813 (gnus-summary-article-header gnus-current-article)
13814 gnus-article-current
13815 (cons gnus-newsgroup-name gnus-current-article))
13816 (unless (vectorp gnus-current-headers)
13817 (setq gnus-current-headers nil))
13818 (gnus-summary-show-thread)
13819 (run-hooks 'gnus-mark-article-hook)
13820 (gnus-set-mode-line 'summary)
13821 (and (gnus-visual-p 'article-highlight 'highlight)
13822 (run-hooks 'gnus-visual-mark-article-hook))
13823 ;; Set the global newsgroup variables here.
13824 ;; Suggested by Jim Sisolak
13825 ;; <sisolak@trans4.neep.wisc.edu>.
13826 (gnus-set-global-variables)
13827 (setq gnus-have-all-headers
13828 (or all-headers gnus-show-all-headers))
13829 (and gnus-use-cache
13830 (vectorp (gnus-summary-article-header article))
13831 (gnus-cache-possibly-enter-article
13833 (gnus-summary-article-header article)
13834 (memq article gnus-newsgroup-marked)
13835 (memq article gnus-newsgroup-dormant)
13836 (memq article gnus-newsgroup-unreads)))))
13837 (when (or (numberp article)
13839 ;; Hooks for getting information from the article.
13840 ;; This hook must be called before being narrowed.
13841 (let (buffer-read-only)
13842 (run-hooks 'internal-hook)
13843 (run-hooks 'gnus-article-prepare-hook)
13844 ;; Decode MIME message.
13846 (if (or (not gnus-strict-mime)
13847 (gnus-fetch-field "Mime-Version"))
13848 (funcall gnus-show-mime-method)
13849 (funcall gnus-decode-encoded-word-method)))
13850 ;; Perform the article display hooks.
13851 (run-hooks 'gnus-article-display-hook))
13853 (goto-char (point-min))
13854 (and gnus-break-pages (gnus-narrow-to-page)))
13855 (gnus-set-mode-line 'article)
13856 (gnus-configure-windows 'article)
13857 (goto-char (point-min))
13860 (defun gnus-article-show-all-headers ()
13861 "Show all article headers in article mode buffer."
13863 (gnus-article-setup-buffer)
13864 (set-buffer gnus-article-buffer)
13865 (let ((buffer-read-only nil))
13866 (gnus-unhide-text (point-min) (point-max)))))
13868 (defun gnus-article-hide-headers-if-wanted ()
13869 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13870 Provided for backwards compatibility."
13871 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13872 gnus-inhibit-hiding
13873 (gnus-article-hide-headers)))
13875 (defsubst gnus-article-header-rank ()
13876 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13877 (let ((list gnus-sorted-header-list)
13880 (when (looking-at (car list))
13882 (setq list (cdr list))
13886 (defun gnus-article-hide-headers (&optional arg delete)
13887 "Toggle whether to hide unwanted headers and possibly sort them as well.
13888 If given a negative prefix, always show; if given a positive prefix,
13890 (interactive (gnus-hidden-arg))
13891 (if (gnus-article-check-hidden-text 'headers arg)
13892 ;; Show boring headers as well.
13893 (gnus-article-show-hidden-text 'boring-headers)
13894 ;; This function might be inhibited.
13895 (unless gnus-inhibit-hiding
13897 (set-buffer gnus-article-buffer)
13899 (let ((buffer-read-only nil)
13900 (props (nconc (list 'gnus-type 'headers)
13901 gnus-hidden-properties))
13902 (max (1+ (length gnus-sorted-header-list)))
13903 (ignored (when (not (stringp gnus-visible-headers))
13904 (cond ((stringp gnus-ignored-headers)
13905 gnus-ignored-headers)
13906 ((listp gnus-ignored-headers)
13907 (mapconcat 'identity gnus-ignored-headers
13910 (cond ((stringp gnus-visible-headers)
13911 gnus-visible-headers)
13912 ((and gnus-visible-headers
13913 (listp gnus-visible-headers))
13914 (mapconcat 'identity gnus-visible-headers "\\|"))))
13916 ;; First we narrow to just the headers.
13918 (goto-char (point-min))
13919 ;; Hide any "From " lines at the beginning of (mail) articles.
13920 (while (looking-at "From ")
13924 (delete-region (point-min) (point))
13925 (gnus-hide-text (point-min) (point) props)))
13926 ;; Then treat the rest of the header lines.
13929 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13930 ;; Then we use the two regular expressions
13931 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13932 ;; select which header lines is to remain visible in the
13934 (goto-char (point-min))
13935 (while (re-search-forward "^[^ \t]*:" nil t)
13936 (beginning-of-line)
13937 ;; We add the headers we want to keep to a list and delete
13938 ;; them from the buffer.
13939 (gnus-put-text-property
13940 (point) (1+ (point)) 'message-rank
13941 (if (or (and visible (looking-at visible))
13943 (not (looking-at ignored))))
13944 (gnus-article-header-rank)
13947 (message-sort-headers-1)
13948 (when (setq beg (text-property-any
13949 (point-min) (point-max) 'message-rank (+ 2 max)))
13950 ;; We make the unwanted headers invisible.
13952 (delete-region beg (point-max))
13953 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13954 (gnus-hide-text-type beg (point-max) 'headers))
13955 ;; Work around XEmacs lossage.
13956 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
13958 (defun gnus-article-hide-boring-headers (&optional arg)
13959 "Toggle hiding of headers that aren't very interesting.
13960 If given a negative prefix, always show; if given a positive prefix,
13962 (interactive (gnus-hidden-arg))
13963 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13965 (set-buffer gnus-article-buffer)
13967 (let ((buffer-read-only nil)
13968 (list gnus-boring-article-headers)
13969 (inhibit-point-motion-hooks t)
13971 (nnheader-narrow-to-headers)
13973 (setq elem (pop list))
13974 (goto-char (point-min))
13976 ;; Hide empty headers.
13978 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13980 (gnus-hide-text-type
13981 (progn (beginning-of-line) (point))
13984 (if (re-search-forward "^[^ \t]" nil t)
13985 (match-beginning 0)
13988 ;; Hide boring Newsgroups header.
13989 ((eq elem 'newsgroups)
13990 (when (equal (message-fetch-field "newsgroups")
13991 (gnus-group-real-name gnus-newsgroup-name))
13992 (gnus-article-hide-header "newsgroups")))
13993 ((eq elem 'followup-to)
13994 (when (equal (message-fetch-field "followup-to")
13995 (message-fetch-field "newsgroups"))
13996 (gnus-article-hide-header "followup-to")))
13997 ((eq elem 'reply-to)
13998 (let ((from (message-fetch-field "from"))
13999 (reply-to (message-fetch-field "reply-to")))
14003 (nth 1 (funcall gnus-extract-address-components from))
14004 (nth 1 (funcall gnus-extract-address-components
14006 (gnus-article-hide-header "reply-to"))))
14008 (let ((date (message-fetch-field "date")))
14010 (< (gnus-days-between date (current-time-string))
14012 (gnus-article-hide-header "date")))))))))))
14014 (defun gnus-article-hide-header (header)
14016 (goto-char (point-min))
14017 (when (re-search-forward (concat "^" header ":") nil t)
14018 (gnus-hide-text-type
14019 (progn (beginning-of-line) (point))
14022 (if (re-search-forward "^[^ \t]" nil t)
14023 (match-beginning 0)
14025 'boring-headers))))
14027 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14028 (defun gnus-article-treat-overstrike ()
14029 "Translate overstrikes into bold text."
14032 (set-buffer gnus-article-buffer)
14033 (let ((buffer-read-only nil))
14034 (while (search-forward "\b" nil t)
14035 (let ((next (following-char))
14036 (previous (char-after (- (point) 2))))
14038 ((eq next previous)
14039 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14040 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14042 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14043 (gnus-put-text-property
14044 (- (point) 2) (1- (point)) 'face 'underline))
14046 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14047 (gnus-put-text-property
14048 (point) (1+ (point)) 'face 'underline))))))))
14050 (defun gnus-article-word-wrap ()
14051 "Format too long lines."
14054 (set-buffer gnus-article-buffer)
14055 (let ((buffer-read-only nil))
14057 (goto-char (point-min))
14058 (search-forward "\n\n" nil t)
14060 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14061 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14062 (adaptive-fill-mode t))
14063 (while (not (eobp))
14064 (and (>= (current-column) (min fill-column (window-width)))
14065 (/= (preceding-char) ?:)
14066 (fill-paragraph nil))
14067 (end-of-line 2))))))
14069 (defun gnus-article-remove-cr ()
14070 "Remove carriage returns from an article."
14073 (set-buffer gnus-article-buffer)
14074 (let ((buffer-read-only nil))
14075 (goto-char (point-min))
14076 (while (search-forward "\r" nil t)
14077 (replace-match "" t t)))))
14079 (defun gnus-article-remove-trailing-blank-lines ()
14080 "Remove all trailing blank lines from the article."
14083 (set-buffer gnus-article-buffer)
14084 (let ((buffer-read-only nil))
14085 (goto-char (point-max))
14089 (while (looking-at "^[ \t]*$")
14094 (defun gnus-article-display-x-face (&optional force)
14095 "Look for an X-Face header and display it if present."
14096 (interactive (list 'force))
14098 (set-buffer gnus-article-buffer)
14099 ;; Delete the old process, if any.
14100 (when (process-status "gnus-x-face")
14101 (delete-process "gnus-x-face"))
14102 (let ((inhibit-point-motion-hooks t)
14103 (case-fold-search nil)
14106 (nnheader-narrow-to-headers)
14107 (setq from (message-fetch-field "from"))
14108 (goto-char (point-min))
14109 (when (and gnus-article-x-face-command
14111 ;; Check whether this face is censored.
14112 (not gnus-article-x-face-too-ugly)
14113 (and gnus-article-x-face-too-ugly from
14114 (not (string-match gnus-article-x-face-too-ugly
14116 ;; Has to be present.
14117 (re-search-forward "^X-Face: " nil t))
14118 ;; We now have the area of the buffer where the X-Face is stored.
14119 (let ((beg (point))
14120 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14121 ;; We display the face.
14122 (if (symbolp gnus-article-x-face-command)
14123 ;; The command is a lisp function, so we call it.
14124 (if (gnus-functionp gnus-article-x-face-command)
14125 (funcall gnus-article-x-face-command beg end)
14126 (error "%s is not a function" gnus-article-x-face-command))
14127 ;; The command is a string, so we interpret the command
14128 ;; as a, well, command, and fork it off.
14129 (let ((process-connection-type nil))
14130 (process-kill-without-query
14132 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
14133 (process-send-region "gnus-x-face" beg end)
14134 (process-send-eof "gnus-x-face")))))))))
14136 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14137 (defun gnus-decode-rfc1522 ()
14138 "Hack to remove QP encoding from headers."
14139 (let ((case-fold-search t)
14140 (inhibit-point-motion-hooks t)
14141 (buffer-read-only nil)
14145 (goto-char (point-min))
14146 (or (search-forward "\n\n" nil t) (point-max)))
14148 (while (re-search-forward
14149 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14150 (setq string (match-string 1))
14151 (narrow-to-region (match-beginning 0) (match-end 0))
14152 (delete-region (point-min) (point-max))
14154 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14155 (subst-char-in-region (point-min) (point-max) ?_ ? )
14157 (goto-char (point-min))))))
14159 (defun gnus-article-de-quoted-unreadable (&optional force)
14160 "Do a naive translation of a quoted-printable-encoded article.
14161 This is in no way, shape or form meant as a replacement for real MIME
14162 processing, but is simply a stop-gap measure until MIME support is
14164 If FORCE, decode the article whether it is marked as quoted-printable
14166 (interactive (list 'force))
14168 (set-buffer gnus-article-buffer)
14169 (let ((case-fold-search t)
14170 (buffer-read-only nil)
14171 (type (gnus-fetch-field "content-transfer-encoding")))
14172 (gnus-decode-rfc1522)
14174 (and type (string-match "quoted-printable" (downcase type))))
14175 (goto-char (point-min))
14176 (search-forward "\n\n" nil 'move)
14177 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14179 (defun gnus-mime-decode-quoted-printable (from to)
14180 "Decode Quoted-Printable in the region between FROM and TO."
14183 (while (search-forward "=" to t)
14184 (cond ((eq (following-char) ?\n)
14187 ((looking-at "[0-9A-F][0-9A-F]")
14188 (subst-char-in-region
14189 (1- (point)) (point) ?=
14190 (hexl-hex-string-to-integer
14191 (buffer-substring (point) (+ 2 (point)))))
14195 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14197 (defun gnus-article-hide-pgp (&optional arg)
14198 "Toggle hiding of any PGP headers and signatures in the current article.
14199 If given a negative prefix, always show; if given a positive prefix,
14201 (interactive (gnus-hidden-arg))
14202 (unless (gnus-article-check-hidden-text 'pgp arg)
14204 (set-buffer gnus-article-buffer)
14205 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14206 buffer-read-only beg end)
14208 (goto-char (point-min))
14209 ;; Hide the "header".
14210 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14211 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14213 ;; Hide the actual signature.
14214 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14215 (setq end (1+ (match-beginning 0)))
14218 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14220 ;; Perhaps we shouldn't hide to the end of the buffer
14221 ;; if there is no end to the signature?
14224 ;; Hide "- " PGP quotation markers.
14225 (when (and beg end)
14226 (narrow-to-region beg end)
14227 (goto-char (point-min))
14228 (while (re-search-forward "^- " nil t)
14229 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14232 (defun gnus-article-hide-signature (&optional arg)
14233 "Hide the signature in the current article.
14234 If given a negative prefix, always show; if given a positive prefix,
14236 (interactive (gnus-hidden-arg))
14237 (unless (gnus-article-check-hidden-text 'signature arg)
14239 (set-buffer gnus-article-buffer)
14241 (let ((buffer-read-only nil))
14242 (when (gnus-narrow-to-signature)
14243 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14245 (defun gnus-article-strip-leading-blank-lines ()
14246 "Remove all blank lines from the beginning of the article."
14249 (set-buffer gnus-article-buffer)
14250 (let (buffer-read-only)
14251 (goto-char (point-min))
14252 (when (search-forward "\n\n" nil t)
14253 (while (looking-at "[ \t]$")
14254 (gnus-delete-line))))))
14256 (defvar mime::preview/content-list)
14257 (defvar mime::preview-content-info/point-min)
14258 (defun gnus-narrow-to-signature ()
14259 "Narrow to the signature."
14261 (if (and (boundp 'mime::preview/content-list)
14262 mime::preview/content-list)
14263 (let ((pcinfo (car (last mime::preview/content-list))))
14265 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14268 (goto-char (point-max))
14269 (when (re-search-backward gnus-signature-separator nil t)
14271 (when (or (null gnus-signature-limit)
14272 (and (numberp gnus-signature-limit)
14273 (< (- (point-max) (point)) gnus-signature-limit))
14274 (and (gnus-functionp gnus-signature-limit)
14275 (funcall gnus-signature-limit))
14276 (and (stringp gnus-signature-limit)
14277 (not (re-search-forward gnus-signature-limit nil t))))
14278 (narrow-to-region (point) (point-max))
14281 (defun gnus-hidden-arg ()
14282 "Return the current prefix arg as a number, or 0 if no prefix."
14283 (list (if current-prefix-arg
14284 (prefix-numeric-value current-prefix-arg)
14287 (defun gnus-article-check-hidden-text (type arg)
14288 "Return nil if hiding is necessary.
14289 Arg can be nil or a number. Nil and positive means hide, negative
14290 means show, 0 means toggle."
14292 (set-buffer gnus-article-buffer)
14293 (let ((hide (gnus-article-hidden-text-p type)))
14299 (gnus-article-show-hidden-text type))
14301 (if (eq hide 'hidden)
14302 (gnus-article-show-hidden-text type)
14305 (defun gnus-article-hidden-text-p (type)
14306 "Say whether the current buffer contains hidden text of type TYPE."
14307 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14309 (if (get-text-property pos 'invisible)
14313 (defun gnus-article-hide (&optional arg force)
14314 "Hide all the gruft in the current article.
14315 This means that PGP stuff, signatures, cited text and (some)
14316 headers will be hidden.
14317 If given a prefix, show the hidden text instead."
14318 (interactive (list current-prefix-arg 'force))
14319 (gnus-article-hide-headers arg)
14320 (gnus-article-hide-pgp arg)
14321 (gnus-article-hide-citation-maybe arg force)
14322 (gnus-article-hide-signature arg))
14324 (defun gnus-article-show-hidden-text (type &optional hide)
14325 "Show all hidden text of type TYPE.
14326 If HIDE, hide the text instead."
14328 (set-buffer gnus-article-buffer)
14329 (let ((buffer-read-only nil)
14330 (inhibit-point-motion-hooks t)
14332 (while (gnus-goto-char (text-property-any
14333 beg (point-max) 'gnus-type type))
14337 (gnus-hide-text beg (point) gnus-hidden-properties)
14338 (gnus-unhide-text beg (point)))
14339 (setq beg (point)))
14342 (defvar gnus-article-time-units
14343 `((year . ,(* 365.25 24 60 60))
14344 (week . ,(* 7 24 60 60))
14345 (day . ,(* 24 60 60))
14346 (hour . ,(* 60 60))
14349 "Mapping from time units to seconds.")
14351 (defun gnus-article-date-ut (&optional type highlight)
14352 "Convert DATE date to universal time in the current article.
14353 If TYPE is `local', convert to local time; if it is `lapsed', output
14354 how much time has lapsed since DATE."
14355 (interactive (list 'ut t))
14356 (let* ((header (or gnus-current-headers
14357 (gnus-summary-article-header) ""))
14358 (date (and (vectorp header) (mail-header-date header)))
14359 (date-regexp "^Date: \\|^X-Sent: ")
14360 (now (current-time))
14361 (inhibit-point-motion-hooks t)
14363 (when (and date (not (string= date "")))
14365 (set-buffer gnus-article-buffer)
14367 (nnheader-narrow-to-headers)
14368 (let ((buffer-read-only nil))
14369 ;; Delete any old Date headers.
14370 (if (re-search-forward date-regexp nil t)
14372 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14373 eface (get-text-property (1- (gnus-point-at-eol))
14375 (message-remove-header date-regexp t)
14376 (beginning-of-line))
14377 (goto-char (point-max)))
14378 (insert (gnus-make-date-line date type))
14379 ;; Do highlighting.
14381 (when (and (gnus-visual-p 'article-highlight 'highlight)
14382 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14383 (gnus-put-text-property (match-beginning 1) (match-end 1)
14385 (gnus-put-text-property (match-beginning 2) (match-end 2)
14386 'face eface))))))))
14388 (defun gnus-make-date-line (date type)
14389 "Return a DATE line of TYPE."
14391 ;; Convert to the local timezone. We have to slap a
14392 ;; `condition-case' round the calls to the timezone
14393 ;; functions since they aren't particularly resistant to
14396 (concat "Date: " (condition-case ()
14397 (timezone-make-date-arpa-standard date)
14400 ;; Convert to Universal Time.
14404 (timezone-make-date-arpa-standard date nil "UT")
14407 ;; Get the original date from the article.
14408 ((eq type 'original)
14409 (concat "Date: " date "\n"))
14410 ;; Do an X-Sent lapsed format.
14412 ;; If the date is seriously mangled, the timezone
14413 ;; functions are liable to bug out, so we condition-case
14414 ;; the entire thing.
14415 (let* ((now (current-time))
14420 (timezone-make-date-arpa-standard
14421 (current-time-string now)
14422 (current-time-zone now) "UT"))
14424 (timezone-make-date-arpa-standard
14427 (real-sec (+ (* (float (car real-time)) 65536)
14429 (sec (abs real-sec))
14432 ((equal real-time '(0 0))
14433 "X-Sent: Unknown\n")
14439 ;; This is a bit convoluted, but basically we go
14440 ;; through the time units for years, weeks, etc,
14441 ;; and divide things to see whether that results
14442 ;; in positive answers.
14445 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14446 ;; The (remaining) seconds are too few to
14447 ;; be divided into this time unit.
14449 ;; It's big enough, so we output it.
14450 (setq sec (- sec (* num (cdr unit))))
14452 (concat (if prev ", " "") (int-to-string
14454 " " (symbol-name (car unit))
14455 (if (> num 1) "s" ""))
14457 gnus-article-time-units "")
14458 ;; If dates are odd, then it might appear like the
14459 ;; article was sent in the future.
14462 " in the future\n"))))))
14464 (error "Unknown conversion type: %s" type))))
14466 (defun gnus-article-date-local (&optional highlight)
14467 "Convert the current article date to the local timezone."
14468 (interactive (list t))
14469 (gnus-article-date-ut 'local highlight))
14471 (defun gnus-article-date-original (&optional highlight)
14472 "Convert the current article date to what it was originally.
14473 This is only useful if you have used some other date conversion
14474 function and want to see what the date was before converting."
14475 (interactive (list t))
14476 (gnus-article-date-ut 'original highlight))
14478 (defun gnus-article-date-lapsed (&optional highlight)
14479 "Convert the current article date to time lapsed since it was sent."
14480 (interactive (list t))
14481 (gnus-article-date-ut 'lapsed highlight))
14483 (defun gnus-article-maybe-highlight ()
14484 "Do some article highlighting if `gnus-visual' is non-nil."
14485 (if (gnus-visual-p 'article-highlight 'highlight)
14486 (gnus-article-highlight-some)))
14488 ;;; Article savers.
14490 (defun gnus-output-to-rmail (file-name)
14491 "Append the current article to an Rmail file named FILE-NAME."
14493 ;; Most of these codes are borrowed from rmailout.el.
14494 (setq file-name (expand-file-name file-name))
14495 (setq rmail-default-rmail-file file-name)
14496 (let ((artbuf (current-buffer))
14497 (tmpbuf (get-buffer-create " *Gnus-output*")))
14499 (or (get-file-buffer file-name)
14500 (file-exists-p file-name)
14501 (if (gnus-yes-or-no-p
14502 (concat "\"" file-name "\" does not exist, create it? "))
14503 (let ((file-buffer (create-file-buffer file-name)))
14505 (set-buffer file-buffer)
14506 (rmail-insert-rmail-file-header)
14507 (let ((require-final-newline nil))
14508 (write-region (point-min) (point-max) file-name t 1)))
14509 (kill-buffer file-buffer))
14510 (error "Output file does not exist")))
14511 (set-buffer tmpbuf)
14512 (buffer-disable-undo (current-buffer))
14514 (insert-buffer-substring artbuf)
14515 (gnus-convert-article-to-rmail)
14516 ;; Decide whether to append to a file or to an Emacs buffer.
14517 (let ((outbuf (get-file-buffer file-name)))
14519 (append-to-file (point-min) (point-max) file-name)
14520 ;; File has been visited, in buffer OUTBUF.
14521 (set-buffer outbuf)
14522 (let ((buffer-read-only nil)
14523 (msg (and (boundp 'rmail-current-message)
14524 (symbol-value 'rmail-current-message))))
14525 ;; If MSG is non-nil, buffer is in RMAIL mode.
14528 (narrow-to-region (point-max) (point-max))))
14529 (insert-buffer-substring tmpbuf)
14532 (goto-char (point-min))
14534 (search-backward "\^_")
14535 (narrow-to-region (point) (point-max))
14536 (goto-char (1+ (point-min)))
14537 (rmail-count-new-messages t)
14538 (rmail-show-message msg)))))))
14539 (kill-buffer tmpbuf)))
14541 (defun gnus-output-to-file (file-name)
14542 "Append the current article to a file named FILE-NAME."
14543 (setq file-name (expand-file-name file-name))
14544 (let ((artbuf (current-buffer))
14545 (tmpbuf (get-buffer-create " *Gnus-output*")))
14547 (set-buffer tmpbuf)
14548 (buffer-disable-undo (current-buffer))
14550 (insert-buffer-substring artbuf)
14551 ;; Append newline at end of the buffer as separator, and then
14552 ;; save it to file.
14553 (goto-char (point-max))
14555 (append-to-file (point-min) (point-max) file-name))
14556 (kill-buffer tmpbuf)))
14558 (defun gnus-convert-article-to-rmail ()
14559 "Convert article in current buffer to Rmail message format."
14560 (let ((buffer-read-only nil))
14561 ;; Convert article directly into Babyl format.
14562 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14563 (goto-char (point-min))
14564 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14565 (while (search-forward "\n\^_" nil t) ;single char
14566 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14567 (goto-char (point-max))
14570 (defun gnus-narrow-to-page (&optional arg)
14571 "Narrow the article buffer to a page.
14572 If given a numerical ARG, move forward ARG pages."
14574 (setq arg (if arg (prefix-numeric-value arg) 0))
14576 (set-buffer gnus-article-buffer)
14577 (goto-char (point-min))
14579 (when (gnus-visual-p 'page-marker)
14580 (let ((buffer-read-only nil))
14581 (gnus-remove-text-with-property 'gnus-prev)
14582 (gnus-remove-text-with-property 'gnus-next)))
14585 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14587 (re-search-forward page-delimiter nil 'move arg)))
14588 (goto-char (match-end 0)))
14591 (if (re-search-forward page-delimiter nil 'move)
14592 (match-beginning 0)
14594 (when (and (gnus-visual-p 'page-marker)
14595 (not (= (point-min) 1)))
14597 (goto-char (point-min))
14598 (gnus-insert-prev-page-button)))
14599 (when (and (gnus-visual-p 'page-marker)
14600 (not (= (1- (point-max)) (buffer-size))))
14602 (goto-char (point-max))
14603 (gnus-insert-next-page-button)))))
14605 ;; Article mode commands
14607 (defun gnus-article-goto-next-page ()
14608 "Show the next page of the article."
14610 (when (gnus-article-next-page)
14611 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14613 (defun gnus-article-goto-prev-page ()
14614 "Show the next page of the article."
14616 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14617 (gnus-article-prev-page nil)))
14619 (defun gnus-article-next-page (&optional lines)
14620 "Show the next page of the current article.
14621 If end of article, return non-nil. Otherwise return nil.
14622 Argument LINES specifies lines to be scrolled up."
14624 (move-to-window-line -1)
14625 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14626 (if (save-excursion
14628 (and (pos-visible-in-window-p) ;Not continuation line.
14630 ;; Nothing in this page.
14631 (if (or (not gnus-break-pages)
14634 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14636 (gnus-narrow-to-page 1) ;Go to next page.
14638 ;; More in this page.
14642 ;; Long lines may cause an end-of-buffer error.
14643 (goto-char (point-max))))
14644 (move-to-window-line 0)
14647 (defun gnus-article-prev-page (&optional lines)
14648 "Show previous page of current article.
14649 Argument LINES specifies lines to be scrolled down."
14651 (move-to-window-line 0)
14652 (if (and gnus-break-pages
14654 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14656 (gnus-narrow-to-page -1) ;Go to previous page.
14657 (goto-char (point-max))
14661 (scroll-down lines)
14663 (move-to-window-line 0))))
14665 (defun gnus-article-refer-article ()
14666 "Read article specified by message-id around point."
14668 (let ((point (point)))
14669 (search-forward ">" nil t) ;Move point to end of "<....>".
14670 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14671 (let ((message-id (match-string 1)))
14673 (set-buffer gnus-summary-buffer)
14674 (gnus-summary-refer-article message-id))
14675 (goto-char (point))
14676 (error "No references around point"))))
14678 (defun gnus-article-show-summary ()
14679 "Reconfigure windows to show summary buffer."
14681 (gnus-configure-windows 'article)
14682 (gnus-summary-goto-subject gnus-current-article))
14684 (defun gnus-article-describe-briefly ()
14685 "Describe article mode commands briefly."
14688 (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")))
14690 (defun gnus-article-summary-command ()
14691 "Execute the last keystroke in the summary buffer."
14693 (let ((obuf (current-buffer))
14694 (owin (current-window-configuration))
14696 (switch-to-buffer gnus-summary-buffer 'norecord)
14697 (setq func (lookup-key (current-local-map) (this-command-keys)))
14698 (call-interactively func)
14700 (set-window-configuration owin)
14701 (set-window-point (get-buffer-window (current-buffer)) (point))))
14703 (defun gnus-article-summary-command-nosave ()
14704 "Execute the last keystroke in the summary buffer."
14707 (pop-to-buffer gnus-summary-buffer 'norecord)
14708 (setq func (lookup-key (current-local-map) (this-command-keys)))
14709 (call-interactively func)))
14711 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14712 "Read a summary buffer key sequence and execute it from the article buffer."
14715 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14716 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14717 "=" "^" "\M-^" "|"))
14720 (set-buffer gnus-summary-buffer)
14721 (push (or key last-command-event) unread-command-events)
14722 (setq keys (read-key-sequence nil)))
14725 (if (member keys nosaves)
14727 (pop-to-buffer gnus-summary-buffer 'norecord)
14728 (if (setq func (lookup-key (current-local-map) keys))
14729 (call-interactively func)
14731 (let ((obuf (current-buffer))
14732 (owin (current-window-configuration))
14735 (if not-restore-window
14736 (pop-to-buffer gnus-summary-buffer 'norecord)
14737 (switch-to-buffer gnus-summary-buffer 'norecord))
14738 (setq in-buffer (current-buffer))
14739 (if (setq func (lookup-key (current-local-map) keys))
14740 (call-interactively func)
14742 (when (eq in-buffer (current-buffer))
14744 (unless not-restore-window
14745 (set-window-configuration owin))
14746 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14750 ;;; Kill file handling.
14754 (defalias 'gnus-batch-kill 'gnus-batch-score)
14756 (defun gnus-batch-score ()
14757 "Run batched scoring.
14758 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14759 Newsgroups is a list of strings in Bnews format. If you want to score
14760 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14761 score the alt hierarchy, you'd say \"!alt.all\"."
14764 (gnus-newsrc-parse-options
14765 (apply (function concat)
14766 (mapcar (lambda (g) (concat g " "))
14767 command-line-args-left))))
14768 (gnus-expert-user t)
14769 (nnmail-spool-file nil)
14770 (gnus-use-dribble-file nil)
14771 (yes (car yes-and-no))
14772 (no (cdr yes-and-no))
14774 ;; Disable verbose message.
14775 gnus-novice-user gnus-large-newsgroup)
14776 ;; Eat all arguments.
14777 (setq command-line-args-left nil)
14780 ;; Apply kills to specified newsgroups in command line arguments.
14781 (setq newsrc (cdr gnus-newsrc-alist))
14783 (setq group (caar newsrc))
14784 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14785 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14787 (or (eq (car entry) t)
14788 (not (zerop (car entry)))))
14789 (if yes (string-match yes group) t)
14790 (or (null no) (not (string-match no group))))
14792 (gnus-summary-read-group group nil t nil t)
14793 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14794 (gnus-summary-exit))))
14795 (setq newsrc (cdr newsrc)))
14797 (switch-to-buffer gnus-group-buffer)
14798 (gnus-group-save-newsrc)))
14800 (defun gnus-apply-kill-file ()
14801 "Apply a kill file to the current newsgroup.
14802 Returns the number of articles marked as read."
14803 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14804 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14805 (gnus-apply-kill-file-internal)
14808 (defun gnus-kill-save-kill-buffer ()
14809 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14810 (when (get-file-buffer file)
14812 (set-buffer (get-file-buffer file))
14813 (and (buffer-modified-p) (save-buffer))
14814 (kill-buffer (current-buffer))))))
14816 (defvar gnus-kill-file-name "KILL"
14817 "Suffix of the kill files.")
14819 (defun gnus-newsgroup-kill-file (newsgroup)
14820 "Return the name of a kill file name for NEWSGROUP.
14821 If NEWSGROUP is nil, return the global kill file name instead."
14823 ;; The global KILL file is placed at top of the directory.
14824 ((or (null newsgroup)
14825 (string-equal newsgroup ""))
14826 (expand-file-name gnus-kill-file-name
14827 gnus-kill-files-directory))
14828 ;; Append ".KILL" to newsgroup name.
14829 ((gnus-use-long-file-name 'not-kill)
14830 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14831 "." gnus-kill-file-name)
14832 gnus-kill-files-directory))
14833 ;; Place "KILL" under the hierarchical directory.
14835 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14836 "/" gnus-kill-file-name)
14837 gnus-kill-files-directory))))
14844 (defvar gnus-dribble-ignore nil)
14845 (defvar gnus-dribble-eval-file nil)
14847 (defun gnus-dribble-file-name ()
14848 "Return the dribble file for the current .newsrc."
14850 (if gnus-dribble-directory
14851 (concat (file-name-as-directory gnus-dribble-directory)
14852 (file-name-nondirectory gnus-current-startup-file))
14853 gnus-current-startup-file)
14856 (defun gnus-dribble-enter (string)
14857 "Enter STRING into the dribble buffer."
14858 (if (and (not gnus-dribble-ignore)
14859 gnus-dribble-buffer
14860 (buffer-name gnus-dribble-buffer))
14861 (let ((obuf (current-buffer)))
14862 (set-buffer gnus-dribble-buffer)
14863 (insert string "\n")
14864 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14865 (set-buffer obuf))))
14867 (defun gnus-dribble-read-file ()
14868 "Read the dribble file from disk."
14869 (let ((dribble-file (gnus-dribble-file-name)))
14871 (set-buffer (setq gnus-dribble-buffer
14873 (file-name-nondirectory dribble-file))))
14874 (gnus-add-current-to-buffer-list)
14876 (setq buffer-file-name dribble-file)
14878 (buffer-disable-undo (current-buffer))
14879 (bury-buffer (current-buffer))
14880 (set-buffer-modified-p nil)
14881 (let ((auto (make-auto-save-file-name))
14882 (gnus-dribble-ignore t)
14884 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14885 ;; Load whichever file is newest -- the auto save file
14886 ;; or the "real" file.
14887 (if (file-newer-than-file-p auto dribble-file)
14888 (insert-file-contents auto)
14889 (insert-file-contents dribble-file))
14890 (unless (zerop (buffer-size))
14891 (set-buffer-modified-p t))
14892 ;; Set the file modes to reflect the .newsrc file modes.
14894 (when (and (file-exists-p gnus-current-startup-file)
14895 (setq modes (file-modes gnus-current-startup-file)))
14896 (set-file-modes dribble-file modes))
14897 ;; Possibly eval the file later.
14898 (when (gnus-y-or-n-p
14899 "Auto-save file exists. Do you want to read it? ")
14900 (setq gnus-dribble-eval-file t)))))))
14902 (defun gnus-dribble-eval-file ()
14903 (when gnus-dribble-eval-file
14904 (setq gnus-dribble-eval-file nil)
14906 (let ((gnus-dribble-ignore t))
14907 (set-buffer gnus-dribble-buffer)
14908 (eval-buffer (current-buffer))))))
14910 (defun gnus-dribble-delete-file ()
14911 (when (file-exists-p (gnus-dribble-file-name))
14912 (delete-file (gnus-dribble-file-name)))
14913 (when gnus-dribble-buffer
14915 (set-buffer gnus-dribble-buffer)
14916 (let ((auto (make-auto-save-file-name)))
14917 (if (file-exists-p auto)
14918 (delete-file auto))
14920 (set-buffer-modified-p nil)))))
14922 (defun gnus-dribble-save ()
14923 (when (and gnus-dribble-buffer
14924 (buffer-name gnus-dribble-buffer))
14926 (set-buffer gnus-dribble-buffer)
14929 (defun gnus-dribble-clear ()
14930 (when (gnus-buffer-exists-p gnus-dribble-buffer)
14932 (set-buffer gnus-dribble-buffer)
14934 (set-buffer-modified-p nil)
14935 (setq buffer-saved-size (buffer-size)))))
14939 ;;; Server Communication
14942 (defun gnus-start-news-server (&optional confirm)
14943 "Open a method for getting news.
14944 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14946 (if gnus-current-select-method
14947 ;; Stream is already opened.
14949 ;; Open NNTP server.
14950 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14953 ;; Read server name with completion.
14954 (setq gnus-nntp-server
14955 (completing-read "NNTP server: "
14956 (mapcar (lambda (server) (list server))
14957 (cons (list gnus-nntp-server)
14958 gnus-secondary-servers))
14959 nil nil gnus-nntp-server))))
14961 (if (and gnus-nntp-server
14962 (stringp gnus-nntp-server)
14963 (not (string= gnus-nntp-server "")))
14964 (setq gnus-select-method
14965 (cond ((or (string= gnus-nntp-server "")
14966 (string= gnus-nntp-server "::"))
14967 (list 'nnspool (system-name)))
14968 ((string-match "^:" gnus-nntp-server)
14969 (list 'nnmh gnus-nntp-server
14970 (list 'nnmh-directory
14971 (file-name-as-directory
14973 (concat "~/" (substring
14974 gnus-nntp-server 1)))))
14975 (list 'nnmh-get-new-mail nil)))
14977 (list 'nntp gnus-nntp-server)))))
14979 (setq how (car gnus-select-method))
14980 (cond ((eq how 'nnspool)
14982 (gnus-message 5 "Looking up local news spool..."))
14985 (gnus-message 5 "Looking up mh spool..."))
14988 (setq gnus-current-select-method gnus-select-method)
14989 (run-hooks 'gnus-open-server-hook)
14991 ;; gnus-open-server-hook might have opened it
14992 (gnus-server-opened gnus-select-method)
14993 (gnus-open-server gnus-select-method)
14996 "%s (%s) open error: '%s'. Continue? "
14997 (car gnus-select-method) (cadr gnus-select-method)
14998 (gnus-status-message gnus-select-method)))
14999 (gnus-error 1 "Couldn't open server on %s"
15000 (nth 1 gnus-select-method))))))
15002 (defun gnus-check-group (group)
15003 "Try to make sure that the server where GROUP exists is alive."
15004 (let ((method (gnus-find-method-for-group group)))
15005 (or (gnus-server-opened method)
15006 (gnus-open-server method))))
15008 (defun gnus-check-server (&optional method silent)
15009 "Check whether the connection to METHOD is down.
15010 If METHOD is nil, use `gnus-select-method'.
15011 If it is down, start it up (again)."
15012 (let ((method (or method gnus-select-method)))
15013 ;; Transform virtual server names into select methods.
15014 (when (stringp method)
15015 (setq method (gnus-server-to-method method)))
15016 (if (gnus-server-opened method)
15017 ;; The stream is already opened.
15019 ;; Open the server.
15021 (gnus-message 5 "Opening %s server%s..." (car method)
15022 (if (equal (nth 1 method) "") ""
15023 (format " on %s" (nth 1 method)))))
15024 (run-hooks 'gnus-open-server-hook)
15026 (gnus-open-server method)
15030 (defun gnus-get-function (method function)
15031 "Return a function symbol based on METHOD and FUNCTION."
15032 ;; Translate server names into methods.
15034 (error "Attempted use of a nil select method"))
15035 (when (stringp method)
15036 (setq method (gnus-server-to-method method)))
15037 (let ((func (intern (format "%s-%s" (car method) function))))
15038 ;; If the functions isn't bound, we require the backend in
15040 (unless (fboundp func)
15041 (require (car method))
15042 (unless (fboundp func)
15043 ;; This backend doesn't implement this function.
15044 (error "No such function: %s" func)))
15049 ;;; Interface functions to the backends.
15052 (defun gnus-open-server (method)
15053 "Open a connection to METHOD."
15054 (when (stringp method)
15055 (setq method (gnus-server-to-method method)))
15056 (let ((elem (assoc method gnus-opened-servers)))
15057 ;; If this method was previously denied, we just return nil.
15058 (if (eq (nth 1 elem) 'denied)
15060 (gnus-message 1 "Denied server")
15062 ;; Open the server.
15064 (funcall (gnus-get-function method 'open-server)
15065 (nth 1 method) (nthcdr 2 method))))
15066 ;; If this hasn't been opened before, we add it to the list.
15068 (setq elem (list method nil)
15069 gnus-opened-servers (cons elem gnus-opened-servers)))
15070 ;; Set the status of this server.
15071 (setcar (cdr elem) (if result 'ok 'denied))
15072 ;; Return the result from the "open" call.
15075 (defun gnus-close-server (method)
15076 "Close the connection to METHOD."
15077 (when (stringp method)
15078 (setq method (gnus-server-to-method method)))
15079 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15081 (defun gnus-request-list (method)
15082 "Request the active file from METHOD."
15083 (when (stringp method)
15084 (setq method (gnus-server-to-method method)))
15085 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15087 (defun gnus-request-list-newsgroups (method)
15088 "Request the newsgroups file from METHOD."
15089 (when (stringp method)
15090 (setq method (gnus-server-to-method method)))
15091 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15093 (defun gnus-request-newgroups (date method)
15094 "Request all new groups since DATE from METHOD."
15095 (when (stringp method)
15096 (setq method (gnus-server-to-method method)))
15097 (funcall (gnus-get-function method 'request-newgroups)
15098 date (nth 1 method)))
15100 (defun gnus-server-opened (method)
15101 "Check whether a connection to METHOD has been opened."
15102 (when (stringp method)
15103 (setq method (gnus-server-to-method method)))
15104 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15106 (defun gnus-status-message (method)
15107 "Return the status message from METHOD.
15108 If METHOD is a string, it is interpreted as a group name. The method
15109 this group uses will be queried."
15110 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15112 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15114 (defun gnus-request-group (group &optional dont-check method)
15115 "Request GROUP. If DONT-CHECK, no information is required."
15116 (let ((method (or method (gnus-find-method-for-group group))))
15117 (when (stringp method)
15118 (setq method (gnus-server-to-method method)))
15119 (funcall (gnus-get-function method 'request-group)
15120 (gnus-group-real-name group) (nth 1 method) dont-check)))
15122 (defun gnus-request-asynchronous (group &optional articles)
15123 "Request that GROUP behave asynchronously.
15124 ARTICLES is the `data' of the group."
15125 (let ((method (gnus-find-method-for-group group)))
15126 (funcall (gnus-get-function method 'request-asynchronous)
15127 (gnus-group-real-name group) (nth 1 method) articles)))
15129 (defun gnus-list-active-group (group)
15130 "Request active information on GROUP."
15131 (let ((method (gnus-find-method-for-group group))
15132 (func 'list-active-group))
15133 (when (gnus-check-backend-function func group)
15134 (funcall (gnus-get-function method func)
15135 (gnus-group-real-name group) (nth 1 method)))))
15137 (defun gnus-request-group-description (group)
15138 "Request a description of GROUP."
15139 (let ((method (gnus-find-method-for-group group))
15140 (func 'request-group-description))
15141 (when (gnus-check-backend-function func group)
15142 (funcall (gnus-get-function method func)
15143 (gnus-group-real-name group) (nth 1 method)))))
15145 (defun gnus-close-group (group)
15146 "Request the GROUP be closed."
15147 (let ((method (gnus-find-method-for-group group)))
15148 (funcall (gnus-get-function method 'close-group)
15149 (gnus-group-real-name group) (nth 1 method))))
15151 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15152 "Request headers for ARTICLES in GROUP.
15153 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15154 (let ((method (gnus-find-method-for-group group)))
15155 (if (and gnus-use-cache (numberp (car articles)))
15156 (gnus-cache-retrieve-headers articles group fetch-old)
15157 (funcall (gnus-get-function method 'retrieve-headers)
15158 articles (gnus-group-real-name group) (nth 1 method)
15161 (defun gnus-retrieve-groups (groups method)
15162 "Request active information on GROUPS from METHOD."
15163 (when (stringp method)
15164 (setq method (gnus-server-to-method method)))
15165 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15167 (defun gnus-request-type (group &optional article)
15168 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15169 (let ((method (gnus-find-method-for-group group)))
15170 (if (not (gnus-check-backend-function 'request-type (car method)))
15172 (funcall (gnus-get-function method 'request-type)
15173 (gnus-group-real-name group) article))))
15175 (defun gnus-request-update-mark (group article mark)
15176 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15177 (let ((method (gnus-find-method-for-group group)))
15178 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15180 (funcall (gnus-get-function method 'request-update-mark)
15181 (gnus-group-real-name group) article mark))))
15183 (defun gnus-request-article (article group &optional buffer)
15184 "Request the ARTICLE in GROUP.
15185 ARTICLE can either be an article number or an article Message-ID.
15186 If BUFFER, insert the article in that group."
15187 (let ((method (gnus-find-method-for-group group)))
15188 (funcall (gnus-get-function method 'request-article)
15189 article (gnus-group-real-name group) (nth 1 method) buffer)))
15191 (defun gnus-request-head (article group)
15192 "Request the head of ARTICLE in GROUP."
15193 (let ((method (gnus-find-method-for-group group)))
15194 (funcall (gnus-get-function method 'request-head)
15195 article (gnus-group-real-name group) (nth 1 method))))
15197 (defun gnus-request-body (article group)
15198 "Request the body of ARTICLE in GROUP."
15199 (let ((method (gnus-find-method-for-group group)))
15200 (funcall (gnus-get-function method 'request-body)
15201 article (gnus-group-real-name group) (nth 1 method))))
15203 (defun gnus-request-post (method)
15204 "Post the current buffer using METHOD."
15205 (when (stringp method)
15206 (setq method (gnus-server-to-method method)))
15207 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15209 (defun gnus-request-scan (group method)
15210 "Request a SCAN being performed in GROUP from METHOD.
15211 If GROUP is nil, all groups on METHOD are scanned."
15212 (let ((method (if group (gnus-find-method-for-group group) method)))
15213 (funcall (gnus-get-function method 'request-scan)
15214 (and group (gnus-group-real-name group)) (nth 1 method))))
15216 (defsubst gnus-request-update-info (info method)
15217 "Request that METHOD update INFO."
15218 (when (stringp method)
15219 (setq method (gnus-server-to-method method)))
15220 (when (gnus-check-backend-function 'request-update-info (car method))
15221 (funcall (gnus-get-function method 'request-update-info)
15222 (gnus-group-real-name (gnus-info-group info))
15223 info (nth 1 method))))
15225 (defun gnus-request-expire-articles (articles group &optional force)
15226 (let ((method (gnus-find-method-for-group group)))
15227 (funcall (gnus-get-function method 'request-expire-articles)
15228 articles (gnus-group-real-name group) (nth 1 method)
15231 (defun gnus-request-move-article
15232 (article group server accept-function &optional last)
15233 (let ((method (gnus-find-method-for-group group)))
15234 (funcall (gnus-get-function method 'request-move-article)
15235 article (gnus-group-real-name group)
15236 (nth 1 method) accept-function last)))
15238 (defun gnus-request-accept-article (group method &optional last)
15239 ;; Make sure there's a newline at the end of the article.
15240 (when (stringp method)
15241 (setq method (gnus-server-to-method method)))
15242 (when (and (not method)
15244 (setq method (gnus-find-method-for-group group)))
15245 (goto-char (point-max))
15248 (let ((func (car (or method (gnus-find-method-for-group group)))))
15249 (funcall (intern (format "%s-request-accept-article" func))
15250 (if (stringp group) (gnus-group-real-name group) group)
15254 (defun gnus-request-replace-article (article group buffer)
15255 (let ((func (car (gnus-find-method-for-group group))))
15256 (funcall (intern (format "%s-request-replace-article" func))
15257 article (gnus-group-real-name group) buffer)))
15259 (defun gnus-request-associate-buffer (group)
15260 (let ((method (gnus-find-method-for-group group)))
15261 (funcall (gnus-get-function method 'request-associate-buffer)
15262 (gnus-group-real-name group))))
15264 (defun gnus-request-restore-buffer (article group)
15265 "Request a new buffer restored to the state of ARTICLE."
15266 (let ((method (gnus-find-method-for-group group)))
15267 (funcall (gnus-get-function method 'request-restore-buffer)
15268 article (gnus-group-real-name group) (nth 1 method))))
15270 (defun gnus-request-create-group (group &optional method)
15271 (when (stringp method)
15272 (setq method (gnus-server-to-method method)))
15273 (let ((method (or method (gnus-find-method-for-group group))))
15274 (funcall (gnus-get-function method 'request-create-group)
15275 (gnus-group-real-name group) (nth 1 method))))
15277 (defun gnus-request-delete-group (group &optional force)
15278 (let ((method (gnus-find-method-for-group group)))
15279 (funcall (gnus-get-function method 'request-delete-group)
15280 (gnus-group-real-name group) force (nth 1 method))))
15282 (defun gnus-request-rename-group (group new-name)
15283 (let ((method (gnus-find-method-for-group group)))
15284 (funcall (gnus-get-function method 'request-rename-group)
15285 (gnus-group-real-name group)
15286 (gnus-group-real-name new-name) (nth 1 method))))
15288 (defun gnus-member-of-valid (symbol group)
15289 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15290 (memq symbol (assoc
15291 (symbol-name (car (gnus-find-method-for-group group)))
15292 gnus-valid-select-methods)))
15294 (defun gnus-method-option-p (method option)
15295 "Return non-nil if select METHOD has OPTION as a parameter."
15296 (when (stringp method)
15297 (setq method (gnus-server-to-method method)))
15298 (memq option (assoc (format "%s" (car method))
15299 gnus-valid-select-methods)))
15301 (defun gnus-server-extend-method (group method)
15302 ;; This function "extends" a virtual server. If the server is
15303 ;; "hello", and the select method is ("hello" (my-var "something"))
15304 ;; in the group "alt.alt", this will result in a new virtual server
15305 ;; called "hello+alt.alt".
15307 (gnus-copy-sequence
15308 (if (equal (car method) "native") gnus-select-method
15309 (cdr (assoc (car method) gnus-server-alist))))))
15310 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15311 (nconc entry (cdr method))))
15313 (defun gnus-find-method-for-group (group &optional info)
15314 "Find the select method that GROUP uses."
15315 (or gnus-override-method
15317 gnus-select-method)
15318 (let ((info (or info (gnus-get-info group)))
15321 (not (setq method (gnus-info-method info)))
15322 (equal method "native"))
15325 (cond ((stringp method)
15326 (gnus-server-to-method method))
15327 ((stringp (car method))
15328 (gnus-server-extend-method group method))
15331 (cond ((equal (cadr method) "")
15333 ((null (cadr method))
15334 (list (car method) ""))
15336 (gnus-server-add-address method)))))))
15338 (defun gnus-check-backend-function (func group)
15339 "Check whether GROUP supports function FUNC."
15340 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15342 (fboundp (intern (format "%s-%s" method func)))))
15344 (defun gnus-methods-using (feature)
15345 "Find all methods that have FEATURE."
15346 (let ((valids gnus-valid-select-methods)
15349 (if (memq feature (car valids))
15350 (setq outs (cons (car valids) outs)))
15351 (setq valids (cdr valids)))
15356 ;;; Active & Newsrc File Handling
15359 (defun gnus-setup-news (&optional rawfile level dont-connect)
15360 "Setup news information.
15361 If RAWFILE is non-nil, the .newsrc file will also be read.
15362 If LEVEL is non-nil, the news will be set up at level LEVEL."
15363 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15366 ;; Clear some variables to re-initialize news information.
15367 (setq gnus-newsrc-alist nil
15368 gnus-active-hashtb nil)
15369 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15370 (gnus-read-newsrc-file rawfile))
15372 (when (and (not (assoc "archive" gnus-server-alist))
15373 gnus-message-archive-method)
15374 (push (cons "archive" gnus-message-archive-method)
15375 gnus-server-alist))
15377 ;; If we don't read the complete active file, we fill in the
15379 (if (or (null gnus-read-active-file)
15380 (eq gnus-read-active-file 'some))
15381 (gnus-update-active-hashtb-from-killed))
15383 ;; Read the active file and create `gnus-active-hashtb'.
15384 ;; If `gnus-read-active-file' is nil, then we just create an empty
15385 ;; hash table. The partial filling out of the hash table will be
15386 ;; done in `gnus-get-unread-articles'.
15387 (and gnus-read-active-file
15389 (gnus-read-active-file))
15391 (or gnus-active-hashtb
15392 (setq gnus-active-hashtb (make-vector 4095 0)))
15394 ;; Initialize the cache.
15395 (when gnus-use-cache
15398 ;; Possibly eval the dribble file.
15399 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15401 ;; Slave Gnusii should then clear the dribble buffer.
15402 (when (and init gnus-slave)
15403 (gnus-dribble-clear))
15405 (gnus-update-format-specifications)
15407 ;; See whether we need to read the description file.
15408 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15409 (not gnus-description-hashtb)
15411 gnus-read-active-file)
15412 (gnus-read-all-descriptions-files))
15414 ;; Find new newsgroups and treat them.
15415 (if (and init gnus-check-new-newsgroups (not level)
15416 (gnus-check-server gnus-select-method))
15417 (gnus-find-new-newsgroups))
15419 ;; We might read in new NoCeM messages here.
15420 (when (and gnus-use-nocem
15422 (not dont-connect))
15423 (gnus-nocem-scan-groups))
15425 ;; Find the number of unread articles in each non-dead group.
15426 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15427 (gnus-get-unread-articles level))
15429 (if (and init gnus-check-bogus-newsgroups
15430 gnus-read-active-file (not level)
15431 (gnus-server-opened gnus-select-method))
15432 (gnus-check-bogus-newsgroups))))
15434 (defun gnus-find-new-newsgroups (&optional arg)
15435 "Search for new newsgroups and add them.
15436 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15437 The `-n' option line from .newsrc is respected.
15438 If ARG (the prefix), use the `ask-server' method to query
15439 the server for new groups."
15441 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15442 (null gnus-read-active-file)
15443 (eq gnus-read-active-file 'some))
15444 'ask-server gnus-check-new-newsgroups)))
15445 (unless (gnus-check-first-time-used)
15446 (if (or (consp check)
15447 (eq check 'ask-server))
15448 ;; Ask the server for new groups.
15449 (gnus-ask-server-for-new-groups)
15450 ;; Go through the active hashtb and look for new groups.
15452 group new-newsgroups)
15453 (gnus-message 5 "Looking for new newsgroups...")
15454 (unless gnus-have-read-active-file
15455 (gnus-read-active-file))
15456 (setq gnus-newsrc-last-checked-date (current-time-string))
15457 (unless gnus-killed-hashtb
15458 (gnus-make-hashtable-from-killed))
15459 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15460 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15463 (if (or (null (setq group (symbol-name sym)))
15465 (null (symbol-value sym))
15466 (gnus-gethash group gnus-killed-hashtb)
15467 (gnus-gethash group gnus-newsrc-hashtb))
15469 (let ((do-sub (gnus-matches-options-n group)))
15471 ((eq do-sub 'subscribe)
15472 (setq groups (1+ groups))
15473 (gnus-sethash group group gnus-killed-hashtb)
15474 (funcall gnus-subscribe-options-newsgroup-method group))
15475 ((eq do-sub 'ignore)
15478 (setq groups (1+ groups))
15479 (gnus-sethash group group gnus-killed-hashtb)
15480 (if gnus-subscribe-hierarchical-interactive
15481 (setq new-newsgroups (cons group new-newsgroups))
15482 (funcall gnus-subscribe-newsgroup-method group)))))))
15483 gnus-active-hashtb)
15484 (when new-newsgroups
15485 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15486 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15488 (gnus-message 6 "%d new newsgroup%s arrived."
15489 groups (if (> groups 1) "s have" " has"))
15490 (gnus-message 6 "No new newsgroups.")))))))
15492 (defun gnus-matches-options-n (group)
15493 ;; Returns `subscribe' if the group is to be unconditionally
15494 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15495 ;; no match for the group.
15497 ;; First we check the two user variables.
15499 ((and gnus-options-subscribe
15500 (string-match gnus-options-subscribe group))
15502 ((and gnus-auto-subscribed-groups
15503 (string-match gnus-auto-subscribed-groups group))
15505 ((and gnus-options-not-subscribe
15506 (string-match gnus-options-not-subscribe group))
15508 ;; Then we go through the list that was retrieved from the .newsrc
15509 ;; file. This list has elements on the form
15510 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15511 ;; is in the reverse order of the options line) is returned.
15513 (let ((regs gnus-newsrc-options-n))
15515 (not (string-match (caar regs) group)))
15516 (setq regs (cdr regs)))
15517 (and regs (cdar regs))))))
15519 (defun gnus-ask-server-for-new-groups ()
15520 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15521 (methods (cons gnus-select-method
15523 (when gnus-message-archive-method
15526 (and (consp gnus-check-new-newsgroups)
15527 gnus-check-new-newsgroups)
15528 gnus-secondary-select-methods))))
15530 (new-date (current-time-string))
15531 group new-newsgroups got-new method hashtb
15532 gnus-override-subscribe-method)
15533 ;; Go through both primary and secondary select methods and
15534 ;; request new newsgroups.
15535 (while (setq method (gnus-server-get-method nil (pop methods)))
15536 (setq new-newsgroups nil)
15537 (setq gnus-override-subscribe-method method)
15538 (when (and (gnus-check-server method)
15539 (gnus-request-newgroups date method))
15542 (setq hashtb (gnus-make-hashtable 100))
15543 (set-buffer nntp-server-buffer)
15544 ;; Enter all the new groups into a hashtable.
15545 (gnus-active-to-gnus-format method hashtb 'ignore))
15546 ;; Now all new groups from `method' are in `hashtb'.
15548 (lambda (group-sym)
15549 (if (or (null (setq group (symbol-name group-sym)))
15550 (not (boundp group-sym))
15551 (null (symbol-value group-sym))
15552 (gnus-gethash group gnus-newsrc-hashtb)
15553 (member group gnus-zombie-list)
15554 (member group gnus-killed-list))
15555 ;; The group is already known.
15557 ;; Make this group active.
15558 (when (symbol-value group-sym)
15559 (gnus-set-active group (symbol-value group-sym)))
15560 ;; Check whether we want it or not.
15561 (let ((do-sub (gnus-matches-options-n group)))
15563 ((eq do-sub 'subscribe)
15565 (gnus-sethash group group gnus-killed-hashtb)
15566 (funcall gnus-subscribe-options-newsgroup-method group))
15567 ((eq do-sub 'ignore)
15571 (gnus-sethash group group gnus-killed-hashtb)
15572 (if gnus-subscribe-hierarchical-interactive
15573 (push group new-newsgroups)
15574 (funcall gnus-subscribe-newsgroup-method group)))))))
15576 (when new-newsgroups
15577 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15578 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15580 (gnus-message 6 "%d new newsgroup%s arrived."
15581 groups (if (> groups 1) "s have" " has")))
15582 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15585 (defun gnus-check-first-time-used ()
15586 (if (or (> (length gnus-newsrc-alist) 1)
15587 (file-exists-p gnus-startup-file)
15588 (file-exists-p (concat gnus-startup-file ".el"))
15589 (file-exists-p (concat gnus-startup-file ".eld")))
15591 (gnus-message 6 "First time user; subscribing you to default groups")
15592 (unless (gnus-read-active-file-p)
15593 (gnus-read-active-file))
15594 (setq gnus-newsrc-last-checked-date (current-time-string))
15595 (let ((groups gnus-default-subscribed-newsgroups)
15599 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15602 (if (null (setq group (symbol-name sym)))
15604 (let ((do-sub (gnus-matches-options-n group)))
15606 ((eq do-sub 'subscribe)
15607 (gnus-sethash group group gnus-killed-hashtb)
15608 (funcall gnus-subscribe-options-newsgroup-method group))
15609 ((eq do-sub 'ignore)
15612 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15613 gnus-active-hashtb)
15615 (if (gnus-active (car groups))
15616 (gnus-group-change-level
15617 (car groups) gnus-level-default-subscribed gnus-level-killed))
15618 (setq groups (cdr groups)))
15619 (gnus-group-make-help-group)
15620 (and gnus-novice-user
15621 (gnus-message 7 "`A k' to list killed groups"))))))
15623 (defun gnus-subscribe-group (group previous &optional method)
15624 (gnus-group-change-level
15626 (list t group gnus-level-default-subscribed nil nil method)
15628 gnus-level-default-subscribed gnus-level-killed previous t))
15630 ;; `gnus-group-change-level' is the fundamental function for changing
15631 ;; subscription levels of newsgroups. This might mean just changing
15632 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15633 ;; again, which subscribes/unsubscribes a group, which is equally
15634 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15635 ;; from 8-9 to 1-7 means that you remove the group from the list of
15636 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15637 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15638 ;; which is trivial.
15639 ;; ENTRY can either be a string (newsgroup name) or a list (if
15640 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15641 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15643 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15644 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15646 (defun gnus-group-change-level (entry level &optional oldlevel
15647 previous fromkilled)
15648 (let (group info active num)
15649 ;; Glean what info we can from the arguments
15651 (if fromkilled (setq group (nth 1 entry))
15652 (setq group (car (nth 2 entry))))
15653 (setq group entry))
15654 (if (and (stringp entry)
15656 (< oldlevel gnus-level-zombie))
15657 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15658 (if (and (not oldlevel)
15660 (setq oldlevel (gnus-info-level (nth 2 entry)))
15661 (setq oldlevel (or oldlevel 9)))
15662 (if (stringp previous)
15663 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15665 (if (and (>= oldlevel gnus-level-zombie)
15666 (gnus-gethash group gnus-newsrc-hashtb))
15667 ;; We are trying to subscribe a group that is already
15671 (or (gnus-ephemeral-group-p group)
15672 (gnus-dribble-enter
15673 (format "(gnus-group-change-level %S %S %S %S %S)"
15674 group level oldlevel (car (nth 2 previous)) fromkilled)))
15676 ;; Then we remove the newgroup from any old structures, if needed.
15677 ;; If the group was killed, we remove it from the killed or zombie
15678 ;; list. If not, and it is in fact going to be killed, we remove
15679 ;; it from the newsrc hash table and assoc.
15681 ((>= oldlevel gnus-level-zombie)
15682 (if (= oldlevel gnus-level-zombie)
15683 (setq gnus-zombie-list (delete group gnus-zombie-list))
15684 (setq gnus-killed-list (delete group gnus-killed-list))))
15686 (if (and (>= level gnus-level-zombie)
15689 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15691 (setcdr (gnus-gethash (car (nth 3 entry))
15692 gnus-newsrc-hashtb)
15694 (setcdr (cdr entry) (cdddr entry))))))
15696 ;; Finally we enter (if needed) the list where it is supposed to
15697 ;; go, and change the subscription level. If it is to be killed,
15698 ;; we enter it into the killed or zombie list.
15700 ((>= level gnus-level-zombie)
15701 ;; Remove from the hash table.
15702 (gnus-sethash group nil gnus-newsrc-hashtb)
15703 ;; We do not enter foreign groups into the list of dead
15705 (unless (gnus-group-foreign-p group)
15706 (if (= level gnus-level-zombie)
15707 (setq gnus-zombie-list (cons group gnus-zombie-list))
15708 (setq gnus-killed-list (cons group gnus-killed-list)))))
15710 ;; If the list is to be entered into the newsrc assoc, and
15711 ;; it was killed, we have to create an entry in the newsrc
15712 ;; hashtb format and fix the pointers in the newsrc assoc.
15713 (if (< oldlevel gnus-level-zombie)
15714 ;; It was alive, and it is going to stay alive, so we
15715 ;; just change the level and don't change any pointers or
15716 ;; hash table entries.
15717 (setcar (cdaddr entry) level)
15719 (setq info (cdr entry)
15721 (setq active (gnus-active group))
15723 (if active (- (1+ (cdr active)) (car active)) t))
15724 ;; Check whether the group is foreign. If so, the
15725 ;; foreign select method has to be entered into the
15727 (let ((method (or gnus-override-subscribe-method
15728 (gnus-group-method group))))
15729 (if (eq method gnus-select-method)
15730 (setq info (list group level nil))
15731 (setq info (list group level nil nil method)))))
15734 (let ((p gnus-newsrc-alist))
15738 (setq entry (cons info (cddr previous)))
15741 (setcdr (cdr previous) entry)
15742 (gnus-sethash group (cons num (cdr previous))
15743 gnus-newsrc-hashtb))
15744 (setcdr previous entry)
15745 (gnus-sethash group (cons num previous)
15746 gnus-newsrc-hashtb))
15748 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15749 (when gnus-group-change-level-function
15750 (funcall gnus-group-change-level-function group level oldlevel)))))
15752 (defun gnus-kill-newsgroup (newsgroup)
15753 "Obsolete function. Kills a newsgroup."
15754 (gnus-group-change-level
15755 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15757 (defun gnus-check-bogus-newsgroups (&optional confirm)
15758 "Remove bogus newsgroups.
15759 If CONFIRM is non-nil, the user has to confirm the deletion of every
15761 (let ((newsrc (cdr gnus-newsrc-alist))
15762 bogus group entry info)
15763 (gnus-message 5 "Checking bogus newsgroups...")
15764 (unless (gnus-read-active-file-p)
15765 (gnus-read-active-file))
15766 (when (gnus-read-active-file-p)
15767 ;; Find all bogus newsgroup that are subscribed.
15769 (setq info (pop newsrc)
15770 group (gnus-info-group info))
15771 (unless (or (gnus-active group) ; Active
15772 (gnus-info-method info) ; Foreign
15774 (not (gnus-y-or-n-p
15775 (format "Remove bogus newsgroup: %s " group)))))
15776 ;; Found a bogus newsgroup.
15777 (push group bogus)))
15778 ;; Remove all bogus subscribed groups by first killing them, and
15779 ;; then removing them from the list of killed groups.
15781 (when (setq entry (gnus-gethash (setq group (pop bogus))
15782 gnus-newsrc-hashtb))
15783 (gnus-group-change-level entry gnus-level-killed)
15784 (setq gnus-killed-list (delete group gnus-killed-list))))
15785 ;; Then we remove all bogus groups from the list of killed and
15786 ;; zombie groups. They are are removed without confirmation.
15787 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15790 (setq killed (symbol-value (car dead-lists)))
15792 (unless (gnus-active (setq group (pop killed)))
15793 ;; The group is bogus.
15794 ;; !!!Slow as hell.
15795 (set (car dead-lists)
15796 (delete group (symbol-value (car dead-lists))))))
15797 (setq dead-lists (cdr dead-lists))))
15798 (gnus-message 5 "Checking bogus newsgroups...done"))))
15800 (defun gnus-check-duplicate-killed-groups ()
15801 "Remove duplicates from the list of killed groups."
15803 (let ((killed gnus-killed-list))
15805 (gnus-message 9 "%d" (length killed))
15806 (setcdr killed (delete (car killed) (cdr killed)))
15807 (setq killed (cdr killed)))))
15809 ;; We want to inline a function from gnus-cache, so we cheat here:
15812 (require 'gnus-cache))
15814 (defun gnus-get-unread-articles-in-group (info active &optional update)
15816 ;; Allow the backend to update the info in the group.
15818 (gnus-request-update-info
15819 info (gnus-find-method-for-group (gnus-info-group info))))
15820 (gnus-activate-group (gnus-info-group info) nil t))
15821 (let* ((range (gnus-info-read info))
15823 ;; If a cache is present, we may have to alter the active info.
15824 (when (and gnus-use-cache info)
15825 (inline (gnus-cache-possibly-alter-active
15826 (gnus-info-group info) active)))
15827 ;; Modify the list of read articles according to what articles
15828 ;; are available; then tally the unread articles and add the
15829 ;; number to the group hash table entry.
15831 ((zerop (cdr active))
15834 (setq num (- (1+ (cdr active)) (car active))))
15835 ((not (listp (cdr range)))
15836 ;; Fix a single (num . num) range according to the
15837 ;; active hash table.
15838 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15839 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15840 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15841 ;; Compute number of unread articles.
15842 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15844 ;; The read list is a list of ranges. Fix them according to
15845 ;; the active hash table.
15846 ;; First peel off any elements that are below the lower
15848 (while (and (cdr range)
15850 (or (and (atom (cadr range)) (cadr range))
15852 (if (numberp (car range))
15855 (or (and (numberp (cadr range))
15858 (setcdr (car range)
15859 (or (and (numberp (nth 1 range)) (nth 1 range))
15861 (setcdr range (cddr range)))
15862 ;; Adjust the first element to be the same as the lower limit.
15863 (if (and (not (atom (car range)))
15864 (< (cdar range) (car active)))
15865 (setcdr (car range) (1- (car active))))
15866 ;; Then we want to peel off any elements that are higher
15867 ;; than the upper active limit.
15868 (let ((srange range))
15869 ;; Go past all legal elements.
15870 (while (and (cdr srange)
15871 (<= (or (and (atom (cadr srange))
15873 (caadr srange)) (cdr active)))
15874 (setq srange (cdr srange)))
15876 ;; Nuke all remaining illegal elements.
15877 (setcdr srange nil))
15879 ;; Adjust the final element.
15880 (if (and (not (atom (car srange)))
15881 (> (cdar srange) (cdr active)))
15882 (setcdr (car srange) (cdr active))))
15883 ;; Compute the number of unread articles.
15885 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15887 (or (and (atom (car range)) (car range))
15889 (setq range (cdr range)))
15890 (setq num (max 0 (- (cdr active) num)))))
15891 ;; Set the number of unread articles.
15893 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15896 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15897 ;; and compute how many unread articles there are in each group.
15898 (defun gnus-get-unread-articles (&optional level)
15899 (let* ((newsrc (cdr gnus-newsrc-alist))
15900 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15903 (cond ((and gnus-activate-foreign-newsgroups
15904 (not (numberp gnus-activate-foreign-newsgroups)))
15905 (1+ gnus-level-subscribed))
15906 ((numberp gnus-activate-foreign-newsgroups)
15907 gnus-activate-foreign-newsgroups)
15910 info group active method)
15911 (gnus-message 5 "Checking new news...")
15914 (setq active (gnus-active (setq group (gnus-info-group
15915 (setq info (pop newsrc))))))
15917 ;; Check newsgroups. If the user doesn't want to check them, or
15918 ;; they can't be checked (for instance, if the news server can't
15919 ;; be reached) we just set the number of unread articles in this
15920 ;; newsgroup to t. This means that Gnus thinks that there are
15921 ;; unread articles, but it has no idea how many.
15922 (if (and (setq method (gnus-info-method info))
15923 (not (gnus-server-equal
15925 (setq method (gnus-server-get-method nil method))))
15926 (not (gnus-secondary-method-p method)))
15927 ;; These groups are foreign. Check the level.
15928 (when (<= (gnus-info-level info) foreign-level)
15929 (setq active (gnus-activate-group group 'scan))
15930 (unless (inline (gnus-virtual-group-p group))
15931 (inline (gnus-close-group group)))
15932 (when (fboundp (intern (concat (symbol-name (car method))
15933 "-request-update-info")))
15934 (inline (gnus-request-update-info info method))))
15935 ;; These groups are native or secondary.
15936 (when (and (<= (gnus-info-level info) level)
15937 (not gnus-read-active-file))
15938 (setq active (gnus-activate-group group 'scan))
15939 (inline (gnus-close-group group))))
15941 ;; Get the number of unread articles in the group.
15943 (inline (gnus-get-unread-articles-in-group info active))
15944 ;; The group couldn't be reached, so we nix out the number of
15945 ;; unread articles and stuff.
15946 (gnus-set-active group nil)
15947 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15949 (gnus-message 5 "Checking new news...done")))
15951 ;; Create a hash table out of the newsrc alist. The `car's of the
15952 ;; alist elements are used as keys.
15953 (defun gnus-make-hashtable-from-newsrc-alist ()
15954 (let ((alist gnus-newsrc-alist)
15955 (ohashtb gnus-newsrc-hashtb)
15957 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15959 (setq prev (setq gnus-newsrc-alist
15960 (if (equal (caar gnus-newsrc-alist)
15963 (cons (list "dummy.group" 0 nil) alist)))))
15967 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15969 gnus-newsrc-hashtb)
15971 alist (cdr alist)))))
15973 (defun gnus-make-hashtable-from-killed ()
15974 "Create a hash table from the killed and zombie lists."
15975 (let ((lists '(gnus-killed-list gnus-zombie-list))
15977 (setq gnus-killed-hashtb
15978 (gnus-make-hashtable
15979 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15980 (while (setq list (pop lists))
15981 (setq list (symbol-value list))
15983 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15985 (defun gnus-activate-group (group &optional scan dont-check)
15986 ;; Check whether a group has been activated or not.
15987 ;; If SCAN, request a scan of that group as well.
15988 (let ((method (gnus-find-method-for-group group))
15990 (and (gnus-check-server method)
15991 ;; We escape all bugs and quit here to make it possible to
15992 ;; continue if a group is so out-there that it reports bugs
15996 (gnus-check-backend-function 'request-scan (car method))
15997 (gnus-request-scan group method))
16000 (gnus-request-group group dont-check)
16004 (set-buffer nntp-server-buffer)
16005 (goto-char (point-min))
16006 ;; Parse the result we got from `gnus-request-group'.
16007 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16009 (goto-char (match-beginning 1))
16011 group (setq active (cons (read (current-buffer))
16012 (read (current-buffer)))))
16013 ;; Return the new active info.
16016 (defun gnus-update-read-articles (group unread)
16017 "Update the list of read and ticked articles in GROUP using the
16018 UNREAD and TICKED lists.
16019 Note: UNSELECTED has to be sorted over `<'.
16020 Returns whether the updating was successful."
16021 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16022 (entry (gnus-gethash group gnus-newsrc-hashtb))
16023 (info (nth 2 entry))
16025 (unread (sort (copy-sequence unread) '<))
16027 (if (or (not info) (not active))
16028 ;; There is no info on this group if it was, in fact,
16029 ;; killed. Gnus stores no information on killed groups, so
16030 ;; there's nothing to be done.
16031 ;; One could store the information somewhere temporarily,
16032 ;; perhaps... Hmmm...
16034 ;; Remove any negative articles numbers.
16035 (while (and unread (< (car unread) 0))
16036 (setq unread (cdr unread)))
16037 ;; Remove any expired article numbers
16038 (while (and unread (< (car unread) (car active)))
16039 (setq unread (cdr unread)))
16040 ;; Compute the ranges of read articles by looking at the list of
16041 ;; unread articles.
16043 (if (/= (car unread) prev)
16044 (setq read (cons (if (= prev (1- (car unread))) prev
16045 (cons prev (1- (car unread)))) read)))
16046 (setq prev (1+ (car unread)))
16047 (setq unread (cdr unread)))
16048 (when (<= prev (cdr active))
16049 (setq read (cons (cons prev (cdr active)) read)))
16050 ;; Enter this list into the group info.
16051 (gnus-info-set-read
16052 info (if (> (length read) 1) (nreverse read) read))
16053 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16054 (gnus-get-unread-articles-in-group info (gnus-active group))
16057 (defun gnus-make-articles-unread (group articles)
16058 "Mark ARTICLES in GROUP as unread."
16059 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16060 (gnus-gethash (gnus-group-real-name group)
16061 gnus-newsrc-hashtb))))
16062 (ranges (gnus-info-read info))
16065 (when (gnus-member-of-range
16066 (setq article (pop articles)) ranges)
16067 (setq news (cons article news))))
16069 (gnus-info-set-read
16070 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16071 (gnus-group-update-group group t))))
16073 ;; Enter all dead groups into the hashtb.
16074 (defun gnus-update-active-hashtb-from-killed ()
16075 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16076 (lists (list gnus-killed-list gnus-zombie-list))
16079 (setq killed (car lists))
16081 (gnus-sethash (car killed) nil hashtb)
16082 (setq killed (cdr killed)))
16083 (setq lists (cdr lists)))))
16085 (defun gnus-get-killed-groups ()
16086 "Go through the active hashtb and all all unknown groups as killed."
16087 ;; First make sure active file has been read.
16088 (unless (gnus-read-active-file-p)
16089 (let ((gnus-read-active-file t))
16090 (gnus-read-active-file)))
16091 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16092 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16096 (group (symbol-name sym)))
16097 (if (or (null group)
16098 (gnus-gethash group gnus-killed-hashtb)
16099 (gnus-gethash group gnus-newsrc-hashtb))
16101 (let ((do-sub (gnus-matches-options-n group)))
16102 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16104 (setq groups (1+ groups))
16105 (setq gnus-killed-list
16106 (cons group gnus-killed-list))
16107 (gnus-sethash group group gnus-killed-hashtb))))))
16108 gnus-active-hashtb))
16110 ;; Get the active file(s) from the backend(s).
16111 (defun gnus-read-active-file ()
16112 (gnus-group-set-mode-line)
16115 (if (gnus-check-server gnus-select-method)
16116 ;; The native server is available.
16117 (cons gnus-select-method gnus-secondary-select-methods)
16118 ;; The native server is down, so we just do the
16120 gnus-secondary-select-methods)
16121 ;; Also read from the archive server.
16122 (when gnus-message-archive-method
16123 (list "archive"))))
16125 (setq gnus-have-read-active-file nil)
16127 (set-buffer nntp-server-buffer)
16129 (let* ((method (if (stringp (car methods))
16130 (gnus-server-get-method nil (car methods))
16132 (where (nth 1 method))
16133 (mesg (format "Reading active file%s via %s..."
16134 (if (and where (not (zerop (length where))))
16135 (concat " from " where) "")
16137 (gnus-message 5 mesg)
16138 (when (gnus-check-server method)
16139 ;; Request that the backend scan its incoming messages.
16140 (and (gnus-check-backend-function 'request-scan (car method))
16141 (gnus-request-scan nil method))
16143 ((and (eq gnus-read-active-file 'some)
16144 (gnus-check-backend-function 'retrieve-groups (car method)))
16145 (let ((newsrc (cdr gnus-newsrc-alist))
16146 (gmethod (gnus-server-get-method nil method))
16148 (while (setq info (pop newsrc))
16149 (when (gnus-server-equal
16150 (gnus-find-method-for-group
16151 (gnus-info-group info) info)
16153 (push (gnus-group-real-name (gnus-info-group info))
16156 (gnus-check-server method)
16157 (setq list-type (gnus-retrieve-groups groups method))
16161 1.2 "Cannot read partial active file from %s server."
16163 ((eq list-type 'active)
16164 (gnus-active-to-gnus-format method gnus-active-hashtb))
16166 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16168 (if (not (gnus-request-list method))
16169 (unless (equal method gnus-message-archive-method)
16170 (gnus-error 1 "Cannot read active file from %s server."
16172 (gnus-message 5 mesg)
16173 (gnus-active-to-gnus-format method gnus-active-hashtb)
16174 ;; We mark this active file as read.
16175 (push method gnus-have-read-active-file)
16176 (gnus-message 5 "%sdone" mesg))))))
16177 (setq methods (cdr methods))))))
16179 ;; Read an active file and place the results in `gnus-active-hashtb'.
16180 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16182 (setq method gnus-select-method))
16183 (let ((cur (current-buffer))
16185 (if (and gnus-active-hashtb
16186 (not (equal method gnus-select-method)))
16188 (setq gnus-active-hashtb
16189 (if (equal method gnus-select-method)
16190 (gnus-make-hashtable
16191 (count-lines (point-min) (point-max)))
16192 (gnus-make-hashtable 4096)))))))
16193 ;; Delete unnecessary lines.
16194 (goto-char (point-min))
16195 (while (search-forward "\nto." nil t)
16196 (delete-region (1+ (match-beginning 0))
16197 (progn (forward-line 1) (point))))
16198 (or (string= gnus-ignored-newsgroups "")
16200 (goto-char (point-min))
16201 (delete-matching-lines gnus-ignored-newsgroups)))
16202 ;; Make the group names readable as a lisp expression even if they
16203 ;; contain special characters.
16204 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16205 (goto-char (point-max))
16206 (while (re-search-backward "[][';?()#]" nil t)
16208 ;; If these are groups from a foreign select method, we insert the
16209 ;; group prefix in front of the group names.
16210 (and method (not (gnus-server-equal
16211 (gnus-server-get-method nil method)
16212 (gnus-server-get-method nil gnus-select-method)))
16213 (let ((prefix (gnus-group-prefixed-name "" method)))
16214 (goto-char (point-min))
16215 (while (and (not (eobp))
16216 (progn (insert prefix)
16217 (zerop (forward-line 1)))))))
16218 ;; Store the active file in a hash table.
16219 (goto-char (point-min))
16220 (if (string-match "%[oO]" gnus-group-line-format)
16221 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16222 ;; If we want information on moderated groups, we use this
16224 (let* ((mod-hashtb (make-vector 7 0))
16225 (m (intern "m" mod-hashtb))
16227 (while (not (eobp))
16228 (condition-case nil
16230 (narrow-to-region (point) (gnus-point-at-eol))
16231 (setq group (let ((obarray hashtb)) (read cur)))
16232 (if (and (numberp (setq max (read cur)))
16233 (numberp (setq min (read cur)))
16235 (skip-chars-forward " \t")
16237 (or (= (following-char) ?=)
16238 (= (following-char) ?x)
16239 (= (following-char) ?j)))))
16240 (set group (cons min max))
16242 ;; Enter moderated groups into a list.
16243 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16244 (setq gnus-moderated-list
16245 (cons (symbol-name group) gnus-moderated-list))))
16252 ;; And if we do not care about moderation, we use this loop,
16253 ;; which is faster.
16254 (let (group max min)
16255 (while (not (eobp))
16258 (narrow-to-region (point) (gnus-point-at-eol))
16259 ;; group gets set to a symbol interned in the hash table
16260 ;; (what a hack!!) - jwz
16261 (setq group (let ((obarray hashtb)) (read cur)))
16262 (if (and (numberp (setq max (read cur)))
16263 (numberp (setq min (read cur)))
16265 (skip-chars-forward " \t")
16267 (or (= (following-char) ?=)
16268 (= (following-char) ?x)
16269 (= (following-char) ?j)))))
16270 (set group (cons min max))
16278 (gnus-message 3 "Warning - illegal active: %s"
16280 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16282 (forward-line 1))))))
16284 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16285 ;; Parse a "groups" active file.
16286 (let ((cur (current-buffer))
16288 (if (and method gnus-active-hashtb)
16290 (setq gnus-active-hashtb
16291 (gnus-make-hashtable
16292 (count-lines (point-min) (point-max)))))))
16293 (prefix (and method
16294 (not (gnus-server-equal
16295 (gnus-server-get-method nil method)
16296 (gnus-server-get-method nil gnus-select-method)))
16297 (gnus-group-prefixed-name "" method))))
16299 (goto-char (point-min))
16300 ;; We split this into to separate loops, one with the prefix
16301 ;; and one without to speed the reading up somewhat.
16303 (let (min max opoint group)
16304 (while (not (eobp))
16307 (read cur) (read cur)
16308 (setq min (read cur)
16311 (skip-chars-forward " \t")
16314 (set (let ((obarray hashtb)) (read cur))
16316 (error (and group (symbolp group) (set group nil))))
16318 (let (min max group)
16319 (while (not (eobp))
16321 (if (= (following-char) ?2)
16323 (read cur) (read cur)
16324 (setq min (read cur)
16326 (set (setq group (let ((obarray hashtb)) (read cur)))
16328 (error (and group (symbolp group) (set group nil))))
16329 (forward-line 1))))))
16331 (defun gnus-read-newsrc-file (&optional force)
16332 "Read startup file.
16333 If FORCE is non-nil, the .newsrc file is read."
16334 ;; Reset variables that might be defined in the .newsrc.eld file.
16335 (let ((variables gnus-variable-list))
16337 (set (car variables) nil)
16338 (setq variables (cdr variables))))
16339 (let* ((newsrc-file gnus-current-startup-file)
16340 (quick-file (concat newsrc-file ".el")))
16342 ;; We always load the .newsrc.eld file. If always contains
16343 ;; much information that can not be gotten from the .newsrc
16344 ;; file (ticked articles, killed groups, foreign methods, etc.)
16345 (gnus-read-newsrc-el-file quick-file)
16347 (if (and (file-exists-p gnus-current-startup-file)
16349 (and (file-newer-than-file-p newsrc-file quick-file)
16350 (file-newer-than-file-p newsrc-file
16351 (concat quick-file "d")))
16352 (not gnus-newsrc-alist)))
16353 ;; We read the .newsrc file. Note that if there if a
16354 ;; .newsrc.eld file exists, it has already been read, and
16355 ;; the `gnus-newsrc-hashtb' has been created. While reading
16356 ;; the .newsrc file, Gnus will only use the information it
16357 ;; can find there for changing the data already read -
16358 ;; ie. reading the .newsrc file will not trash the data
16359 ;; already read (except for read articles).
16361 (gnus-message 5 "Reading %s..." newsrc-file)
16362 (set-buffer (find-file-noselect newsrc-file))
16363 (buffer-disable-undo (current-buffer))
16364 (gnus-newsrc-to-gnus-format)
16365 (kill-buffer (current-buffer))
16366 (gnus-message 5 "Reading %s...done" newsrc-file)))
16368 ;; Read any slave files.
16370 (gnus-master-read-slave-newsrc))
16372 ;; Convert old to new.
16373 (gnus-convert-old-newsrc))))
16375 (defun gnus-continuum-version (version)
16376 "Return VERSION as a floating point number."
16377 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16378 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16379 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16380 (number (match-string 2 version))
16382 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16383 (setq major (string-to-number (match-string 1 number)))
16384 (setq minor (string-to-number (match-string 2 number)))
16385 (setq least (if (match-beginning 3)
16386 (string-to-number (match-string 3 number))
16390 (format "%s00%02d%02d"
16392 ((member alpha '("(ding)" "d")) "4.99")
16393 ((member alpha '("September" "s")) "5.01")
16394 ((member alpha '("Red" "r")) "5.03"))
16396 (format "%d.%02d%02d" major minor least))))))
16398 (defun gnus-convert-old-newsrc ()
16399 "Convert old newsrc into the new format, if needed."
16400 (let ((fcv (and gnus-newsrc-file-version
16401 (gnus-continuum-version gnus-newsrc-file-version))))
16403 ;; No .newsrc.eld file was loaded.
16405 ;; Gnus 5 .newsrc.eld was loaded.
16406 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16407 (gnus-convert-old-ticks)))))
16409 (defun gnus-convert-old-ticks ()
16410 (let ((newsrc (cdr gnus-newsrc-alist))
16411 marks info dormant ticked)
16412 (while (setq info (pop newsrc))
16413 (when (setq marks (gnus-info-marks info))
16414 (setq dormant (cdr (assq 'dormant marks))
16415 ticked (cdr (assq 'tick marks)))
16416 (when (or dormant ticked)
16417 (gnus-info-set-read
16420 (gnus-info-read info)
16421 (nconc (gnus-uncompress-range dormant)
16422 (gnus-uncompress-range ticked)))))))))
16424 (defun gnus-read-newsrc-el-file (file)
16425 (let ((ding-file (concat file "d")))
16426 ;; We always, always read the .eld file.
16427 (gnus-message 5 "Reading %s..." ding-file)
16428 (let (gnus-newsrc-assoc)
16429 (condition-case nil
16430 (load ding-file t t t)
16432 (gnus-error 1 "Error in %s" ding-file)))
16433 (when gnus-newsrc-assoc
16434 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16435 (gnus-make-hashtable-from-newsrc-alist)
16436 (when (file-newer-than-file-p file ding-file)
16437 ;; Old format quick file
16438 (gnus-message 5 "Reading %s..." file)
16439 ;; The .el file is newer than the .eld file, so we read that one
16441 (gnus-read-old-newsrc-el-file file))))
16443 ;; Parse the old-style quick startup file
16444 (defun gnus-read-old-newsrc-el-file (file)
16445 (let (newsrc killed marked group m info)
16447 (let ((gnus-killed-assoc nil)
16448 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16450 (condition-case nil
16453 (setq newsrc gnus-newsrc-assoc
16454 killed gnus-killed-assoc
16455 marked gnus-marked-assoc)))
16456 (setq gnus-newsrc-alist nil)
16457 (while (setq group (pop newsrc))
16458 (if (setq info (gnus-get-info (car group)))
16460 (gnus-info-set-read info (cddr group))
16461 (gnus-info-set-level
16462 info (if (nth 1 group) gnus-level-default-subscribed
16463 gnus-level-default-unsubscribed))
16464 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16467 (if (nth 1 group) gnus-level-default-subscribed
16468 gnus-level-default-unsubscribed)
16470 gnus-newsrc-alist))
16471 ;; Copy marks into info.
16472 (when (setq m (assoc (car group) marked))
16473 (unless (nthcdr 3 info)
16474 (nconc info (list nil)))
16475 (gnus-info-set-marks
16476 info (list (cons 'tick (gnus-compress-sequence
16477 (sort (cdr m) '<) t))))))
16478 (setq newsrc killed)
16480 (setcar newsrc (caar newsrc))
16481 (setq newsrc (cdr newsrc)))
16482 (setq gnus-killed-list killed))
16483 ;; The .el file version of this variable does not begin with
16484 ;; "options", while the .eld version does, so we just add it if it
16487 gnus-newsrc-options
16489 (and (not (string-match "^ *options" gnus-newsrc-options))
16490 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16491 (and (not (string-match "\n$" gnus-newsrc-options))
16492 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16493 ;; Finally, if we read some options lines, we parse them.
16494 (or (string= gnus-newsrc-options "")
16495 (gnus-newsrc-parse-options gnus-newsrc-options))))
16497 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16498 (gnus-make-hashtable-from-newsrc-alist)))
16500 (defun gnus-make-newsrc-file (file)
16501 "Make server dependent file name by catenating FILE and server host name."
16502 (let* ((file (expand-file-name file nil))
16503 (real-file (concat file "-" (nth 1 gnus-select-method))))
16504 (if (or (file-exists-p real-file)
16505 (file-exists-p (concat real-file ".el"))
16506 (file-exists-p (concat real-file ".eld")))
16509 (defun gnus-newsrc-to-gnus-format ()
16510 (setq gnus-newsrc-options "")
16511 (setq gnus-newsrc-options-n nil)
16513 (or gnus-active-hashtb
16514 (setq gnus-active-hashtb (make-vector 4095 0)))
16515 (let ((buf (current-buffer))
16516 (already-read (> (length gnus-newsrc-alist) 1))
16517 group subscribed options-symbol newsrc Options-symbol
16519 (goto-char (point-min))
16520 ;; We intern the symbol `options' in the active hashtb so that we
16521 ;; can `eq' against it later.
16522 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16523 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16525 (while (not (eobp))
16526 ;; We first read the first word on the line by narrowing and
16527 ;; then reading into `gnus-active-hashtb'. Most groups will
16528 ;; already exist in that hashtb, so this will save some string
16532 (progn (skip-chars-forward "^ \t!:\n") (point)))
16533 (goto-char (point-min))
16535 (and (/= (point-min) (point-max))
16536 (let ((obarray gnus-active-hashtb)) (read buf))))
16538 ;; Now, the symbol we have read is either `options' or a group
16539 ;; name. If it is an options line, we just add it to a string.
16541 ((or (eq symbol options-symbol)
16542 (eq symbol Options-symbol))
16543 (setq gnus-newsrc-options
16544 ;; This concating is quite inefficient, but since our
16545 ;; thorough studies show that approx 99.37% of all
16546 ;; .newsrc files only contain a single options line, we
16547 ;; don't give a damn, frankly, my dear.
16548 (concat gnus-newsrc-options
16550 (gnus-point-at-bol)
16551 ;; Options may continue on the next line.
16552 (or (and (re-search-forward "^[^ \t]" nil 'move)
16553 (progn (beginning-of-line) (point)))
16557 ;; Group names can be just numbers.
16558 (when (numberp symbol)
16559 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16560 (or (boundp symbol) (set symbol nil))
16561 ;; It was a group name.
16562 (setq subscribed (= (following-char) ?:)
16563 group (symbol-name symbol)
16566 ;; If the line ends here, this is clearly a buggy line, so
16567 ;; we put point a the beginning of line and let the cond
16568 ;; below do the error handling.
16569 (beginning-of-line)
16570 ;; We skip to the beginning of the ranges.
16571 (skip-chars-forward "!: \t"))
16572 ;; We are now at the beginning of the list of read articles.
16573 ;; We read them range by range.
16576 ((looking-at "[0-9]+")
16577 ;; We narrow and read a number instead of buffer-substring/
16578 ;; string-to-int because it's faster. narrow/widen is
16579 ;; faster than save-restriction/narrow, and save-restriction
16580 ;; produces a garbage object.
16582 (narrow-to-region (match-beginning 0) (match-end 0))
16585 ;; If the next character is a dash, then this is a range.
16586 (if (= (following-char) ?-)
16588 ;; We read the upper bound of the range.
16590 (if (not (looking-at "[0-9]+"))
16591 ;; This is a buggy line, by we pretend that
16592 ;; it's kinda OK. Perhaps the user should be
16594 (setq reads (cons num1 reads))
16599 (narrow-to-region (match-beginning 0)
16604 ;; It was just a simple number, so we add it to the
16606 (setq reads (cons num1 reads)))
16607 ;; If the next char in ?\n, then we have reached the end
16608 ;; of the line and return nil.
16609 (/= (following-char) ?\n))
16610 ((= (following-char) ?\n)
16611 ;; End of line, so we end.
16614 ;; Not numbers and not eol, so this might be a buggy
16617 ;; If it was eob instead of ?\n, we allow it.
16619 ;; The line was buggy.
16621 (gnus-error 3.1 "Mangled line: %s"
16622 (buffer-substring (gnus-point-at-bol)
16623 (gnus-point-at-eol)))))
16625 ;; Skip past ", ". Spaces are illegal in these ranges, but
16626 ;; we allow them, because it's a common mistake to put a
16627 ;; space after the comma.
16628 (skip-chars-forward ", "))
16630 ;; We have already read .newsrc.eld, so we gently update the
16631 ;; data in the hash table with the information we have just
16634 (let ((info (gnus-get-info group))
16637 ;; There is an entry for this file in the alist.
16639 (gnus-info-set-read info (nreverse reads))
16640 ;; We update the level very gently. In fact, we
16641 ;; only change it if there's been a status change
16642 ;; from subscribed to unsubscribed, or vice versa.
16643 (setq level (gnus-info-level info))
16644 (cond ((and (<= level gnus-level-subscribed)
16646 (setq level (if reads
16647 gnus-level-default-unsubscribed
16648 (1+ gnus-level-default-unsubscribed))))
16649 ((and (> level gnus-level-subscribed) subscribed)
16650 (setq level gnus-level-default-subscribed)))
16651 (gnus-info-set-level info level))
16652 ;; This is a new group.
16653 (setq info (list group
16655 gnus-level-default-subscribed
16657 (1+ gnus-level-subscribed)
16658 gnus-level-default-unsubscribed))
16659 (nreverse reads))))
16660 (setq newsrc (cons info newsrc))))))
16663 (setq newsrc (nreverse newsrc))
16665 (if (not already-read)
16667 ;; We now have two newsrc lists - `newsrc', which is what we
16668 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16669 ;; what we've read from .newsrc.eld. We have to merge these
16670 ;; lists. We do this by "attaching" any (foreign) groups in the
16671 ;; gnus-newsrc-alist to the (native) group that precedes them.
16672 (let ((rc (cdr gnus-newsrc-alist))
16673 (prev gnus-newsrc-alist)
16676 (or (null (nth 4 (car rc))) ; It's a native group.
16677 (assoc (caar rc) newsrc) ; It's already in the alist.
16678 (if (setq entry (assoc (caar prev) newsrc))
16679 (setcdr (setq mentry (memq entry newsrc))
16680 (cons (car rc) (cdr mentry)))
16681 (setq newsrc (cons (car rc) newsrc))))
16685 (setq gnus-newsrc-alist newsrc)
16686 ;; We make the newsrc hashtb.
16687 (gnus-make-hashtable-from-newsrc-alist)
16689 ;; Finally, if we read some options lines, we parse them.
16690 (or (string= gnus-newsrc-options "")
16691 (gnus-newsrc-parse-options gnus-newsrc-options))))
16693 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16694 ;; The return value will be a list on the form
16695 ;; ((regexp1 . ignore)
16696 ;; (regexp2 . subscribe)...)
16697 ;; When handling new newsgroups, groups that match a `ignore' regexp
16698 ;; will be ignored, and groups that match a `subscribe' regexp will be
16699 ;; subscribed. A line like
16700 ;; options -n !all rec.all
16701 ;; will lead to a list that looks like
16702 ;; (("^rec\\..+" . subscribe)
16703 ;; ("^.+" . ignore))
16704 ;; So all "rec.*" groups will be subscribed, while all the other
16705 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16706 ;; different from "options -n rec.all !all".
16707 (defun gnus-newsrc-parse-options (options)
16710 (gnus-set-work-buffer)
16711 (insert (regexp-quote options))
16712 ;; First we treat all continuation lines.
16713 (goto-char (point-min))
16714 (while (re-search-forward "\n[ \t]+" nil t)
16715 (replace-match " " t t))
16716 ;; Then we transform all "all"s into ".+"s.
16717 (goto-char (point-min))
16718 (while (re-search-forward "\\ball\\b" nil t)
16719 (replace-match ".+" t t))
16720 (goto-char (point-min))
16721 ;; We remove all other options than the "-n" ones.
16722 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16723 (replace-match " ")
16725 (goto-char (point-min))
16727 ;; We are only interested in "options -n" lines - we
16728 ;; ignore the other option lines.
16729 (while (re-search-forward "[ \t]-n" nil t)
16731 (or (save-excursion
16732 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16734 (gnus-point-at-eol)))
16735 ;; Search for all "words"...
16736 (while (re-search-forward "[^ \t,\n]+" eol t)
16737 (if (= (char-after (match-beginning 0)) ?!)
16738 ;; If the word begins with a bang (!), this is a "not"
16739 ;; spec. We put this spec (minus the bang) and the
16740 ;; symbol `ignore' into the list.
16741 (setq out (cons (cons (concat
16742 "^" (buffer-substring
16743 (1+ (match-beginning 0))
16746 ;; There was no bang, so this is a "yes" spec.
16747 (setq out (cons (cons (concat "^" (match-string 0))
16748 'subscribe) out)))))
16750 (setq gnus-newsrc-options-n out))))
16752 (defun gnus-save-newsrc-file (&optional force)
16753 "Save .newsrc file."
16754 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16755 ;; from the variable gnus-newsrc-alist.
16756 (when (and (or gnus-newsrc-alist gnus-killed-list)
16757 gnus-current-startup-file)
16759 (if (and (or gnus-use-dribble-file gnus-slave)
16761 (or (not gnus-dribble-buffer)
16762 (not (buffer-name gnus-dribble-buffer))
16763 (zerop (save-excursion
16764 (set-buffer gnus-dribble-buffer)
16766 (gnus-message 4 "(No changes need to be saved)")
16767 (run-hooks 'gnus-save-newsrc-hook)
16769 (gnus-slave-save-newsrc)
16771 (when gnus-save-newsrc-file
16772 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16773 (gnus-gnus-to-newsrc-format)
16774 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16775 ;; Save .newsrc.eld.
16776 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16777 (make-local-variable 'version-control)
16778 (setq version-control 'never)
16779 (setq buffer-file-name
16780 (concat gnus-current-startup-file ".eld"))
16781 (setq default-directory (file-name-directory buffer-file-name))
16782 (gnus-add-current-to-buffer-list)
16783 (buffer-disable-undo (current-buffer))
16785 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16786 (gnus-gnus-to-quick-newsrc-format)
16787 (run-hooks 'gnus-save-quick-newsrc-hook)
16789 (kill-buffer (current-buffer))
16791 5 "Saving %s.eld...done" gnus-current-startup-file))
16792 (gnus-dribble-delete-file)
16793 (gnus-group-set-mode-line)))))
16795 (defun gnus-gnus-to-quick-newsrc-format ()
16796 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16797 (insert ";; Gnus startup file.\n")
16798 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16799 (insert ";; to read .newsrc.\n")
16800 (insert "(setq gnus-newsrc-file-version "
16801 (prin1-to-string gnus-version) ")\n")
16803 (if gnus-save-killed-list gnus-variable-list
16804 ;; Remove the `gnus-killed-list' from the list of variables
16805 ;; to be saved, if required.
16806 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16807 ;; Peel off the "dummy" group.
16808 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16810 ;; Insert the variables into the file.
16812 (when (and (boundp (setq variable (pop variables)))
16813 (symbol-value variable))
16814 (insert "(setq " (symbol-name variable) " '")
16815 (prin1 (symbol-value variable) (current-buffer))
16818 (defun gnus-gnus-to-newsrc-format ()
16819 ;; Generate and save the .newsrc file.
16821 (set-buffer (create-file-buffer gnus-current-startup-file))
16822 (let ((newsrc (cdr gnus-newsrc-alist))
16823 (standard-output (current-buffer))
16824 info ranges range method)
16825 (setq buffer-file-name gnus-current-startup-file)
16826 (setq default-directory (file-name-directory buffer-file-name))
16827 (buffer-disable-undo (current-buffer))
16830 (if gnus-newsrc-options (insert gnus-newsrc-options))
16831 ;; Write subscribed and unsubscribed.
16832 (while (setq info (pop newsrc))
16833 ;; Don't write foreign groups to .newsrc.
16834 (when (or (null (setq method (gnus-info-method info)))
16835 (equal method "native")
16836 (gnus-server-equal method gnus-select-method))
16837 (insert (gnus-info-group info)
16838 (if (> (gnus-info-level info) gnus-level-subscribed)
16840 (when (setq ranges (gnus-info-read info))
16842 (if (not (listp (cdr ranges)))
16843 (if (= (car ranges) (cdr ranges))
16844 (princ (car ranges))
16845 (princ (car ranges))
16847 (princ (cdr ranges)))
16848 (while (setq range (pop ranges))
16849 (if (or (atom range) (= (car range) (cdr range)))
16850 (princ (or (and (atom range) range) (car range)))
16851 (princ (car range))
16853 (princ (cdr range)))
16854 (if ranges (insert ",")))))
16856 (make-local-variable 'version-control)
16857 (setq version-control 'never)
16858 ;; It has been reported that sometime the modtime on the .newsrc
16859 ;; file seems to be off. We really do want to overwrite it, so
16860 ;; we clear the modtime here before saving. It's a bit odd,
16862 ;; sometimes the modtime clear isn't sufficient. most brute force:
16863 ;; delete the silly thing entirely first. but this fails to provide
16864 ;; such niceties as .newsrc~ creation.
16865 (if gnus-modtime-botch
16866 (delete-file gnus-startup-file)
16867 (clear-visited-file-modtime))
16868 (run-hooks 'gnus-save-standard-newsrc-hook)
16870 (kill-buffer (current-buffer)))))
16874 ;;; Slave functions.
16877 (defun gnus-slave-save-newsrc ()
16879 (set-buffer gnus-dribble-buffer)
16881 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16882 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16884 (defun gnus-master-read-slave-newsrc ()
16887 (file-name-directory gnus-current-startup-file)
16891 (file-name-nondirectory gnus-current-startup-file)
16895 (if (not slave-files)
16896 () ; There are no slave files to read.
16897 (gnus-message 7 "Reading slave newsrcs...")
16899 (set-buffer (get-buffer-create " *gnus slave*"))
16900 (buffer-disable-undo (current-buffer))
16902 (sort (mapcar (lambda (file)
16903 (list (nth 5 (file-attributes file)) file))
16906 (or (< (caar f1) (caar f2))
16907 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16910 (setq file (nth 1 (car slave-files)))
16911 (insert-file-contents file)
16912 (if (condition-case ()
16914 (eval-buffer (current-buffer))
16917 (gnus-error 3.2 "Possible error in %s" file)
16919 (or gnus-slave ; Slaves shouldn't delete these files.
16923 (setq slave-files (cdr slave-files))))
16924 (gnus-message 7 "Reading slave newsrcs...done"))))
16928 ;;; Group description.
16931 (defun gnus-read-all-descriptions-files ()
16932 (let ((methods (cons gnus-select-method
16934 (when gnus-message-archive-method
16936 gnus-secondary-select-methods))))
16938 (gnus-read-descriptions-file (car methods))
16939 (setq methods (cdr methods)))
16942 (defun gnus-read-descriptions-file (&optional method)
16943 (let ((method (or method gnus-select-method)))
16944 (when (stringp method)
16945 (setq method (gnus-server-to-method method)))
16946 ;; We create the hashtable whether we manage to read the desc file
16947 ;; to avoid trying to re-read after a failed read.
16948 (or gnus-description-hashtb
16949 (setq gnus-description-hashtb
16950 (gnus-make-hashtable (length gnus-active-hashtb))))
16951 ;; Mark this method's desc file as read.
16952 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16953 gnus-description-hashtb)
16955 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16957 ((not (gnus-check-server method))
16958 (gnus-message 1 "Couldn't open server")
16960 ((not (gnus-request-list-newsgroups method))
16961 (gnus-message 1 "Couldn't read newsgroups descriptions")
16967 (set-buffer nntp-server-buffer)
16968 (goto-char (point-min))
16969 (if (or (search-forward "\n.\n" nil t)
16970 (goto-char (point-max)))
16972 (beginning-of-line)
16973 (narrow-to-region (point-min) (point))))
16974 (goto-char (point-min))
16975 (while (not (eobp))
16976 ;; If we get an error, we set group to 0, which is not a
16980 (let ((obarray gnus-description-hashtb))
16981 ;; Group is set to a symbol interned in this
16983 (read nntp-server-buffer))
16985 (skip-chars-forward " \t")
16986 ;; ... which leads to this line being effectively ignored.
16987 (and (symbolp group)
16988 (set group (buffer-substring
16989 (point) (progn (end-of-line) (point)))))
16990 (forward-line 1))))
16991 (gnus-message 5 "Reading descriptions file...done")
16994 (defun gnus-group-get-description (group)
16995 "Get the description of a group by sending XGTITLE to the server."
16996 (when (gnus-request-group-description group)
16998 (set-buffer nntp-server-buffer)
16999 (goto-char (point-min))
17000 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17001 (match-string 1)))))
17005 ;;; Buffering of read articles.
17008 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17009 (defvar gnus-backlog-articles nil)
17010 (defvar gnus-backlog-hashtb nil)
17012 (defun gnus-backlog-buffer ()
17013 "Return the backlog buffer."
17014 (or (get-buffer gnus-backlog-buffer)
17016 (set-buffer (get-buffer-create gnus-backlog-buffer))
17017 (buffer-disable-undo (current-buffer))
17018 (setq buffer-read-only t)
17019 (gnus-add-current-to-buffer-list)
17020 (get-buffer gnus-backlog-buffer))))
17022 (defun gnus-backlog-setup ()
17023 "Initialize backlog variables."
17024 (unless gnus-backlog-hashtb
17025 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17027 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17029 (defun gnus-backlog-shutdown ()
17030 "Clear all backlog variables and buffers."
17031 (when (get-buffer gnus-backlog-buffer)
17032 (kill-buffer gnus-backlog-buffer))
17033 (setq gnus-backlog-hashtb nil
17034 gnus-backlog-articles nil))
17036 (defun gnus-backlog-enter-article (group number buffer)
17037 (gnus-backlog-setup)
17038 (let ((ident (intern (concat group ":" (int-to-string number))
17039 gnus-backlog-hashtb))
17041 (if (memq ident gnus-backlog-articles)
17042 () ; It's already kept.
17043 ;; Remove the oldest article, if necessary.
17044 (and (numberp gnus-keep-backlog)
17045 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17046 (gnus-backlog-remove-oldest-article))
17047 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17048 ;; Insert the new article.
17050 (set-buffer (gnus-backlog-buffer))
17051 (let (buffer-read-only)
17052 (goto-char (point-max))
17053 (or (bolp) (insert "\n"))
17055 (insert-buffer-substring buffer)
17056 ;; Tag the beginning of the article with the ident.
17057 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17059 (defun gnus-backlog-remove-oldest-article ()
17061 (set-buffer (gnus-backlog-buffer))
17062 (goto-char (point-min))
17063 (if (zerop (buffer-size))
17064 () ; The buffer is empty.
17065 (let ((ident (get-text-property (point) 'gnus-backlog))
17067 ;; Remove the ident from the list of articles.
17069 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17070 ;; Delete the article itself.
17072 (point) (next-single-property-change
17073 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17075 (defun gnus-backlog-remove-article (group number)
17076 "Remove article NUMBER in GROUP from the backlog."
17077 (when (numberp number)
17078 (gnus-backlog-setup)
17079 (let ((ident (intern (concat group ":" (int-to-string number))
17080 gnus-backlog-hashtb))
17082 (when (memq ident gnus-backlog-articles)
17083 ;; It was in the backlog.
17085 (set-buffer (gnus-backlog-buffer))
17086 (let (buffer-read-only)
17087 (when (setq beg (text-property-any
17088 (point-min) (point-max) 'gnus-backlog
17090 ;; Find the end (i. e., the beginning of the next article).
17092 (next-single-property-change
17093 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17094 (delete-region beg end)
17098 (defun gnus-backlog-request-article (group number buffer)
17099 (when (numberp number)
17100 (gnus-backlog-setup)
17101 (let ((ident (intern (concat group ":" (int-to-string number))
17102 gnus-backlog-hashtb))
17104 (when (memq ident gnus-backlog-articles)
17105 ;; It was in the backlog.
17107 (set-buffer (gnus-backlog-buffer))
17108 (if (not (setq beg (text-property-any
17109 (point-min) (point-max) 'gnus-backlog
17111 ;; It wasn't in the backlog after all.
17113 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17114 ;; Find the end (i. e., the beginning of the next article).
17116 (next-single-property-change
17117 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17118 (let ((buffer-read-only nil))
17120 (insert-buffer-substring gnus-backlog-buffer beg end)
17123 ;; Allow redefinition of Gnus functions.
17125 (gnus-ems-redefine)
17129 ;;; gnus.el ends here